Search in sources :

Example 26 with DocumentReference

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

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_relates_to_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
@Disabled("TODO: TXA-13 is not yet mapped in DocumentReference.yml")
void doc_ref_relates_to_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>||||4466^TRANSCLast^TRANSCFirst^J||||||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);
    String requesterRef = documentReference.getContext().getRelatedFirstRep().getReference();
    Practitioner practBundle = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRef);
    DocumentReference.DocumentReferenceRelatesToComponent relatesTo = documentReference.getRelatesToFirstRep();
    assertThat(relatesTo.getCode()).hasToString("appends");
    Identifier practitionerIdentifier = practBundle.getIdentifierFirstRep();
    // TXA-13.1
    assertThat(practitionerIdentifier.getValue()).isEqualTo("4466");
    // TXA-13.2
    assertThat(practitionerIdentifier.getSystem()).isEqualTo("TRANSCLast");
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) 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) Disabled(org.junit.jupiter.api.Disabled)

Example 27 with DocumentReference

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

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_master_identifier_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_master_identifier_test(String segment) {
    // Test masterIdentifier uses the value(12.1) but does not require a system if 12.2 is empty
    String documentReference = "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|||||<MESSAGEID>|||||PA|R|AV|||||\n" + "OBX|1|SN|||||||||X";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReference);
    assertThat(report.hasMasterIdentifier()).isTrue();
    Identifier masterID = report.getMasterIdentifier();
    assertThat(masterID.getValue()).isEqualTo("<MESSAGEID>");
    assertThat(masterID.getSystem()).isNull();
    // Test masterIdentifier uses the value(12.1) and pulls systemID from 12.2
    documentReference = "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|||||<MESSAGEID>^SYSTEM|||||PA|R|AV|||||\n" + "OBX|1|SN|||||||||X";
    report = ResourceUtils.getDocumentReference(ftv, documentReference);
    assertThat(report.hasMasterIdentifier()).isTrue();
    masterID = report.getMasterIdentifier();
    assertThat(masterID.getValue()).isEqualTo("<MESSAGEID>");
    assertThat(masterID.getSystem()).isEqualTo("urn:id:SYSTEM");
    // Test masterIdentifier uses the backup value(12.3) and does not have a system
    documentReference = "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|||||^SYSTEM^<BACKUPID>|||||PA|R|AV|||||\n" + "OBX|1|SN|||||||||X";
    report = ResourceUtils.getDocumentReference(ftv, documentReference);
    assertThat(report.hasMasterIdentifier()).isTrue();
    masterID = report.getMasterIdentifier();
    assertThat(masterID.getValue()).isEqualTo("<BACKUPID>");
    assertThat(masterID.getSystem()).isNull();
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 28 with DocumentReference

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

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_description_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_description_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>|||||||This segment is for description|||AV|||<PHYSID2>||\n" + "OBX|1|ST|100||This is content|||||||X\n";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    String description = report.getDescription();
    // TXA.16
    assertThat(description).isEqualTo("This segment is for description");
}
Also used : DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 29 with DocumentReference

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

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_ppr_test.

@ParameterizedTest
// Spot check for PPR messages
@ValueSource(strings = { "PPR^PC1" /* "PPR^PC2", "PPR^PC3" */
})
void doc_ref_ppr_test(String messageType) {
    String documentReferenceMessage = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|202101010000|security|" + messageType + "|1|P^I|2.6||||||ASCII||\r" + "PID|||1234^^^^MR||DOE^JANE^|||F|||||||||||||||||||||\r" + "PV1||I|6N^1234^A^GENHOS|||||||SUR|||||||0148^ANDERSON^CARL|S|1400|A|||||||||||||||||||SF|K||||199501102300\r" + "PRB|AD||202101010000|aortic stenosis|53692||2|||202101010000\r" + "OBX|1|NM|111^TotalProtein||7.5|gm/dl|5.9-8.4||||F\r" + "NTE|1|P|Problem Comments\r" + "ORC|NW|1000^OE|9999999^RX|||E|^Q6H^D10^^^R\r" + "OBR|1|TESTID|TESTID|||201801180346|201801180347||||||||||||||||||F||||||WEAKNESS||||||||||||\r" + // Next three lines create an attachment because OBX type TX
    "OBX|1|TX|||ECHOCARDIOGRAPHIC REPORT||||||F|||202101010000|||\r" + "OBX|2|TX|||NORMAL LV CHAMBER SIZE WITH MILD CONCENTRIC LVH||||||F|||202101010000|||\r" + "OBX|3|TX|||HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%||||||F|||202101010000|||\n";
    DocumentReference documentRef = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    DocumentReference.DocumentReferenceContextComponent drContext = documentRef.getContext();
    // Should contain a reference to the service request
    assertThat(drContext.hasPeriod()).isFalse();
    DocumentReference.DocumentReferenceContentComponent content = documentRef.getContentFirstRep();
    // Currently always defaults to text/plain
    assertThat(content.getAttachment().getContentType()).isEqualTo("text/plain");
    // No TXA.7 in message
    assertThat(content.getAttachment().getCreation()).isNull();
    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%");
}
Also used : DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 30 with DocumentReference

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

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_type_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_type_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|OP|TEXT||||201801180346||<PHYSID1>||||||||PA||AV|||<PHYSID2>||\n" + "OBX|1|SN|||||||||X";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    CodeableConcept type = report.getType();
    // TXA.2
    assertThat(type.getCodingFirstRep().getCode()).isEqualTo("OP");
    assertThat(type.getCodingFirstRep().getDisplay()).isEqualTo("Operative report");
    assertThat(type.getCodingFirstRep().getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0270");
}
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)

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)12 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)10 Coding (org.hl7.fhir.r4.model.Coding)8 Attachment (org.hl7.fhir.r4.model.Attachment)7 Reference (org.hl7.fhir.r4.model.Reference)7 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)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 Bundle (org.hl7.fhir.r4.model.Bundle)5 HashMap (java.util.HashMap)4 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)4 DocumentReferenceContextComponent (org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextComponent)4 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)4 Test (org.junit.jupiter.api.Test)4 Identifiable (org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable)4