use of ca.uhn.fhir.rest.param.DateParam in project openmrs-module-fhir2 by openmrs.
the class EncounterSearchQueryTest method searchForEncounters_shouldSearchForEncountersByDate.
@Test
public void searchForEncounters_shouldSearchForEncountersByDate() {
DateRangeParam date = new DateRangeParam(new DateParam(ENCOUNTER_DATETIME));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, date);
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()).getId(), equalTo(ENC_UUID));
}
use of ca.uhn.fhir.rest.param.DateParam in project openmrs-module-fhir2 by openmrs.
the class FhirEncounterServiceImplTest method searchForEncounter_shouldReturnCollectionOfEncounterByDate.
@Test
public void searchForEncounter_shouldReturnCollectionOfEncounterByDate() {
List<Encounter> encounters = new ArrayList<>();
DateRangeParam dateRangeParam = new DateRangeParam(new DateParam(ENCOUNTER_DATETIME));
encounters.add(openMrsEncounter);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, dateRangeParam);
fhirEncounter.setId(ENCOUNTER_UUID);
when(dao.getSearchResults(any(), any())).thenReturn(encounters);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(ENCOUNTER_UUID));
when(encounterTranslator.toFhirResource(openMrsEncounter)).thenReturn(fhirEncounter);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, encounterTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(visitService.searchForVisits(any())).thenReturn(new SimpleBundleProvider());
IBundleProvider results = encounterService.searchForEncounters(dateRangeParam, null, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(((org.hl7.fhir.r4.model.Encounter) resultList.iterator().next()).getId(), equalTo(ENCOUNTER_UUID));
}
use of ca.uhn.fhir.rest.param.DateParam in project openmrs-module-fhir2 by openmrs.
the class VisitSearchQueryTest method searchForVisits_shouldSearchForVisitsByDate.
@Test
public void searchForVisits_shouldSearchForVisitsByDate() {
DateRangeParam date = new DateRangeParam(new DateParam(VISIT_STARTDATE));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, date);
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()).getId(), equalTo(VISIT_UUID));
}
use of ca.uhn.fhir.rest.param.DateParam in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryImpl_2_2Test method searchForConditions_shouldReturnConditionByOnsetDateRange.
@Test
public void searchForConditions_shouldReturnConditionByOnsetDateRange() {
DateRangeParam onsetDate = new DateRangeParam(new DateParam(ONSET_START_DATE), new DateParam(ONSET_END_DATE));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, "onsetDate", onsetDate);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getOnsetDateTimeType().getValue().toString(), containsString(ONSET_DATE));
}
use of ca.uhn.fhir.rest.param.DateParam in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryImpl_2_2Test method searchForConditions_shouldReturnConditionByRecordedDate.
@Test
public void searchForConditions_shouldReturnConditionByRecordedDate() {
DateRangeParam recordedDate = new DateRangeParam(new DateParam("eq" + RECORDED_DATE_TIME));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, "dateCreated", recordedDate);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getRecordedDate().toString(), containsString(RECORDED_DATE));
}
Aggregations