refactor: Remove redundant ValueSet call and convert global function to private method
- TestsController: Remove duplicate rangeTypeOptions assignment that was being set inside the NUM condition block, causing it to be set unnecessarily when it's also handled elsewhere - ResponseTrait: Convert global helper function convert_empty_strings_to_null() to private class method convertEmptyStringsToNull() for better encapsulation and to avoid dependency on global functions - Database schema: Update clqms_database.dbml with accurate table structure derived from app/Models/ directory, reorganizing tables by functional categories (Patient, Visit, Organization, Location, Test, Specimen, Order, Contact management)
This commit is contained in:
parent
425595f5c0
commit
30c0c538d6
@ -184,7 +184,6 @@ class TestsController extends BaseController
|
||||
];
|
||||
}, $refnumData ?? []);
|
||||
|
||||
$row['rangeTypeOptions'] = ValueSet::getOptions('range_type');
|
||||
}
|
||||
|
||||
if ($refType === '2' || $refType === 'TEXT' || $refType === '4' || $refType === 'VSET') {
|
||||
|
||||
@ -23,9 +23,41 @@ trait ResponseTrait
|
||||
{
|
||||
// Convert empty strings to null in the data
|
||||
if ($data !== null && (is_array($data) || is_object($data))) {
|
||||
$data = convert_empty_strings_to_null($data);
|
||||
$data = $this->convertEmptyStringsToNull($data);
|
||||
}
|
||||
|
||||
return $this->baseRespond($data, $status, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively convert empty strings to null in arrays or objects
|
||||
*
|
||||
* @param mixed $data The data to process (array, object, or scalar)
|
||||
* @return mixed The processed data with empty strings converted to null
|
||||
*/
|
||||
private function convertEmptyStringsToNull($data)
|
||||
{
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$data[$key] = $this->convertEmptyStringsToNull($value);
|
||||
} elseif (is_object($value)) {
|
||||
$data[$key] = $this->convertEmptyStringsToNull($value);
|
||||
} elseif ($value === '') {
|
||||
$data[$key] = null;
|
||||
}
|
||||
}
|
||||
} elseif (is_object($data)) {
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$data->$key = $this->convertEmptyStringsToNull($value);
|
||||
} elseif (is_object($value)) {
|
||||
$data->$key = $this->convertEmptyStringsToNull($value);
|
||||
} elseif ($value === '') {
|
||||
$data->$key = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user