fix pvadt
This commit is contained in:
parent
d5c8cac5ec
commit
d4c92af9e4
@ -104,22 +104,18 @@ class PatVisitModel extends BaseModel {
|
||||
throw new \Exception("Failed to update PatDiag record. ". $error['message']);
|
||||
}
|
||||
|
||||
// patvisitadt
|
||||
$exist = $modelPVA->where('InternalPVID',$InternalPVID)->find();
|
||||
if($exist) {
|
||||
if(!empty($input['PatVisitADT'])) {
|
||||
$tmp = $modelPVA->where('InternalPVID',$InternalPVID)->set($input['PatVisitADT'])->update();
|
||||
} else { $tmp = $modelPVA->where('InternalPVID',$InternalPVID)->delete(); }
|
||||
} else {
|
||||
if(!empty($input['PatVisitADT'])) {
|
||||
$input['PatVisitADT']['InternalPVID'] = $InternalPVID;
|
||||
$tmp = $modelPVA->insert($input['PatVisitADT']);
|
||||
if(!empty($input['PatVisitADT'])) {
|
||||
$adtList = $input['PatVisitADT'];
|
||||
usort($adtList, fn($a, $b) => $a['sequence'] <=> $b['sequence']);
|
||||
foreach ($adtList as $adt) {
|
||||
$adt['InternalPVID'] = $InternalPVID;
|
||||
$tmp = $modelPVA->insert($adt);
|
||||
if ($tmp === false) {
|
||||
$error = $db->error();
|
||||
throw new \Exception("Failed to update PatVisitADT record. ". $error['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($tmp === false) {
|
||||
$error = $db->error();
|
||||
throw new \Exception("Failed to update PatVisitADT record. ". $error['message']);
|
||||
}
|
||||
|
||||
if ($db->transStatus() === FALSE) {
|
||||
$db->transRollback();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user