Exemplo n.º 1
0
  public ElementVerification verifyUsage(
      Profile p, Profile baseP, String id, String type, String eltName, String eltValue) {
    // Type can be SegmentRef, Group, Field, Component, Code
    // EltName is Usage
    String hl7Version = p.getMetaData().getHl7Version();
    Usage referenceUsage = Usage.R;
    Usage currentUsage = Usage.R;

    switch (type) {
      case "segmentRef":
        SegmentRefOrGroup srog = p.getMessages().findOneSegmentRefOrGroup(id);
        currentUsage = srog.getUsage();
        SegmentRefOrGroup basesrog = baseP.getMessages().findOneSegmentRefOrGroup(id);
        referenceUsage = basesrog.getUsage();
        break;
      case "group":
        SegmentRefOrGroup srog_ = p.getMessages().findOneSegmentRefOrGroup(id);
        currentUsage = srog_.getUsage();
        SegmentRefOrGroup basesrog_ = baseP.getMessages().findOneSegmentRefOrGroup(id);
        referenceUsage = basesrog_.getUsage();
        break;
      case "field":
        // Field f = p.getSegmentLibrary().findOneField(id);
        // currentUsage = f.getUsage();
        // Field basef = baseP.getSegmentLibrary().findOneField(id);
        // referenceUsage = basef.getUsage();
        break;
      case "component":
        // Component c = p.getDatatypeLibrary().findOneComponent(id);
        // currentUsage = c.getUsage();
        // Component basec = baseP.getDatatypeLibrary().findOneComponent(id);
        // referenceUsage = basec.getUsage();
        break;
      case "code":
        // Code cd = p.getTableLibrary().findOneCodeById(id);
        // currentUsage = Usage.fromValue(cd.getCodeUsage());
        // Code basecd = baseP.getTableLibrary().findOneCodeById(id);
        // referenceUsage = Usage.fromValue(basecd.getCodeUsage());
        break;
    }

    String result = this.validateChangeUsage(hl7Version, referenceUsage, currentUsage);
    ElementVerification ev = new ElementVerification(id, type);
    ElementVerificationResult evRst = new ElementVerificationResult(eltName, eltValue, result);
    ev.addElementVerifications(evRst);

    return ev;
  }
Exemplo n.º 2
0
 public ElementVerification verifyMessages(Profile p, Profile baseP, String id, String type) {
   ElementVerification evm = new ElementVerification(id, type);
   for (Message m : p.getMessages().getChildren()) {
     evm.addChildrenVerification(verifyMessages(p, baseP, m.getId(), m.getType()));
   }
   return evm;
 }
Exemplo n.º 3
0
 public ElementVerification verifyDatatypes(Profile p, Profile baseP, String id, String type) {
   DatatypeLibrary dtLib = p.getDatatypeLibrary();
   ElementVerification evdtLib = new ElementVerification(id, type);
   // for (Datatype dt : dtLib.getChildren()){
   // evdtLib.addChildrenVerification(verifyDatatype(p, baseP, dt.getId(), dt.getType()));
   // }
   return evdtLib;
 }
Exemplo n.º 4
0
  public ElementVerification verifyMessage(Profile p, Profile baseP, String id, String type) {
    ElementVerification evm = new ElementVerification(id, type);
    Message m = p.getMessages().findOne(id);

    for (SegmentRefOrGroup srog : m.getChildren()) {
      evm.addChildrenVerification(verifySegmentOrGroup(p, baseP, srog.getId(), srog.getType()));
    }
    return evm;
  }
Exemplo n.º 5
0
 public ElementVerification verifySegments(Profile p, Profile baseP, String id, String type) {
   ElementVerification evsLib = new ElementVerification(id, type);
   for (SegmentLink sl : p.getSegmentLibrary().getChildren()) {
     Segment s = segmentRepository.findOne(sl.getId());
     ElementVerification evs = verifySegment(p, baseP, s.getId(), s.getType());
     evs.addChildrenVerification(evsLib);
   }
   return evsLib;
 }
