Update (insert, patch & get/show) Patient Pattat dan perbaikan Patcom. Dan VID

This commit is contained in:
mikael-zakaria 2025-10-02 13:56:23 +07:00
parent 7db10f5cc6
commit 103b5ae19a
2 changed files with 9 additions and 9 deletions

View File

@ -74,11 +74,11 @@ class CreatePatientRegTables extends Migration {
'AccountNumber' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'Country' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'Race' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'MaritalStatus' => ['type' => 'VARCHAR', 'constraint' => 1, 'null' => true],
'MaritalStatus' => ['type' => 'TINYINT', 'null' => true],
'Religion' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'Ethnic' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'Citizenship' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'DeathIndicator'=> ['type' => 'BIT', 'constraint' => 1, 'null' => true],
'DeathIndicator'=> ['type' => 'TINYINT', 'null' => true],
'DeathDateTime' => ['type' => 'DATETIME', 'null' => true],
'LinkTo' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',

View File

@ -46,6 +46,9 @@ class PatientModel extends Model {
race.VDesc as Race,
religion.VDesc as Religion,
ethnic.VDesc as Ethnic,
gender.VDesc as Gender,
deathindicator.VDesc as DeathIndicator,
maritalstatus.VDesc as MaritalStatus,
patcom.Comment as Comment,
patidt.IdentifierType,
patidt.Identifier,
@ -55,6 +58,9 @@ class PatientModel extends Model {
->join('valueset race', 'race.VID = p.Race', 'left')
->join('valueset religion', 'religion.VID = p.Religion', 'left')
->join('valueset ethnic', 'ethnic.VID = p.Ethnic', 'left')
->join('valueset gender', 'gender.VID = p.Gender', 'left')
->join('valueset deathindicator', 'deathindicator.VID = p.DeathIndicator', 'left')
->join('valueset maritalstatus', 'maritalstatus.VID = p.MaritalStatus', 'left')
->join('patcom', 'patcom.InternalPID = p.InternalPID', 'left')
->join('patidt', 'patidt.InternalPID = p.InternalPID', 'left')
->join('patatt', 'patatt.InternalPID = p.InternalPID and patatt.DelDate is null', 'left')
@ -70,7 +76,6 @@ class PatientModel extends Model {
// Default nested structures
$patient['PatIdt'] = null;
$patient['PatCom'] = null;
$patient['PatAtt'] = [];
foreach ($rows as $row) {
@ -81,10 +86,6 @@ class PatientModel extends Model {
];
}
if ($row['Comment']) {
$patient['PatCom'] = $row['Comment'];
}
if ($row['Address']) {
$patient['PatAtt'][] = ['Address' => $row['Address']];
}
@ -142,7 +143,7 @@ class PatientModel extends Model {
$db = \Config\Database::connect();
$patidt = $input['PatIdt'] ?? [];
$patatt = $input['PatAtt'] ?? [];
$patcom['Comment'] = $input['PatCom'] ?? [];
$patcom['Comment'] = $input['Comment'] ?? [];
try {
$db->transStart();
@ -259,7 +260,6 @@ class PatientModel extends Model {
return $patient;
}
private function getLinkedPatients(?string $linkTo): ?array {
if (empty($linkTo)) { return null; }