use of org.hl7.fhir.r4.model.Immunization 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.Immunization in project openmrs-module-fhir2 by openmrs.
the class FhirImmunizationServiceImplTest method updateImmunization_shouldUpdateImmunizationAccordingly.
@Test
public void updateImmunization_shouldUpdateImmunizationAccordingly() {
// setup
FhirContext ctx = FhirContext.forR4();
IParser parser = ctx.newJsonParser();
Immunization updatedImmunization = parser.parseResource(Immunization.class, "{\n" + " \"resourceType\": \"Immunization\",\n" + " \"id\": \"9353776b-dead-4588-8723-d687197d8438\",\n" + " \"status\": \"completed\",\n" + " \"vaccineCode\": {\n" + " \"coding\": [\n" + " {\n" + " \"code\": \"d144d24f-6913-4b63-9660-a9108c2bebef\",\n" + " \"display\": \"STAVUDINE LAMIVUDINE AND NEVIRAPINE\"\n" + " }\n" + " ]\n" + " },\n" + " \"patient\": {\n" + " \"reference\": \"Patient/a7e04421-525f-442f-8138-05b619d16def\",\n" + " \"type\": \"Patient\"\n" + " },\n" + " \"encounter\": {\n" + " \"reference\": \"Encounter/7d8c1980-6b78-11e0-93c3-18a905e044dc\",\n" + " \"type\": \"Encounter\"\n" + " },\n" + " \"occurrenceDateTime\": \"2020-07-08T20:30:00+02:00\",\n" + " \"manufacturer\": {\n" + " \"display\": \"Pharma Inc.\"\n" + " },\n" + " \"lotNumber\": \"YU765YT-1\",\n" + " \"expirationDate\": \"2020-10-08\",\n" + " \"performer\": [\n" + " {\n" + " \"actor\": {\n" + " \"reference\": \"Practitioner/f9badd80-ab76-11e2-9e96-0800200c9a66\",\n" + " \"type\": \"Practitioner\"\n" + " }\n" + " }\n" + " ],\n" + " \"protocolApplied\": [\n" + " {\n" + " \"doseNumberPositiveInt\": 4\n" + " }\n" + " ]\n" + "}");
// replay
Immunization savedImmunization = service.update("9353776b-dead-4588-8723-d687197d8438", updatedImmunization);
Obs obs = obsService.getObsByUuid(savedImmunization.getId());
// verify
helper.validateImmunizationObsGroup(obs);
assertObsCommons(obs, "a7e04421-525f-442f-8138-05b619d16def", "7d8c1980-6b78-11e0-93c3-18a905e044dc", "f9badd80-ab76-11e2-9e96-0800200c9a66");
obs.getGroupMembers().forEach(o -> {
assertObsCommons(o, "a7e04421-525f-442f-8138-05b619d16def", "7d8c1980-6b78-11e0-93c3-18a905e044dc", "f9badd80-ab76-11e2-9e96-0800200c9a66");
});
Map<String, Obs> members = helper.getObsMembersMap(obs);
assertThat(members.get(CIEL_984).getValueCoded().getUuid(), is("d144d24f-6913-4b63-9660-a9108c2bebef"));
assertThat(members.get(CIEL_1410).getValueDatetime(), equalTo(new DateTimeType("2020-07-08T20:30:00+02:00").getValue()));
assertThat(members.get(CIEL_1418).getValueNumeric(), equalTo(4.0));
assertThat(members.get(CIEL_1419).getValueText(), is("Pharma Inc."));
assertThat(members.get(CIEL_1420).getValueText(), is("YU765YT-1"));
assertThat(members.get(CIEL_165907).getValueDate(), equalTo(new DateType("2020-10-08").getValue()));
}
use of org.hl7.fhir.r4.model.Immunization in project openmrs-module-fhir2 by openmrs.
the class FhirImmunizationServiceImplTest method searchImmunizations_shouldFetchImmunizationsByPatientIdentifier.
@Test
public void searchImmunizations_shouldFetchImmunizationsByPatientIdentifier() {
// setup
ReferenceAndListParam param = new ReferenceAndListParam();
param.addValue(new ReferenceOrListParam().add(new ReferenceParam(SP_IDENTIFIER, "12345K")));
// replay
List<Immunization> immunizations = get(service.searchImmunizations(param, null));
// verify (in chronological order)
assertThat(immunizations.size(), is(2));
{
Immunization immunization = immunizations.get(0);
Coding coding = immunization.getVaccineCode().getCoding().get(0);
assertThat(coding.getDisplay(), is("STAVUDINE LAMIVUDINE AND NEVIRAPINE"));
assertThat(coding.getCode(), is("d144d24f-6913-4b63-9660-a9108c2bebef"));
assertThat(immunization.getPatient().getReference(), is("Patient/a7e04421-525f-442f-8138-05b619d16def"));
assertThat(immunization.getPatient().getType(), is(PATIENT));
assertThat(immunization.getEncounter().getReference(), is("Encounter/7d8c1980-6b78-11e0-93c3-18a905e044dc"));
assertThat(immunization.getEncounter().getType(), is(ENCOUNTER));
assertThat(immunization.getOccurrenceDateTimeType().getValue().toString(), is("2020-07-08 20:30:00.0"));
assertThat(immunization.getManufacturer().getDisplay(), is("Pharma Inc."));
assertThat(immunization.getLotNumber(), is("YU765YT"));
assertThat(immunization.getExpirationDate().toString(), is("2022-01-01 12:00:00.0"));
assertThat(immunization.getPerformer().size(), is(1));
assertThat(immunization.getPerformer().get(0).getActor().getReference(), is("Practitioner/f9badd80-ab76-11e2-9e96-0800200c9a66"));
assertThat(immunization.getPerformer().get(0).getActor().getType(), is(PRACTITIONER));
assertThat(immunization.getProtocolApplied().size(), is(1));
assertThat(immunization.getProtocolApplied().get(0).getDoseNumberPositiveIntType().getValue(), is(3));
}
{
Immunization immunization = immunizations.get(1);
Coding coding = immunization.getVaccineCode().getCoding().get(0);
assertThat(coding.getDisplay(), is("COUGH SYRUP"));
assertThat(coding.getCode(), is("0cbe2ed3-cd5f-4f46-9459-26127c9265ab"));
assertThat(immunization.getPatient().getReference(), is("Patient/a7e04421-525f-442f-8138-05b619d16def"));
assertThat(immunization.getPatient().getType(), is(PATIENT));
assertThat(immunization.getEncounter().getReference(), is("Encounter/7d8c1980-6b78-11e0-93c3-18a905e044dc"));
assertThat(immunization.getEncounter().getType(), is(ENCOUNTER));
assertThat(immunization.getOccurrenceDateTimeType().getValue().toString(), is("2020-06-08 20:30:00.0"));
assertThat(immunization.getManufacturer().getDisplay(), is("Biotech Ltd"));
assertThat(immunization.getLotNumber(), is("WV654XU"));
assertThat(immunization.getExpirationDate().toString(), is("2023-01-01 12:00:00.0"));
assertThat(immunization.getPerformer().size(), is(1));
assertThat(immunization.getPerformer().get(0).getActor().getReference(), is("Practitioner/f9badd80-ab76-11e2-9e96-0800200c9a66"));
assertThat(immunization.getPerformer().get(0).getActor().getType(), is(PRACTITIONER));
assertThat(immunization.getProtocolApplied().size(), is(1));
assertThat(immunization.getProtocolApplied().get(0).getDoseNumberPositiveIntType().getValue(), is(11));
}
}
use of org.hl7.fhir.r4.model.Immunization in project openmrs-module-fhir2 by openmrs.
the class ImmunizationFhirResourceProviderTest method updateImmunization_shouldThrowInvalidRequestExceptionForMissingId.
@Test(expected = InvalidRequestException.class)
public void updateImmunization_shouldThrowInvalidRequestExceptionForMissingId() {
Immunization noIdImmunization = new Immunization();
when(immunizationService.update(IMMUNIZATION_UUID, noIdImmunization)).thenThrow(InvalidRequestException.class);
resourceProvider.updateImmunization(new IdType().setValue(IMMUNIZATION_UUID), noIdImmunization);
}
use of org.hl7.fhir.r4.model.Immunization in project openmrs-module-fhir2 by openmrs.
the class ImmunizationFhirResourceProviderTest method searchImmunizations_shouldReturnMatchingImmunizationsWhenPatientParamIsSpecified.
@Test
public void searchImmunizations_shouldReturnMatchingImmunizationsWhenPatientParamIsSpecified() {
ReferenceAndListParam patient = new ReferenceAndListParam();
patient.addValue(new ReferenceOrListParam().add(new ReferenceParam(Immunization.SP_PATIENT, "John")));
when(immunizationService.searchImmunizations(any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(immunization), 10, 1));
IBundleProvider result = resourceProvider.searchImmunizations(patient, null);
List<IBaseResource> resources = getResources(result, 1, 0);
assertThat(result, notNullValue());
assertThat(resources, hasSize(equalTo(1)));
assertThat(resources.get(0), notNullValue());
assertThat(resources.get(0).fhirType(), equalTo(FhirConstants.IMMUNIZATION));
assertThat(resources.get(0).getIdElement().getIdPart(), equalTo(IMMUNIZATION_UUID));
}
Aggregations