Exemplo n.º 6
0
 public ElementVerification verifySegmentOrGroup(
     Profile p, Profile baseP, String id, String type) {
   SegmentRefOrGroup srog = p.getMessages().findOneSegmentRefOrGroup(id);
   ElementVerification evSrog = verifySegmentRef(srog); // verify usage, min and max for segref and
   // group
   if (srog instanceof Group) {
     evSrog.addChildrenVerification(verifyGroup(srog));
   }
   return evSrog;
 }
 @Test
 public void testApplyProfileMetaDataChanges() throws IOException {
   String p = IOUtils.toString(this.getClass().getResourceAsStream("/vxuTest/Profile.xml"));
   String v = IOUtils.toString(this.getClass().getResourceAsStream("/vxuTest/ValueSets_all.xml"));
   String c = IOUtils.toString(this.getClass().getResourceAsStream("/vxuTest/Constraints.xml"));
   Profile p1 = new ProfileSerializationImpl().deserializeXMLToProfile(p, v, c);
   String jsonChanges =
       "\r\n\r\n {\r\n  \"profile\": {\r\n    \"edit\": [\r\n      {\r\n        \"id\": \"552014603004d0a9f09caf16\",\r\n        \"identifier\": \"ddddddddddddd\",\r\n        \"subTitle\": \"ddddddddd\",\r\n        \"orgName\": \"NISTddddd\",\r\n        \"name\": \"VXU_V04ddddd\"\r\n      }\r\n    ]\r\n  }\r\n}\r\n                ";
   try {
     p1 = profileService.apply(p1);
     assertEquals("ddddddddddddd", p1.getMetaData().getProfileID());
     assertEquals("ddddddddd", p1.getMetaData().getSubTitle());
     assertEquals("NISTddddd", p1.getMetaData().getOrgName());
     assertEquals("VXU_V04ddddd", p1.getMetaData().getName());
     // assertEquals(jsonChanges, p1.getChanges());
   } catch (ProfileSaveException e) {
     if (e.getErrors() != null && !e.getErrors().isEmpty()) {
       for (ProfilePropertySaveError error : e.getErrors()) {
         System.out.println(error);
       }
     }
   }
 }
