Search in sources :

Example 6 with CURRENT

use of org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.CURRENT in project kindling by HL7.

the class OldVersionRedirector method fileIsInCurrent.

private boolean fileIsInCurrent(String filename, String existing, String current) {
    String tail = filename.substring(existing.length());
    if (tail.endsWith(".htm"))
        tail = tail + "l";
    String target = current + tail;
    return new File(target).exists();
}
Also used : CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile) File(java.io.File)

Example 7 with CURRENT

use of org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.CURRENT in project kindling by HL7.

the class OldVersionRedirector method process.

private void process(String existing, String current, String oldVersion, String newVersion) throws Exception {
    List<String> filenames = new ArrayList<String>();
    listAllFiles(filenames, new File(existing));
    for (String filename : filenames) {
        System.out.println(filename);
        String content = TextFile.fileToString(filename);
        if (content.contains("<div class=\"col-9\">")) {
            String message = fileIsInCurrent(filename, existing, current) ? upd_exists.replace("[x]", newUrl(filename, existing)) : upd_no_exists.replace("[x]", "index.html");
            message = message.replace("[ov]", "(" + oldVersion + ")").replace("[nv]", "(" + newVersion + ")").replace("[p]", prefix(filename, existing));
            int i = content.indexOf("<!--old-s-->");
            if (i > -1) {
                int j = content.indexOf("<!--old-e-->");
                content = content.substring(0, i) + content.substring(j + 14);
            }
            i = content.indexOf("<div class=\"col-9\">");
            content = content.substring(0, i + 22) + message + content.substring(i + 22);
            TextFile.stringToFile(content, filename);
        } else if (content.contains("<div class=\"content\"")) {
            String message = fileIsInCurrent(filename, existing, current) ? upd_exists.replace("[x]", newUrl(filename, existing)) : upd_no_exists.replace("[x]", "index.html");
            message = message.replace("[ov]", "(" + oldVersion + ")").replace("[nv]", "(" + newVersion + ")").replace("[p]", prefix(filename, existing));
            int i = content.indexOf("<!--old-s-->");
            if (i > -1) {
                int j = content.indexOf("<!--old-e-->");
                content = content.substring(0, i) + content.substring(j + 14);
            }
            i = content.indexOf("<div class=\"content\">");
            content = content.substring(0, i + 22) + message + content.substring(i + 22);
            TextFile.stringToFile(content, filename);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile) File(java.io.File)

Example 8 with CURRENT

use of org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.CURRENT in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_status_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_status_test(String segment) {
    // Check TXA.19
    // TXA.19 value maps to status; OBR.25 is ignored
    String documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||PA||OB|||<PHYSID2>||\n" + "OBX|1|SN|||||||||X";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus status = report.getStatus();
    // TXA.19
    assertThat(status.toCode()).isEqualTo("superseded");
    assertThat(status.getSystem()).isEqualTo("http://hl7.org/fhir/document-reference-status");
    // Check OBR.25 as fallback
    // TXA.19 value is empty so OBR.25 is used
    documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS\n" + "OBR|1||||||20170825010500|||||||||||||002|||||X\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||PA|||||<PHYSID2>\n" + "OBX|1|SN|||||||||X";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    status = report.getStatus();
    // OBR.25
    assertThat(status.toCode()).isEqualTo("entered-in-error");
    assertThat(status.getSystem()).isEqualTo("http://hl7.org/fhir/document-reference-status");
    // Check default value case
    // TXA.19 and OBR.25 values are empty so should fallback to "current"
    documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||PA\n" + "OBX|1|SN|||||||||X";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    status = report.getStatus();
    // default value
    assertThat(status.toCode()).isEqualTo("current");
    assertThat(status.getSystem()).isEqualTo("http://hl7.org/fhir/document-reference-status");
}
Also used : DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with CURRENT

use of org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.CURRENT in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7MDMMessageTest method test_mdm_ORDER_with_OBXnotTX.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void test_mdm_ORDER_with_OBXnotTX(String message) throws IOException {
    // Also check NTE working for MDM messages.
    String hl7message = "MSH|^~\\&|HNAM|W|RAD_IMAGING_REPORT|W|20180118111520||" + message + "|<MESSAGEID>|P|2.6\r" + "EVN||20150502090000|\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "PV1||O||||||||||||||||||||||||||||||||||||||||||199501102300\r" + "ORC|NW|622470H432|||||^^^^^R||||||||||||||\r" + "OBR|1|622470H432|102397CE432|||20170725143849|20180102|||||||||||||||||RAD|O||^^^^^R||||REASON_ID_1^REASON_TEXT_1||||\r" + // ServiceRequest NTE has a practitioner reference in NTE.5
    "NTE|1|O|TEST ORC/OBR NOTE AA line 1||Pract1ID^Pract1Last^Pract1First|\n" + "NTE|2|O|TEST NOTE AA line 2|\n" + "TXA|1|HP^History and physical examination|TX||||201801171442||||||||||||AV|||||\r" + "OBX|1|NM|Most Current Weight^Most current measured weight (actual)||90|kg\r" + // Observation NTE has a practitioner reference in second NTE.5. Annotation uses the first valid NTE.5
    "NTE|1|L|TEST OBX NOTE BB line 1|\n" + "NTE|2|L|TEST NOTE BB line 2||Pract2ID^Pract2Last^Pract2First|\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    // Check for the expected resources
    List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // from EVN, PV1
    assertThat(encounterResource).hasSize(1);
    List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // from PID
    assertThat(patientResource).hasSize(1);
    List<Resource> serviceRequestResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    // from ORC, OBR
    assertThat(serviceRequestResource).hasSize(1);
    // Light check that ServiceRequest contains NTE for ORC/OBR;  Deep check of NTE in Hl7NoteFHIRConverterTest.
    ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequestResource.get(0), ResourceUtils.context);
    assertThat(serviceRequest.hasNote()).isTrue();
    assertThat(serviceRequest.getNote()).hasSize(1);
    // NOTE: the note contains an Annotation, which contains a MarkdownType that has the string.
    // Must use getTextElement().getValueAsString() to see untrimmed contents.
    assertThat(serviceRequest.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST ORC/OBR NOTE AA line 1  \nTEST NOTE AA line 2");
    assertThat(serviceRequest.getNote().get(0).hasAuthorReference()).isTrue();
    List<Resource> documentReferenceResource = ResourceUtils.getResourceList(e, ResourceType.DocumentReference);
    // from TXA
    assertThat(documentReferenceResource).hasSize(1);
    List<Resource> observationResources = ResourceUtils.getResourceList(e, ResourceType.Observation);
    // from OBX(not type TX)
    assertThat(observationResources).hasSize(1);
    // Light check that Observation contains NTE for OBX;  Deep check of NTE in Hl7NoteFHIRConverterTest.
    Observation observation = ResourceUtils.getResourceObservation(observationResources.get(0), ResourceUtils.context);
    // Validate the note contents and reference existance.
    assertThat(observation.hasNote()).isTrue();
    assertThat(observation.getNote()).hasSize(1);
    // NOTE: the note contains an Annotation, which contains a MarkdownType that has the string.
    // Must use getTextElement().getValueAsString() to see untrimmed contents.
    assertThat(observation.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST OBX NOTE BB line 1  \nTEST NOTE BB line 2");
    assertThat(observation.getNote().get(0).hasAuthorReference()).isTrue();
    // Two Practitioners, one for the serviceRequest, one for the Observation
    List<Resource> practitioners = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
    // from NTE.4 references
    assertThat(practitioners).hasSize(2);
    // Confirm that no extra resources are created
    assertThat(e.size()).isEqualTo(7);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with CURRENT

use of org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus.CURRENT in project cqf-ruler by DBCG.

the class ReportProvider method report.

/**
 * Implements the <a href=
 * "https://build.fhir.org/ig/HL7/davinci-ra/OperationDefinition-report.html">$report</a>
 * operation found in the
 * <a href="https://build.fhir.org/ig/HL7/davinci-ra/index.html">Da Vinci Risk
 * Adjustment IG</a>.
 *
 * @param requestDetails metadata about the current request being processed.
 *                       Generally auto-populated by the HAPI FHIR server
 *                       framework.
 * @param periodStart    the start of the clinical evaluation period
 * @param periodEnd      the end of the clinical evaluation period
 * @param subject        a Patient or Patient Group
 * @return a Parameters with Bundles of MeasureReports and evaluatedResource
 *         Resources
 */
@Description(shortDefinition = "$report", value = "Implements the <a href=\"https://build.fhir.org/ig/HL7/davinci-ra/OperationDefinition-report.html\">$report</a> operation found in the <a href=\"https://build.fhir.org/ig/HL7/davinci-ra/index.html\">Da Vinci Risk Adjustment IG</a>.")
@Operation(name = "$report", idempotent = true, type = MeasureReport.class)
public Parameters report(RequestDetails requestDetails, @OperationParam(name = "periodStart", min = 1, max = 1) String periodStart, @OperationParam(name = "periodEnd", min = 1, max = 1) String periodEnd, @OperationParam(name = "subject", min = 1, max = 1) String subject) throws FHIRException {
    validateParameters(periodStart, periodEnd, subject);
    Parameters result = newResource(Parameters.class, subject.replace("/", "-") + "-report");
    Date periodStartDate = Operations.resolveRequestDate(periodStart, true);
    Date periodEndDate = Operations.resolveRequestDate(periodEnd, false);
    Period period = new Period().setStart(periodStartDate).setEnd(periodEndDate);
    List<Patient> patients = getPatientListFromSubject(subject);
    (patients).forEach(patient -> {
        Parameters.ParametersParameterComponent patientParameter = patientReport(patient, period, requestDetails.getFhirServerBase());
        result.addParameter(patientParameter);
    });
    return result;
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) Period(org.hl7.fhir.r4.model.Period) Patient(org.hl7.fhir.r4.model.Patient) Date(java.util.Date) Description(ca.uhn.fhir.model.api.annotation.Description) Operation(ca.uhn.fhir.rest.annotation.Operation)

Aggregations

ArrayList (java.util.ArrayList)38 Date (java.util.Date)31 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)24 Coding (org.hl7.fhir.r4.model.Coding)21 Reference (org.hl7.fhir.r4.model.Reference)21 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)20 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)17 Reference (org.hl7.fhir.dstu3.model.Reference)16 HashMap (java.util.HashMap)15 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)15 Coding (org.hl7.fhir.dstu3.model.Coding)14 Identifier (org.hl7.fhir.r4.model.Identifier)14 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)13 JsonObject (com.google.gson.JsonObject)12 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)12 Meta (org.hl7.fhir.r4.model.Meta)12 List (java.util.List)11 Period (org.hl7.fhir.r4.model.Period)11 Test (org.junit.jupiter.api.Test)11 Extension (org.hl7.fhir.r4.model.Extension)10