Search in sources :

Example 36 with RelatedPerson

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);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) Before(org.junit.Before)

Example 37 with 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));
}
Also used : RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 38 with RelatedPerson

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());
}
Also used : RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Test(org.junit.Test)

Example 39 with RelatedPerson

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()));
}
Also used : Date(java.util.Date) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Test(org.junit.Test)

Example 40 with RelatedPerson

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)));
}
Also used : RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)87 RelatedPerson (org.hl7.fhir.r4.model.RelatedPerson)54 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)51 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)33 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)29 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)24 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)24 StringParam (ca.uhn.fhir.rest.param.StringParam)24 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)24 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)20 RelatedPerson (org.hl7.fhir.dstu3.model.RelatedPerson)17 Test (org.junit.jupiter.api.Test)17 Resource (org.hl7.fhir.r4.model.Resource)14 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)13 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)12 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)12 Patient (org.hl7.fhir.r4.model.Patient)12 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)11 Identifier (org.hl7.fhir.r4.model.Identifier)10 Reference (org.hl7.fhir.r4.model.Reference)9