use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method initRelatedPerson.
@Before
public void initRelatedPerson() {
HumanName name = new HumanName();
name.addGiven(GIVEN_NAME);
name.setFamily(FAMILY_NAME);
relatedPerson = new org.hl7.fhir.r4.model.RelatedPerson();
relatedPerson.setId(RELATED_PERSON_UUID);
relatedPerson.setGender(Enumerations.AdministrativeGender.MALE);
relatedPerson.addName(name);
setProvenanceResources(relatedPerson);
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method getRelatedPersonById_shouldReturnMatchingRelatedPerson.
@Test
public void getRelatedPersonById_shouldReturnMatchingRelatedPerson() {
when(relatedPersonService.get(RELATED_PERSON_UUID)).thenReturn(relatedPerson);
IdType id = new IdType();
id.setValue(RELATED_PERSON_UUID);
RelatedPerson relatedPerson = resourceProvider.getRelatedPersonById(id);
assertThat(relatedPerson, notNullValue());
assertThat(relatedPerson.getId(), notNullValue());
assertThat(relatedPerson.getId(), equalTo(RELATED_PERSON_UUID));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonTranslatorImplTest method shouldNotTranslateGenderIfPersonAGenderIsNull.
@Test
public void shouldNotTranslateGenderIfPersonAGenderIsNull() {
personA.setGender(null);
relationship.setPersonA(personA);
RelatedPerson result = relatedPersonTranslator.toFhirResource(relationship);
assertThat(result, notNullValue());
assertThat(result.getGender(), nullValue());
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonTranslatorImplTest method shouldTranslateStartDateEndDateToRelatedPersonPeriod.
@Test
public void shouldTranslateStartDateEndDateToRelatedPersonPeriod() {
relationship.setStartDate(new Date());
relationship.setEndDate(new Date());
RelatedPerson result = relatedPersonTranslator.toFhirResource(relationship);
assertThat(result, notNullValue());
assertThat(result.getPeriod(), notNullValue());
assertThat(result.getPeriod().getStart(), DateMatchers.sameDay(new Date()));
assertThat(result.getPeriod().getEnd(), DateMatchers.sameDay(new Date()));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonNarrativeTest method shouldGenerateRelatedPersonNarrative.
/**
* Check that the expected narrative is generated for some example RelatedPerson resource
*
* @throws IOException
*/
@Test
public void shouldGenerateRelatedPersonNarrative() throws IOException {
RelatedPerson given = parser.parseResource(RelatedPerson.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
RelatedPerson result = parser.parseResource(RelatedPerson.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)));
}
Aggregations