Fix IPD assigned doctor updates

Allow doctor assignments to be removed when the optional deletion archive table is unavailable, while retaining archival behavior where supported.
This commit is contained in:
DevSoftTech Server 2026-08-08 15:17:35 +05:30
parent 51f5a87f92
commit b264b8fd92

View File

@ -94,20 +94,22 @@ class IpdModel extends Model
return 0; return 0;
} }
$user = $this->getUserIdentity(); if ($this->db->tableExists('ipd_master_doc_list_delete')) {
$row['update_by_id'] = $user['id']; $user = $this->getUserIdentity();
$row['update_by'] = $user['name'] . '[' . date('Y-m-d H:i:s') . ']'; $row['update_by_id'] = $user['id'];
$row['update_by'] = $user['name'] . '[' . date('Y-m-d H:i:s') . ']';
$archiveData = $this->filterTableDataByExistingColumns('ipd_master_doc_list_delete', $row);
$inserted = $this->db->table('ipd_master_doc_list_delete')->insert($row); if (empty($archiveData) || ! $this->db->table('ipd_master_doc_list_delete')->insert($archiveData)) {
if (! $inserted) { return 0;
return 0; }
} }
$this->db->table('ipd_master_doc_list') $deleted = $this->db->table('ipd_master_doc_list')
->where('id', $ipdDocId) ->where('id', $ipdDocId)
->delete(); ->delete();
return 1; return $deleted ? 1 : 0;
} }
public function replaceIpdDoctors(int $ipdId, array $doctorIds): void public function replaceIpdDoctors(int $ipdId, array $doctorIds): void