use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorProviderImpl method toOpenmrsType.
@Override
public Provider toOpenmrsType(@Nonnull Provider existingProvider, @Nonnull Practitioner practitioner) {
if (existingProvider == null) {
return null;
}
if (practitioner == null) {
return null;
}
existingProvider.setUuid(practitioner.getId());
existingProvider.setIdentifier(practitioner.getIdentifierFirstRep().getValue());
if (existingProvider.getPerson() == null) {
existingProvider.setPerson(new Person());
}
if (practitioner.hasBirthDateElement()) {
birthDateTranslator.toOpenmrsType(existingProvider.getPerson(), practitioner.getBirthDateElement());
}
for (HumanName name : practitioner.getName()) {
existingProvider.getPerson().addName(nameTranslator.toOpenmrsType(name));
}
if (practitioner.hasGender()) {
existingProvider.getPerson().setGender(genderTranslator.toOpenmrsType(practitioner.getGender()));
}
for (Address address : practitioner.getAddress()) {
existingProvider.getPerson().addAddress(addressTranslator.toOpenmrsType(address));
}
practitioner.getTelecom().stream().map(contactPoint -> (ProviderAttribute) telecomTranslator.toOpenmrsType(new ProviderAttribute(), contactPoint)).filter(Objects::nonNull).forEach(existingProvider::addAttribute);
return existingProvider;
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorProviderImpl method toFhirResource.
@Override
public Practitioner toFhirResource(@Nonnull Provider provider) {
if (provider == null) {
return null;
}
Practitioner practitioner = new Practitioner();
Identifier identifier = new Identifier();
identifier.setSystem(FhirConstants.OPENMRS_FHIR_EXT_PROVIDER_IDENTIFIER);
identifier.setValue(provider.getIdentifier());
practitioner.addIdentifier(identifier);
practitioner.setId(provider.getUuid());
practitioner.setActive(provider.getRetired());
practitioner.setTelecom(getProviderContactDetails(provider));
if (provider.getPerson() != null) {
practitioner.setBirthDateElement(birthDateTranslator.toFhirResource(provider.getPerson()));
practitioner.setGender(genderTranslator.toFhirResource(provider.getPerson().getGender()));
for (PersonName name : provider.getPerson().getNames()) {
practitioner.addName(nameTranslator.toFhirResource(name));
}
for (PersonAddress address : provider.getPerson().getAddresses()) {
practitioner.addAddress(addressTranslator.toFhirResource(address));
}
}
practitioner.getMeta().setLastUpdated(provider.getDateChanged());
practitioner.addContained(provenanceTranslator.getCreateProvenance(provider));
practitioner.addContained(provenanceTranslator.getUpdateProvenance(provider));
return practitioner;
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorUserImpl method toFhirResource.
@Override
public Practitioner toFhirResource(@Nonnull User user) {
notNull(user, "The User object should not be null");
Practitioner practitioner = new Practitioner();
practitioner.setId(user.getUuid());
Identifier userIdentifier = new Identifier();
userIdentifier.setSystem(FhirConstants.OPENMRS_FHIR_EXT_USER_IDENTIFIER);
userIdentifier.setValue(user.getSystemId());
practitioner.addIdentifier(userIdentifier);
if (user.getPerson() != null) {
practitioner.setBirthDateElement(birthDateTranslator.toFhirResource(user.getPerson()));
practitioner.setGender(genderTranslator.toFhirResource(user.getPerson().getGender()));
for (PersonName name : user.getPerson().getNames()) {
practitioner.addName(nameTranslator.toFhirResource(name));
}
for (PersonAddress address : user.getPerson().getAddresses()) {
practitioner.addAddress(addressTranslator.toFhirResource(address));
}
}
practitioner.getMeta().setLastUpdated(user.getDateChanged());
return practitioner;
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerFhirResourceProviderWebTest method getPractitionerHistoryById_shouldReturnBundleWithEmptyEntriesIfPractitionerContainedIsEmpty.
@Test
public void getPractitionerHistoryById_shouldReturnBundleWithEmptyEntriesIfPractitionerContainedIsEmpty() throws Exception {
org.hl7.fhir.r4.model.Practitioner practitioner = new org.hl7.fhir.r4.model.Practitioner();
practitioner.setId(PRACTITIONER_UUID);
practitioner.setContained(new ArrayList<>());
when(practitionerService.get(PRACTITIONER_UUID)).thenReturn(practitioner);
MockHttpServletResponse response = getPractitionerHistoryByIdRequest();
Bundle results = readBundleResponse(response);
assertThat(results.hasEntry(), is(false));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerFhirResourceProviderWebTest method deletePractitioner_shouldDeletePractitioner.
@Test
public void deletePractitioner_shouldDeletePractitioner() throws Exception {
OperationOutcome retVal = new OperationOutcome();
retVal.setId(PRACTITIONER_UUID);
retVal.getText().setDivAsString("Deleted successfully");
org.hl7.fhir.r4.model.Practitioner practitioner = new org.hl7.fhir.r4.model.Practitioner();
practitioner.setId(PRACTITIONER_UUID);
when(practitionerService.delete(PRACTITIONER_UUID)).thenReturn(practitioner);
MockHttpServletResponse response = delete("/Practitioner/" + PRACTITIONER_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
}
Aggregations