feat(patvisit): enrich AttDoc fields in patient visit response
Add AttDocFirstName, AttDocLastName, and AttDocContactCode to showByPatient via joins to contact and site-scoped contactdetail. Keep existing AttDoc ID field unchanged for backward compatibility. Update PatientVisit OpenAPI schema, regenerate bundled docs, and extend PatVisitByPatientTest assertions for new fields.
This commit is contained in:
parent
4aad7d331a
commit
2053ab4596
@ -30,7 +30,7 @@ class PatVisitModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function showByPatient($InternalPID) {
|
public function showByPatient($InternalPID) {
|
||||||
$rows = $this->select("*, patvisit.InternalPID, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate")
|
$rows = $this->select("*, patvisit.InternalPID, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate, attDoc.NameFirst as AttDocFirstName, attDoc.NameLast as AttDocLastName, attDocDetail.ContactCode as AttDocContactCode")
|
||||||
->join('patdiag', 'patdiag.InternalPVID=patvisit.InternalPVID and patdiag.DelDate is null', 'left')
|
->join('patdiag', 'patdiag.InternalPVID=patvisit.InternalPVID and patdiag.DelDate is null', 'left')
|
||||||
->join('(SELECT a1.*
|
->join('(SELECT a1.*
|
||||||
FROM patvisitadt a1
|
FROM patvisitadt a1
|
||||||
@ -43,6 +43,8 @@ class PatVisitModel extends BaseModel {
|
|||||||
'patvisitadt.InternalPVID = patvisit.InternalPVID',
|
'patvisitadt.InternalPVID = patvisit.InternalPVID',
|
||||||
'left')
|
'left')
|
||||||
->join('location', 'location.LocationID=patvisitadt.LocationID', 'left')
|
->join('location', 'location.LocationID=patvisitadt.LocationID', 'left')
|
||||||
|
->join('contact attDoc', 'attDoc.ContactID = patvisitadt.AttDoc', 'left')
|
||||||
|
->join('contactdetail attDocDetail', 'attDocDetail.ContactID = attDoc.ContactID AND attDocDetail.SiteID = patvisit.SiteID', 'left')
|
||||||
->where('patvisit.InternalPID',$InternalPID)
|
->where('patvisit.InternalPID',$InternalPID)
|
||||||
->where('patvisit.EndDate IS NULL') // Exclude soft deleted
|
->where('patvisit.EndDate IS NULL') // Exclude soft deleted
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|||||||
@ -6734,6 +6734,18 @@ components:
|
|||||||
LastLocation:
|
LastLocation:
|
||||||
type: string
|
type: string
|
||||||
description: Full name of the last/current location from patvisitadt
|
description: Full name of the last/current location from patvisitadt
|
||||||
|
AttDocFirstName:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
|
description: Attending doctor first name (from contact)
|
||||||
|
AttDocLastName:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
|
description: Attending doctor last name (from contact)
|
||||||
|
AttDocContactCode:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
|
description: Attending doctor contact code for visit SiteID (from contactdetail)
|
||||||
CreateDate:
|
CreateDate:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
|||||||
@ -19,6 +19,18 @@ PatientVisit:
|
|||||||
LastLocation:
|
LastLocation:
|
||||||
type: string
|
type: string
|
||||||
description: Full name of the last/current location from patvisitadt
|
description: Full name of the last/current location from patvisitadt
|
||||||
|
AttDocFirstName:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
|
description: Attending doctor first name (from contact)
|
||||||
|
AttDocLastName:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
|
description: Attending doctor last name (from contact)
|
||||||
|
AttDocContactCode:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
|
description: Attending doctor contact code for visit SiteID (from contactdetail)
|
||||||
CreateDate:
|
CreateDate:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
|
|||||||
@ -37,6 +37,13 @@ class PatVisitByPatientTest extends CIUnitTestCase
|
|||||||
// Pastikan 'data' ada
|
// Pastikan 'data' ada
|
||||||
$this->assertArrayHasKey('data', $json);
|
$this->assertArrayHasKey('data', $json);
|
||||||
$this->assertIsArray($json['data']);
|
$this->assertIsArray($json['data']);
|
||||||
|
|
||||||
|
if (!empty($json['data'])) {
|
||||||
|
$this->assertArrayHasKey('AttDoc', $json['data'][0]);
|
||||||
|
$this->assertArrayHasKey('AttDocFirstName', $json['data'][0]);
|
||||||
|
$this->assertArrayHasKey('AttDocLastName', $json['data'][0]);
|
||||||
|
$this->assertArrayHasKey('AttDocContactCode', $json['data'][0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user