79 lines
6.9 KiB
PHP
79 lines
6.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
require dirname(__DIR__) . '/app/adminapi/service/TcmHerbalPremiseGuard.php';
|
|
use app\adminapi\service\TcmHerbalPremiseGuard as Guard;
|
|
$checks = 0;
|
|
function premiseExpect(bool $ok, string $reason): void {
|
|
++$GLOBALS['checks']; if (!$ok) throw new RuntimeException($reason);
|
|
}
|
|
$proposal = "六、中药方药及复核监测\n\n主方方向:可考虑甲乙散方向,仅作医师审核。\n\n";
|
|
foreach (['阴虚及心悸等关键方证证据不足', '核心方证尚未确立', '本方的关键依据缺失',
|
|
'本次辨证核心支持依据尚未证实', '尚缺关键的阳性方证', '关键用方条件未满足'] as $gap) {
|
|
$r = Guard::validate($proposal . '局限:' . $gap . '。');
|
|
premiseExpect(!$r['valid'] && $r['issues'] === [['code' => 'HERBAL_PREMISE_SELF_CONFLICT', 'source_id' => 'report']],
|
|
'A current concrete proposal cannot coexist with an explicit essential-basis admission: ' . $gap);
|
|
}
|
|
premiseExpect(!Guard::validate('建议考虑丙丁汤。核心辨证依据不足。')['valid'], 'A different named formula and wording have the same contradiction.');
|
|
premiseExpect(!Guard::validate('拟用药味:甲药、乙药。关键方证证据不足。')['valid'], 'An explicit new herb list cannot bypass the same premise check.');
|
|
premiseExpect(!Guard::validate('拟用中药:甲药。核心方证尚未确立。')['valid'], 'An explicit single-herb proposal uses the same rule without a drug dictionary.');
|
|
foreach ([
|
|
'关键方证证据不足,暂不列方名,继续补采与监测。',
|
|
'主方方向:暂不采用甲乙散。关键方证证据不足。',
|
|
'历史方:甲乙散早已停用。当年关键方证证据不足。',
|
|
'历史:2020-01-01甲乙散早已停用。当年关键方证证据不足。',
|
|
$proposal . '适用前须核实:是否存在过敏或肝肾功能变化?',
|
|
$proposal . '关键安全信息尚未核实,需核对相互作用。',
|
|
$proposal . '阴虚证据不足,另列鉴别。',
|
|
$proposal . '若关键方证证据不足,暂不采用。',
|
|
$proposal . '适用前须核实:是否关键方证证据不足?',
|
|
$proposal . '并非关键方证证据不足,而是监测安排需补充。',
|
|
] as $control) premiseExpect(Guard::validate($control)['valid'], 'Historical/deferred/source/safety/hypothetical controls are not self-admissions.');
|
|
premiseExpect(!Guard::validate('主方方向:“甲乙散”。关键方证证据不足。')['valid'], 'Unsourced quotation marks cannot hide a new proposal.');
|
|
premiseExpect(!Guard::validate('主方方向:可供医师考虑甲乙散方向,不作合方,不列加味、剂量、频次或疗程,不构成可直接执行处方。反证与局限:阴虚、虚热及心悸等关键方证证据不足。')['valid'],
|
|
'No-dose/no-combination disclaimers do not erase the actual current named proposal.');
|
|
premiseExpect(!Guard::validate('既往甲乙散早已停用,但本次可考虑丙丁丸。核心方证证据不足。')['valid'], 'A current proposal after a historical clause remains current.');
|
|
$ledger = ['sources' => [
|
|
's1' => ['id' => 's1', 'quote' => '乏力、活动后气短。', 'scope' => 'current'],
|
|
's2' => ['id' => 's2', 'quote' => '当年核心方证证据不足,尚未选方。', 'scope' => 'historical'],
|
|
's3' => ['id' => 's3', 'quote' => '甲乙散', 'scope' => 'historical'],
|
|
's4' => ['id' => 's4', 'quote' => '当年建议沿用甲乙散,核心方证证据不足。', 'scope' => 'historical'],
|
|
]];
|
|
foreach (['s1', 's99', 's3'] as $id) {
|
|
premiseExpect(!Guard::validate('主方方向:“甲乙散”(' . $id . ')。核心方证证据不足。', $ledger)['valid'],
|
|
'Unrelated, missing, or genuine historical name citations never hide a current outside proposal operator.');
|
|
}
|
|
premiseExpect(Guard::validate('历史记录:2020-01-01“甲乙散”(s3)。当年关键方证证据不足。', $ledger)['valid'],
|
|
'A genuinely attributed verified historical name is not a current proposal.');
|
|
premiseExpect(Guard::validate($proposal . '历史记录原文:“当年核心方证证据不足,尚未选方。”(s2)。', $ledger)['valid'],
|
|
'An exact source-qualified historical evidence admission is not the current report admitting a missing premise.');
|
|
premiseExpect(!Guard::validate($proposal . '资料原文:“核心方证证据不足”(s1)。', $ledger)['valid'],
|
|
'Attribution wording cannot hide an admission absent from the cited source.');
|
|
premiseExpect(!Guard::validate($proposal . '资料原文:“核心方证证据不足”(s2,s99)。', $ledger)['valid'],
|
|
'Every cited source must exist and contain the quote before it can be ignored.');
|
|
premiseExpect(Guard::validate($proposal . '适用前须复核药物相互作用与肝肾功能,关键安全资料待核实。', $ledger)['valid'],
|
|
'Ordinary pre-use safety review remains distinct from critical positive-premise absence.');
|
|
foreach ([
|
|
'历史记录:“甲乙散”(s3),本次建议沿用。',
|
|
'甲乙散,本次建议采用。',
|
|
'甲乙散,建议作为主方。',
|
|
'历史记录:“甲乙散”(s3)。本次建议沿用该方。',
|
|
'历史记录:“甲乙散”(s3)。本次沿用旧方。',
|
|
'历史记录:“甲乙散”(s3)。建议继续服用该方。',
|
|
] as $postfix) premiseExpect(!Guard::validate($postfix . '核心方证证据不足。', $ledger)['valid'],
|
|
'A bounded outside current-use recommendation keeps the earlier quoted or unquoted named antecedent.');
|
|
foreach ([
|
|
'历史记录:“甲乙散”(s3),仅作历史。',
|
|
'历史记录:“甲乙散”(s3),本次不沿用。',
|
|
'历史记录:“甲乙散”(s3)。本次不建议使用该方。',
|
|
'历史记录:“甲乙散”(s3)。本次建议不使用该方。',
|
|
'历史记录:“甲乙散”(s3)。当前仍按既有医嘱服用该方,属于用药基线记录。',
|
|
'历史记录:“甲乙散”(s3)。当前仍使用该方,属于既有用药记录。',
|
|
'历史记录:“甲乙散”(s3)。本次建议核查该方是否早已停用。',
|
|
'历史记录:“当年建议沿用甲乙散,核心方证证据不足。”(s4)。',
|
|
'历史记录:“甲乙散”(s3)。另一段单独讨论资料范围。本次建议沿用该方。',
|
|
] as $control) premiseExpect(Guard::validate($control . '核心方证证据不足。', $ledger)['valid'],
|
|
'Historical, local non-use, baseline, safety-inquiry and out-of-bounds references are not new named proposals: ' . $control);
|
|
premiseExpect(!Guard::validate('历史记录:“甲乙散”(s3),本次不沿用;丙丁汤,建议采用。核心方证证据不足。', $ledger)['valid'],
|
|
'A local non-use statement never waives an independent current positive proposal.');
|
|
echo "TCM explicit herbal-premise contradiction: {$checks} assertions passed (pure lexical scope; no clinical certification).\n";
|