feat: add reviewed follow-up audio patient enrichment

This commit is contained in:
2026-09-29 15:44:30 +08:00
parent 3cdc812f2b
commit 70be2fc70f
46 changed files with 7384 additions and 246 deletions
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace app\common\service\followupaudio;
/** Do not buffer a 500 MB recording into PHP memory or allow public caching. */
final class FollowupAudioStream extends \think\Response
{
private string $path;
public function __construct(string $path, string $extension)
{
$this->path = $path;
$this->init('', 200);
$mime = ['mp3' => 'audio/mpeg', 'm4a' => 'audio/mp4', 'wav' => 'audio/wav', 'amr' => 'audio/amr'][$extension];
$this->header([
'Content-Type' => $mime, 'Content-Length' => (string) filesize($path),
'Content-Disposition' => 'inline; filename="recording.' . $extension . '"',
'Cache-Control' => 'private, no-store, max-age=0', 'Pragma' => 'no-cache',
'X-Content-Type-Options' => 'nosniff', 'Accept-Ranges' => 'none',
]);
}
protected function sendData(string $data): void
{
$stream = fopen($this->path, 'rb');
if ($stream === false) {
return;
}
try {
while (!feof($stream) && !connection_aborted()) {
echo fread($stream, 1048576);
}
} finally {
fclose($stream);
}
}
}