更新
This commit is contained in:
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
use app\adminapi\logic\doctor\AppointmentLogic;
|
||||
use app\adminapi\lists\firstvisit\MyPatientLists;
|
||||
use app\adminapi\lists\firstvisit\MyPatientProgressLists;
|
||||
use app\adminapi\lists\tcm\DiagnosisLists;
|
||||
use app\adminapi\validate\doctor\AppointmentValidate;
|
||||
use app\common\enum\AppointmentTypeEnum;
|
||||
@@ -41,7 +43,7 @@ foreach (['video' => '视频问诊', 'text' => '图文问诊'] as $type => $labe
|
||||
appointmentTypeExpect(AppointmentTypeEnum::withDefault(['appointment_type' => $type])['appointment_type'] === $type, 'default does not override an explicit choice');
|
||||
}
|
||||
|
||||
$invalidValues = ['', ' ', 'phone', 'Text', ' video ', 'unknown', 0, 1, true, false, null, [], ['text']];
|
||||
$invalidValues = ['', ' ', 'phone', 'offline', 'Text', ' video ', 'unknown', 0, 1, true, false, null, [], ['text']];
|
||||
foreach ($invalidValues as $value) {
|
||||
foreach (['create', 'adminEdit'] as $scene) {
|
||||
appointmentTypeExpect(!(new AppointmentValidate())->scene($scene)->check($payload + ['appointment_type' => $value]), "$scene rejects " . json_encode($value));
|
||||
@@ -80,4 +82,54 @@ appointmentTypeExpect($row['latest_appointment_id'] === 8 && $row['latest_appoin
|
||||
$summary->invokeArgs($lists, [&$row, ['id' => 9, 'appointment_type' => null]]);
|
||||
appointmentTypeExpect($row['latest_appointment_type'] === 'video', 'next legacy appointment does not inherit previous text type');
|
||||
|
||||
echo "Appointment type validation, defaults, legacy labels and summary: OK\n";
|
||||
$myPatientReflection = new ReflectionClass(MyPatientLists::class);
|
||||
$myPatientLists = $myPatientReflection->newInstanceWithoutConstructor();
|
||||
$pickPrimary = $myPatientReflection->getMethod('pickPrimaryAppointment');
|
||||
$primarySummary = $myPatientReflection->getMethod('appendPrimaryAppointmentSummary');
|
||||
$appointments = [
|
||||
['id' => 101, 'doctor_id' => 201, 'appointment_date' => '2026-09-09', 'appointment_time' => '08:30:00', 'status' => 3, 'appointment_type' => 'video'],
|
||||
['id' => 102, 'doctor_id' => 202, 'appointment_date' => '2026-09-10', 'appointment_time' => '09:30:00', 'status' => 1, 'appointment_type' => 'text'],
|
||||
['id' => 103, 'doctor_id' => 203, 'appointment_date' => '2026-09-11', 'appointment_time' => '10:30:00', 'status' => 1, 'appointment_type' => 'video'],
|
||||
];
|
||||
$adminNames = [201 => '医生甲', 202 => '医生乙', 203 => '医生丙'];
|
||||
$row = [];
|
||||
$primary = $pickPrimary->invoke($myPatientLists, $appointments, '', '', '2026-09-10');
|
||||
$primarySummary->invokeArgs($myPatientLists, [&$row, $primary, $adminNames]);
|
||||
appointmentTypeExpect(
|
||||
$row['appointment_id'] === 102 && $row['appointment_doctor_id'] === 202
|
||||
&& $row['appointment_time_text'] === '2026-09-10 09:30'
|
||||
&& $row['appointment_type'] === 'text' && $row['appointment_type_desc'] === '图文问诊',
|
||||
'my patient row uses the upcoming primary appointment type instead of the latest appointment type'
|
||||
);
|
||||
|
||||
$primary = $pickPrimary->invoke($myPatientLists, $appointments, '2026-09-11', '2026-09-11', '2026-09-10');
|
||||
$primarySummary->invokeArgs($myPatientLists, [&$row, $primary, $adminNames]);
|
||||
appointmentTypeExpect($row['appointment_id'] === 103 && $row['appointment_type'] === 'video', 'date filter updates both the primary appointment and its type');
|
||||
$primary = $pickPrimary->invoke($myPatientLists, $appointments, '', '', '2026-09-10', [3]);
|
||||
$primarySummary->invokeArgs($myPatientLists, [&$row, $primary, $adminNames]);
|
||||
appointmentTypeExpect($row['appointment_id'] === 101 && $row['appointment_type'] === 'video', 'status filter updates both the primary appointment and its type');
|
||||
|
||||
foreach ([null, '', ' ', 'phone', 'unknown'] as $storedType) {
|
||||
$primary = $appointments[1];
|
||||
$primary['appointment_type'] = $storedType;
|
||||
$primarySummary->invokeArgs($myPatientLists, [&$row, $primary, $adminNames]);
|
||||
appointmentTypeExpect($row['appointment_type'] === AppointmentTypeEnum::normalizeStored($storedType), 'my patient row normalizes only legacy empty types');
|
||||
appointmentTypeExpect($row['appointment_type_desc'] === AppointmentTypeEnum::description($storedType), 'my patient row preserves historical and unknown labels');
|
||||
}
|
||||
|
||||
$primary = $pickPrimary->invoke($myPatientLists, [], '', '', '2026-09-10');
|
||||
$primarySummary->invokeArgs($myPatientLists, [&$row, $primary, $adminNames]);
|
||||
appointmentTypeExpect(
|
||||
$row['has_appointment'] === 0 && $row['appointment_id'] === 0
|
||||
&& $row['appointment_type'] === null && $row['appointment_type_desc'] === '',
|
||||
'a patient without an appointment does not inherit a previous type or gain a default video appointment'
|
||||
);
|
||||
|
||||
$progressReflection = new ReflectionClass(MyPatientProgressLists::class);
|
||||
$progressLists = $progressReflection->newInstanceWithoutConstructor();
|
||||
$progressTypeText = $progressReflection->getMethod('appointmentTypeText');
|
||||
foreach (['video' => '视频问诊', 'text' => '图文问诊', 'phone' => '电话问诊', '' => '视频问诊', ' ' => '视频问诊', 'unknown' => '未知'] as $type => $label) {
|
||||
appointmentTypeExpect($progressTypeText->invoke($progressLists, $type) === $label, 'progress labels agree with stored appointment types');
|
||||
}
|
||||
|
||||
echo "Appointment type validation, defaults, legacy labels and primary summaries: OK\n";
|
||||
|
||||
Reference in New Issue
Block a user