use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorProviderImplTest method shouldTranslateProviderGenderToFhirPractitionerType.
@Test
public void shouldTranslateProviderGenderToFhirPractitionerType() {
Person person = new Person();
PersonName name = new PersonName();
name.setGivenName(GIVEN_NAME);
name.setFamilyName(FAMILY_NAME);
person.addName(name);
provider.setPerson(person);
HumanName humanName = new HumanName();
humanName.setFamily(FAMILY_NAME);
humanName.addGiven(GIVEN_NAME);
when(nameTranslator.toFhirResource(name)).thenReturn(humanName);
Practitioner practitioner = practitionerTranslator.toFhirResource(provider);
assertThat(practitioner, notNullValue());
assertThat(practitioner.getName(), notNullValue());
assertThat(practitioner.getName(), not(empty()));
assertThat(practitioner.getName().get(0).getGiven().get(0).getValue(), equalTo(GIVEN_NAME));
assertThat(practitioner.getName().get(0).getFamily(), equalTo(FAMILY_NAME));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorUserImplTest method shouldTranslateUserGenderToFhirPractitionerType.
@Test
public void shouldTranslateUserGenderToFhirPractitionerType() {
Person person = new Person();
PersonName name = new PersonName();
name.setGivenName(GIVEN_NAME);
name.setFamilyName(FAMILY_NAME);
person.addName(name);
user.setPerson(person);
HumanName humanName = new HumanName();
humanName.setFamily(FAMILY_NAME);
humanName.addGiven(GIVEN_NAME);
when(nameTranslator.toFhirResource(name)).thenReturn(humanName);
Practitioner practitioner = practitionerTranslatorUser.toFhirResource(user);
assertThat(practitioner, notNullValue());
assertThat(practitioner.getName(), notNullValue());
assertThat(practitioner.getName(), not(empty()));
assertThat(practitioner.getName().get(0).getGiven().get(0).getValue(), equalTo(GIVEN_NAME));
assertThat(practitioner.getName().get(0).getFamily(), equalTo(FAMILY_NAME));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorUserImplTest method shouldTranslateToFhirBirthDate.
@Test
public void shouldTranslateToFhirBirthDate() {
User user = new User();
Calendar calendar = Calendar.getInstance();
DateType dateType = new DateType();
// when birthdate more than 5 year
calendar.set(2000, Calendar.AUGUST, 12);
Person person = new Person();
person.setBirthdateEstimated(true);
person.setBirthdate(calendar.getTime());
user.setPerson(person);
Practitioner result = practitionerTranslatorUser.toFhirResource(user);
assertThat(result, notNullValue());
assertThat(result.getBirthDateElement().getPrecision(), equalTo(TemporalPrecisionEnum.YEAR));
assertThat(result.getBirthDateElement().getYear(), equalTo(2000));
// when birthDate less then 5 year
Date date = new Date();
user.getPerson().setBirthdate(date);
dateType.setValue(date, TemporalPrecisionEnum.MONTH);
result = practitionerTranslatorUser.toFhirResource(user);
assertThat(result, notNullValue());
assertThat(result.getBirthDateElement().getPrecision(), equalTo(TemporalPrecisionEnum.MONTH));
assertThat(result.getBirthDateElement().getYear(), equalTo(dateType.getYear()));
assertThat(result.getBirthDateElement().getMonth(), equalTo(dateType.getMonth()));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorUserImplTest method shouldTranslateOpenMrsDateChangedToLastUpdatedDate.
@Test
public void shouldTranslateOpenMrsDateChangedToLastUpdatedDate() {
user.setDateChanged(new Date());
Practitioner result = practitionerTranslatorUser.toFhirResource(user);
assertThat(result, notNullValue());
assertThat(result.getMeta().getLastUpdated(), DateMatchers.sameDay(new Date()));
}
use of org.hl7.fhir.r4.model.Practitioner in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorUserImplTest method setup.
@Before
public void setup() {
practitionerTranslatorUser = new PractitionerTranslatorUserImpl();
practitionerTranslatorUser.setNameTranslator(nameTranslator);
practitionerTranslatorUser.setAddressTranslator(addressTranslator);
practitionerTranslatorUser.setGenderTranslator(genderTranslator);
practitionerTranslatorUser.setBirthDateTranslator(birthDateTranslator);
user = new User();
user.setUuid(USER_UUID);
user.setSystemId(SYSTEM_ID);
Identifier identifier = new Identifier();
identifier.setValue((SYSTEM_ID));
identifier.setSystem(FhirConstants.OPENMRS_FHIR_EXT_USER_IDENTIFIER);
practitioner = new Practitioner();
practitioner.setId(USER_UUID);
practitioner.addIdentifier(identifier);
}
Aggregations