use of org.hl7.fhir.r4.model.Person 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.Person 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.Person 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.Person in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorUserImplTest method shouldTranslateUserGenderToFhirPractitionerGender.
@Test
public void shouldTranslateUserGenderToFhirPractitionerGender() {
Person person = new Person();
person.setGender(GENDER);
user.setPerson(person);
when(genderTranslator.toFhirResource(GENDER)).thenReturn(Enumerations.AdministrativeGender.MALE);
Practitioner practitioner = practitionerTranslatorUser.toFhirResource(user);
assertThat(practitioner, notNullValue());
assertThat(practitioner.getGender(), notNullValue());
assertThat(practitioner.getGender(), equalTo(Enumerations.AdministrativeGender.MALE));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class ProvenanceTranslatorImplTest method shouldGetUpdateProvenanceWithCorrectAgentRoleForOpenmrsData.
@Test
public void shouldGetUpdateProvenanceWithCorrectAgentRoleForOpenmrsData() {
Provenance provenance = personProvenanceTranslator.getUpdateProvenance(person);
assertThat(provenance, notNullValue());
assertThat(provenance.getAgent(), not(empty()));
assertThat(provenance.getAgentFirstRep().getRoleFirstRep(), notNullValue());
assertThat(provenance.getAgentFirstRep().getRoleFirstRep().getCodingFirstRep(), notNullValue());
assertThat(provenance.getAgentFirstRep().getRoleFirstRep().getCodingFirstRep().getCode(), equalTo(AGENT_ROLE_CODE));
assertThat(provenance.getAgentFirstRep().getRoleFirstRep().getCodingFirstRep().getDisplay(), equalTo(AGENT_ROLE_DISPLAY));
assertThat(provenance.getAgentFirstRep().getRoleFirstRep().getCodingFirstRep().getSystem(), equalTo(FhirConstants.FHIR_TERMINOLOGY_PARTICIPATION_TYPE));
}
Aggregations