From ee7b677ae4aa9824c658d17e59d882bc007d126e Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Mon, 13 Apr 2026 12:15:05 +0700 Subject: [PATCH] fix: align patient check email lookup --- app/Controllers/Patient/PatientController.php | 10 +++------- public/api-docs.bundled.yaml | 12 ------------ public/paths/patients.yaml | 12 ------------ tests/feature/Patients/PatientCheckTest.php | 4 ++-- 4 files changed, 5 insertions(+), 33 deletions(-) diff --git a/app/Controllers/Patient/PatientController.php b/app/Controllers/Patient/PatientController.php index e10f931..923ca33 100755 --- a/app/Controllers/Patient/PatientController.php +++ b/app/Controllers/Patient/PatientController.php @@ -256,8 +256,6 @@ class PatientController extends Controller { try { $PatientID = $this->request->getVar('PatientID'); $EmailAddress = $this->request->getVar('EmailAddress'); - $EmailAddress1 = $this->request->getVar('EmailAddress1'); - $EmailAddress2 = $this->request->getVar('EmailAddress2'); $Phone = $this->request->getVar('Phone'); if (!empty($PatientID)){ @@ -273,13 +271,11 @@ class PatientController extends Controller { ->where('PatientID', $PatientID) ->get() ->getRowArray(); - } elseif (!empty($EmailAddress) || !empty($EmailAddress1) || !empty($EmailAddress2)){ - $searchEmail = $EmailAddress ?: $EmailAddress1 ?: $EmailAddress2; - + } elseif (!empty($EmailAddress)) { $patient = $this->db->table('patient') ->groupStart() - ->where('EmailAddress1', $searchEmail) - ->orWhere('EmailAddress2', $searchEmail) + ->where('EmailAddress1', $EmailAddress) + ->orWhere('EmailAddress2', $EmailAddress) ->groupEnd() ->get() ->getRowArray(); diff --git a/public/api-docs.bundled.yaml b/public/api-docs.bundled.yaml index 8a827b5..cf36230 100755 --- a/public/api-docs.bundled.yaml +++ b/public/api-docs.bundled.yaml @@ -2937,18 +2937,6 @@ paths: type: string format: email description: Email address to check - - name: EmailAddress1 - in: query - schema: - type: string - format: email - description: Email address alias to check - - name: EmailAddress2 - in: query - schema: - type: string - format: email - description: Email address alias to check - name: Phone in: query schema: diff --git a/public/paths/patients.yaml b/public/paths/patients.yaml index 537ef2e..2084d73 100755 --- a/public/paths/patients.yaml +++ b/public/paths/patients.yaml @@ -109,18 +109,6 @@ type: string format: email description: Email address to check - - name: EmailAddress1 - in: query - schema: - type: string - format: email - description: Email address alias to check - - name: EmailAddress2 - in: query - schema: - type: string - format: email - description: Email address alias to check - name: Phone in: query schema: diff --git a/tests/feature/Patients/PatientCheckTest.php b/tests/feature/Patients/PatientCheckTest.php index 691b15c..0ef1194 100755 --- a/tests/feature/Patients/PatientCheckTest.php +++ b/tests/feature/Patients/PatientCheckTest.php @@ -66,10 +66,10 @@ class PatientCheckTest extends CIUnitTestCase $this->assertIsBool($data['data']); } - public function testCheckEmailAddressAliasExists() + public function testCheckEmailAddressMatchesSecondaryColumn() { $result = $this->withHeaders(['Accept' => 'application/json'])->call('get', $this->endpoint, [ - 'EmailAddress1' => 'dummy1@test.com', + 'EmailAddress' => 'dummy1@test.com', ]); $result->assertStatus(200);