桌面端编辑处方可修改手机号、身份证号
- 桌面端开方/编辑处方表单新增「手机号」「身份证号」,已开处方编辑时可修改(姓名仍只读);身份证号本地先校验格式 - 服务端 add/edit 接收 phone(写入处方笺)与 id_card(写回关联诊单,校验格式与重复,按出生日期更新年龄,与处方保存同一事务); 编辑时须可管理该诊单;处方详情仅对可管理诊单的账号返回 patient_id_card Co-Authored-By: Claude Opus 5 <[EMAIL]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
365b16c14d
commit
c6df345138
@@ -1050,8 +1050,9 @@ namespace {
|
||||
Db::name('system_role_menu')->insert(['role_id' => 1, 'menu_id' => 6]);
|
||||
Db::execute("INSERT INTO zyt_system_role VALUES (1, 'Doctor', 4, NULL), (2, 'Read only', 4, NULL), (3, 'Audit', 1, NULL)");
|
||||
Db::execute('CREATE TABLE zyt_tcm_diagnosis (id INTEGER PRIMARY KEY, status INTEGER, patient_id INTEGER,
|
||||
assistant_id INTEGER, patient_name TEXT, gender INTEGER, age INTEGER, phone TEXT, delete_time INTEGER)');
|
||||
Db::execute("INSERT INTO zyt_tcm_diagnosis VALUES (10, 1, 99, 3, 'Test patient', 1, 30, '13800000000', NULL)");
|
||||
assistant_id INTEGER, patient_name TEXT, gender INTEGER, age INTEGER, phone TEXT, delete_time INTEGER, id_card TEXT DEFAULT "")');
|
||||
Db::execute("INSERT INTO zyt_tcm_diagnosis VALUES (10, 1, 99, 3, 'Test patient', 1, 30, '13800000000', NULL, '')");
|
||||
Db::execute("INSERT INTO zyt_tcm_diagnosis VALUES (11, 1, 98, 3, 'Other patient', 1, 40, '', NULL, '110101199001011237')");
|
||||
Db::execute('CREATE TABLE zyt_doctor_appointment (id INTEGER PRIMARY KEY, patient_id INTEGER, doctor_id INTEGER, status INTEGER)');
|
||||
Db::execute('INSERT INTO zyt_doctor_appointment VALUES (40, 10, 1, 3)');
|
||||
Db::execute('CREATE TABLE zyt_doctor_note (id INTEGER PRIMARY KEY, diagnosis_id INTEGER, delete_time INTEGER)');
|
||||
@@ -1244,6 +1245,34 @@ namespace {
|
||||
Db::name('tcm_prescription_order')->where('id', 3002)->update(['gancao_order_state' => 91, 'fulfillment_status' => 4]);
|
||||
$assert(PrescriptionLogic::detail($gancaoRx, 1, $doctor)['can_void'] === true && PrescriptionLogic::void($gancaoRx, 1, $doctor),
|
||||
'a Gancao withdrawal callback (91) makes the prescription voidable');
|
||||
|
||||
// 开方/编辑处方可修改处方笺手机号;身份证号写回诊单(校验格式与重复、按出生日期更新年龄),仅可管理诊单者可见。
|
||||
$contactRx = PrescriptionLogic::add($params + ['phone' => '13900000001', 'id_card' => '11010119800101123x'], 1, $doctor);
|
||||
$contact = Db::name('tcm_prescription')->find($contactRx);
|
||||
$assert($contactRx !== null && $contact['phone'] === '13900000001'
|
||||
&& Db::name('tcm_diagnosis')->where('id', 10)->value('id_card') === '11010119800101123X'
|
||||
&& (int) $contact['age'] === (int) Db::name('tcm_diagnosis')->where('id', 10)->value('age')
|
||||
&& (int) $contact['age'] >= 45, 'new prescriptions store the phone and fill the diagnosis ID card with derived age');
|
||||
$assert(PrescriptionLogic::detail($contactRx, 1, $doctor)['patient_id_card'] === '11010119800101123X'
|
||||
&& !array_key_exists('patient_id_card', PrescriptionLogic::detail($contactRx, 4, ['root' => 0, 'admin_id' => 4, 'role_id' => [3]]) ?? []),
|
||||
'the ID card is returned only to accounts that manage the diagnosis');
|
||||
$edit = static fn (array $fields): array => ['id' => $contactRx, 'diagnosis_id' => 10, 'herbs' => $params['herbs'],
|
||||
'prescription_date' => $params['prescription_date']] + $fields;
|
||||
$assert(!PrescriptionLogic::edit($edit(['id_card' => '110101199001011237']), 1, $doctor)
|
||||
&& str_contains(PrescriptionLogic::getError(), '已登记')
|
||||
&& Db::name('tcm_diagnosis')->where('id', 10)->value('id_card') === '11010119800101123X',
|
||||
'a duplicate ID card is refused and nothing is saved');
|
||||
$assert(!PrescriptionLogic::edit($edit(['id_card' => '1234']), 1, $doctor)
|
||||
&& str_contains(PrescriptionLogic::getError(), '格式'), 'a malformed ID card is refused');
|
||||
$assert(!PrescriptionLogic::edit($edit(['phone' => '13900000002', 'id_card' => '110101200001011234']), 1)
|
||||
&& Db::name('tcm_prescription')->where('id', $contactRx)->value('phone') === '13900000001',
|
||||
'editing the ID card without a verified diagnosis scope is refused and rolls back the phone');
|
||||
$assert(PrescriptionLogic::edit($edit(['phone' => '13900000002', 'id_card' => '110101200001011234']), 1, $doctor),
|
||||
'phone and ID card can be edited together: ' . PrescriptionLogic::getError());
|
||||
$assert(Db::name('tcm_prescription')->where('id', $contactRx)->value('phone') === '13900000002'
|
||||
&& Db::name('tcm_diagnosis')->where('id', 10)->value('id_card') === '110101200001011234'
|
||||
&& (int) Db::name('tcm_prescription')->where('id', $contactRx)->value('age') === (int) Db::name('tcm_diagnosis')->where('id', 10)->value('age'),
|
||||
'edit saves the phone on the prescription and the ID card and age on the diagnosis');
|
||||
$decimalRow = array_replace($sample, ['dosage_amount' => '10.0000', 'amount' => '20.00']);
|
||||
$floatRow = array_replace($sample, ['dosage_amount' => 10.0, 'amount' => 20]);
|
||||
$assert(Policy::hash($decimalRow) === Policy::hash($floatRow), 'raw DECIMAL and ORM float hashes agree');
|
||||
|
||||
Reference in New Issue
Block a user