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");
}
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();
}
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();
}
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");
}
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");
}
Aggregations