use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7OMLMessageTest method testOMLO21WithPatientWithPatientVisitAndMinimumOrder.
@Test
public void testOMLO21WithPatientWithPatientVisitAndMinimumOrder() throws IOException {
String hl7message = "MSH|^~\\&||Test System|||20210917110100||OML^O21^OML_O21|||2.6\r" + "PID|1||7659afb9-0dfc-d744-1f40-5b9314807108^^^^MR||Feeney^Sam^^^^^L|||M||||||||\r" + "PV1|1|O|||||||||||||||||2462201|||||||||||||||||||||||||20180520230000\r" + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||||||||||\r";
String json = ftv.convert(hl7message, OPTIONS_PRETTYPRINT);
assertThat(json).isNotBlank();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
// from PID
assertThat(patientResource).hasSize(1);
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
// from PV1
assertThat(encounterResource).hasSize(1);
// TODO: When function is added to create ServiceRequest from ORC then also check for ServiceRequest
// List<Resource> serviceResource = e.stream()
// .filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType())
// .map(BundleEntryComponent::getResource).collect(Collectors.toList());
// assertThat(serviceResource).hasSize(1);
// Confirm that there are no extra resources
// TODO: When ServiceRequest is added then this line should check for 3.
assertThat(e.size()).isEqualTo(2);
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7OMLMessageTest method testOMLO21WithPatientAndOrderWithObservationRequestWithDG1.
@Test
public void testOMLO21WithPatientAndOrderWithObservationRequestWithDG1() throws IOException {
String hl7message = "MSH|^~\\&||Test System|||20210917110100||OML^O21^OML_O21|||2.6\r" + "PID|1||7659afb9-0dfc-d744-1f40-5b9314807108^^^^MR||Feeney^Sam^^^^^L|||M||||||||\r" + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||||||||||\r" + "OBR|1|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||58410-2^CBC panel - Blood by Automated count^LN||||||||||||\r" + "DG1|1||A013^Paratyphoid fever C^I10C|||A|||||||||1\r";
String json = ftv.convert(hl7message, OPTIONS_PRETTYPRINT);
assertThat(json).isNotBlank();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
List<BundleEntryComponent> e = b.getEntry();
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
// from PID
assertThat(patientResource).hasSize(1);
List<Resource> serviceResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
// from ORC
assertThat(serviceResource).hasSize(1);
List<Resource> diagnosticresource = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
// from OBR
assertThat(diagnosticresource).hasSize(1);
List<Resource> conditionresource = ResourceUtils.getResourceList(e, ResourceType.Condition);
// from DG1
assertThat(conditionresource).hasSize(1);
DiagnosticReport diag = ResourceUtils.getResourceDiagnosticReport(diagnosticresource.get(0), context);
Reference patRef = diag.getSubject();
assertThat(patRef.isEmpty()).isFalse();
ServiceRequest request = ResourceUtils.getResourceServiceRequest(serviceResource.get(0), context);
Reference patientRef = request.getSubject();
assertThat(patientRef.isEmpty()).isFalse();
// Confirm that there are no extra resources
assertThat(e.size()).isEqualTo(4);
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7OMLMessageTest method testOMLO21MultipleOrdersWithoutObservations.
@Test
@Disabled
public // Note that even though the HL7 message definition does not require PID, it is necessary so that the resulting FHIR ServiceRequests pass FHIR validation.
void testOMLO21MultipleOrdersWithoutObservations() throws IOException {
String hl7message = "MSH|^~\\&||Test System|||20210917110100||OML^O21^OML_O21|||2.6\r" + "PID|1||7659afb9-0dfc-d744-1f40-5b9314807108^^^^MR||Feeney^Sam^^^^^L|||M||||||||\r" + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||||||||||\r" + "ORC|NW|8125550e-04db-11ec-a9a8-086d41d421ca^^ID^UUID||||||||||\r";
String json = ftv.convert(hl7message, OPTIONS_PRETTYPRINT);
assertThat(json).isNotBlank();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
assertThat(b.getType()).isEqualTo(BundleType.COLLECTION);
List<BundleEntryComponent> e = b.getEntry();
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
// from PID
assertThat(patientResource).hasSize(1);
List<Resource> serviceResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
// from ORC
assertThat(serviceResource).hasSize(2);
// Confirm that there are no extra resources
assertThat(e.size()).isEqualTo(3);
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7DFTMessageTest method testResourceCreationFromDFT.
@Test
void testResourceCreationFromDFT() throws IOException {
// Tests structure of DFT_P03 message type and DFT messages in general
// DFT_P03 message types and IN1 are tested in detail in Hl7FinancialInsuranceTest
String hl7message = "MSH|^~\\&|||||20151008111200||DFT^P03^DFT_P03|MSGID000001|T|2.6|||||||||\n" + "EVN||20210407191342||||||\n" + "PID|||MR1^^^XYZ^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + // Minimal ORC for ServiceRequest
"ORC|NW|||||||||||||||\n" + // Minimal OBR for ServiceRequest
"OBR|1||||||||||||||||||||||||||||||||\n" + "NTE|1|O|TEST ORC/OBR NOTE AA|||\n" + // OBX is type ST so an observation will be created
"OBX|1|ST|100||This is content|||||||X\n" + "NTE|1|L|TEST OBXa NOTE|\n" + // FT1.7 is required transaction code (currently not used)
"FT1||||20201231145045||CG|FAKE|||||||||||||||||||||||||||||||||||||\n" + // IN1.2.4, IN1.2.6 to Identifier 2
"IN1|1|Value1^^System3^Value4^^System6" + // IN1.5 to 15 NOT REFERENCED (See test testBasicInsuranceCoverageFields)
"|IdValue1^^^IdSystem4^^^^|Large Blue Organization|||||||||||" + // IN1.18 through IN1.35 NOT REFERENCED
"|DoeFake^Judy^^^Rev.|PAR||||||||||||||||||" + // IN1.50 through IN1.53 NOT REFERENCED
"|MEMBER36||||||||||Value46|||J494949||||\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);
List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
// From Payor created by IN1
assertThat(organizations).hasSize(1);
List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
// From IN1 segment
assertThat(coverages).hasSize(1);
List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
// From IN1.16 through IN1.19; IN1.43; INI.49
assertThat(relatedPersons).hasSize(1);
List<Resource> serviceRequests = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
// From ORC / OBR
assertThat(serviceRequests).hasSize(1);
ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequests.get(0), ResourceUtils.context);
assertThat(serviceRequest.getNote()).hasSize(1);
assertThat(serviceRequest.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST ORC/OBR NOTE AA");
List<Resource> observations = ResourceUtils.getResourceList(e, ResourceType.Observation);
// From OBX
assertThat(observations).hasSize(1);
Observation observation = ResourceUtils.getResourceObservation(observations.get(0), ResourceUtils.context);
assertThat(observation.getNote()).hasSize(1);
assertThat(observation.getNote().get(0).getTextElement().getValueAsString()).isEqualTo("TEST OBXa NOTE");
// Confirm there are no unaccounted for resources
// Expected: Coverage, Organization, Patient, Encounter, RelatedPerson, ServiceRequest, Observation
assertThat(e).hasSize(7);
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class InputTimeZoneIdTest method testEncounterLengthWithZoneIdContext.
@Test
void testEncounterLengthWithZoneIdContext() {
// This is the same as the test for PV1.44 and PV1.45 in Hl7EncounterFHIRConversionTest.testEncounterLength, but
// here we pass in ZoneIdText context to ensure that Hl7RelatedGeneralUtils.pv1DurationLength works correctly with an input ZoneId.
// Both start PV1.44 and end PV1.45 must be present to use either value as part of length
// When both are present, the calculation value is provided in "Minutes"
String hl7message = "MSH|^~\\&|PROSOLV||||20151008111200||ADT^A01^ADT_A01|MSGID000001|T|2.6|||||||||\n" + "EVN|A04|20151008111200|||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // PV1.44 present; PV1.45 present
"PV1|1|E||||||||||||||||||||||||||||||||||||||||||20161013154626|20161014154634|||||||\n";
// Test with city based ZoneId passed through options
ConverterOptions customOptionsWithTenant = new Builder().withValidateResource().withPrettyPrint().withZoneIdText("Europe/Paris").build();
// "Europe/Paris" will become -01:00, but it we don't see because it is internal and relative to other date.
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message, customOptionsWithTenant);
// Find the encounter from the FHIR bundle.
List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
assertThat(encounters).hasSize(1);
Encounter encounter = (Encounter) encounters.get(0);
assertThat(encounter.hasLength()).isTrue();
Duration encounterLength = encounter.getLength();
assertThat(encounterLength.getValue()).isEqualTo((BigDecimal.valueOf(1440)));
assertThat(encounterLength.getUnit()).isEqualTo("minutes");
assertThat(encounterLength.getCode()).isEqualTo("min");
assertThat(encounterLength.getSystem()).isEqualTo("http://unitsofmeasure.org");
}
Aggregations