use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerFhirResourceProviderWebTest method shouldVerifyGetPractitionerHistoryByIdUri.
@Test
public void shouldVerifyGetPractitionerHistoryByIdUri() throws Exception {
Practitioner practitioner = new Practitioner();
practitioner.setId(PRACTITIONER_UUID);
when(practitionerService.get(PRACTITIONER_UUID)).thenReturn(practitioner);
MockHttpServletResponse response = getPractitionerHistoryByIdRequest();
MatcherAssert.assertThat(response, isOk());
MatcherAssert.assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerFhirResourceProviderWebTest method updatePractitioner_shouldUpdateExistingPractitioner.
@Test
public void updatePractitioner_shouldUpdateExistingPractitioner() throws Exception {
String jsonPractitioner;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_UPDATE_PRACTITIONER_PATH)) {
Objects.requireNonNull(is);
jsonPractitioner = IOUtils.toString(is, StandardCharsets.UTF_8);
}
org.hl7.fhir.r4.model.Practitioner practitioner = new org.hl7.fhir.r4.model.Practitioner();
practitioner.setId(PRACTITIONER_UUID);
when(practitionerService.update(anyString(), any(org.hl7.fhir.r4.model.Practitioner.class))).thenReturn(practitioner);
MockHttpServletResponse response = put("/Practitioner/" + PRACTITIONER_UUID).jsonContent(jsonPractitioner).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerNarrativeTest method shouldGeneratePractitionerNarrative.
/**
* Check that the expected narrative is generated for some example Practitioner resource
*
* @throws IOException
*/
@Test
public void shouldGeneratePractitionerNarrative() throws IOException {
Practitioner given = parser.parseResource(Practitioner.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
Practitioner result = parser.parseResource(Practitioner.class, parser.encodeResourceToString(given));
assertThat(result, notNullValue());
assertThat(result.getText(), notNullValue());
assertThat(result.getText().getStatusAsString(), equalTo("generated"));
assertThat(result.getText().getDivAsString(), equalTo(readNarrativeFile(EXPECTED_NARRATIVE_PATH)));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerFhirResourceProviderIntegrationTest method shouldUpdateExistingPractitionerAsXML.
@Test
public void shouldUpdateExistingPractitionerAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Practitioner/" + PRACTITIONER_UUID).accept(FhirMediaTypes.XML).go();
Practitioner practitioner = readResponse(response);
// update the existing record
Date birthDate = DateUtils.truncate(new Date(), Calendar.DATE);
practitioner.setBirthDate(birthDate);
// send the update to the server
response = put("/Practitioner/" + PRACTITIONER_UUID).xmlContent(toXML(practitioner)).accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
// read the updated record
Practitioner updatedPractitioner = readResponse(response);
assertThat(updatedPractitioner, notNullValue());
assertThat(updatedPractitioner.getIdElement().getIdPart(), equalTo(PRACTITIONER_UUID));
assertThat(updatedPractitioner.getBirthDate(), equalTo(birthDate));
assertThat(practitioner, validResource());
// double-check the record returned via get
response = get("/Practitioner/" + PRACTITIONER_UUID).accept(FhirMediaTypes.XML).go();
Practitioner reReadPractitioner = readResponse(response);
assertThat(reReadPractitioner.getBirthDate(), equalTo(birthDate));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerFhirResourceProviderIntegrationTest method shouldReturnCountForPractitionerAsJson.
@Test
public void shouldReturnCountForPractitionerAsJson() throws Exception {
MockHttpServletResponse response = get("/Practitioner?&_summary=count").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(6)));
}
Aggregations