Search in sources :

Example 11 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project kindling by HL7.

the class ProfileGenerator method makeSearchParam.

public SearchParameter makeSearchParam(StructureDefinition p, String id, String rn, SearchParameterDefn spd, ResourceDefn rd) throws Exception {
    boolean shared;
    boolean created = true;
    SearchParameter sp;
    if (definitions.getCommonSearchParameters().containsKey(rn + "::" + spd.getCode())) {
        shared = true;
        CommonSearchParameter csp = definitions.getCommonSearchParameters().get(rn + "::" + spd.getCode());
        if (csp.getDefinition() == null) {
            sp = new SearchParameter();
            csp.setDefinition(sp);
            sp.setId(csp.getId());
        } else {
            created = false;
            sp = csp.getDefinition();
        }
    } else {
        shared = false;
        sp = new SearchParameter();
        sp.setId(id.replace("[", "").replace("]", ""));
    }
    spd.setCommonId(sp.getId());
    if (created) {
        sp.setUrl("http://hl7.org/fhir/SearchParameter/" + sp.getId());
        sp.setVersion(version.toCode());
        if (context.getSearchParameter(sp.getUrl()) != null)
            throw new Exception("Duplicated Search Parameter " + sp.getUrl());
        context.cacheResource(sp);
        spd.setResource(sp);
        definitions.addNs(sp.getUrl(), "Search Parameter: " + sp.getName(), rn.toLowerCase() + ".html#search");
        sp.setStatus(spd.getStandardsStatus() == StandardsStatus.NORMATIVE ? PublicationStatus.fromCode("active") : PublicationStatus.fromCode("draft"));
        StandardsStatus sst = ToolingExtensions.getStandardsStatus(sp);
        if (sst == null || (spd.getStandardsStatus() == null && spd.getStandardsStatus().isLowerThan(sst)))
            ToolingExtensions.setStandardsStatus(sp, spd.getStandardsStatus(), spd.getNormativeVersion());
        sp.setExperimental(p.getExperimental());
        sp.setName(spd.getCode());
        sp.setCode(spd.getCode());
        sp.setDate(genDate.getTime());
        sp.setPublisher(p.getPublisher());
        for (ContactDetail tc : p.getContact()) {
            ContactDetail t = sp.addContact();
            if (tc.hasNameElement())
                t.setNameElement(tc.getNameElement().copy());
            for (ContactPoint ts : tc.getTelecom()) t.getTelecom().add(ts.copy());
        }
        if (!definitions.hasResource(p.getType()) && !p.getType().equals("Resource") && !p.getType().equals("DomainResource"))
            throw new Exception("unknown resource type " + p.getType());
        sp.setType(getSearchParamType(spd.getType()));
        if (sp.getType() == SearchParamType.REFERENCE && spd.isHierarchy()) {
            sp.addModifier(SearchParameter.SearchModifierCode.BELOW);
            sp.addModifier(SearchParameter.SearchModifierCode.ABOVE);
        }
        if (shared) {
            sp.setDescription("Multiple Resources: \r\n\r\n* [" + rn + "](" + rn.toLowerCase() + ".html): " + spd.getDescription() + "\r\n");
        } else
            sp.setDescription(preProcessMarkdown(spd.getDescription(), "Search Description"));
        if (!Utilities.noString(spd.getExpression()))
            sp.setExpression(spd.getExpression());
        // addModifiers(sp);
        addComparators(sp);
        String xpath = Utilities.noString(spd.getXPath()) ? new XPathQueryGenerator(this.definitions, null, null).generateXpath(spd.getPaths(), rn) : spd.getXPath();
        if (xpath != null) {
            if (xpath.contains("[x]"))
                xpath = convertToXpath(xpath);
            sp.setXpath(xpath);
            sp.setXpathUsage(spd.getxPathUsage());
        }
        if (sp.getType() == SearchParamType.COMPOSITE) {
            for (CompositeDefinition cs : spd.getComposites()) {
                SearchParameterDefn cspd = findSearchParameter(rd, cs.getDefinition());
                if (cspd != null)
                    sp.addComponent().setExpression(cs.getExpression()).setDefinition(cspd.getUrl());
                else
                    sp.addComponent().setExpression(cs.getExpression()).setDefinition("http://hl7.org/fhir/SearchParameter/" + rn + "-" + cs.getDefinition());
            }
            sp.setMultipleOr(false);
        }
        sp.addBase(p.getType());
    } else {
        if (sp.getType() != getSearchParamType(spd.getType()))
            throw new FHIRException("Type mismatch on common parameter: expected " + sp.getType().toCode() + " but found " + getSearchParamType(spd.getType()).toCode());
        if (!sp.getDescription().contains("[" + rn + "](" + rn.toLowerCase() + ".html)"))
            sp.setDescription(sp.getDescription() + "* [" + rn + "](" + rn.toLowerCase() + ".html): " + spd.getDescription() + "\r\n");
        // ext.addExtension("description", new MarkdownType(spd.getDescription()));
        if (!Utilities.noString(spd.getExpression()) && !sp.getExpression().contains(spd.getExpression()))
            sp.setExpression(sp.getExpression() + " | " + spd.getExpression());
        String xpath = new XPathQueryGenerator(this.definitions, null, null).generateXpath(spd.getPaths(), rn);
        if (xpath != null) {
            if (xpath.contains("[x]"))
                xpath = convertToXpath(xpath);
            if (sp.getXpath() != null && !sp.getXpath().contains(xpath))
                sp.setXpath(sp.getXpath() + " | " + xpath);
            if (sp.getXpathUsage() != spd.getxPathUsage())
                throw new FHIRException("Usage mismatch on common parameter: expected " + sp.getXpathUsage().toCode() + " but found " + spd.getxPathUsage().toCode());
        }
        boolean found = false;
        for (CodeType ct : sp.getBase()) found = found || p.getType().equals(ct.asStringValue());
        if (!found)
            sp.addBase(p.getType());
    }
    spd.setUrl(sp.getUrl());
    for (String target : spd.getWorkingTargets()) {
        if ("Any".equals(target) == true) {
            for (String resourceName : definitions.sortedResourceNames()) {
                boolean found = false;
                for (CodeType st : sp.getTarget()) found = found || st.asStringValue().equals(resourceName);
                if (!found)
                    sp.addTarget(resourceName);
            }
        } else {
            boolean found = false;
            for (CodeType st : sp.getTarget()) found = found || st.asStringValue().equals(target);
            if (!found)
                sp.addTarget(target);
        }
    }
    return sp;
}
Also used : SearchParameterDefn(org.hl7.fhir.definitions.model.SearchParameterDefn) FHIRException(org.hl7.fhir.exceptions.FHIRException) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) CompositeDefinition(org.hl7.fhir.definitions.model.SearchParameterDefn.CompositeDefinition) ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) CodeType(org.hl7.fhir.r5.model.CodeType) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) StandardsStatus(org.hl7.fhir.utilities.StandardsStatus)

