Search in sources :

Example 16 with FINISHED

use of org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED in project cqf-ruler by DBCG.

the class CodeSystemProviderIT method testR4UpdateCodeSystems.

@Test
@Order(5)
public void testR4UpdateCodeSystems() throws IOException {
    log.info("Beginning Test R4 Update Code Systems");
    assertEquals(0, performCodeSystemSearchByUrl(cptUrl).size());
    File[] valuesets = new File(CodeSystemProviderIT.class.getResource("valueset").getPath()).listFiles();
    for (File file : valuesets) {
        if (file.isFile() && FilenameUtils.getExtension(file.getPath()).equals("json")) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            String resourceString = reader.lines().collect(Collectors.joining(System.lineSeparator()));
            reader.close();
            loadResource("json", resourceString);
        } else if (file.isFile() && FilenameUtils.getExtension(file.getPath()).equals("xml")) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            String resourceString = reader.lines().collect(Collectors.joining(System.lineSeparator()));
            reader.close();
            loadResource("xml", resourceString);
        }
    }
    OperationOutcome outcome = codeSystemUpdateProvider.updateCodeSystems();
    for (OperationOutcomeIssueComponent issue : outcome.getIssue()) {
        assertEquals(OperationOutcome.IssueSeverity.INFORMATION, issue.getSeverity());
        assertTrue(issue.getDetails().getText().startsWith("Successfully updated the following CodeSystems: "));
        assertTrue(issue.getDetails().getText().contains("cpt"));
        assertTrue(issue.getDetails().getText().contains("sct"));
        assertTrue(issue.getDetails().getText().contains("loinc"));
    }
    assertEquals(1, performCodeSystemSearchByUrl(loincUrl).size());
    assertEquals(1, performCodeSystemSearchByUrl(snomedSctUrl).size());
    assertEquals(1, performCodeSystemSearchByUrl(cptUrl).size());
    log.info("Finished Test R4 Update Code Systems");
}
Also used : InputStreamReader(java.io.InputStreamReader) OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) BufferedReader(java.io.BufferedReader) File(java.io.File) FileInputStream(java.io.FileInputStream) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 17 with FINISHED

use of org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED in project cqf-ruler by DBCG.

the class DataOperationProviderIT method testR4LibraryFhirQueryPattern.

@Test
public void testR4LibraryFhirQueryPattern() throws IOException {
    String bundleAsText = stringFromResource("ExmLogicTransactionBundle.json");
    Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(bundleAsText);
    getClient().transaction().withBundle(bundle).execute();
    Parameters params = new Parameters();
    params.addParameter().setName("target").setValue(new StringType("dummy"));
    Library returnLibrary = getClient().operation().onInstance(new IdType("Library", "EXMLogic")).named("$data-requirements").withParameters(params).returnResourceType(Library.class).execute();
    assertNotNull(returnLibrary);
    for (DataRequirement dr : returnLibrary.getDataRequirement()) {
        switch(dr.getType()) {
            case "Patient":
                {
                    String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
                    assertTrue("Patient?_id={{context.patientId}}".equals(query));
                }
                break;
            case "Encounter":
                {
                    String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
                    if (dr.hasCodeFilter()) {
                        assertTrue("Encounter?status=finished&subject=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292".equals(query));
                    } else {
                        assertTrue("Encounter?subject=Patient/{{context.patientId}}".equals(query));
                    }
                }
                break;
            case "Coverage":
                {
                    String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
                    assertTrue("Coverage?policy-holder=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591".equals(query));
                }
                break;
        }
    }
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) Bundle(org.hl7.fhir.r4.model.Bundle) Library(org.hl7.fhir.r4.model.Library) DataRequirement(org.hl7.fhir.r4.model.DataRequirement) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 18 with FINISHED

use of org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED in project cqf-ruler by DBCG.

the class DataOperationProviderIT method testR4MeasureFhirQueryPattern.

