Search in sources :

Example 1 with DocumentReference

use of org.hl7.fhir.dstu3.model.DocumentReference 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 2 with DocumentReference

use of org.hl7.fhir.dstu3.model.DocumentReference in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_doc_status_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_doc_status_test(String segment) {
    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|||20180117144200|201801180346||<PHYSID1>||||||||PA||AV|||<PHYSID2>||\n" + "OBX|1|ST|100||This is content|||||||X\n";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    DocumentReference.ReferredDocumentStatus docStatus = report.getDocStatus();
    // TXA.17
    assertThat(docStatus.toCode()).isEqualTo("preliminary");
    assertThat(docStatus.getDefinition()).contains("This is a preliminary composition or document (also known as initial or interim).");
    assertThat(docStatus.getSystem()).isEqualTo("http://hl7.org/fhir/composition-status");
    // Check OBX.11 as fallback
    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|||555|||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||TEXT|||20180117144200|201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + "OBX|1|SN|||||||||F";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    docStatus = report.getDocStatus();
    // OBX.11
    assertThat(docStatus.toCode()).isEqualTo("final");
    assertThat(docStatus.getDefinition()).contains("This version of the composition is complete and verified by an appropriate person and no further work is planned.");
    assertThat(docStatus.getSystem()).isEqualTo("http://hl7.org/fhir/composition-status");
    // Check a value that is not mapped results is no docStatus
    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|||555|||20170825010500|||||||||||||002|||||F\n" + "TXA|1||TEXT|||20180117144200|201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>\n" + "OBX|1|SN|||||||||X";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    // OBX-11 'X' is not mapped
    assertThat(report.getDocStatus()).isNull();
}
Also used : DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with DocumentReference

use of org.hl7.fhir.dstu3.model.DocumentReference in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_content_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_content_test(String segment) {
    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>||||||||||AV|||<PHYSID2>||\n" + // Next three lines create an attachment
    "OBX|1|TX|||ECHOCARDIOGRAPHIC REPORT||||||F|||202101010000|||\n" + "OBX|2|TX|||NORMAL LV CHAMBER SIZE WITH MILD CONCENTRIC LVH||||||F|||202101010000|||\n" + "OBX|3|TX|||HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%||||||F|||202101010000|||\n";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    DocumentReference.DocumentReferenceContentComponent content = report.getContentFirstRep();
    // Future TXA.3, currently always defaults to text/plain
    assertThat(content.getAttachment().getContentType()).isEqualTo("text/plain");
    // TXA.7 date
    assertThat(content.getAttachment().getCreationElement().toString()).containsPattern("2018-01-18T03:46:00");
    assertThat(content.getAttachment().hasData()).isTrue();
    String decodedData = new String(Base64.getDecoder().decode(content.getAttachment().getDataElement().getValueAsString()));
    assertThat(decodedData).isEqualTo("ECHOCARDIOGRAPHIC REPORT\nNORMAL LV CHAMBER SIZE WITH MILD CONCENTRIC LVH\nHYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%");
    // TODO: Determine if we need to look at anything other than OBX.2 when it is TX
    // Leave this test in place as a reminder
    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||||||201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + // TODO: find better code for this test which is to see that OBX.2 is the fallback.
    "OBX|1|SN|||||||||F";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    content = report.getContentFirstRep();
    // Because the OBX is not TX, the content is put in an Observation
    // FHIR requires a Content element, so only a minimal one is created.
    // Future OBX.2 is the backup for content type, but currently always defaults to text/plain
    assertThat(content.getAttachment().hasContentType()).isTrue();
    // Currently always defaults to text/plain
    assertThat(content.getAttachment().getContentType()).isEqualTo("text/plain");
    // TXA.7 date
    assertThat(content.getAttachment().getCreationElement().toString()).containsPattern("2018-01-18T03:46:00");
    assertThat(content.getAttachment().hasData()).isFalse();
    // Test that content is created even if TXA.7 is empty
    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" + // Ensure that empty TXA.7 still works
    "TXA|1||||||||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + "OBX|1|SN|||||||||F";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    content = report.getContentFirstRep();
    // Because the OBX is not TX, the content is put in an Observation
    // FHIR requires a Content element, so only a minimal one is created.
    // Currently always defaults to text/plain
    assertThat(content.getAttachment().hasContentType()).isTrue();
    // Currently always defaults to text/plain, even if not data for content
    assertThat(content.getAttachment().getContentType()).isEqualTo("text/plain");
    // No TXA.7 date
    assertThat(content.getAttachment().hasCreationElement()).isFalse();
    assertThat(content.getAttachment().hasData()).isFalse();
}
Also used : DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with DocumentReference

use of org.hl7.fhir.dstu3.model.DocumentReference in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_security_label_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_security_label_test(String segment) {
    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|R|AV|||<PHYSID2>||\n" + "OBX|1|SN|||||||||X";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    CodeableConcept securityLabel = report.getSecurityLabelFirstRep();
    // TXA.18
    assertThat(securityLabel.getCodingFirstRep().getCode()).isEqualTo("R");
    assertThat(securityLabel.getCodingFirstRep().getDisplay()).isEqualTo("Restricted");
    assertThat(securityLabel.getCodingFirstRep().getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0272");
}
Also used : DocumentReference(org.hl7.fhir.r4.model.DocumentReference) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with DocumentReference

use of org.hl7.fhir.dstu3.model.DocumentReference in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_subject_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_subject_test(String segment) {
    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>||||||||||AV|||<PHYSID2>||\n" + "OBX|1|SN|||||||||X";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, documentReferenceMessage);
    List<Resource> documentReferenceList = ResourceUtils.getResourceList(e, ResourceType.DocumentReference);
    String s = context.getParser().encodeResourceToString(documentReferenceList.get(0));
    Class<? extends IBaseResource> klass = DocumentReference.class;
    DocumentReference documentReference = (DocumentReference) context.getParser().parseResource(klass, s);
    assertThat(documentReference.hasSubject()).isTrue();
    assertThat(documentReference.getSubject().getReference()).startsWith("Patient");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DocumentReference (org.hl7.fhir.r4.model.DocumentReference)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 ValueSource (org.junit.jupiter.params.provider.ValueSource)15 Identifier (org.hl7.fhir.r4.model.Identifier)11 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)9 Attachment (org.hl7.fhir.r4.model.Attachment)7 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)7 Coding (org.hl7.fhir.r4.model.Coding)7 Reference (org.hl7.fhir.r4.model.Reference)7 Bundle (org.hl7.fhir.r4.model.Bundle)6 Practitioner (org.hl7.fhir.r4.model.Practitioner)6 Resource (org.hl7.fhir.r4.model.Resource)6 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)5 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)5 HashMap (java.util.HashMap)4 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)4 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)4 Test (org.junit.jupiter.api.Test)4 ArrayList (java.util.ArrayList)3 DocumentReferenceContextComponent (org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextComponent)3