Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix patient search API #2224

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading