fix(abdm): expand health_records local link query to match by patient reference and abha

This commit is contained in:
DevSoftTech Server 2026-10-08 13:12:46 +05:30
parent 3876a7444e
commit d826f3e072

View File

@ -13299,9 +13299,15 @@ class AbdmGateway extends BaseController
// Also merge local health_records with push_status IN ('linked', 'pushed')
if ($this->db->tableExists('health_records') && $patientId > 0) {
$hrRows = $this->db->table('health_records')
$hrQuery = $this->db->table('health_records')
->select('care_context_reference')
->where('patient_id', $patientId)
->groupStart()
->where('patient_id', $patientId)
->orWhere('care_context_reference LIKE', '%-' . $patientId . '-%');
if ($effAbhaAddress !== '') {
$hrQuery->orWhere('abha_id', $effAbhaAddress);
}
$hrRows = $hrQuery->groupEnd()
->whereIn('push_status', ['linked', 'pushed'])
->get()
->getResultArray();