fix(ipd): define dischargeRaw and match care context reference on discharge health_records save
This commit is contained in:
parent
8fb03b3c8f
commit
d2dd84b27f
|
|
@ -9394,8 +9394,9 @@ class Ipd_discharge extends BaseController
|
||||||
$dischargeCombined .= ' ' . $dischargeTimeRaw;
|
$dischargeCombined .= ' ' . $dischargeTimeRaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dischargeRaw = $dischargeCombined !== '' ? $dischargeCombined : $dischargeDateRaw;
|
||||||
$admissionIso = $this->toIsoDateTimeOrNow($admissionCombined !== '' ? $admissionCombined : $admissionDateRaw);
|
$admissionIso = $this->toIsoDateTimeOrNow($admissionCombined !== '' ? $admissionCombined : $admissionDateRaw);
|
||||||
$dischargeIso = $this->toIsoDateTimeOrNow($dischargeCombined !== '' ? $dischargeCombined : $dischargeDateRaw);
|
$dischargeIso = $this->toIsoDateTimeOrNow($dischargeRaw);
|
||||||
$visitDate = $dischargeDateRaw !== ''
|
$visitDate = $dischargeDateRaw !== ''
|
||||||
? date('Y-m-d', strtotime($dischargeDateRaw))
|
? date('Y-m-d', strtotime($dischargeDateRaw))
|
||||||
: ($admissionDateRaw !== '' ? date('Y-m-d', strtotime($admissionDateRaw)) : date('Y-m-d'));
|
: ($admissionDateRaw !== '' ? date('Y-m-d', strtotime($admissionDateRaw)) : date('Y-m-d'));
|
||||||
|
|
@ -9816,8 +9817,13 @@ class Ipd_discharge extends BaseController
|
||||||
|
|
||||||
if ($this->db && $this->db->tableExists('health_records')) {
|
if ($this->db && $this->db->tableExists('health_records')) {
|
||||||
$existingHr = $this->db->table('health_records')
|
$existingHr = $this->db->table('health_records')
|
||||||
->where('entity_type', 'ipd')
|
->groupStart()
|
||||||
->where('entity_id', (string) $ipdId)
|
->groupStart()
|
||||||
|
->where('entity_type', 'ipd')
|
||||||
|
->where('entity_id', (string) $ipdId)
|
||||||
|
->groupEnd()
|
||||||
|
->orWhere('care_context_reference LIKE', 'DISCHARGE-' . $ipdId . '%')
|
||||||
|
->groupEnd()
|
||||||
->whereIn('hi_type', ['DischargeSummaryRecord', 'DischargeSummary'])
|
->whereIn('hi_type', ['DischargeSummaryRecord', 'DischargeSummary'])
|
||||||
->orderBy('id', 'DESC')
|
->orderBy('id', 'DESC')
|
||||||
->get(1)
|
->get(1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user