use of org.hl7.fhir.r4.model.RelatedPerson in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderIntegrationTest method shouldReturnSortedAndFilterSearchResultsForRelatedPersonAsXML.
@Test
public void shouldReturnSortedAndFilterSearchResultsForRelatedPersonAsXML() throws Exception {
MockHttpServletResponse response = get("/RelatedPerson?name=John&_sort=-date").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
List<Bundle.BundleEntryComponent> entries = results.getEntry();
assertThat(entries, everyItem(hasResource(hasProperty("nameFirstRep", hasProperty("family", containsString("Doe"))))));
assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("nameFirstRep", hasProperty("givenAsSingleString", containsString("F"))))));
}
use of org.hl7.fhir.r4.model.RelatedPerson in project integration-adaptor-111 by nhsconnect.
the class RelatedPersonMapperTest method shouldCreateRelatedPersonWhenPatientHasEcTelecom.
@Test
public void shouldCreateRelatedPersonWhenPatientHasEcTelecom() {
TEL[] telecomArray = createTelecomArray();
telecomArray[0].setUse(Collections.singletonList("EC"));
when(clinicalDocumentDocument.getRecordTargetArray(0)).thenReturn(recordTarget);
when(recordTarget.getPatientRole()).thenReturn(patientRole);
when(patientRole.getTelecomArray()).thenReturn(telecomArray);
when(contactPoint.getValue()).thenReturn(TELECOM_VALUE);
when(contactPointMapper.mapContactPoint(ArgumentMatchers.any())).thenReturn(contactPoint);
RelatedPerson relatedPerson = relatedPersonMapper.createEmergencyContactRelatedPerson(clinicalDocumentDocument, encounter);
assertThat(relatedPerson.hasRelationship()).isTrue();
assertThat(relatedPerson.getRelationship().getCoding().size()).isEqualTo(1);
assertThat(relatedPerson.getRelationship().getCodingFirstRep().getCode()).isEqualTo("C");
assertThat(relatedPerson.getRelationship().getCodingFirstRep().getDisplay()).isEqualTo("Emergency Contact");
assertThat(relatedPerson.getTelecom().get(0).getValue()).isEqualTo(TELECOM_VALUE);
}
use of org.hl7.fhir.r4.model.RelatedPerson in project integration-adaptor-111 by nhsconnect.
the class RelatedPersonMapperTest method shouldMapRelatedPersonWithTwoCodingsInRelationship.
@Test
public void shouldMapRelatedPersonWithTwoCodingsInRelationship() {
setup();
TEL[] telecomArray = createTelecomArray();
telecomArray[0].setUse(Collections.singletonList("EC"));
relatedEntity.setTelecomArray(telecomArray);
informant12.setRelatedEntity(relatedEntity);
RelatedPerson relatedPerson = relatedPersonMapper.mapRelatedPerson(informant12, encounter);
assertThat(relatedPerson.hasRelationship()).isTrue();
assertThat(relatedPerson.getRelationship().getCoding().size()).isEqualTo(2);
}
use of org.hl7.fhir.r4.model.RelatedPerson in project integration-adaptor-111 by nhsconnect.
the class ParticipantMapperTest method shouldMapEncounterRelatedPerson.
@Test
public void shouldMapEncounterRelatedPerson() {
IVLTS time = IVLTS.Factory.newInstance();
POCDMT000002UK01RelatedEntity relatedEntity = POCDMT000002UK01RelatedEntity.Factory.newInstance();
relatedEntity.setEffectiveTime(time);
POCDMT000002UK01Informant12 informant = POCDMT000002UK01Informant12.Factory.newInstance();
informant.setTypeCode("INF");
informant.setRelatedEntity(relatedEntity);
Encounter encounter = new Encounter();
RelatedPerson relatedPerson = new RelatedPerson();
relatedPerson.setId(RELATED_PERSON_ID);
when(relatedPersonMapper.mapRelatedPerson(informant, encounter)).thenReturn(relatedPerson);
when(periodMapper.mapPeriod(ArgumentMatchers.isA(IVLTS.class))).thenReturn(period);
when(resourceUtil.createReference(relatedPerson)).thenReturn(new Reference(relatedPerson));
Encounter.EncounterParticipantComponent participantComponent = participantMapper.mapEncounterRelatedPerson(informant, encounter);
assertThat(participantComponent.getType().get(0).getText()).isEqualTo("Informant");
assertThat(participantComponent.getIndividualTarget().getId()).isEqualTo(RELATED_PERSON_ID);
assertThat(participantComponent.getPeriod()).isEqualTo(period);
}
use of org.hl7.fhir.r4.model.RelatedPerson in project integration-adaptor-111 by nhsconnect.
the class RelatedPersonMapper method setRelationship.
private void setRelationship(POCDMT000002UK01RelatedEntity relatedEntity, RelatedPerson relatedPerson) {
if (relatedEntity.isSetCode()) {
CE code = relatedEntity.getCode();
Coding coding = new Coding().setCode(code.getCode()).setDisplay(code.getDisplayName()).setSystem(code.getCodeSystem());
relatedPerson.setRelationship(new CodeableConcept(coding));
}
}
Aggregations