use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR 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");
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class FHIRConverterTest method testCodingSystems.
@Test
/*
* This tests some of coding systems of interest or potential problems
*/
void testCodingSystems() throws FHIRException {
String hl7VUXmessageRep = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|201305330||VXU^V04^VXU_V04|20130531RI881401010105|P|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "EVN|A01|20130617154644||01\r" + "PID|1||12345678^^^MYEMR^MR||TestPatient^John|||M|\r" + "ORC|RE||197027|||||||^Clerk^Myron||MD67895^Pediatric^MARY^^^^MD^^RIA|||||RI2050\r" + // Test MVX
"RXA|0|1|20130528|20130529|48^HIB PRP-T^CVX|0.5|ML^^ISO+||00^new immunization record^NIP001|^Sticker^Nurse|^^^RI2050||||33k2a|20131210|PMC^sanofi^MVX|||CP|A\r" + // Test HL70162 & HL70163
"RXR|C28161^IM^NCIT^IM^INTRAMUSCULAR^HL70162|RT^right thigh^HL70163\r";
String json = ftv.convert(hl7VUXmessageRep, OPTIONS);
FHIRContext context = new FHIRContext();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
assertThat(b.getType()).isEqualTo(BundleType.COLLECTION);
assertThat(b.getId()).isNotNull();
List<BundleEntryComponent> e = b.getEntry();
List<Resource> obsResource = e.stream().filter(v -> ResourceType.Immunization == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(obsResource).hasSize(1);
Immunization immunization = (Immunization) obsResource.get(0);
// Check that organization identifier (MVX) has a system
Organization org = (Organization) immunization.getManufacturer().getResource();
List<Identifier> li = org.getIdentifier();
Identifier ident = li.get(0);
assertThat(ident.hasSystem()).isTrue();
assertThat(ident.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/MVX");
assertThat(ident.hasValue()).isTrue();
assertThat(ident.getValue()).isEqualTo("PMC");
// Check that route (HL70162) has a system
CodeableConcept route = immunization.getRoute();
assertThat(route.hasCoding()).isTrue();
List<Coding> codings = route.getCoding();
assertThat(codings.size()).isEqualTo(2);
Coding coding = codings.get(0);
// If the first one is not the one we want look at the second one.
if (coding.getCode().contains("C28161")) {
coding = codings.get(1);
}
assertThat(coding.hasSystem()).isTrue();
assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0162");
// Check that site (HL70163) has a system
CodeableConcept site = immunization.getSite();
coding = site.getCodingFirstRep();
assertThat(coding.hasSystem()).isTrue();
assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0163");
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project cqf-ruler by DBCG.
the class SubmitDataProviderIT method testSubmitData.
@Test
public void testSubmitData() {
// Create a MR and a resource
MeasureReport mr = newResource(MeasureReport.class, "test-mr");
Observation obs = newResource(Observation.class, "test-obs");
// Submit it
mySubmitDataProvider.submitData(new SystemRequestDetails(), new IdType("Measure", "test-m"), mr, Lists.newArrayList(obs));
// Check if they made it to the db
Observation savedObs = read(obs.getIdElement());
assertNotNull(savedObs);
MeasureReport savedMr = read(mr.getIdElement());
assertNotNull(savedMr);
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project cqf-ruler by DBCG.
the class SubmitDataProviderIT method testSubmitDataNoId.
@Test
public void testSubmitDataNoId() {
// Create a MR and a resource
MeasureReport mr = newResource(MeasureReport.class).setMeasure(new Reference("Measure/123"));
Observation obs = newResource(Observation.class).setValue(new StringType("ABC"));
// Submit it
mySubmitDataProvider.submitData(new SystemRequestDetails(), new IdType("Measure", "123"), mr, Lists.newArrayList(obs));
// Check if they made it to the db
Observation savedObs = search(Observation.class, Searches.all()).single();
assertNotNull(savedObs);
assertEquals("ABC", savedObs.getValue().primitiveValue());
MeasureReport savedMr = search(MeasureReport.class, Searches.all()).single();
assertNotNull(savedMr);
assertEquals("Measure/123", savedMr.getMeasure().getReference());
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project org.hl7.fhir.core by hapifhir.
the class R3R4ConversionTests method loadLib.
private void loadLib(String dir) throws FileNotFoundException, IOException {
StructureMapUtilities smu = new StructureMapUtilities(contextR4);
for (String s : new File(dir).list()) {
String map = TextFile.fileToString(Utilities.path(dir, s));
try {
StructureMap sm = smu.parse(map, s);
contextR3.cacheResource(sm);
contextR4.cacheResource(sm);
for (Resource r : sm.getContained()) {
if (r instanceof MetadataResource) {
MetadataResource mr = (MetadataResource) r.copy();
mr.setUrl(sm.getUrl() + "#" + r.getId());
contextR3.cacheResource(mr);
contextR4.cacheResource(mr);
}
}
} catch (FHIRException e) {
System.out.println("Unable to load " + Utilities.path(dir, s) + ": " + e.getMessage());
loadErrors.put(s, e);
// e.printStackTrace();
}
}
}
Aggregations