Fix OPD prescription autosave 500 on non-string payload values
This commit is contained in:
parent
5de65a73f1
commit
6767fce287
|
|
@ -354,6 +354,7 @@ class Opd_prescription extends BaseController
|
||||||
|
|
||||||
public function opd_prescription_save()
|
public function opd_prescription_save()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
if (!$this->request->isAJAX()) {
|
if (!$this->request->isAJAX()) {
|
||||||
return $this->response->setStatusCode(400)->setJSON([
|
return $this->response->setStatusCode(400)->setJSON([
|
||||||
'update' => 0,
|
'update' => 0,
|
||||||
|
|
@ -628,7 +629,11 @@ class Opd_prescription extends BaseController
|
||||||
$abdmValidationErrors = $this->validateAbdmReadinessForConsult($payload, $patientRow, (array) $opdRow);
|
$abdmValidationErrors = $this->validateAbdmReadinessForConsult($payload, $patientRow, (array) $opdRow);
|
||||||
|
|
||||||
foreach ($payload as $value) {
|
foreach ($payload as $value) {
|
||||||
if (mb_strlen($value) > 4000) {
|
if (is_array($value) || is_object($value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mb_strlen((string) $value) > 4000) {
|
||||||
return $this->response->setJSON([
|
return $this->response->setJSON([
|
||||||
'update' => 0,
|
'update' => 0,
|
||||||
'error_text' => 'Each section allows up to 4000 characters.',
|
'error_text' => 'Each section allows up to 4000 characters.',
|
||||||
|
|
@ -732,6 +737,16 @@ class Opd_prescription extends BaseController
|
||||||
'csrfName' => csrf_token(),
|
'csrfName' => csrf_token(),
|
||||||
'csrfHash' => csrf_hash(),
|
'csrfHash' => csrf_hash(),
|
||||||
]);
|
]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
log_message('error', 'opd_prescription_save failed: {message}', ['message' => $e->getMessage()]);
|
||||||
|
|
||||||
|
return $this->response->setStatusCode(500)->setJSON([
|
||||||
|
'update' => 0,
|
||||||
|
'error_text' => 'Unable to save prescription right now. Please retry.',
|
||||||
|
'csrfName' => csrf_token(),
|
||||||
|
'csrfHash' => csrf_hash(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clinical_autotype()
|
public function clinical_autotype()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user