use of org.hl7.fhir.r4.model.Encounter.EncounterStatus.UNKNOWN in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7FinancialInsuranceTest method testInsuranceCoverageUnknownRelationship.
@Test
// As part of the test, there is a valid code in IN2.72 that would create a related person, but it should be ignored.
void testInsuranceCoverageUnknownRelationship() throws IOException {
String hl7message = "MSH|^~\\&|TEST|TEST|||20220101120000||DFT^P03|1234|P|2.6\n" + // + "EVN||20210407191342||||||\n"
"PID|||workers_comp^^^XYZ^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + // FT1.7 is required transaction code (currently not used)
"FT1||||20201231145045||CG|FAKE|||||||||||||||||||||||||||||||||||||\n" + // IN1.2.4, IN1.2.6 to second XV Coverage.identifier
"IN1|1|Value1^^System3^Value4^^System6" + // IN1.5 through 15 NOT REFERENCED (Tested in testBasicInsuranceCoverageFields)
"|IdValue1^^^IdSystem4^^^^|Large Blue Organization|||||||||||" + // IN1.18 through IN1.53 NOT REFERENCED
"||05||||||||||||||||||||||||||||||||||||\n" + // IN2.1 through IN2.71 NOT REFERENCED
"IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" + // A valid code in IN2.72 does not take priority over an invalid code in IN1.17.
"04|\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
// From PV1
assertThat(encounters).hasSize(1);
List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
// From PID
assertThat(patients).hasSize(1);
Patient patient = (Patient) patients.get(0);
String patientId = patient.getId();
List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
// From Payor created by IN1
assertThat(organizations).hasSize(1);
Organization org = (Organization) organizations.get(0);
// Check organization Id's
assertThat(org.getIdentifier()).hasSize(1);
// Org identifiers checked deeply in other tests
List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
// From IN1 segment
assertThat(coverages).hasSize(1);
Coverage coverage = (Coverage) coverages.get(0);
// Confirm Coverage Identifiers
// XV, XV
assertThat(coverage.getIdentifier()).hasSize(2);
// Coverage Identifiers deep check in testBasicInsuranceCoverageFields
// Because the relationship is 05, an unknown code, no subscriber is created
assertThat(coverage.hasSubscriber()).isFalse();
// Confirm Coverage Beneficiary references to Patient, and Payor references to Organization
assertThat(coverage.getBeneficiary().getReference()).isEqualTo(patientId);
assertThat(coverage.getPayorFirstRep().getReference()).isEqualTo(organizations.get(0).getId());
// Expect no RelatedPerson because IN1.17 was an unknown code
List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
// No related person should be created because IN1.17 was an unknown code
assertThat(relatedPersons).isEmpty();
// Check coverage.relationship (from SubscriberRelationship mapping)
DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getRelationship(), "05", null, null, // IN1.17, because it is unkown there is no system or display.
null);
// Confirm there are no unaccounted for resources
// Expected: Coverage, Organization, Patient, Encounter
assertThat(e).hasSize(4);
}
use of org.hl7.fhir.r4.model.Encounter.EncounterStatus.UNKNOWN in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7OrderRequestFHIRConversionTest method testAdditionalOBRFieldsNoORCSegment.
@Test
void testAdditionalOBRFieldsNoORCSegment() {
String hl7message = "MSH|^~\\&|Epic|ATRIUS|||20180924152907|34001|ORU^R01^ORU_R01|213|T|2.6|||||||||PHLabReport-Ack^^2.16.840.1.114222.4.10.3^ISO||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1|1|E|||||||||||||||||||||||||||||||||||||||||||\n" + // ORC.15 is missing, so use OBR.7 as ServiceRequest.occurrenceDateTime
"OBR|1|248648498^|248648498^|83036E^HEMOGLOBIN A1C^PACSEAP^^^^^^HEMOGLOBIN A1C|||20170707120707|20180808120808|||||||||||||||||F|||||||||||||||||||||||||\n";
String json = ftv.convert(hl7message, PatientUtils.OPTIONS);
assertThat(json).isNotBlank();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle bundle = (Bundle) bundleResource;
List<BundleEntryComponent> e = bundle.getEntry();
List<Resource> diagnosticReportList = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
DiagnosticReport diagnosticReport = ResourceUtils.getResourceDiagnosticReport(diagnosticReportList.get(0), context);
// OBR.7 and OBR.8 together map to DiagnosticReport.effectivePeriod
assertThat(diagnosticReport.hasEffectivePeriod()).isTrue();
assertThat(diagnosticReport.getEffectivePeriod().getStartElement().toString()).containsPattern("2017-07-07T12:07:07");
assertThat(diagnosticReport.getEffectivePeriod().getEndElement().toString()).containsPattern("2018-08-08T12:08:08");
List<Resource> serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
// Important that we have exactly one service request (no duplication). OBR creates it as a reference.
assertThat(serviceRequestList).hasSize(1);
ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequestList.get(0), context);
assertThat(serviceRequest.hasStatus()).isTrue();
// OBR.7 should create an ServiceRequest.occurrenceDateTime date
assertThat(serviceRequest.hasOccurrenceDateTimeType()).isTrue();
assertThat(serviceRequest.getOccurrenceDateTimeType().toString()).containsPattern("2017-07-07T12:07:07");
// ORC.5 is missing, so serviceRequest.status() should be unknown
assertThat(serviceRequest.hasStatus()).isTrue();
assertThat(serviceRequest.getStatusElement().getCode()).isEqualTo("unknown");
}
use of org.hl7.fhir.r4.model.Encounter.EncounterStatus.UNKNOWN in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ServiceRequestFHIRConversionTest method test_ppr_pc1_service_request.
@Test
void test_ppr_pc1_service_request() throws IOException {
// Currently only tests limited items, TODO add tests for other field
String hl7message = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|202101010000|security|PPR^PC1^PPR_PC1|1|P^I|2.6||||||ASCII||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F|||||||||||||||||||||\n" + "PV1||I|6N^1234^A^GENHOS|||||||SUR||||||||S||||||||||||||||||||||||||\n" + "PRB|AD||202101010000|aortic stenosis|53692||2|||202101010000\n" + "OBX|1|NM|111^TotalProtein||7.5|gm/dl|5.9-8.4||||W\n" + "ORC|NW|1000^OE|9999999^RX||SC|E|^Q6H^D10^^^R\n" + "OBR|1|TESTID|TESTID|||202101010000|202101010000||||||||||||||||||F||||||WEAKNESS||||||||||||\n" + "OBX|1|TX|||ECHOCARDIOGRAPHIC REPORT||||||F|||202101010000|||\n" + "OBX|2|TX|||NORMAL LV CHAMBER SIZE WITH MILD CONCENTRIC LVH||||||F|||202101010000|||\n";
String json = ftv.convert(hl7message, OPTIONS);
assertThat(json).isNotBlank();
IBaseResource bundleResource = context.getParser().parseResource(json);
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
// OBX under PRB (the PROBLEM.PROBLEM_OBSERVATION.OBSERVATION) creates an Observation resource
// Verifying this OBX to assure ServiceRequest is using correct OBX information
List<Resource> obsResource = e.stream().filter(v -> ResourceType.Observation == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
Observation o = (Observation) obsResource.get(0);
assertEquals("111", o.getCode().getCodingFirstRep().getCode());
assertEquals("TotalProtein", o.getCode().getText());
// From OBX.11 'W'
assertEquals("Entered in Error", o.getStatus().getDisplay());
List<Resource> serviceRequestResource = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
ServiceRequest sr = (ServiceRequest) serviceRequestResource.get(0);
assertEquals(1, serviceRequestResource.size());
// From ORC.5 'SC'
assertEquals("Active", sr.getStatus().getDisplay());
// Ensure the intent is set to "order" for all messages
assertEquals("order", sr.getIntentElement().getValueAsString());
// status defaults to "unknown"
hl7message = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|202101010000|security|PPR^PC1^PPR_PC1|1|P^I|2.6||||||ASCII||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F|||||||||||||||||||||\n" + "PV1||I|6N^1234^A^GENHOS|||||||SUR||||||||S||||||||||||||||||||||||||\n" + "PRB|AD||202101010000|aortic stenosis|53692||2|||202101010000\n" + "ORC|NW|1000^OE|9999999^RX|||E|^Q6H^D10^^^R\n";
json = ftv.convert(hl7message, OPTIONS);
assertThat(json).isNotBlank();
bundleResource = context.getParser().parseResource(json);
b = (Bundle) bundleResource;
e = b.getEntry();
serviceRequestResource = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
sr = (ServiceRequest) serviceRequestResource.get(0);
// Default since no OBX in message
assertEquals("Unknown", sr.getStatus().getDisplay());
}
use of org.hl7.fhir.r4.model.Encounter.EncounterStatus.UNKNOWN in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method testMedicationRequestReasonCode.
@Test
void testMedicationRequestReasonCode() {
// Reason code from RXO.20, should ignore ORC.16
String hl7message = "MSH|^~\\&||||||S1|PPR^PC1||T|2.6|||||||||\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\r" + "PRB|AD|20141015103243|15777000^Prediabetes (disorder)^SNM|654321^^OtherSoftware.ProblemOID|||||\r" + // ORC.16 purposely present to be ignored because RXO.20 is present
"ORC|NW|||||||||||||||4338008^Wheezing^PRN\r" + "OBR|1|||555|||20170825010500||||||||||||||||||F\r" + // RXO.2 through RXO.35 otherwise purposely empty
"RXO|65862-063-01^METOPROLOL TARTRATE^NDC|||||||||||||||||||134006\r";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getReasonCode()).hasSize(1);
assertThat(medicationRequest.getReasonCodeFirstRep().getCoding()).hasSize(1);
// RXO.20.1
assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getCode()).isEqualTo("134006");
// No RXO.20.2
assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isNull();
// No RXO.20.3
assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getSystem()).isNull();
// Reason code from RXE.27. Ignores ORC.16.
hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // ORC.16 purposely present to be ignored because RXE.27 is present
"ORC|NW|||||||||||||||4338008^Wheezing^PRN\n" + // RXE.6 through RXE.44 otherwise purposely empty
"RXE|^Q24H&0600^^20210330144208^^ROU|DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|3||mL||||||||||||||||||||||Wheezing^Wheezing^PRN|||||||||||||\r";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getReasonCode()).hasSize(1);
assertThat(medicationRequest.getReasonCodeFirstRep().getCoding()).hasSize(1);
// RXE.27
assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getCode()).isEqualTo("Wheezing");
// RXE.27
assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isEqualTo("Wheezing");
// RXE.27
assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getSystem()).isEqualTo("urn:id:PRN");
// Reason code from ORC.16 (when RXE.27 is not present)
hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // ORC.16 to reason code
"ORC|NW|||||||||||||||4338008^Wheezing^PRN\n" + // RXE.6 through RXE.44 purposely empty
"RXE|^Q24H&0600^^20210330144208^^ROU|DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|3||mL|||||||||||||||||||||||||||||||||||\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getReasonCode()).hasSize(1);
assertThat(medicationRequest.getReasonCodeFirstRep().getCoding()).hasSize(1);
// ORC.16.1
assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getCode()).isEqualTo("4338008");
// ORC.16.2
assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isEqualTo("Wheezing");
// ORC.16.3 (unknown system)
assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getSystem()).isEqualTo("urn:id:PRN");
}
use of org.hl7.fhir.r4.model.Encounter.EncounterStatus.UNKNOWN in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7OrderRequestFHIRConversionTest method testBroadORCPlusOBRFields2.
@Test
void testBroadORCPlusOBRFields2() {
String hl7message = "MSH|^~\\&|||||20180924152907|34001|ORU^R01^ORU_R01|213|T|2.6|||||||||||\n" + // PID.18 is empty, MSH.7 will be used as identifier visit number
"PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // PV1.19 is empty, MSH.7 will be used as identifier visit number
"PV1|1|E|||||||||||||||||||||||||||||||||||||||||||\n" + // ORC.5 with purposely bad code to see that 'unknown' is result
"ORC|RE|248648498^|248648498^||ZZ||||20120628071200||||||||||||||||||||||\n" + "OBR|1|248648498^|248648498^|83036E^HEMOGLOBIN A1C^PACSEAP^^^^^^HEMOGLOBIN A1C|||||||L||||||||||||||F||^^^20120606120606|||||||||||||||||||||||\n";
String json = ftv.convert(hl7message, PatientUtils.OPTIONS);
assertThat(json).isNotBlank();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle bundle = (Bundle) bundleResource;
List<BundleEntryComponent> e = bundle.getEntry();
List<Resource> serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
// Important that we have exactly one service request (no duplication). OBR creates it as a reference.
assertThat(serviceRequestList).hasSize(1);
ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequestList.get(0), context);
assertThat(serviceRequest.hasStatus()).isTrue();
assertThat(serviceRequest.hasIdentifier()).isTrue();
assertThat(serviceRequest.getIdentifier()).hasSize(3);
// Identifier 1: visit number should be set by in this test by tertiary MSH.7
// See notes about identifier testing in previous tests
Identifier identifier = serviceRequest.getIdentifier().get(0);
String value = identifier.getValue();
String system = identifier.getSystem();
// MSH.7 as a string, not as a date
assertThat(value).isEqualTo("20180924152907");
assertThat(system).isNull();
CodeableConcept type = identifier.getType();
DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// OBR.27[0].4 should create an ServiceRequest.occurrenceDateTime date
assertThat(serviceRequest.hasOccurrenceDateTimeType()).isTrue();
assertThat(serviceRequest.getOccurrenceDateTimeType().toString()).containsPattern("2012-06-06T12:06:06");
// // ORC.5 creates the serviceRequest.status() purposely an unknown code
assertThat(serviceRequest.hasStatus()).isTrue();
assertThat(serviceRequest.getStatusElement().getCode()).isEqualTo("unknown");
}
Aggregations