feat(patient): handle array format for Custodian and LinkTo fields

- PatientModel: Convert Custodian from array to integer InternalPID when received as object
- PatientModel: Convert LinkTo from array of objects to comma-separated InternalPID string
- API docs: Add LinkedPatient, Custodian, and PatAttEntry schema definitions
- API docs: Extend Patient schema with DeathIndicator, TimeOfDeath, PatCom,
  PatAtt, Province, City, Country, Race, MaritalStatus, Religion, Ethnic fields
- Add AGENTS.md to .gitignore
This commit is contained in:
mahdahar 2026-01-29 11:21:34 +07:00
parent bf847b6835
commit fcdbc3f20a
3 changed files with 98 additions and 2 deletions

3
.gitignore vendored
View File

@ -127,4 +127,5 @@ _modules/*
/public/.htaccess /public/.htaccess
.serena/ .serena/
.claude/ .claude/
AGENTS.md

View File

@ -118,7 +118,17 @@ class PatientModel extends BaseModel {
$modelPatAtt = new PatAttModel(); $modelPatAtt = new PatAttModel();
$modelPatCom = new PatComModel(); $modelPatCom = new PatComModel();
$modelPatIdt = new PatIdtModel(); $modelPatIdt = new PatIdtModel();
if (!empty($input['Custodian'])) {
if (is_array($input['Custodian']) && isset($input['Custodian']['InternalPID'])) {
$input['Custodian'] = (int) $input['Custodian']['InternalPID'];
}
}
if (!empty($input['LinkTo']) && is_array($input['LinkTo'])) {
$internalPids = array_column($input['LinkTo'], 'InternalPID');
$input['LinkTo'] = implode(',', $internalPids);
}
$input['LinkTo'] = empty($input['LinkTo']) ? null : $input['LinkTo']; $input['LinkTo'] = empty($input['LinkTo']) ? null : $input['LinkTo'];
$db->transBegin(); $db->transBegin();
@ -160,6 +170,16 @@ class PatientModel extends BaseModel {
$modelPatCom = new PatComModel(); $modelPatCom = new PatComModel();
$modelPatAtt = new PatAttModel(); $modelPatAtt = new PatAttModel();
if (!empty($input['Custodian'])) {
if (is_array($input['Custodian']) && isset($input['Custodian']['InternalPID'])) {
$input['Custodian'] = (int) $input['Custodian']['InternalPID'];
}
}
if (!empty($input['LinkTo']) && is_array($input['LinkTo'])) {
$internalPids = array_column($input['LinkTo'], 'InternalPID');
$input['LinkTo'] = implode(',', $internalPids);
}
$input['LinkTo'] = empty($input['LinkTo']) ? null : $input['LinkTo']; $input['LinkTo'] = empty($input['LinkTo']) ? null : $input['LinkTo'];
$db->transBegin(); $db->transBegin();

View File

@ -143,6 +143,36 @@ components:
type: string type: string
maxLength: 255 maxLength: 255
LinkedPatient:
type: object
description: Linked patient reference
properties:
InternalPID:
type: integer
description: Internal patient ID of the linked patient
PatientID:
type: string
description: Patient ID of the linked patient
Custodian:
type: object
description: Patient custodian/guardian
properties:
InternalPID:
type: integer
description: Internal patient ID of the custodian
PatientID:
type: string
description: Patient ID of the custodian
PatAttEntry:
type: object
description: Patient address/attorney entry
properties:
Address:
type: string
description: Address text
Patient: Patient:
type: object type: object
required: required:
@ -227,6 +257,51 @@ components:
maxLength: 100 maxLength: 100
PatIdt: PatIdt:
$ref: '#/components/schemas/PatientIdentifier' $ref: '#/components/schemas/PatientIdentifier'
LinkTo:
type: array
description: Array of linked patient references
items:
$ref: '#/components/schemas/LinkedPatient'
Custodian:
$ref: '#/components/schemas/Custodian'
DeathIndicator:
type: string
enum: [Y, N]
description: 'Y: Yes (deceased), N: No (alive)'
TimeOfDeath:
type: string
format: date-time
description: ISO 8601 UTC datetime of death
PatCom:
type: string
description: Patient comment/notes
PatAtt:
type: array
description: Patient address entries
items:
$ref: '#/components/schemas/PatAttEntry'
Province:
type: string
description: Province area code
City:
type: string
description: City area code
Country:
type: string
maxLength: 100
Race:
type: string
maxLength: 100
MaritalStatus:
type: string
enum: [A, B, D, M, S, W]
description: 'A: Annulled, B: Separated, D: Divorced, M: Married, S: Single, W: Widowed'
Religion:
type: string
maxLength: 100
Ethnic:
type: string
maxLength: 100
PatientListResponse: PatientListResponse:
type: object type: object