已签署处方在业务订单中可修改服用参数(只改订单页面与药房下单,不改 CA 签署原件);查看处方可下载 CA 原件或当前样式的药房联/处方联
- 处方已电子签署(内容冻结)时,「修改服用参数」改写为订单级覆盖值 usage_override(次数/天数/袋数,含辅方), 签署原文、快照哈希与 CA PDF 不变;订单详情、处方笺、甘草/洛阳下单按本订单生效值;未签署处方仍直接修改处方 - 已发货锁定天数按生效值比较;重新开方改关联时清除旧覆盖值 - 迁移 2026_11_30_prescription_order_usage_override.sql - 业务订单「查看处方」下载改为下拉:CA 签署处方 PDF、药房联 PDF、处方联 PDF(当前页面样式,A4);PC 与 H5 一致 - 重新构建管理后台 Co-Authored-By: Claude Opus 5 <[EMAIL]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
18a0989c00
commit
9dde9a34b5
@@ -270,7 +270,7 @@ namespace {
|
||||
fulfillment_status INTEGER, delete_time INTEGER, diagnosis_id INTEGER, creator_id INTEGER,
|
||||
reissue_from_prescription_id INTEGER NOT NULL DEFAULT 0, order_no TEXT DEFAULT "", ship_mode TEXT DEFAULT "gancao",
|
||||
ej_pharmacy_order_no TEXT DEFAULT "", ej_pharmacy_status TEXT DEFAULT "", gancao_reciperl_order_no TEXT DEFAULT "",
|
||||
gancao_order_state INTEGER DEFAULT 0, tracking_number TEXT DEFAULT "", medication_days INTEGER,
|
||||
gancao_order_state INTEGER DEFAULT 0, tracking_number TEXT DEFAULT "", medication_days INTEGER, usage_override TEXT,
|
||||
create_time INTEGER, update_time INTEGER
|
||||
)');
|
||||
Db::execute('CREATE TABLE zyt_tcm_prescription_order_pay_order (id INTEGER PRIMARY KEY, prescription_order_id INTEGER, pay_order_id INTEGER)');
|
||||
@@ -1300,7 +1300,36 @@ namespace {
|
||||
}
|
||||
$assert(PrescriptionOrderLogic::patchPrescriptionUsage($usage(["medication_days" => 14, "times_per_day" => 3]), 1, $root)
|
||||
&& (int) Db::name("tcm_prescription")->where("id", $contactRx)->value("times_per_day") === 3,
|
||||
"other usage fields stay editable after shipping: " . PrescriptionOrderLogic::getError()); $decimalRow = array_replace($sample, ['dosage_amount' => '10.0000', 'amount' => '20.00']);
|
||||
"other usage fields stay editable after shipping: " . PrescriptionOrderLogic::getError());
|
||||
|
||||
// 已签署(冻结)处方:未发货时修改服用参数只写订单覆盖值,签署原文(处方行与快照哈希)不变,订单页面与药房下单按覆盖值。
|
||||
Db::name("tcm_prescription_order")->where("id", 4001)->update(["fulfillment_status" => 2, "tracking_number" => "",
|
||||
"ej_pharmacy_status" => "", "gancao_order_state" => 0, "usage_override" => null]);
|
||||
Db::name("tcm_prescription")->where("id", $contactRx)->update(["esign_required" => 1, "esign_status" => "signed"]);
|
||||
$signedRow = Db::name("tcm_prescription")->find($contactRx);
|
||||
$assert(PrescriptionOrderLogic::patchPrescriptionUsage($usage(["times_per_day" => 3, "usage_days" => 30, "medication_days" => 30,
|
||||
"dosage_bag_count" => 2]), 1, $root), "a signed prescription's order usage can be changed before shipping: " . PrescriptionOrderLogic::getError());
|
||||
$orderRow = Db::name("tcm_prescription_order")->find(4001);
|
||||
$effective = PrescriptionOrderLogic::applyUsageOverride($signedRow, $orderRow);
|
||||
$assert(Db::name("tcm_prescription")->find($contactRx) === $signedRow
|
||||
&& Policy::hash(Db::name("tcm_prescription")->find($contactRx)) === Policy::hash($signedRow)
|
||||
&& (int) $orderRow["medication_days"] === 30
|
||||
&& (int) $effective["times_per_day"] === 3 && (int) $effective["usage_days"] === 30 && (int) $effective["dosage_bag_count"] === 2
|
||||
&& $effective["usage_overridden"] === 1
|
||||
&& str_contains((string) Db::name("tcm_prescription_order_log")->where("prescription_order_id", 4001)
|
||||
->where("action", "patch_rx_usage")->order("id", "desc")->value("summary"), "CA 签署处方不变"),
|
||||
'the signed prescription and its hash stay intact while the order carries the effective usage');
|
||||
$assert(PrescriptionOrderLogic::applyUsageOverride($signedRow, ["usage_override" => null]) === $signedRow,
|
||||
'without an override the prescription is used as signed');
|
||||
$again = PrescriptionOrderLogic::applyUsageOverride($signedRow, Db::name("tcm_prescription_order")->find(4001));
|
||||
$assert(PrescriptionOrderLogic::patchPrescriptionUsage($usage(["times_per_day" => 3, "usage_days" => 30, "medication_days" => 30,
|
||||
"dosage_bag_count" => 2]), 1, $root) && $again["times_per_day"] === 3, 'repeating the same override is a no-op');
|
||||
Db::name("tcm_prescription_order")->where("id", 4001)->update(["fulfillment_status" => 5]);
|
||||
$assert(!PrescriptionOrderLogic::patchPrescriptionUsage($usage(["times_per_day" => 3, "usage_days" => 28, "medication_days" => 30,
|
||||
"dosage_bag_count" => 2]), 1, $root) && PrescriptionOrderLogic::getError() === PrescriptionOrderLogic::SHIPPED_DAYS_LOCKED,
|
||||
'the shipped-day lock compares against the effective overridden days');
|
||||
Db::name("tcm_prescription")->where("id", $contactRx)->update(["esign_status" => "pending"]);
|
||||
$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');
|
||||
$assert(Policy::hash(Policy::snapshot($decimalRow)) === Policy::hash($decimalRow), 'snapshot hashing is idempotent');
|
||||
|
||||
Reference in New Issue
Block a user