Exemplo n.º 8
0
 public ElementVerification verifyValueSet(Profile p, Profile baseP, String id, String type) {
   // Type is ValueSet (or Table)
   String result = "";
   TableLink t = p.getTableLibrary().findOneTableById(id);
   ElementVerification evt = new ElementVerification(id, type);
   // for (Code c : t.getCodes()){
   // result = this.validateChangeUsage(p.getMetaData().getHl7Version(),
   // Usage.fromValue(baseP.getTableLibrary().findOneCodeById(id).getCodeUsage()),
   // Usage.fromValue(p.getTableLibrary().findOneCodeById(id).getCodeUsage()));
   // ElementVerification evc = new ElementVerification(c.getId(), c.getType());
   // ElementVerificationResult evcRst = new ElementVerificationResult("usage", c.getCodeUsage(),
   // result);
   // evc.addElementVerifications(evcRst);
   // evt.addChildrenVerification(evc);
   // }
   return evt;
 }
  @Test
  public void testApplyMessageChanges() throws IOException {
    String p = IOUtils.toString(this.getClass().getResourceAsStream("/vxuTest/Profile.xml"));
    String v = IOUtils.toString(this.getClass().getResourceAsStream("/vxuTest/ValueSets_all.xml"));
    String c = IOUtils.toString(this.getClass().getResourceAsStream("/vxuTest/Constraints.xml"));
    Profile p1 = new ProfileSerializationImpl().deserializeXMLToProfile(p, v, c);

    Message message = p1.getMessages().getChildren().toArray(new Message[] {})[0];
    SegmentRef segmentRef = (SegmentRef) message.getChildren().get(0);
    Group group = (Group) message.getChildren().get(5);
    Segment segment = p1.getSegmentLibrary().findOneSegmentById(segmentRef.getRef());
    Field field = segment.getFields().get(0);
    Datatype datatype = p1.getDatatypeLibrary().getChildren().toArray(new Datatype[] {})[0];
    String jsonChanges =
        "{\r\n  \"segmentRef\": {\r\n    \"edit\": [\r\n      {\r\n        \"id\": \""
            + segmentRef.getId()
            + "\",\r\n        \"usage\": \"X\",\r\n        \"min\": \"100\",\r\n        \"max\": \"100\"\r\n      }\r\n    ]\r\n  },\r\n  \"message\": {\r\n    \"edit\": [\r\n      {\r\n        \"id\": \""
            + message.getId()
            + "\",\r\n        \"identifier\": \"identifier\",\r\n        \"version\": \"version\",\r\n        \"oid\": \"oid\",\r\n        \"date\": \"today\",\r\n        \"comment\": \"comment\"\r\n      }\r\n    ]\r\n  }\r\n,  \"group\": {\r\n    \"edit\": [\r\n      {\r\n        \"id\": \""
            + message.getChildren().get(5).getId()
            + "\",\r\n        \"usage\": \"W\"\r\n      }\r\n    ]\r\n  }, \"segment\": {\r\n    \"edit\": [\r\n      {\r\n        \"id\": \""
            + segment.getId()
            + "\",\r\n        \"label\": \"label\",\r\n        \"description\": \"desc\",\r\n        \"comment\": \"comment\",\r\n        \"text2\": \"posttest\",\r\n        \"text1\": \"pretest\"\r\n      }\r\n    ]\r\n  },\r\n  \"field\": {\r\n    \"edit\": [\r\n      {\r\n        \"id\": \""
            + field.getId()
            + "\",\r\n        \"usage\": \"X\",\r\n        \"min\": \"10\",\r\n        \"max\": \"10\",\r\n        \"minLength\": \"10\",\r\n        \"maxLength\": \"10\",\r\n        \"confLength\": \"10\",\r\n        \"datatype\": {\r\n          \"id\": \""
            + datatype.getId()
            + "\"\r\n        }\r\n      }\r\n    ]\r\n  }, "
            + "\"datatype\": {\n    \"add\": [\n      {\n        \"type\": \"datatype\",\n        \"id\": -3821077,\n        \"label\": \"HD_IZ_3821077\",\n        \"components\": [\n          {\n            \"type\": \"component\",\n            \"name\": \"Namespace ID\",\n            \"usage\": \"C\",\n            \"minLength\": 1,\n            \"maxLength\": \"20\",\n            \"confLength\": \"\",\n            \"table\": {\n              \"id\": \"552014603004d0a9f09ca2b3\"\n            },\n            \"bindingStrength\": \"\",\n            \"bindingLocation\": \"\",\n            \"datatype\": {\n              \"id\": \"552014603004d0a9f09cab27\"\n            },\n            \"position\": 1,\n            \"comment\": null,\n            \"id\": -4399911,\n            \"path\": \"MSH.3.1\"\n          },\n          {\n            \"type\": \"component\",\n            \"name\": \"Universal ID\",\n            \"usage\": \"C\",\n            \"minLength\": 1,\n            \"maxLength\": \"199\",\n            \"confLength\": \"\",\n            \"table\": null,\n            \"bindingStrength\": \"\",\n            \"bindingLocation\": \"\",\n            \"datatype\": {\n              \"id\": \"552014603004d0a9f09cab29\"\n            },\n            \"position\": 2,\n            \"comment\": null,\n            \"id\": -740343,\n            \"path\": \"MSH.3.2\"\n          },\n          {\n            \"type\": \"component\",\n            \"name\": \"Universal ID Type\",\n            \"usage\": \"C\",\n            \"minLength\": 1,\n            \"maxLength\": \"6\",\n            \"confLength\": \"\",\n            \"table\": {\n              \"id\": \"552014603004d0a9f09ca25e\"\n            },\n            \"bindingStrength\": \"\",\n            \"bindingLocation\": \"\",\n            \"datatype\": {\n              \"id\": \"552014603004d0a9f09cab2e\"\n            },\n            \"position\": 3,\n            \"comment\": null,\n            \"id\": -7086103,\n            \"path\": \"MSH.3.3\"\n          }\n        ],\n        \"name\": \"HD\",\n        \"description\": \"Hierarchic Designator\",\n        \"predicates\": [\n          {\n            \"id\": -1307454,\n            \"constraintId\": \"[HD_IZ]1[1]\",\n            \"constraintTarget\": \"1[1]\",\n            \"reference\": null,\n            \"description\": \"If HD.2 (Universal ID) is not valued.\",\n            \"assertion\": \"<Condition>\\n <NOT>\\n <Presence Path=\\\"2[1]\\\"/>\\n </NOT>\\n </Condition>\",\n            \"trueUsage\": \"R\",\n            \"falseUsage\": \"O\"\n          },\n          {\n            \"id\": -3885632,\n            \"constraintId\": \"[HD_IZ]2[1]\",\n            \"constraintTarget\": \"2[1]\",\n            \"reference\": null,\n            \"description\": \"If HD.1 (Namespace ID) is not valued.\",\n            \"assertion\": \"<Condition>\\n <NOT>\\n <Presence Path=\\\"1[1]\\\"/>\\n </NOT>\\n </Condition>\",\n            \"trueUsage\": \"R\",\n            \"falseUsage\": \"O\"\n          },\n          {\n            \"id\": -5889559,\n            \"constraintId\": \"[HD_IZ]3[1]\",\n            \"constraintTarget\": \"3[1]\",\n            \"reference\": null,\n            \"description\": \"If HD.2 (Universal ID) is valued.\",\n            \"assertion\": \"<Condition>\\n <Presence Path=\\\"2[1]\\\"/>\\n </Condition>\",\n            \"trueUsage\": \"R\",\n            \"falseUsage\": \"X\"\n          }\n        ],\n        \"conformanceStatements\": [\n          {\n            \"id\": -7578659,\n            \"constraintId\": \"IZ-5\",\n            \"constraintTarget\": \"2[1]\",\n            \"reference\": null,\n            \"description\": \"The value of HD.2 (Universal ID) SHALL be formatted with ISO-compliant OID.\",\n            \"assertion\": \"<Assertion>\\n <Format Path=\\\"2[1]\\\" Regex=\\\"[0-2](\\\\.(0|[1-9][0-9]*))*\\\"/>\\n </Assertion>\"\n          },\n          {\n            \"id\": -3467488,\n            \"constraintId\": \"IZ-6\",\n            \"constraintTarget\": \"3[1]\",\n            \"reference\": null,\n            \"description\": \"The value of HD.3 (Universal ID Type) SHALL be 'ISO'.\",\n            \"assertion\": \"<Assertion>\\n <PlainText IgnoreCase=\\\"false\\\" Path=\\\"3[1]\\\" Text=\\\"ISO\\\"/>\\n </Assertion>\"\n          }\n        ],\n        \"comment\": null,\n        \"usageNote\": null\n      }\n    ]\n  }"
            + " }\r\n    ";
    try {
      p1 = profileService.apply(p1);
      assertEquals("identifier", message.getIdentifier());
      assertEquals("comment", message.getComment());

      assertEquals("X", segmentRef.getUsage().toString());
      assertEquals("100", segmentRef.getMin() + "");

      assertEquals("W", group.getUsage().toString());

      assertEquals("label", segment.getLabel());
      assertEquals("comment", segment.getComment());
      assertEquals("pretest", segment.getText1());
      assertEquals("posttest", segment.getText2());
      assertEquals("desc", segment.getDescription());

      assertEquals(datatype.getId(), field.getDatatype());

      assertEquals("X", field.getUsage().value());
      assertEquals(new Integer(10), field.getMin());
      assertEquals("10", field.getMax());
      assertEquals(new Integer(10), field.getMinLength());
      assertEquals("10", field.getMaxLength());
      assertEquals("10", field.getConfLength());
    } catch (ProfileSaveException e) {
      if (e.getErrors() != null && !e.getErrors().isEmpty()) {
        for (ProfilePropertySaveError error : e.getErrors()) {
          System.out.println(error);
        }
      }
    }

    //
  }