Skip to content

Commit

Permalink
Fix patient search API (#2224)
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak authored Jun 3, 2024
1 parent a9f8d3d commit 2472d0e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
25 changes: 25 additions & 0 deletions care/facility/tests/test_patient_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,28 @@ def test_transfer_disallowed_by_facility(self):
response.data["Patient"],
"Patient transfer cannot be completed because the source facility does not permit it",
)


class PatientSearchTestCase(TestUtils, APITestCase):
@classmethod
def setUpTestData(cls):
cls.state = cls.create_state()
cls.district = cls.create_district(cls.state)
cls.local_body = cls.create_local_body(cls.district)
cls.super_user = cls.create_super_user("su", cls.district)
cls.facility = cls.create_facility(cls.super_user, cls.district, cls.local_body)
cls.destination_facility = cls.create_facility(
cls.super_user, cls.district, cls.local_body, name="Facility 2"
)
cls.location = cls.create_asset_location(cls.facility)
cls.user = cls.create_user(
"doctor1", cls.district, home_facility=cls.facility, user_type=15
)
cls.patient = cls.create_patient(cls.district, cls.facility)

def test_patient_search(self):
response = self.client.get(
"/api/v1/patient/search/", {"phone_number": self.patient.phone_number}
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data["count"], 1)
3 changes: 1 addition & 2 deletions config/api_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
router.register("assetbed", AssetBedViewSet, basename="asset-bed")
router.register("consultationbed", ConsultationBedViewSet, basename="consultation-bed")

router.register("patient/search", PatientSearchViewSet, basename="patient-search")
router.register("patient", PatientViewSet, basename="patient")
patient_nested_router = NestedSimpleRouter(router, r"patient", lookup="patient")
patient_nested_router.register(
Expand All @@ -251,8 +252,6 @@
)
patient_nested_router.register(r"abha", AbhaViewSet)

router.register("patient/search", PatientSearchViewSet, basename="patient-search")

router.register(
"external_result", PatientExternalTestViewSet, basename="patient-external-result"
)
Expand Down

0 comments on commit 2472d0e

Please sign in to comment.