Example 12 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project kindling by HL7.

the class FhirTurtleGenerator method genPrimitiveType.

/* ==============================================
     Generators for various FHIR types
   * ============================================== */
/**
 * PrimitiveType Generator
 *
 * @param pt FHIR Primitive Type (e.g. int, string, dateTime)
 */
// Note: For unknown reasons, getPrimitives returns DefinedCodes, not PrimitiveTypes...
private void genPrimitiveType(DefinedCode pt) {
    String ptName = pt.getCode();
    FHIRResource ptRes = fact.fhir_class(ptName, "Primitive").addDefinition(pt.getDefinition());
    Resource rdfType = RDFTypeMap.xsd_type_for(ptName, owlTarget);
    if (rdfType != null)
        ptRes.restriction(fact.fhir_cardinality_restriction(value, fact.fhir_datatype(rdfType).resource, 1, 1));
}
Also used : FHIRResource(org.hl7.fhir.rdf.FHIRResource) Resource(org.apache.jena.rdf.model.Resource) FHIRResource(org.hl7.fhir.rdf.FHIRResource)

Example 13 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN 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)

Example 14 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testForDataBleedFromPatientToOrganization.

@Test
// Ensure that Patient data does not bleed into Organizations created for the Patient's insurance
void testForDataBleedFromPatientToOrganization() throws IOException {
    String hl7message = "MSH|^~\\&|TEST|TEST|||20220101120000||ADT^A01^ADT_A01|1234|P|2.6\n" + // PID.12 Used for district calculation
    "PID|1|103456|MR12345678^^^^MR||DOE^JANE^|||F|||19 Raymond St^Route3^Albany^NY^56321^USA^P|12||||||||||||||||||||||||||\n" + // PD1.4 Used for org creation to check for bleed of districts
    "PD1|||Mayo|123456^Walt^^^^Dr||||||||||||||||||\n" + // IN1 Broadly populated to create organization
    "IN1|1|GLOBAL|7776664|Blue Cross Blue Shield|456 Blue Cross Lane||||Blue|987123|IBM||||||NON||||||||||||20210322145350|Dr Disney|S|GOOD|200|12|B6543|H789456|||17|||1|M|123 IBM way|True|NONE|B|NO|J321456|M|20210322145605|London|YES\n" + // IN2 Broadly populated to create organizations
    "IN2|A23456|222001111|IBM 1345|EMPLOYEED|E|N23497234|R3294809|S234234|Army|U439823|SGT SCHULTZ|Army|Fort Wayne|USA|E1... E9|ACT|20300402145954|N|N|N|Yes|Grey Duck|Goose|T34941341232|D123123123|C435435345|2|SPR|2ANC|1234.00|O|A0|USA|EN|F|F|Y|N|COG|Stanley|DUTCH|N|M|20170322150208||Software Engineer|8|P|Mr Blue|1-555-333-4444|SURGERY|Jim Stanley|1-555-222-3333|FIRST|20170202150409|20210322150400|3|1-222-333-4444|GLOBAL|GROUP|B14456789|OTH|1-444-777-8888|1-444-555-3333|NONE|N|Y|N|GVH 123456|CDP 98765|2106-3|9\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // From PID
    assertThat(patients).hasSize(1);
    Patient patient = (Patient) patients.get(0);
    assertThat(patient.getAddressFirstRep().getDistrict()).hasToString("12");
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // From Payor created by IN1
    assertThat(organizations).hasSize(3);
    Organization org = (Organization) organizations.get(0);
    assertThat(org.getAddressFirstRep().hasDistrict()).isFalse();
    org = (Organization) organizations.get(1);
    assertThat(org.hasAddress()).isFalse();
    org = (Organization) organizations.get(2);
    assertThat(org.hasAddress()).isFalse();
    List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
    // From IN1 segment
    assertThat(coverages).hasSize(1);
    Coverage coverage = (Coverage) coverages.get(0);
    // Confirm Coverage Identifiers
    assertThat(coverage.getIdentifier()).hasSize(6);
    // Coverage Identifiers deep check in testBasicInsuranceCoverageFields
    // Because the relationship is NON, no subscriber is created
    assertThat(coverage.hasSubscriber()).isFalse();
    // Expect no RelatedPerson because IN1.17 is NON
    List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
    // No related person should be created because IN1.17 was an unknown code
    assertThat(relatedPersons).isEmpty();
    // Confirm there are no unaccounted for resources
    // Expected: Coverage, Organization (3), Patient, Practitioner
    assertThat(e).hasSize(6);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) 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)

