use of org.hl7.fhir.dstu3.model.ResourceType 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.dstu3.model.ResourceType in project openmrs-module-fhir2 by openmrs.
the class PatientFhirResourceProviderIntegrationTest method shouldReturnForPatientTypeEverythingWhenCountIsSpecifiedAsJson.
@Test
public void shouldReturnForPatientTypeEverythingWhenCountIsSpecifiedAsJson() throws Exception {
MockHttpServletResponse response = get("/Patient/$everything?_count=5").accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle result = readBundleResponse(response);
assertThat(result, notNullValue());
assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(result, hasProperty("total", equalTo(46)));
assertThat(result.getEntry(), hasSize(5));
List<Bundle.BundleEntryComponent> entries = result.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/"))));
assertThat(entries, everyItem(hasResource(hasProperty("resourceType", in(getEverythingValidResourceTypes())))));
}
use of org.hl7.fhir.dstu3.model.ResourceType in project openmrs-module-fhir2 by openmrs.
the class PatientFhirResourceProviderIntegrationTest method shouldReturnPatientTypeEverythingAsJson.
@Test
public void shouldReturnPatientTypeEverythingAsJson() throws Exception {
MockHttpServletResponse response = get("/Patient/$everything").accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle result = readBundleResponse(response);
assertThat(result, notNullValue());
assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(result, hasProperty("total", equalTo(46)));
assertThat(result.getEntry(), hasSize(46));
List<Bundle.BundleEntryComponent> entries = result.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/"))));
assertThat(entries, everyItem(hasResource(hasProperty("resourceType", in(getEverythingValidResourceTypes())))));
}
use of org.hl7.fhir.dstu3.model.ResourceType in project openmrs-module-fhir2 by openmrs.
the class PatientFhirResourceProviderIntegrationTest method shouldReturnForPatientTypeEverythingWhenCountIsSpecifiedAsXml.
@Test
public void shouldReturnForPatientTypeEverythingWhenCountIsSpecifiedAsXml() throws Exception {
MockHttpServletResponse response = get("/Patient/$everything?_count=5").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle result = readBundleResponse(response);
assertThat(result, notNullValue());
assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(result, hasProperty("total", equalTo(46)));
assertThat(result.getEntry(), hasSize(5));
List<Bundle.BundleEntryComponent> entries = result.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/"))));
assertThat(entries, everyItem(hasResource(hasProperty("resourceType", in(getEverythingValidResourceTypes())))));
}
use of org.hl7.fhir.dstu3.model.ResourceType in project openmrs-module-fhir2 by openmrs.
the class PatientFhirResourceProviderIntegrationTest method shouldReturnPatientTypeEverythingAsXml.
@Test
public void shouldReturnPatientTypeEverythingAsXml() throws Exception {
MockHttpServletResponse response = get("/Patient/$everything").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle result = readBundleResponse(response);
assertThat(result, notNullValue());
assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(result, hasProperty("total", equalTo(46)));
assertThat(result.getEntry(), hasSize(46));
List<Bundle.BundleEntryComponent> entries = result.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R4/"))));
assertThat(entries, everyItem(hasResource(hasProperty("resourceType", in(getEverythingValidResourceTypes())))));
}
Aggregations