From 0fe95f331af752360576d3fdbec9caa93de8e877 Mon Sep 17 00:00:00 2001 From: Chi Bong Ho Date: Sat, 26 Oct 2024 21:50:53 -0400 Subject: [PATCH] FM2-648 fix NPE when querying deceased patient with openmrsPatients named query --- .../fhir2/api/search/param/OpenmrsPatientSearchParams.java | 2 +- .../r3/PatientFhirResourceProviderIntegrationTest.java | 4 ++-- .../r4/PatientFhirResourceProviderIntegrationTest.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/search/param/OpenmrsPatientSearchParams.java b/api/src/main/java/org/openmrs/module/fhir2/api/search/param/OpenmrsPatientSearchParams.java index 161e887b0..e43e8cedf 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/search/param/OpenmrsPatientSearchParams.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/search/param/OpenmrsPatientSearchParams.java @@ -70,7 +70,7 @@ public SearchParameterMap toSearchParameterMap() { .addParameter(FhirConstants.GENDER_SEARCH_HANDLER, "gender", getGender()) .addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, "birthdate", getBirthDate()) .addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, "deathDate", getDeathDate()) - .addParameter(FhirConstants.BOOLEAN_SEARCH_HANDLER, getDeceased()) + .addParameter(FhirConstants.BOOLEAN_SEARCH_HANDLER, "dead", getDeceased()) .addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, getCity()) .addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, getState()) .addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.POSTAL_CODE_PROPERTY, getPostalCode()) diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderIntegrationTest.java index d3ccfc9dc..2ac208a9a 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r3/PatientFhirResourceProviderIntegrationTest.java @@ -477,7 +477,7 @@ public void shouldReturnSortedAndFilteredSearchResultsForPatientsAsJson() throws @Test public void shouldAllowNamedQueryForPatientsAsJson() throws Exception { - MockHttpServletResponse response = get("/Patient?_query=openmrsPatients&q=Doe&_sort=given") + MockHttpServletResponse response = get("/Patient?_query=openmrsPatients&q=Doe&_sort=given&deceased=false") .accept(FhirMediaTypes.JSON).go(); assertThat(response, isOk()); @@ -563,7 +563,7 @@ public void shouldReturnSortedAndFilteredSearchResultsForPatientsAsXML() throws @Test public void shouldAllowNamedQueryForPatientsAsXml() throws Exception { - MockHttpServletResponse response = get("/Patient?_query=openmrsPatients&q=Doe&_sort=given") + MockHttpServletResponse response = get("/Patient?_query=openmrsPatients&q=Doe&_sort=given&deceased=false") .accept(FhirMediaTypes.XML).go(); assertThat(response, isOk()); diff --git a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PatientFhirResourceProviderIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PatientFhirResourceProviderIntegrationTest.java index 9b0cbaf5e..05821c95a 100644 --- a/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PatientFhirResourceProviderIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/module/fhir2/providers/r4/PatientFhirResourceProviderIntegrationTest.java @@ -561,7 +561,7 @@ public void shouldReturnSortedAndFilteredSearchResultsForPatientsAsJson() throws @Test public void shouldAllowNamedQueryForPatientsAsJson() throws Exception { - MockHttpServletResponse response = get("/Patient?_query=openmrsPatients&q=Doe&_sort=given") + MockHttpServletResponse response = get("/Patient?_query=openmrsPatients&q=Doe&_sort=given&deceased=false") .accept(FhirMediaTypes.JSON).go(); assertThat(response, isOk()); @@ -647,7 +647,7 @@ public void shouldReturnSortedAndFilteredSearchResultsForPatientsAsXML() throws @Test public void shouldAllowNamedQueryForPatientsAsXml() throws Exception { - MockHttpServletResponse response = get("/Patient?_query=openmrsPatients&q=Doe&_sort=given") + MockHttpServletResponse response = get("/Patient?_query=openmrsPatients&q=Doe&_sort=given&deceased=false") .accept(FhirMediaTypes.XML).go(); assertThat(response, isOk());