Search in sources :

Example 6 with DateParam

use of ca.uhn.fhir.rest.param.DateParam in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyCollectionByWrongIssueDate.

@Test
public void searchForDiagnosticReports_shouldReturnEmptyCollectionByWrongIssueDate() {
    DateRangeParam issueDate = new DateRangeParam(new DateParam(DIAGNOSTIC_REPORT_WRONG_DATETIME));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, issueDate);
    IBundleProvider diagnosticReports = search(theParams);
    assertThat(diagnosticReports, notNullValue());
    assertThat(diagnosticReports.size(), equalTo(0));
    List<DiagnosticReport> resultList = get(diagnosticReports);
    assertThat(resultList, empty());
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) DateParam(ca.uhn.fhir.rest.param.DateParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 7 with DateParam

use of ca.uhn.fhir.rest.param.DateParam in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnDiagnosticReportByIssueDate.

@Test
public void searchForDiagnosticReports_shouldReturnDiagnosticReportByIssueDate() {
    DateRangeParam issueDate = new DateRangeParam(new DateParam(DIAGNOSTIC_REPORT_DATETIME));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, issueDate);
    IBundleProvider diagnosticReports = search(theParams);
    List<DiagnosticReport> resultList = get(diagnosticReports);
    assertThat(diagnosticReports, notNullValue());
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getIssued().toString(), equalTo(DIAGNOSTIC_REPORT_DATE));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) DateParam(ca.uhn.fhir.rest.param.DateParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 8 with DateParam

use of ca.uhn.fhir.rest.param.DateParam in project openmrs-module-fhir2 by openmrs.

the class ObservationSearchQueryTest method searchForObs_shouldSearchForObsByValueDate.

@Test
public void searchForObs_shouldSearchForObsByValueDate() {
    SearchParameterMap theParams = new SearchParameterMap();
    theParams.addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, "valueDatetime", new DateRangeParam(new DateParam(VALUE_DATE)));
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), equalTo(1));
    List<IBaseResource> resultList = get(results);
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasItem(hasProperty("id", equalTo(OBS_VALUE_CONCEPT_UUID))));
    assertThat(((Observation) resultList.get(0)).getIssued().toString(), startsWith(VALUE_DATE));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) Observation(org.hl7.fhir.r4.model.Observation) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) DateParam(ca.uhn.fhir.rest.param.DateParam) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 9 with DateParam

use of ca.uhn.fhir.rest.param.DateParam in project openmrs-module-fhir2 by openmrs.

the class ObservationSearchQueryTest method searchForObs_shouldSearchByObsDateAndTime.

@Test
public void searchForObs_shouldSearchByObsDateAndTime() {
    SearchParameterMap theParams = new SearchParameterMap();
    theParams.addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, "obsDatetime", new DateRangeParam(new DateParam(OBS_DATE_AND_TIME)));
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), equalTo(12));
    List<IBaseResource> resultList = get(results);
    assertThat(resultList, not(empty()));
    assertThat(resultList.size(), equalTo(10));
    assertThat(resultList, hasItem(hasProperty("id", equalTo(OBS_VALUE_CONCEPT_UUID))));
    assertThat(((Observation) resultList.get(0)).getEffectiveDateTimeType().getValue().toString(), equalTo(EXPECTED_OBS_DATE_AND_TIME));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) DateParam(ca.uhn.fhir.rest.param.DateParam) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 10 with DateParam

use of ca.uhn.fhir.rest.param.DateParam in project openmrs-module-fhir2 by openmrs.

the class PatientSearchQueryTest method searchForPatients_shouldSearchForPatientsByBirthDate.

@Test
public void searchForPatients_shouldSearchForPatientsByBirthDate() {
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, "birthdate", new DateRangeParam(new DateParam(PATIENT_BIRTHDATE)));
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), greaterThanOrEqualTo(1));
    List<Patient> resultList = get(results);
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasItem(hasProperty("id", equalTo(PATIENT_BIRTHDATE_PATIENT_UUID))));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) Patient(org.hl7.fhir.r4.model.Patient) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) DateParam(ca.uhn.fhir.rest.param.DateParam) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

DateParam (ca.uhn.fhir.rest.param.DateParam)31 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)24 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)21 Test (org.junit.Test)21 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)21 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)20 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)19 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)4 StringParam (ca.uhn.fhir.rest.param.StringParam)4 TokenParam (ca.uhn.fhir.rest.param.TokenParam)4 ArrayList (java.util.ArrayList)4 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)3 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)3 Test (org.junit.jupiter.api.Test)3 FhirContext (ca.uhn.fhir.context.FhirContext)2 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)2 DateOrListParam (ca.uhn.fhir.rest.param.DateOrListParam)2 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)2 Date (java.util.Date)2 List (java.util.List)2