use of org.hl7.fhir.r4.model.Encounter in project openmrs-module-fhir2 by openmrs.
the class VisitSearchQueryTest method searchForVisits_shouldSearchForVisitsByTypeUUID.
@Test
public void searchForVisits_shouldSearchForVisitsByTypeUUID() {
TokenAndListParam typeUuid = new TokenAndListParam().addAnd(new TokenParam(VISIT_TYPE_UUID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ENCOUNTER_TYPE_REFERENCE_SEARCH_HANDLER, typeUuid);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((Encounter) resultList.iterator().next()).getIdElement().getIdPart(), equalTo(VISIT_UUID));
}
use of org.hl7.fhir.r4.model.Encounter in project openmrs-module-fhir2 by openmrs.
the class VisitSearchQueryTest method searchForVisits_shouldSearchForVisitsByMultipleSubjectIdentifierOr.
@Test
public void searchForVisits_shouldSearchForVisitsByMultipleSubjectIdentifierOr() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_IDENTIFIER);
patient.setChain(Patient.SP_IDENTIFIER);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(WRONG_IDENTIFIER);
badPatient.setChain(Patient.SP_IDENTIFIER);
referenceParam.addValue(new ReferenceOrListParam().add(patient).add(badPatient));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((Encounter) resultList.iterator().next()).getSubject().getReference(), endsWith(PATIENT_UUID));
}
use of org.hl7.fhir.r4.model.Encounter in project openmrs-module-fhir2 by openmrs.
the class VisitSearchQueryTest method searchForVisits_shouldSearchForVisitsByUuid.
@Test
public void searchForVisits_shouldSearchForVisitsByUuid() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(VISIT_UUID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
assertThat(((Encounter) resultList.iterator().next()).getIdElement().getIdPart(), equalTo(VISIT_UUID));
}
use of org.hl7.fhir.r4.model.Encounter in project openmrs-module-fhir2 by openmrs.
the class VisitSearchQueryTest method searchForVisits_shouldSearchForVisitsByLocationUUID.
@Test
public void searchForVisits_shouldSearchForVisitsByLocationUUID() {
ReferenceAndListParam locationReference = new ReferenceAndListParam();
ReferenceParam location = new ReferenceParam();
location.setValue(LOCATION_UUID);
locationReference.addValue(new ReferenceOrListParam().add(location));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.LOCATION_REFERENCE_SEARCH_HANDLER, locationReference);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((Encounter) resultList.iterator().next()).getLocationFirstRep().getLocation().getReferenceElement().getIdPart(), equalTo(LOCATION_UUID));
}
use of org.hl7.fhir.r4.model.Encounter in project openmrs-module-fhir2 by openmrs.
the class EncounterTranslatorImplTest method toOpenMrsType_shouldTranslatePeriodToEncounterDatetime.
@Test
public void toOpenMrsType_shouldTranslatePeriodToEncounterDatetime() {
Date encounterDate = new java.util.Date();
Period period = new Period();
period.setStart(encounterDate);
fhirEncounter.setPeriod(period);
when(encounterPeriodTranslator.toOpenmrsType(ArgumentMatchers.any(), ArgumentMatchers.any())).then(invocation -> {
org.openmrs.Encounter encounter = invocation.getArgument(0);
encounter.setEncounterDatetime(((Period) invocation.getArgument(1)).getStart());
return encounter;
});
when(patientReferenceTranslator.toOpenmrsType(patientRef)).thenReturn(patient);
org.openmrs.Encounter result = encounterTranslator.toOpenmrsType(fhirEncounter);
assertThat(result, notNullValue());
assertThat(result.getEncounterDatetime(), equalTo(encounterDate));
}
Aggregations