use of org.hl7.fhir.r4.model.Practitioner 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.Practitioner 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.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerSearchQueryTest method searchForPractitioners_shouldSearchForPractitionersByUuid.
@Test
public void searchForPractitioners_shouldSearchForPractitionersByUuid() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(PRACTITIONER_UUID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
assertThat(((Practitioner) resultList.iterator().next()).getIdElement().getIdPart(), equalTo(PRACTITIONER_UUID));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerSearchQueryTest method searchForPractitioners_shouldReturnPractitionersByCity.
@Test
public void searchForPractitioners_shouldReturnPractitionersByCity() {
StringAndListParam city = new StringAndListParam().addAnd(new StringParam(CITY));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, city);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
assertThat(((Practitioner) resultList.iterator().next()).getAddressFirstRep().getCity(), equalTo(CITY));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerSearchQueryTest method searchForPractitioners_shouldHandleComplexQuery.
@Test
public void searchForPractitioners_shouldHandleComplexQuery() {
StringAndListParam name = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(PRACTITIONER_GIVEN_NAME)));
TokenAndListParam identifier = new TokenAndListParam().addAnd(new TokenOrListParam().add(PRACTITIONER_IDENTIFIER));
SearchParameterMap theParams = new SearchParameterMap().addParameter(NAME_SEARCH_HANDLER, NAME_PROPERTY, name).addParameter(FhirConstants.IDENTIFIER_SEARCH_HANDLER, identifier);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
assertThat(((Practitioner) resultList.iterator().next()).getIdentifierFirstRep().getValue(), equalTo(PRACTITIONER_IDENTIFIER));
assertThat(resultList.iterator().next().getIdElement().getIdPart(), equalTo(PRACTITIONER_UUID));
}
Aggregations