@Test
public void testR4MeasureFhirQueryPattern() throws IOException {
    String bundleAsText = stringFromResource("ExmLogicMeasureTransactionBundle.json");
    Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(bundleAsText);
    getClient().transaction().withBundle(bundle).execute();
    Parameters params = new Parameters();
    params.addParameter().setName("startPeriod").setValue(new StringType("2019-01-01"));
    params.addParameter().setName("endPeriod").setValue(new StringType("2020-01-01"));
    Library returnLibrary = getClient().operation().onInstance(new IdType("Measure", "measure-exm")).named("$data-requirements").withParameters(params).returnResourceType(Library.class).execute();
    assertNotNull(returnLibrary);
    for (DataRequirement dr : returnLibrary.getDataRequirement()) {
        switch(dr.getType()) {
            case "Patient":
                {
                    String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
                    assertTrue("Patient?_id={{context.patientId}}".equals(query));
                }
                break;
            case "Encounter":
                {
                    String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
                    if (dr.hasCodeFilter()) {
                        assertTrue("Encounter?status=finished&subject=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292".equals(query));
                    } else {
                        assertTrue("Encounter?subject=Patient/{{context.patientId}}".equals(query));
                    }
                }
                break;
            case "Coverage":
                {
                    String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
                    assertTrue("Coverage?policy-holder=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591".equals(query));
                }
                break;
        }
    }
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) Bundle(org.hl7.fhir.r4.model.Bundle) Library(org.hl7.fhir.r4.model.Library) DataRequirement(org.hl7.fhir.r4.model.DataRequirement) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 19 with FINISHED

use of org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED in project summary-care-record-api by NHSDigital.

the class DiagnosisMapper method mapEncounter.

private void mapEncounter(Node diagnosis, Condition condition, List<Resource> resources) {
    Optional<Node> author = xmlUtils.detachOptionalNodeByXPath(diagnosis, DIAGNOSIS_AUTHOR_XPATH);
    Optional<Node> informant = xmlUtils.detachOptionalNodeByXPath(diagnosis, DIAGNOSIS_INFORMANT_XPATH);
    if (author.isPresent() || informant.isPresent()) {
        Encounter encounter = new Encounter();
        encounter.setStatus(FINISHED);
        encounter.setClass_(new Coding().setCode("UNK").setSystem("http://terminology.hl7.org/CodeSystem/v3-NullFlavor").setDisplay("Unknown"));
        encounter.setId(randomUUID());
        author.ifPresent(authorNode -> mapAuthor(resources, encounter, authorNode));
        informant.ifPresent(informantNode -> mapInformant(resources, encounter, informantNode));
        condition.setEncounter(new Reference(encounter));
        resources.add(encounter);
    }
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) Node(org.w3c.dom.Node) Encounter(org.hl7.fhir.r4.model.Encounter)

Example 20 with FINISHED

use of org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED in project summary-care-record-api by NHSDigital.

the class FindingMapper method mapEncounter.

private void mapEncounter(Node finding, Observation observation, List<Resource> resources) {
    Optional<Node> author = xmlUtils.detachOptionalNodeByXPath(finding, FINDING_AUTHOR_XPATH);
    Optional<Node> informant = xmlUtils.detachOptionalNodeByXPath(finding, FINDING_INFORMANT_XPATH);
    NodeList performerNodes = xmlUtils.getNodeListByXPath(finding, FINDING_PERFORMER_XPATH);
    if (author.isPresent() || informant.isPresent() || performerNodes.getLength() > 0) {
        Encounter encounter = new Encounter();
        encounter.setStatus(FINISHED);
        encounter.setClass_(new Coding().setCode("UNK").setSystem(ENCOUNTER_CLASS_SYSTEM).setDisplay("Unknown"));
        encounter.setId(randomUUID());
        mapPerformers(resources, encounter, performerNodes);
        author.ifPresent(authorNode -> mapAuthor(resources, encounter, authorNode));
        informant.ifPresent(informantNode -> mapInformant(resources, encounter, informantNode));
        observation.setEncounter(new Reference(encounter));
        resources.add(encounter);
    }
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Encounter(org.hl7.fhir.r4.model.Encounter)

Aggregations

Test (org.junit.jupiter.api.Test)8 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 Bundle (org.hl7.fhir.r4.model.Bundle)7 File (java.io.File)6 Date (java.util.Date)6 Order (org.junit.jupiter.api.Order)6 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)6 FileInputStream (java.io.FileInputStream)5 BufferedReader (java.io.BufferedReader)4 InputStreamReader (java.io.InputStreamReader)4 Reference (org.hl7.fhir.r4.model.Reference)4 TokenClientParam (ca.uhn.fhir.rest.gclient.TokenClientParam)3 HashSet (java.util.HashSet)3 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)3 Coding (org.hl7.fhir.r4.model.Coding)3 Task (org.hl7.fhir.r4.model.Task)3 ValueSet (org.hl7.fhir.r4.model.ValueSet)3 Provider (org.mitre.synthea.world.agents.Provider)3 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)3