Search in sources :

Example 31 with Identifier

use of org.hl7.fhir.r4b.model.Identifier in project beneficiary-fhir-data by CMSgov.

the class R4PatientResourceProviderIT method searchForExistingPatientByMbiHashIncludeIdentifiersTrue.

/**
 * Verifies that {@link
 * gov.cms.bfd.server.war.r4.providers.R4PatientResourceProvider#searchByIdentifier(ca.uhn.fhir.rest.param.TokenParam)}
 * works as expected for a {@link Patient} that does exist in the DB, including identifiers to
 * return the unhashed HICN and MBI.
 */
@Test
public void searchForExistingPatientByMbiHashIncludeIdentifiersTrue() {
    List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
    IGenericClient fhirClient = createFhirClient("true", "true");
    Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
    Bundle searchResults = fhirClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndIdentifier(TransformerConstants.CODING_BBAPI_BENE_MBI_HASH, beneficiary.getMbiHash().get())).returnBundle(Bundle.class).execute();
    assertNotNull(searchResults);
    Patient patientFromSearchResult = (Patient) searchResults.getEntry().get(0).getResource();
    /*
     * Ensure the unhashed values for MBI is present.
     */
    Boolean mbiUnhashedPresent = false;
    Iterator<Identifier> identifiers = patientFromSearchResult.getIdentifier().iterator();
    while (identifiers.hasNext()) {
        Identifier identifier = identifiers.next();
        if (identifier.getSystem().equals(TransformerConstants.CODING_BBAPI_MEDICARE_BENEFICIARY_ID_UNHASHED)) {
            mbiUnhashedPresent = true;
        }
    }
    assertTrue(mbiUnhashedPresent);
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) StaticRifResource(gov.cms.bfd.model.rif.samples.StaticRifResource) Date(java.util.Date) ExtraParamsInterceptor(gov.cms.bfd.server.war.stu3.providers.ExtraParamsInterceptor) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Constants(ca.uhn.fhir.rest.api.Constants) Identifier(org.hl7.fhir.r4.model.Identifier) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) RequestHeaders(gov.cms.bfd.server.war.commons.RequestHeaders) CCWUtils(gov.cms.bfd.server.war.commons.CCWUtils) PipelineTestUtils(gov.cms.bfd.pipeline.sharedutils.PipelineTestUtils) BeforeAll(org.junit.jupiter.api.BeforeAll) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) BeneficiaryHistory(gov.cms.bfd.model.rif.BeneficiaryHistory) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) Patient(org.hl7.fhir.r4.model.Patient) Iterator(java.util.Iterator) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) MedicareBeneficiaryIdHistory(gov.cms.bfd.model.rif.MedicareBeneficiaryIdHistory) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) Stream(java.util.stream.Stream) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Bundle(org.hl7.fhir.r4.model.Bundle) Identifier(org.hl7.fhir.r4.model.Identifier) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.r4.model.Bundle) Patient(org.hl7.fhir.r4.model.Patient) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) Test(org.junit.jupiter.api.Test)

Example 32 with Identifier

use of org.hl7.fhir.r4b.model.Identifier in project kindling by HL7.

the class Publisher method resolve.

@Override
public javax.xml.transform.Source resolve(String href, String base) throws TransformerException {
    if (!href.startsWith("http://fhir.healthintersections.com.au/open/ValueSet/$expand"))
        return null;
    try {
        Map<String, String> params = splitQuery(new URL(href));
        ValueSet vs = page.getValueSets().get(params.get("identifier"));
        if (vs == null) {
            page.log("unable to resolve " + params.get("identifier"), LogMessageType.Process);
            return null;
        }
        vs = page.expandValueSet(vs, true);
        if (vs == null) {
            page.log("unable to expand " + params.get("identifier"), LogMessageType.Process);
            return null;
        }
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        new XmlParser().compose(bytes, vs, false);
        bytes.close();
        return new StreamSource(new ByteArrayInputStream(bytes.toByteArray()));
    } catch (Exception e) {
        throw new TransformerException(e);
    }
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) ByteArrayInputStream(java.io.ByteArrayInputStream) StreamSource(javax.xml.transform.stream.StreamSource) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ValueSet(org.hl7.fhir.r5.model.ValueSet) URL(java.net.URL) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) TransformerException(javax.xml.transform.TransformerException)

Example 33 with Identifier

use of org.hl7.fhir.r4b.model.Identifier in project kindling by HL7.

the class PageProcessor method generateConstraintsTable.

private void generateConstraintsTable(String path, ElementDefn e, Map<String, String> invs, boolean base, String prefix) throws Exception {
    for (Invariant inv : e.getInvariants().values()) {
        String s = "";
        if (base)
            s = "<tr><td><b title=\"Formal Invariant Identifier\">" + inv.getId() + "</b></td><td>" + presentLevel(inv) + "</td><td>(base)</td><td>" + Utilities.escapeXml(inv.getEnglish()) + "</td><td><span style=\"font-family: Courier New, monospace\">" + Utilities.escapeXml(inv.getExpression()) + "</span>";
        else
            s = "<tr><td><b title=\"Formal Invariant Identifier\">" + inv.getId() + "</b></td><td>" + presentLevel(inv) + "</td><td>" + path + "</td><td>" + Utilities.escapeXml(inv.getEnglish()) + "</td><td><span style=\"font-family: Courier New, monospace\">" + Utilities.escapeXml(inv.getExpression()) + "</span>";
        if (!Utilities.noString(inv.getExplanation()))
            s = s + "<br/>This is (only) a best practice guideline because: <blockquote>" + processMarkdown("best practice guideline", inv.getExplanation(), prefix) + "</blockquote>";
        s = s + "</td></tr>";
        invs.put(inv.getId(), s);
    }
    for (ElementDefn c : e.getElements()) {
        generateConstraintsTable(path + "." + c.getName(), c, invs, false, prefix);
    }
}
Also used : Invariant(org.hl7.fhir.definitions.model.Invariant) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn)

