Search in sources :

Example 26 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.

the class CodeSystemConvertor method convert.

public void convert(IParser p, ValueSet vs, String name, PackageVersion packageInfo) throws Exception {
    String nname = name.replace("valueset-", "codesystem-");
    if (nname.equals(name))
        nname = Utilities.changeFileExt(name, "-cs.xml");
    if (new File(nname).exists()) {
        FileInputStream input = new FileInputStream(nname);
        CodeSystem cs = CodeSystemUtilities.makeShareable((CodeSystem) p.parse(input));
        if (!cs.hasTitle())
            cs.setTitle(Utilities.capitalize(Utilities.unCamelCase(cs.getName())));
        populate(cs, vs);
        // if (codeSystems.containsKey(cs.getUrl()))
        // throw new Exception("Duplicate Code System: "+cs.getUrl());
        codeSystems.see(cs, packageInfo);
    }
}
Also used : File(java.io.File) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) FileInputStream(java.io.FileInputStream)

Example 27 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.

the class CodeSystemConvertor method populate.

public static void populate(CodeSystem cs, ValueSet vs) {
    if (!vs.hasName())
        throw new Error("No name vs " + vs.getUrl());
    if (!vs.hasDescription())
        throw new Error("No description vs " + vs.getUrl());
    if (cs.getUserData("conv-vs") != null)
        throw new Error("This code system has already been converted");
    cs.setUserData("conv-vs", "done");
    vs.setUserData("cs", cs);
    if (vs.hasUserData("filename"))
        cs.setUserData("filename", vs.getUserString("filename").replace("valueset-", "codesystem-"));
    if (vs.hasUserData("path"))
        cs.setUserData("path", vs.getUserString("path").replace("valueset-", "codesystem-"));
    if (vs.hasUserData("committee"))
        cs.setUserData("committee", vs.getUserData("committee"));
    cs.setId(vs.getId());
    cs.setVersion(vs.getVersion());
    cs.setName(vs.getName());
    cs.setTitle(vs.getTitle());
    cs.setStatus(vs.getStatus());
    cs.setExperimentalElement(vs.getExperimentalElement());
    cs.setPublisher(vs.getPublisher());
    for (ContactDetail csrc : vs.getContact()) {
        ContactDetail ctgt = cs.addContact();
        ctgt.setName(csrc.getName());
        for (ContactPoint cc : csrc.getTelecom()) ctgt.addTelecom(cc);
    }
    cs.setDate(vs.getDate());
    cs.setDescription(vs.getDescription());
    cs.getDescriptionElement().getExtension().addAll(vs.getDescriptionElement().getExtension());
    for (UsageContext cc : vs.getUseContext()) cs.addUseContext(cc);
    cs.setPurpose(vs.getPurpose());
    cs.setCopyright(vs.getCopyright());
    if (vs.hasCompose() && vs.getCompose().getInclude().size() == 1 && vs.getCompose().getExclude().size() == 0 && vs.getCompose().getInclude().get(0).getSystem().equals(cs.getUrl()) && !vs.getCompose().getInclude().get(0).hasValueSet() && !vs.getCompose().getInclude().get(0).hasConcept() && !vs.getCompose().getInclude().get(0).hasFilter())
        cs.setValueSet(vs.getUrl());
    vs.setImmutable(true);
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) UsageContext(org.hl7.fhir.r5.model.UsageContext)

Example 28 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.

the class ProfileGenerator method generate.

