签署原文中金额为 0、辅方不代煎时不再写入

- 金额(元)为 0 / 0.00 时省略,非 0 照常写入
- 辅方代煎为 0 时省略;代煎时显示「是」(与主方代煎一致),不再显示 0/1

Co-Authored-By: Claude Opus 5 (1M context) <[EMAIL]>
This commit is contained in:
Your Name
2026-11-27 18:27:13 +08:00
co-authored by Claude Opus 5 (1M context)
parent c22be5d586
commit 7c916d8053
2 changed files with 22 additions and 1 deletions
@@ -1204,6 +1204,17 @@ namespace {
$mainOnly = PrescriptionPdf::render(array_replace($sample, ['aux_usage' => $auxUsage,
'herbs' => array_map(static fn (array $herb): array => $herb + ['formula_type' => '主方'], $sampleHerbs)]), 'sandbox');
$assert(!str_contains($mainOnly, $pdfText('辅方')), 'a prescription without auxiliary herbs omits the default auxiliary usage');
$auxHerbs = array_merge($sampleHerbs, [['name' => '虚构辅方药', 'dosage' => 6, 'unit' => 'g', 'formula_type' => '辅方']]);
foreach (['0', '0.00', 0] as $zero) {
$zeroPdf = PrescriptionPdf::render(array_replace($sample, ['amount' => $zero, 'herbs' => $auxHerbs,
'aux_usage' => ['need_decoction' => 0, 'usage_days' => 7]]), 'sandbox');
$assert(!str_contains($zeroPdf, $pdfText('金额(元)')) && !str_contains($zeroPdf, $pdfText('辅方代煎'))
&& str_contains($zeroPdf, $pdfText('辅方服用天数:7')), 'zero amount and no auxiliary decoction are omitted: ' . var_export($zero, true));
}
$paidPdf = PrescriptionPdf::render(array_replace($sample, ['amount' => '18.50', 'herbs' => $auxHerbs,
'aux_usage' => ['need_decoction' => 1]]), 'sandbox');
$assert(str_contains($paidPdf, $pdfText('金额(元):18.5')) && str_contains($paidPdf, $pdfText('辅方代煎:是')),
'a non-zero amount and auxiliary decoction are still disclosed');
$manyHerbs = [];
for ($i = 1; $i <= 65; ++$i) { $manyHerbs[] = ['name' => '虚构药品' . $i, 'dosage' => $i, 'unit' => 'g']; }
$largePdf = PrescriptionPdf::render(array_replace($sample, ['herbs' => $manyHerbs, 'amount' => '18.50']), 'sandbox');