From 87d609315c2223da475ae7a1c81839809cf54bb6 Mon Sep 17 00:00:00 2001 From: Yash Raj Bothra <47683556+yashrajbothra@users.noreply.github.com> Date: Sun, 28 Jun 2020 01:54:13 +0530 Subject: [PATCH] Adding/Upgrading Organization Resource (#3662) * Changing Function Names Signed-off-by: Yash Bothra * Added UUID to Facility Signed-off-by: Yash Bothra * Upgraded Standard Facility Endpoints Signed-off-by: Yash Bothra * Upgraded FHIR Organization Endpoints with Tests Signed-off-by: Yash Bothra * Some More Upgrades Signed-off-by: Yash Bothra * Some Fixes Signed-off-by: Yash Bothra * Added CLIA and Fax in FHIR Signed-off-by: Yash Bothra * Fixture fix Signed-off-by: Yash Bothra --- _rest_routes.inc.php | 25 +- .../batchcom/batch_phone_notification.php | 2 +- interface/login/login.php | 2 +- interface/orders/pending_followup.php | 2 +- interface/reports/appt_encounter_report.php | 2 +- interface/reports/daily_summary_report.php | 2 +- interface/reports/ippf_daily.php | 2 +- interface/reports/ippf_statistics.php | 2 +- interface/usergroup/facilities.php | 6 +- library/options.inc.php | 2 +- library/patient.inc | 2 +- .../batch_phone_notification.php | 2 +- sql/5_0_2-to-6_0_0_upgrade.sql | 11 + sql/database.sql | 4 +- .../FHIR/FhirOrganizationRestController.php | 127 ++++--- .../FacilityRestController.php | 85 +++-- src/Services/FHIR/FhirOrganizationService.php | 342 +++++++++++++----- src/Services/FHIR/FhirPractitionerService.php | 9 + src/Services/FacilityService.php | 190 +++++++++- src/Validators/FacilityValidator.php | 81 +++++ src/Validators/PractitionerValidator.php | 4 +- tests/Tests/Api/FacilityApiTest.php | 178 +++++++++ tests/Tests/Fixtures/BaseFixtureManager.php | 66 ++++ tests/Tests/Fixtures/FHIR/facility.json | 89 +++++ .../Tests/Fixtures/FacilityFixtureManager.php | 146 ++++++++ tests/Tests/Fixtures/facility.json | 103 ++++++ .../FhirOrganizationRestControllerTest.php | 129 +++++++ .../FacilityRestControllerTest.php | 187 ++++++++++ .../FHIR/FhirOrganizationServiceCrudTest.php | 107 ++++++ tests/Tests/Services/FacilityServiceTest.php | 162 +++++++++ version.php | 2 +- 31 files changed, 1886 insertions(+), 187 deletions(-) create mode 100644 src/Validators/FacilityValidator.php create mode 100644 tests/Tests/Api/FacilityApiTest.php create mode 100644 tests/Tests/Fixtures/BaseFixtureManager.php create mode 100644 tests/Tests/Fixtures/FHIR/facility.json create mode 100644 tests/Tests/Fixtures/FacilityFixtureManager.php create mode 100644 tests/Tests/Fixtures/facility.json create mode 100644 tests/Tests/RestControllers/FHIR/FhirOrganizationRestControllerTest.php create mode 100644 tests/Tests/RestControllers/FacilityRestControllerTest.php create mode 100644 tests/Tests/Services/FHIR/FhirOrganizationServiceCrudTest.php create mode 100644 tests/Tests/Services/FacilityServiceTest.php diff --git a/_rest_routes.inc.php b/_rest_routes.inc.php index 6683d1b2735..b335e9538c5 100644 --- a/_rest_routes.inc.php +++ b/_rest_routes.inc.php @@ -43,22 +43,21 @@ }, "GET /api/facility" => function () { RestConfig::authorization_check("admin", "users"); - return (new FacilityRestController())->getAll(); + return (new FacilityRestController())->getAll($_GET); }, - "GET /api/facility/:fid" => function ($fid) { + "GET /api/facility/:fuuid" => function ($fuuid) { RestConfig::authorization_check("admin", "users"); - return (new FacilityRestController())->getOne($fid); + return (new FacilityRestController())->getOne($fuuid); }, "POST /api/facility" => function () { RestConfig::authorization_check("admin", "super"); $data = (array) (json_decode(file_get_contents("php://input"))); return (new FacilityRestController())->post($data); }, - "PUT /api/facility/:fid" => function ($fid) { + "PATCH /api/facility/:fuuid" => function ($fuuid) { RestConfig::authorization_check("admin", "super"); $data = (array) (json_decode(file_get_contents("php://input"))); - $data["fid"] = $fid; - return (new FacilityRestController())->put($data); + return (new FacilityRestController())->patch($fuuid, $data); }, "GET /api/patient" => function () { RestConfig::authorization_check("patients", "demo"); @@ -417,10 +416,20 @@ return (new FhirPractitionerRestController())->patch($id, $data); }, "GET /fhir/Organization" => function () { - return (new FhirOrganizationRestController(null))->getAll($_GET); + return (new FhirOrganizationRestController())->getAll($_GET); }, "GET /fhir/Organization/:id" => function ($id) { - return (new FhirOrganizationRestController(null))->getOne($id); + return (new FhirOrganizationRestController())->getOne($id); + }, + "POST /fhir/Organization" => function () { + RestConfig::authorization_check("admin", "super"); + $data = (array) (json_decode(file_get_contents("php://input"), true)); + return (new FhirOrganizationRestController())->post($data); + }, + "PATCH /fhir/Organization/:id" => function ($id) { + RestConfig::authorization_check("admin", "super"); + $data = (array) (json_decode(file_get_contents("php://input"), true)); + return (new FhirOrganizationRestController())->patch($id, $data); }, "GET /fhir/AllergyIntolerance" => function () { RestConfig::authorization_check("patients", "med"); diff --git a/interface/batchcom/batch_phone_notification.php b/interface/batchcom/batch_phone_notification.php index 83c9c5accf0..5d918af4e76 100644 --- a/interface/batchcom/batch_phone_notification.php +++ b/interface/batchcom/batch_phone_notification.php @@ -222,7 +222,7 @@ function cron_getFacilitiesMap() $facility_phone_map = array(); //get facilities from the database - $facilities = $facilityService->getAll(); + $facilities = $facilityService->getAllFacility(); foreach ($facilities as $prow) { $facility_msg_map[$prow['id']] = $message_map[$prow['name']]; $facility_phone_map[$prow['id']] = $prow['phone']; diff --git a/interface/login/login.php b/interface/login/login.php index 3f365f57df3..b410a7f6cf3 100644 --- a/interface/login/login.php +++ b/interface/login/login.php @@ -208,7 +208,7 @@ function transmit_form(element) { if ($GLOBALS['login_into_facility']) { $facilityService = new FacilityService(); - $facilities = $facilityService->getAll(); + $facilities = $facilityService->getAllFacility(); $facilitySelected = ($GLOBALS['set_facility_cookie'] && isset($_COOKIE['pc_facility'])) ? $_COOKIE['pc_facility'] : null; } ?> diff --git a/interface/orders/pending_followup.php b/interface/orders/pending_followup.php index 343d0b1477b..15f779f0efe 100644 --- a/interface/orders/pending_followup.php +++ b/interface/orders/pending_followup.php @@ -131,7 +131,7 @@ function thisLineItem($row, $codetype, $code) getAll(); + $fres = $facilityService->getAllFacility(); echo " \n"; echo "