Example 34 with Identifier

use of org.hl7.fhir.r4b.model.Identifier in project kindling by HL7.

the class PageProcessor method generateConstraints.

private void generateConstraints(String path, ElementDefn e, Map<String, String> invs, boolean base, String prefix) throws Exception {
    for (Invariant inv : e.getInvariants().values()) {
        String s = "";
        if (base)
            s = "<li>" + presentLevel(inv) + " <b title=\"Formal Invariant Identifier\">" + inv.getId() + "</b>: " + Utilities.escapeXml(inv.getEnglish()) + " (<a href=\"http://hl7.org/fhirpath\">expression</a>: <span style=\"font-family: Courier New, monospace\">" + Utilities.escapeXml(inv.getExpression()) + "</span>)";
        else
            s = "<li>" + presentLevel(inv) + " <b title=\"Formal Invariant Identifier\">" + inv.getId() + "</b>: On " + path + ": " + Utilities.escapeXml(inv.getEnglish()) + " (<a href=\"http://hl7.org/fhirpath\">expression</a> on " + presentPath(path) + ": <span style=\"font-family: Courier New, monospace\">" + Utilities.escapeXml(inv.getExpression()) + "</span>)";
        if (!Utilities.noString(inv.getExplanation()))
            s = s + ". This is (only) a best practice guideline because: <blockquote>" + processMarkdown("best practice guideline", inv.getExplanation(), prefix) + "</blockquote>";
        invs.put(inv.getId(), s + "</li>");
    }
    for (ElementDefn c : e.getElements()) {
        generateConstraints(path + "." + c.getName(), c, invs, false, prefix);
    }
}
Also used : Invariant(org.hl7.fhir.definitions.model.Invariant) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn)

Example 35 with Identifier

use of org.hl7.fhir.r4b.model.Identifier in project kindling by HL7.

the class CDAGenerator method buildInfrastructureRoot.

private void buildInfrastructureRoot() throws DefinitionException {
    StructureDefinition sd = new StructureDefinition();
    sd.setId("InfrastructureRoot");
    sd.setUrl("http://hl7.org/fhir/cda/StructureDefinition/InfrastructureRoot");
    library.put(sd.getUrl(), sd);
    sd.setName("Base Type for all classes in the CDA structure");
    sd.setTitle("InfrastructureRoot");
    sd.setStatus(PublicationStatus.ACTIVE);
    sd.setExperimental(false);
    sd.setPublisher("HL7");
    sd.setDescription("Defines the base elements and attributes on all CDA elements (other than data types)");
    sd.setKind(StructureDefinitionKind.LOGICAL);
    sd.setType(sd.getUrl());
    sd.setAbstract(true);
    sd.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").setValue(new UriType("urn:hl7-org:v3"));
    sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/ANY");
    sd.setDerivation(TypeDerivationRule.SPECIALIZATION);
    ElementDefinition edb = new ElementDefinition();
    edb.setPath(sd.getId());
    seePath(edb);
    edb.setMin(1);
    edb.setMax("*");
    edb.addType().setCode("Element");
    sd.getDifferential().getElement().add(edb);
    ElementDefinition ed = new ElementDefinition();
    ed.setPath("InfrastructureRoot.realmCode");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("*");
    ed.setDefinition("When valued in an instance, this attribute signals the imposition of realm-specific constraints. The value of this attribute identifies the realm in question");
    ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/CS");
    sd.getDifferential().getElement().add(ed);
    ed = new ElementDefinition();
    ed.setPath("InfrastructureRoot.typeId");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("1");
    ed.setDefinition("When valued in an instance, this attribute signals the imposition of constraints defined in an HL7-specified message type. This might be a common type (also known as CMET in the messaging communication environment), or content included within a wrapper. The value of this attribute provides a unique identifier for the type in question.");
    ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/II");
    sd.getDifferential().getElement().add(ed);
    ed = new ElementDefinition();
    ed.setPath("InfrastructureRoot.templateId");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("*");
    ed.setDefinition("When valued in an instance, this attribute signals the imposition of a set of template-defined constraints. The value of this attribute provides a unique identifier for the templates in question");
    ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/II");
    sd.getDifferential().getElement().add(ed);
    new ProfileUtilities(null, null, null).setIds(sd, true);
    structures.add(sd);
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) UriType(org.hl7.fhir.r5.model.UriType)

Aggregations

Identifier (org.hl7.fhir.r4.model.Identifier)212 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)143 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)125 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)116 Test (org.junit.Test)90 Test (org.junit.jupiter.api.Test)84 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)66 ArrayList (java.util.ArrayList)62 Reference (org.hl7.fhir.r4.model.Reference)57 Identifier (org.hl7.fhir.dstu3.model.Identifier)55 Patient (org.hl7.fhir.r4.model.Patient)55 Coding (org.hl7.fhir.r4.model.Coding)49 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)41 Practitioner (org.hl7.fhir.r4.model.Practitioner)41 Date (java.util.Date)40 List (java.util.List)40 Resource (org.hl7.fhir.r4.model.Resource)37 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)36 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)34 Collectors (java.util.stream.Collectors)31