fix contactdetail
This commit is contained in:
parent
5f317a7e38
commit
783018f2f2
@ -38,11 +38,11 @@ class Contact extends Controller {
|
||||
}
|
||||
|
||||
public function show($ContactID = null) {
|
||||
$rows=$this->db->table('contact')
|
||||
$rows=$this->db->table('contact c')
|
||||
->select("*")
|
||||
->join("contactdetail", "contact.ContactID=contactdetail.ContactID", "left")
|
||||
->join("occupation","occupation.OccupationID=contactdetail.OccupationID", "left")
|
||||
->where('contact.ContactID', (int) $ContactID)
|
||||
->join("contactdetail cd", "c.ContactID=cd.ContactID", "left")
|
||||
->join("occupation o","o.OccupationID=cd.OccupationID", "left")
|
||||
->where('c.ContactID', (int) $ContactID)
|
||||
->get()->getResultArray();
|
||||
|
||||
if (empty($rows)) {
|
||||
@ -53,10 +53,43 @@ class Contact extends Controller {
|
||||
], 200);
|
||||
}
|
||||
|
||||
// Rebuild into nested structure
|
||||
$contact = [
|
||||
'ContactID' => $rows[0]['ContactID'],
|
||||
'NameFirst' => $rows[0]['NameFirst'] ?? null,
|
||||
'NameLast' => $rows[0]['NameLast'] ?? null,
|
||||
'Title' => $rows[0]['Title'] ?? null,
|
||||
'Initial' => $rows[0]['Initial'] ?? null,
|
||||
'Birthdate' => $rows[0]['Birthdate'] ?? null,
|
||||
'EmailAddress1' => $rows[0]['EmailAddress1'] ?? null,
|
||||
'EmailAddress2' => $rows[0]['EmailAddress2'] ?? null,
|
||||
'Phone' => $rows[0]['Phone'] ?? null,
|
||||
'MobilePhone1' => $rows[0]['MobilePhone1'] ?? null,
|
||||
'MobilePhone2' => $rows[0]['MobilePhone2'] ?? null,
|
||||
'Specialty' => $rows[0]['Specialty'] ?? null,
|
||||
'SubSpecialty' => $rows[0]['SubSpecialty'] ?? null,
|
||||
'Details' => []
|
||||
];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if (!empty($row['ContactDetID'])) {
|
||||
$contact['Details'][] = [
|
||||
'ContactDetID' => $row['ContactDetID'],
|
||||
'ContactCode' => $row['ContactCode'] ?? null,
|
||||
'ContactEmail' => $row['DetailPhone'] ?? null,
|
||||
'OccupationID' => $row['OccupationID'] ?? null,
|
||||
'JobTitle' => $row['JobTitle'] ?? null,
|
||||
'Department' => $row['Department'] ?? null,
|
||||
'ContactStartDate' => $row['ContactStartDate'] ?? null,
|
||||
'ContactEndDate' => $row['ContactEndDate'] ?? null
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'message'=> "Data fetched successfully",
|
||||
'data' => $rows,
|
||||
'data' => $contact,
|
||||
], 200);
|
||||
}
|
||||
|
||||
|
||||
@ -8,27 +8,29 @@ class DummySeeder extends Seeder {
|
||||
public function run() {
|
||||
// location
|
||||
$data = [
|
||||
['LocationID'=>1, 'LocCode'=>'QLOC', 'LocFull'=>'Dummy Location', 'LocType'=>'ROOM', 'Description'=>'Location made for dummy testing' ]
|
||||
['LocationID'=>1, 'LocCode'=>'QLOC', 'LocFull'=>'Dummy Location', 'LocType'=>'ROOM', 'Description'=>'Location made for dummy testing' ],
|
||||
['LocationID'=>2, 'LocCode'=>'DEFLOC', 'LocFull'=>'Default Location', 'LocType'=>'ROOM', 'Description'=>'Default location' ]
|
||||
];
|
||||
$this->db->table('location')->insertBatch($data);
|
||||
$data = [
|
||||
['LocationID'=>1, 'Street1'=>'Jalan Nginden', 'Street2'=>'Intan Raya', 'City'=>'Surabaya', 'Province'=>'East Java', 'PostCode'=>'60222']
|
||||
['LocationID'=>1, 'Street1'=>'Jalan Nginden', 'Street2'=>'Intan Raya', 'City'=>'Surabaya', 'Province'=>'East Java', 'PostCode'=>'60222'],
|
||||
['LocationID'=>2, 'Street1'=>'Jalan ', 'Street2'=>'Jalan jalan', 'City'=>'Depok', 'Province'=>'DKI Jakarta', 'PostCode'=>'10123']
|
||||
];
|
||||
$this->db->table('locationaddress')->insertBatch($data);
|
||||
|
||||
// contact
|
||||
$data = [
|
||||
['ContactID'=>1, 'NameFirst'=>'Default', 'NameLast'=>'Doctor', 'Title'=>'', 'Initial'=>'DEFDOC', 'Birthdate'=>'', 'EmailAddress1'=>'', 'EmailAddress2'=>'',
|
||||
'Phone'=>'', 'MobilePhone1'=>'', 'MobilePhone2'=>'', 'Specialty'=>'', 'SubSpecialty'=>'' ]
|
||||
['ContactID'=>1, 'NameFirst'=>'Default', 'NameLast'=>'Doctor', 'Title'=>'', 'Initial'=>'DEFDOC', 'Birthdate'=>'', 'EmailAddress1'=>'', 'EmailAddress2'=>'', 'Phone'=>'', 'MobilePhone1'=>'', 'MobilePhone2'=>'', 'Specialty'=>'', 'SubSpecialty'=>'' ],
|
||||
['ContactID'=>2, 'NameFirst'=>'Dummy', 'NameLast'=>'Doctor', 'Title'=>'', 'Initial'=>'QDOC' ]
|
||||
];
|
||||
$this->db->table('contact')->insertBatch($data);
|
||||
$data = [
|
||||
['ContactID'=>1, 'ContactCode'=>'QDOC', 'ContactEmail'=>'qdoc@email.com', 'OccupationID'=>'',
|
||||
'JobTitle'=>'', 'Department'=>'', 'ContactStartDate'=>'', 'ContactEndDate'=>'' ]
|
||||
['ContactID'=>1, 'ContactCode'=>'DEFDOC', 'ContactEmail'=>'defdoc@email.com', 'OccupationID'=>'', 'JobTitle'=>'', 'Department'=>'Jantung Sehat', 'ContactStartDate'=>'2020-01-05', 'ContactEndDate'=>'2023-01-05' ],
|
||||
['ContactID'=>1, 'ContactCode'=>'QDOC', 'ContactEmail'=>'qdoc@email.com', 'OccupationID'=>'', 'JobTitle'=>'', 'Department'=>'Hati Sehat', 'ContactStartDate'=>'2023-01-05', 'ContactEndDate'=>'' ]
|
||||
];
|
||||
$this->db->table('contactdetail')->insertBatch($data);
|
||||
|
||||
// patient
|
||||
// patient
|
||||
$data = [
|
||||
[ 'InternalPID'=>1, 'PatientID'=>'SMAJ1', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient M', 'Gender'=>'1', 'BirthDate'=>'1991-09-09', 'Street_1'=>'Makati', 'IntCountryID'=>'105', 'EmailAddress1'=>'smaj1@5panda.id',
|
||||
'RaceID'=>'1', 'ReligionID'=>'1', 'EthnicID'=>'1', 'DeathIndicator' => '0'],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user