public StructureDefinition generate(DefinedStringPattern type) throws Exception {
    genUml(type);
    StructureDefinition p = new StructureDefinition();
    p.setId(type.getCode());
    p.setUrl("http://hl7.org/fhir/StructureDefinition/" + type.getCode());
    p.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/" + type.getBase());
    p.setType(type.getCode());
    p.setDerivation(TypeDerivationRule.SPECIALIZATION);
    p.setKind(StructureDefinitionKind.PRIMITIVETYPE);
    p.setAbstract(false);
    p.setUserData("filename", type.getCode().toLowerCase());
    p.setUserData("path", "datatypes.html#" + type.getCode());
    p.setFhirVersion(version);
    p.setVersion(version.toCode());
    ToolingExtensions.setStandardsStatus(p, StandardsStatus.NORMATIVE, "4.0.0");
    ToolResourceUtilities.updateUsage(p, "core");
    p.setName(type.getCode());
    p.setPublisher("HL7 FHIR Standard");
    p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
    p.setDescription("Base StructureDefinition for " + type.getCode() + " type: " + type.getDefinition());
    p.setDate(genDate.getTime());
    p.setStatus(PublicationStatus.fromCode("active"));
    Set<String> containedSlices = new HashSet<String>();
    // first, the differential
    p.setDifferential(new StructureDefinitionDifferentialComponent());
    ElementDefinition ec1 = new ElementDefinition();
    p.getDifferential().getElement().add(ec1);
    ec1.setId(type.getCode());
    ec1.setPath(type.getCode());
    ec1.setShort("Primitive Type " + type.getCode());
    ec1.setDefinition(type.getDefinition());
    ec1.setComment(type.getComment());
    ec1.setMin(0);
    ec1.setMax("*");
    ElementDefinition ec2 = new ElementDefinition();
    p.getDifferential().getElement().add(ec2);
    ec2.setId(type.getCode() + ".value");
    ec2.setPath(type.getCode() + ".value");
    ec2.addRepresentation(PropertyRepresentation.XMLATTR);
    ec2.setShort("Primitive value for " + type.getCode());
    ec2.setDefinition("Primitive value for " + type.getCode());
    ec2.setMin(0);
    ec2.setMax("1");
    TypeRefComponent t = ec2.addType();
    t.setCodeElement(new UriType());
    t.getFormatCommentsPre().add("Note: special primitive values have a FHIRPath system type. e.g. this is compiler magic (g)");
    t.setCode(Constants.NS_SYSTEM_TYPE + type.getFHIRPathType());
    ToolingExtensions.addUriExtension(t, ToolingExtensions.EXT_FHIR_TYPE, type.getCode());
    if (!Utilities.noString(type.getRegex())) {
        ToolingExtensions.addStringExtension(t, ToolingExtensions.EXT_REGEX, type.getRegex());
    }
    reset();
    // now. the snapshot
    p.setSnapshot(new StructureDefinitionSnapshotComponent());
    ElementDefinition ecA = new ElementDefinition(true, ElementDefinition.NOT_MODIFIER, ElementDefinition.NOT_IN_SUMMARY);
    p.getSnapshot().getElement().add(ecA);
    ecA.setId(type.getCode());
    ecA.setPath(type.getCode());
    ecA.setShort("Primitive Type " + type.getCode());
    ecA.setDefinition(type.getDefinition());
    ecA.setComment(type.getComment());
    ecA.setMin(0);
    ecA.setMax("*");
    ecA.makeBase(type.getCode(), 0, "*");
    addElementConstraints("Element", ecA);
    ElementDefinition ecid = new ElementDefinition(true, ElementDefinition.NOT_MODIFIER, ElementDefinition.NOT_IN_SUMMARY);
    p.getSnapshot().getElement().add(ecid);
    ecid.setId(type.getCode() + ".id");
    ecid.setPath(type.getCode() + ".id");
    ecid.addRepresentation(PropertyRepresentation.XMLATTR);
    ecid.setDefinition("unique id for the element within a resource (for internal references)");
    ecid.setMin(0);
    ecid.setMax("1");
    ecid.setShort("xml:id (or equivalent in JSON)");
    TypeRefComponent tr = ecid.addType();
    tr.getFormatCommentsPre().add("Note: special primitive values have a FHIRPath system type. e.g. this is compiler magic (h)");
    tr.setCode(Constants.NS_SYSTEM_TYPE + "String");
    ToolingExtensions.addUriExtension(tr, ToolingExtensions.EXT_FHIR_TYPE, "string");
    ecid.makeBase("Element.id", 0, "1");
    makeExtensionSlice("extension", p, p.getSnapshot(), null, type.getCode());
    ElementDefinition ecB = new ElementDefinition(true, ElementDefinition.NOT_MODIFIER, ElementDefinition.NOT_IN_SUMMARY);
    p.getSnapshot().getElement().add(ecB);
    ecB.setPath(type.getCode() + ".value");
    ecB.setId(type.getCode() + ".value");
    ecB.addRepresentation(PropertyRepresentation.XMLATTR);
    ecB.setDefinition("Primitive value for " + type.getCode());
    ecB.setShort("Primitive value for " + type.getCode());
    ecB.setMin(0);
    ecB.setMax("1");
    ecB.makeBase(type.getBase() + ".value", 0, "1");
    t = ecB.addType();
    t.getFormatCommentsPre().add("Note: special primitive values have a FHIRPath system type. e.g. this is compiler magic (i)");
    t.setCode(Constants.NS_SYSTEM_TYPE + "String");
    ToolingExtensions.addUriExtension(t, ToolingExtensions.EXT_FHIR_TYPE, "string");
    if (!Utilities.noString(type.getRegex()))
        ToolingExtensions.addStringExtension(t, ToolingExtensions.EXT_REGEX, type.getRegex());
    // generateElementDefinition(ecB, ecA);
    containedSlices.clear();
    addElementConstraintToSnapshot(p);
    XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
    div.addText("to do");
    p.setText(new Narrative());
    p.getText().setStatus(NarrativeStatus.GENERATED);
    p.getText().setDiv(div);
    checkHasTypes(p);
    return p;
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) TypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent) Narrative(org.hl7.fhir.r5.model.Narrative) StructureDefinitionSnapshotComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent) StructureDefinitionDifferentialComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) HashSet(java.util.HashSet) UriType(org.hl7.fhir.r5.model.UriType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 29 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.

the class ProfileGenerator method generateXhtml.

public StructureDefinition generateXhtml() throws Exception {
    uml.getTypes().put("html:div", new UMLPrimitive("html:div"));
    StructureDefinition p = new StructureDefinition();
    p.setId("xhtml");
    p.setUrl("http://hl7.org/fhir/StructureDefinition/xhtml");
    p.setKind(StructureDefinitionKind.PRIMITIVETYPE);
    p.setAbstract(false);
    p.setUserData("filename", "xhtml");
    p.setUserData("path", "narrative.html#xhtml");
    p.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element");
    p.setType("xhtml");
    p.setDerivation(TypeDerivationRule.SPECIALIZATION);
    p.setFhirVersion(version);
    p.setVersion(version.toCode());
    ToolingExtensions.setStandardsStatus(p, StandardsStatus.NORMATIVE, "4.0.0");
    ToolResourceUtilities.updateUsage(p, "core");
    p.setName("xhtml");
    p.setPublisher("HL7 FHIR Standard");
    p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
    p.setDescription("Base StructureDefinition for xhtml Type");
    p.setDate(genDate.getTime());
    p.setStatus(PublicationStatus.fromCode("active"));
    Set<String> containedSlices = new HashSet<String>();
    // first, the differential
    p.setDifferential(new StructureDefinitionDifferentialComponent());
    ElementDefinition ec = new ElementDefinition();
    p.getDifferential().getElement().add(ec);
    ec.setId("xhtml");
    ec.setPath("xhtml");
    ec.setShort("Primitive Type " + "xhtml");
    ec.setDefinition("XHTML");
    ec.setMin(0);
    ec.setMax("*");
    ec = new ElementDefinition();
    p.getDifferential().getElement().add(ec);
    ec.setId("xhtml" + ".extension");
    ec.setPath("xhtml" + ".extension");
    ec.setMax("0");
    ec = new ElementDefinition();
    p.getDifferential().getElement().add(ec);
    ec.setId("xhtml" + ".value");
    ec.setPath("xhtml" + ".value");
    ec.addRepresentation(PropertyRepresentation.XHTML);
    ec.setShort("Actual xhtml");
    ec.setDefinition("Actual xhtml");
    ec.setMin(1);
    ec.setMax("1");
    TypeRefComponent t = ec.addType();
    t.setCodeElement(new UriType());
    t.getFormatCommentsPre().add("Note: special primitive values have a FHIRPath system type. e.g. this is compiler magic (d)");
    t.setCode(Constants.NS_SYSTEM_TYPE + "String");
    ToolingExtensions.addUriExtension(t, ToolingExtensions.EXT_FHIR_TYPE, "string");
    reset();
    // now. the snapshot
    p.setSnapshot(new StructureDefinitionSnapshotComponent());
    ElementDefinition ec1 = new ElementDefinition(true, ElementDefinition.NOT_MODIFIER, ElementDefinition.NOT_IN_SUMMARY);
    p.getSnapshot().getElement().add(ec1);
    ec1.setId("xhtml");
    ec1.setPath("xhtml");
    ec1.setShort("Primitive Type " + "xhtml");
    ec1.setDefinition("XHTML");
    ec1.setMin(0);
    ec1.setMin(0);
    ec1.setMax("*");
    ec1.makeBase();
    generateElementDefinition(p, ec1, null);
    ElementDefinition ec2 = new ElementDefinition(true, ElementDefinition.NOT_MODIFIER, ElementDefinition.NOT_IN_SUMMARY);
    p.getSnapshot().getElement().add(ec2);
    ec2.setId("xhtml.id");
    ec2.setPath("xhtml.id");
    ec2.addRepresentation(PropertyRepresentation.XMLATTR);
    ec2.setDefinition("unique id for the element within a resource (for internal references)");
    ec2.setMin(0);
    ec2.setMax("1");
    ec2.setShort("xml:id (or equivalent in JSON)");
    TypeRefComponent tr = ec2.addType();
    t.getFormatCommentsPre().add("Note: special primitive values have a FHIRPath system type. e.g. this is compiler magic (e)");
    tr.setCode(Constants.NS_SYSTEM_TYPE + "String");
    ToolingExtensions.addUriExtension(t, ToolingExtensions.EXT_FHIR_TYPE, "string");
    generateElementDefinition(p, ec2, ec1);
    ec2.makeBase("Element.id", 0, "1");
    ElementDefinition ex = makeExtensionSlice("extension", p, p.getSnapshot(), null, "xhtml");
    ex.setMax("0");
    ElementDefinition ec3 = new ElementDefinition(true, ElementDefinition.NOT_MODIFIER, ElementDefinition.NOT_IN_SUMMARY);
    p.getSnapshot().getElement().add(ec3);
    ec3.setId("xhtml.value");
    ec3.setPath("xhtml.value");
    ec3.addRepresentation(PropertyRepresentation.XHTML);
    ec3.setShort("Actual xhtml");
    ec3.setDefinition("Actual xhtml");
    ec3.setMin(1);
    ec3.setMax("1");
    t = ec3.addType();
    t.setCodeElement(new UriType());
    t.getFormatCommentsPre().add("Note: special primitive values have a FHIRPath system type. e.g. this is compiler magic (f)");
    t.setCode(Constants.NS_SYSTEM_TYPE + "String");
    ToolingExtensions.addUriExtension(t, ToolingExtensions.EXT_FHIR_TYPE, "string");
    ec3.makeBase();
    generateElementDefinition(p, ec3, ec);
    containedSlices.clear();
    addElementConstraintToSnapshot(p);
    XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
    div.addText("to do");
    p.setText(new Narrative());
    p.getText().setStatus(NarrativeStatus.GENERATED);
    p.getText().setDiv(div);
    checkHasTypes(p);
    return p;
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) TypeRefComponent(org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent) Narrative(org.hl7.fhir.r5.model.Narrative) StructureDefinitionSnapshotComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionSnapshotComponent) StructureDefinitionDifferentialComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent) UMLPrimitive(org.hl7.fhir.definitions.uml.UMLPrimitive) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) HashSet(java.util.HashSet) UriType(org.hl7.fhir.r5.model.UriType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 30 with System

use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testBasicInsuranceCoverageFields.

// Suppress warnings about too many assertions in a test. Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@Test
void testBasicInsuranceCoverageFields() throws IOException {
    // Tests fields listed below.
    String hl7message = "MSH|^~\\&|||||20151008111200||DFT^P03^DFT_P03|MSGID000001|T|2.6|||||||||\n" + "EVN||20210407191342||||||\n" + "PID|||MR1^^^XYZ^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + // FT1.7 is required transaction code (currently not used)
    "FT1||||20201231145045||CG|FAKE|||||||||||||||||||||||||||||||||||||\n" + // IN1.2.4, IN1.2.6 to second XV Coverage.identifier
    "IN1|1|Value1^^System3^Value4^^System6" + // IN1.3.8 to Organization Identifier.period.end
    "|IdValue1^^^IdSystem4^IdType5^^20201231145045^20211231145045" + // IN1.4 to Organization Name
    "|Large Blue Organization" + // IN1.5 to Organization Address (All XAD standard fields)
    "|456 Ultramarine Lane^^Faketown^CA^ZIP5" + // IN1.6.13 to Organization Contact Name .period.end
    "|LastFake^FirstFake^MiddleFake^III^Dr.^^L^^^^^20201231145045^20211231145045" + // IN1.7.18 to Organization Contact telecom .rank
    "|^WPN^^^^333^4444444^^^^^^20201231145045^20211231145045^^^^1" + // IN1.9.1 (2) to list element Coverage.class.name and value (because IN1.9.10 (2) does not exist)
    "|UA34567|NameBlue^^^^^^^^^IDBlue~NameGreen||" + // IN1.35 to Organization.identifier
    "|20201231145045|20211231145045|||||||||5|||||||||||||COMPANYPLANCODE35" + // IN1.49 has value to show that it is not used for Patient.identifier because NO relationship (IN1.17/IN2.72 empty)
    "|MEMBER36||||||||||Value46|||PatientId49.1||||\n" + // IN2.61 is purposely empty (primary to IN1.36) so IN1.36 will be used as the MB Coverage.identifier
    "IN2|||||||||||||||||||||||||IdValue25.1^^^IdSystem25.4^IdType25.5^^20201231145045^20211231145045|||||||||||||||||||||||||||||||||||||||||||" + // IN2.72 is purposely empty (backup to IN1.17) so no RelatedPerson is created.
    "|Name69.1^^^^^IdSystem69.6^UNK^^^IdValue69.10||\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // From PV1
    assertThat(encounters).hasSize(1);
    List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // From PID
    assertThat(patients).hasSize(1);
    Patient patient = (Patient) patients.get(0);
    String patientId = patient.getId();
    // From PID.3
    assertThat(patient.getIdentifier()).hasSize(1);
    Identifier patientIdentifier = patient.getIdentifier().get(0);
    // PID.3.1
    assertThat(patientIdentifier.getValue()).isEqualTo("MR1");
    // PID.3.4
    assertThat(patientIdentifier.getSystem()).isEqualTo("urn:id:XYZ");
    DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "MR", "Medical record number", "http://terminology.hl7.org/CodeSystem/v2-0203", // PID.3.5
    null);
    // IN1.49 not used
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // From IN1.3 creates Payor, IN2.25 to new PayorId Organization, IN2.69 creates new PolicyHolder Organization Name
    assertThat(organizations).hasSize(3);
    Organization org = (Organization) organizations.get(0);
    // Check Payor Organization Id's
    String payorOrgId = org.getId();
    // IN1.17.1 (no TENANT)  (Id's lowercased)
    assertThat(payorOrgId).isEqualTo("Organization/idvalue1");
    // IN1.4
    assertThat(org.getName()).isEqualTo("Large Blue Organization");
    assertThat(org.getIdentifier()).hasSize(2);
    Identifier orgIdentifier = org.getIdentifier().get(0);
    // IN1.3.1
    assertThat(orgIdentifier.getValue()).isEqualTo("IdValue1");
    // IN1.3.4
    assertThat(orgIdentifier.getSystem()).isEqualTo("urn:id:IdSystem4");
    // IN1.3.7
    assertThat(orgIdentifier.getPeriod().getStartElement().toString()).containsPattern("2020-12-31T14:50:45");
    // IN1.3.8
    assertThat(orgIdentifier.getPeriod().getEndElement().toString()).containsPattern("2021-12-31T14:50:45");
    // IN1.3.5
    DatatypeUtils.checkCommonCodeableConceptAssertions(orgIdentifier.getType(), "IdType5", null, null, null);
    Identifier orgIdentifier1 = org.getIdentifier().get(1);
    // IN1.35
    assertThat(orgIdentifier1.getValue()).isEqualTo("COMPANYPLANCODE35");
    // Check Payor Organization address. IN1.4 is a standard XAD address, which is tested exhaustively in other tests.
    assertThat(org.getAddress()).hasSize(1);
    assertThat(org.getAddress().get(0).getLine().get(0).getValueAsString()).isEqualTo(// IN1.4.1
    "456 Ultramarine Lane");
    // IN1.4.3
    assertThat(org.getAddress().get(0).getCity()).isEqualTo("Faketown");
    // IN1.4.4
    assertThat(org.getAddress().get(0).getState()).isEqualTo("CA");
    // IN1.4.5
    assertThat(org.getAddress().get(0).getPostalCode()).isEqualTo("ZIP5");
    // Check Payor Organization contact name.  IN1.6 name is standard XPN, tested exhaustively in other tests.
    HumanName contactName = org.getContact().get(0).getName();
    assertThat(org.getContact()).hasSize(1);
    // IN1.6.1
    assertThat(contactName.getFamily()).isEqualTo("LastFake");
    // IN1.6.2
    assertThat(contactName.getGiven().get(0).getValueAsString()).isEqualTo("FirstFake");
    // IN1.6.3
    assertThat(contactName.getGiven().get(1).getValueAsString()).isEqualTo("MiddleFake");
    // IN1.6.6
    assertThat(contactName.getPrefixAsSingleString()).hasToString("Dr.");
    // IN1.6.5
    assertThat(contactName.getSuffixAsSingleString()).hasToString("III");
    // from IN1.6 aggregate
    assertThat(contactName.getText()).isEqualTo("Dr. FirstFake MiddleFake LastFake III");
    // IN1.6.7
    assertThat(contactName.getUseElement().getCode()).hasToString("official");
    // IN1.6.12
    assertThat(contactName.getPeriod().getStartElement().toString()).containsPattern("2020-12-31T14:50:45");
    // IN1.6.13
    assertThat(contactName.getPeriod().getEndElement().toString()).containsPattern("2021-12-31T14:50:45");
    // Check there is no purpose. Don't need one, here.
    assertThat(org.getContact().get(0).hasPurpose()).isFalse();
    // Check Payor Organization contact telecom.  IN1.7 is standard XTN, tested exhaustively in other tests.
    assertThat(org.getContact().get(0).getTelecom()).hasSize(1);
    // telecom is type ContactPoint
    ContactPoint contactPoint = org.getContact().get(0).getTelecomFirstRep();
    // default type hardcoded.
    assertThat(contactPoint.getSystemElement().getCode()).hasToString("phone");
    // IN1.7.2 is not mapped (ignored)
    assertThat(contactPoint.hasUseElement()).isFalse();
    // IN1.7.6, IN1.7.7 via getFormattedTelecomNumberValue
    assertThat(contactPoint.getValue()).hasToString("(333) 444 4444");
    // IN1.7.13
    assertThat(contactPoint.getPeriod().getStartElement().toString()).containsPattern("2020-12-31T14:50:45");
    // IN1.7.14
    assertThat(contactPoint.getPeriod().getEndElement().toString()).containsPattern("2021-12-31T14:50:45");
    // IN1.7.18
    assertThat(contactPoint.getRank()).isEqualTo(1);
    // Check PayorId Organization from IN2.25
    org = (Organization) organizations.get(1);
    String payorOrgIdIn25 = org.getId();
    // IN1.25.1 (no TENANT) (Id's lowercased)
    assertThat(payorOrgIdIn25).isEqualTo("Organization/idvalue25.1");
    // IN2.25.1
    assertThat(org.getName()).isEqualTo("IdValue25.1");
    assertThat(org.getIdentifier()).hasSize(1);
    orgIdentifier = org.getIdentifier().get(0);
    // IN2.25.1
    assertThat(orgIdentifier.getValue()).isEqualTo("IdValue25.1");
    // IN2.25.4
    assertThat(orgIdentifier.getSystem()).isEqualTo("urn:id:IdSystem25.4");
    // IN2.25.7
    assertThat(orgIdentifier.getPeriod().getStartElement().toString()).containsPattern("2020-12-31T14:50:45");
    // IN2.25.8
    assertThat(orgIdentifier.getPeriod().getEndElement().toString()).containsPattern("2021-12-31T14:50:45");
    // IN2.25.5
    DatatypeUtils.checkCommonCodeableConceptAssertions(orgIdentifier.getType(), "IdType25.5", null, null, null);
    // Check PolicyHolder Organization Name and ID Organization from IN2.69
    org = (Organization) organizations.get(2);
    String policyHolderOrgId = org.getId();
    // IN2.69.1 (no TENANT) (Id's lowercased)
    assertThat(policyHolderOrgId).isEqualTo("Organization/idvalue69.10");
    // IN2.69.1
    assertThat(org.getName()).isEqualTo("Name69.1");
    assertThat(org.getIdentifier()).hasSize(1);
    orgIdentifier = org.getIdentifier().get(0);
    // IN2.69.10
    assertThat(orgIdentifier.getValue()).isEqualTo("IdValue69.10");
    // IN2.69.6
    assertThat(orgIdentifier.getSystem()).isEqualTo("urn:id:IdSystem69.6");
    // Becuase the code is unknown, the 0203 table lookup fails, and the coding has just the code, no system
    // IN2.69.7
    DatatypeUtils.checkCommonCodeableConceptAssertions(orgIdentifier.getType(), "UNK", null, null, null);
    List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
    // From IN1 segment
    assertThat(coverages).hasSize(1);
    Coverage coverage = (Coverage) coverages.get(0);
    // Confirm Coverage Identifiers - Order matches order of identifier_X in Coverage.yml
    // XV, XV, XV, MB, SN; but not MA (IN2.8) nor MC (IN2.6)
    assertThat(coverage.getIdentifier()).hasSize(5);
    // IN1.2.1
    assertThat(coverage.getIdentifier().get(0).getValue()).isEqualTo("Value1");
    // IN1.2.3
    assertThat(coverage.getIdentifier().get(0).getSystem()).isEqualTo("urn:id:System3");
    // No use, here
    assertThat(coverage.getIdentifier().get(0).getUse()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(0).getType(), "XV", "Health Plan Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN1.2.4
    assertThat(coverage.getIdentifier().get(1).getValue()).isEqualTo("Value4");
    // IN1.2.6
    assertThat(coverage.getIdentifier().get(1).getSystem()).isEqualTo("urn:id:System6");
    // No use, here
    assertThat(coverage.getIdentifier().get(1).getUse()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(1).getType(), "XV", "Health Plan Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN1.46
    assertThat(coverage.getIdentifier().get(2).getValue()).isEqualTo("Value46");
    // No system, here
    assertThat(coverage.getIdentifier().get(2).getSystem()).isNull();
    // Use is enumeration "old"
    assertThat(coverage.getIdentifier().get(2).getUseElement().getCode()).hasToString("old");
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(2).getType(), "XV", "Health Plan Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN1.36
    assertThat(coverage.getIdentifier().get(3).getValue()).isEqualTo("MEMBER36");
    // No system, here
    assertThat(coverage.getIdentifier().get(3).getSystem()).isNull();
    // No use, here
    assertThat(coverage.getIdentifier().get(3).getUse()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(3).getType(), "MB", "Member Number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN1.36
    assertThat(coverage.getIdentifier().get(4).getValue()).isEqualTo("MEMBER36");
    // No system, here
    assertThat(coverage.getIdentifier().get(4).getSystem()).isNull();
    // No use, here
    assertThat(coverage.getIdentifier().get(4).getUse()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(4).getType(), "SN", "Subscriber Number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // Confirm SubscriberId
    // IN1.36
    assertThat(coverage.getSubscriberId()).isEqualTo("MEMBER36");
    // Confirm coverage.Order
    // IN1.22 takes priority over IN1.1
    assertThat(coverage.getOrder()).isEqualTo(5);
    // Confirm Coverage Beneficiary references to Patient, and Payor references correct Organizations
    assertThat(coverage.getBeneficiary().getReference()).isEqualTo(patientId);
    // One for each payorOrganization
    assertThat(coverage.getPayor()).hasSize(2);
    assertThat(coverage.getPayor().get(0).getReference()).isEqualTo(payorOrgId);
    assertThat(coverage.getPayor().get(1).getReference()).isEqualTo(payorOrgIdIn25);
    // Confirm policyHolder references correct organization
    assertThat(coverage.getPolicyHolder().getReference()).isEqualTo(policyHolderOrgId);
    // Only one Coverage Class expected.  (getClass_ is correct name for method)
    assertThat(coverage.getClass_()).hasSize(3);
    // IN1.8  Only has value
    checkCoverageClassExistsWithCorrectValueAndName(coverage.getClass_(), "UA34567", null);
    // IN1.9 (1)
    checkCoverageClassExistsWithCorrectValueAndName(coverage.getClass_(), "IDBlue", "NameBlue");
    // IN1.9 (2) Name is also used for value
    checkCoverageClassExistsWithCorrectValueAndName(coverage.getClass_(), "NameGreen", "NameGreen");
    // Confirm Coverage period
    // IN1.12
    assertThat(coverage.getPeriod().getStartElement().toString()).containsPattern("2020-12-31T14:50:45");
    // IN1.13
    assertThat(coverage.getPeriod().getEndElement().toString()).containsPattern("2021-12-31T14:50:45");
    // Expect no RelatedPerson because IN1.17 was empty
    List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
    // IN1.17 empty
    assertThat(relatedPersons).isEmpty();
    // Confirm there are no unaccounted for resources
    // Expected: Coverage, Organization (3x), Patient, Encounter
    assertThat(e).hasSize(6);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Organization(org.hl7.fhir.r4.model.Organization) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.jupiter.api.Test)92 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)75 ArrayList (java.util.ArrayList)70 Coding (org.hl7.fhir.r4.model.Coding)70 Identifier (org.hl7.fhir.r4.model.Identifier)62 FHIRException (org.hl7.fhir.exceptions.FHIRException)45 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)45 Resource (org.hl7.fhir.r4.model.Resource)45 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)38 Test (org.junit.Test)37 Coding (org.hl7.fhir.dstu3.model.Coding)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)32 HashMap (java.util.HashMap)30 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)28 List (java.util.List)27 IOException (java.io.IOException)26 Bundle (org.hl7.fhir.r4.model.Bundle)26 Patient (org.hl7.fhir.r4.model.Patient)25 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)24 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)21