Example 15 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project hl7v2-fhir-converter by LinuxForHealth.

the class CodeableConceptTest method testCodeableConceptDoubleRaceWithVersionAndAlternate.

@Test
void testCodeableConceptDoubleRaceWithVersionAndAlternate() {
    // This has both a known and an unknown system.
    // "valueCodeableConcept": {
    // "coding": [ {
    // "system": <known-to-FHIR>,  << FIRST CODING
    // "display": <original-display-value>
    // "code": <code-from-input>
    // "version": <version>
    // },
    // {
    // "system": <unknown, so made up "urn:id:L">,  << SECOND (ALTERNATE CODING)
    // "display": <original-alternate display-value>
    // "code": <altenate-code>
    // "version": <alternate-version>
    // } ],
    // "text": <original-display-value>
    // },
    String patientWithDoubleRaceWithVersionAndAlternate = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + // Test double race in the SAME CWE (not a second CWE) and versions.  Use made up Cauc to ensure test doesn't mix up whites.
    "PID|1||12345678^^^^MR||TestPatientLastName^Jane|||||2106-3^White^CDCREC^CA^Caucasian^L^1.1^4|\n";
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientWithDoubleRaceWithVersionAndAlternate);
    assertThat(patient.hasExtension()).isTrue();
    List<Extension> extensions = patient.getExtensionsByUrl(UrlLookup.getExtensionUrl("race"));
    assertThat(extensions).isNotNull();
    assertThat(extensions.size()).isEqualTo(1);
    assertThat(extensions.get(0).hasValue()).isTrue();
    CodeableConcept ccW = (CodeableConcept) extensions.get(0).getValue();
    assertThat(ccW.hasCoding()).isTrue();
    assertThat(ccW.hasText()).isTrue();
    assertThat(ccW.getText()).hasToString("White");
    List<Coding> codings = ccW.getCoding();
    assertThat(codings.size()).isEqualTo(2);
    DatatypeUtils.checkCommonCodingAssertions(codings.get(0), "2106-3", "White", V3_RACE_SYSTEM, "1.1");
    DatatypeUtils.checkCommonCodingAssertions(codings.get(1), "CA", "Caucasian", "urn:id:L", "4");
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Coding(org.hl7.fhir.r4.model.Coding) Patient(org.hl7.fhir.r4.model.Patient) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)51 ArrayList (java.util.ArrayList)41 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)36 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)27 Test (org.junit.jupiter.api.Test)23 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)20 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)18 Reference (org.hl7.fhir.r4.model.Reference)17 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)17 HashMap (java.util.HashMap)15 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)15 Coding (org.hl7.fhir.r4.model.Coding)14 Identifier (org.hl7.fhir.r4.model.Identifier)14 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)13 Patient (org.hl7.fhir.r4.model.Patient)13 IOException (java.io.IOException)12 Header (org.apache.http.Header)11 Test (org.junit.Test)11 File (java.io.File)10 URISyntaxException (java.net.URISyntaxException)10