更新
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
// Read-only comparison diagnostic. Prints dosage units and structural fields only,
|
||||
// never herb names, report text, patient data, URLs or credentials.
|
||||
$serverRoot = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'server' . DIRECTORY_SEPARATOR;
|
||||
chdir($serverRoot);
|
||||
require $serverRoot . 'vendor/autoload.php';
|
||||
$app = new \think\App($serverRoot);
|
||||
$app->initialize();
|
||||
|
||||
use app\common\service\prescriptionai\PrescriptionAiCipher;
|
||||
use app\common\service\prescriptionai\PrescriptionAiPolicy;
|
||||
use think\facade\Db;
|
||||
|
||||
$batchId = (int) ($argv[1] ?? 5);
|
||||
$cipher = new PrescriptionAiCipher();
|
||||
$batch = Db::name('prescription_ai_batch')->where('id', $batchId)->find();
|
||||
$doctor = $cipher->decrypt((string) $batch['prescription_cipher'], 'prescription');
|
||||
$herbs = PrescriptionAiPolicy::decode($doctor['herbs'] ?? []);
|
||||
|
||||
$shape = static function (array $herb): array {
|
||||
return [
|
||||
'has_name' => trim((string) ($herb['name'] ?? '')) !== '',
|
||||
'dosage' => $herb['dosage'] ?? null,
|
||||
'unit' => $herb['unit'] ?? null,
|
||||
'dose_basis' => $herb['dose_basis'] ?? null,
|
||||
'processing' => $herb['processing'] ?? null,
|
||||
'formula_type' => $herb['formula_type'] ?? null,
|
||||
'keys' => array_keys($herb),
|
||||
];
|
||||
};
|
||||
|
||||
$out = ['batch_id' => $batchId, 'doctor' => [
|
||||
'dose_unit' => $doctor['dose_unit'] ?? null,
|
||||
'dose_basis' => $doctor['dose_basis'] ?? null,
|
||||
'prescription_type' => $doctor['prescription_type'] ?? null,
|
||||
'herb_count' => count($herbs),
|
||||
'herbs' => array_map($shape, array_slice($herbs, 0, 5)),
|
||||
]];
|
||||
|
||||
foreach (Db::name('prescription_ai_result')->where('batch_id', $batchId)->select()->toArray() as $row) {
|
||||
$body = $cipher->decrypt((string) $row['body_cipher'], 'result:' . $row['batch_id'] . ':' . $row['model_key']);
|
||||
$candidate = (array) ($body['candidate'] ?? []);
|
||||
$candidateHerbs = (array) ($candidate['herbs'] ?? []);
|
||||
$out['results'][] = [
|
||||
'result_id' => (int) $row['id'], 'model_key' => $row['model_key'],
|
||||
'candidate_status' => $candidate['status'] ?? null,
|
||||
'dose_basis' => $candidate['dose_basis'] ?? null,
|
||||
'prescription_type' => $candidate['prescription_type'] ?? null,
|
||||
'times_per_day' => $candidate['times_per_day'] ?? null,
|
||||
'usage_days' => $candidate['usage_days'] ?? null,
|
||||
'herb_count' => count($candidateHerbs),
|
||||
'herbs' => array_map($shape, array_slice($candidateHerbs, 0, 5)),
|
||||
'comparison_status' => $row['comparison_status'], 'comparison_reason_code' => $row['comparison_reason_code'],
|
||||
];
|
||||
}
|
||||
|
||||
echo json_encode($out, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), "\n";
|
||||
Reference in New Issue
Block a user