use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerFhirResourceProviderWebTest method shouldGetPractitionerHistoryById.
@Test
public void shouldGetPractitionerHistoryById() throws IOException, ServletException {
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
provenance.setRecorded(new Date());
provenance.setActivity(new CodeableConcept().addCoding(new Coding().setCode("CREATE").setSystem(FhirConstants.FHIR_TERMINOLOGY_DATA_OPERATION).setDisplay("create")));
provenance.addAgent(new Provenance.ProvenanceAgentComponent().setType(new CodeableConcept().addCoding(new Coding().setCode(FhirConstants.AUT).setDisplay(FhirConstants.AUTHOR).setSystem(FhirConstants.FHIR_TERMINOLOGY_PROVENANCE_PARTICIPANT_TYPE))).addRole(new CodeableConcept().addCoding(new Coding().setCode("").setDisplay("").setSystem(FhirConstants.FHIR_TERMINOLOGY_PARTICIPATION_TYPE))));
org.hl7.fhir.r4.model.Practitioner practitioner = new org.hl7.fhir.r4.model.Practitioner();
practitioner.setId(PRACTITIONER_UUID);
practitioner.addContained(provenance);
when(practitionerService.get(PRACTITIONER_UUID)).thenReturn(practitioner);
MockHttpServletResponse response = getPractitionerHistoryByIdRequest();
Bundle results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.hasEntry(), is(true));
assertThat(results.getEntry().get(0).getResource(), notNullValue());
assertThat(results.getEntry().get(0).getResource().getResourceType().name(), equalTo(Provenance.class.getSimpleName()));
}
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 {
org.hl7.fhir.r4.model.Practitioner practitioner = new org.hl7.fhir.r4.model.Practitioner();
practitioner.setId(PRACTITIONER_UUID);
when(practitionerService.get(PRACTITIONER_UUID)).thenReturn(practitioner);
MockHttpServletResponse response = getPractitionerHistoryByIdRequest();
assertThat(response, isOk());
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 createPractitioner_shouldCreatePractitioner.
@Test
public void createPractitioner_shouldCreatePractitioner() throws Exception {
String jsonPractitioner;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_CREATE_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.create(any(org.hl7.fhir.r4.model.Practitioner.class))).thenReturn(practitioner);
MockHttpServletResponse response = post("/Practitioner").jsonContent(jsonPractitioner).accept(FhirMediaTypes.JSON).go();
assertThat(response, isCreated());
}
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 PractitionerFhirResourceProviderWebTest method getPractitionerById_shouldReturnPractitioner.
@Test
public void getPractitionerById_shouldReturnPractitioner() throws Exception {
Practitioner practitioner = new Practitioner();
practitioner.setId(PRACTITIONER_UUID);
when(practitionerService.get(PRACTITIONER_UUID)).thenReturn(practitioner);
MockHttpServletResponse response = get("/Practitioner/" + PRACTITIONER_UUID).accept(FhirMediaTypes.JSON).go();
MatcherAssert.assertThat(response, isOk());
MatcherAssert.assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
MatcherAssert.assertThat(readResponse(response).getIdElement().getIdPart(), equalTo(PRACTITIONER_UUID));
}
Aggregations