Implementation of automatic transcription of medical dictations Medical dictation - the doctor dictates the examination, anamnesis, diagnosis, prescriptions - the system creates structured text in the required medical record format. Saves the doctor's time: 30-60 minutes per day. Specifics: high cost of error, medical terminology, abbreviations, Latin names. ### System requirements - WER <5% for medical terms - Structuring in SOAP/HL7 FHIR format - HIPAA/152-FZ compatibility - data in a secure environment - Integration with MIS (1C: Medicine, Medialog, EMIAS) ### Medical dictation architecture
from enum import Enum
from dataclasses import dataclass
class MedicalSection(Enum):
COMPLAINT = "complaint" # Жалобы
ANAMNESIS = "anamnesis" # Анамнез
OBJECTIVE = "objective" # Объективный осмотр
DIAGNOSIS = "diagnosis" # Диагноз
TREATMENT = "treatment" # Назначения
@dataclass
class MedicalRecord:
patient_id: str
doctor_id: str
sections: dict[MedicalSection, str]
raw_transcript: str
created_at: str
class MedicalDictationProcessor:
def __init__(self):
# Whisper дообученный на медицинских данных
self.stt = WhisperModel(
"whisper-medical-ru-v1",
device="cuda",
compute_type="float16"
)
self.medical_normalizer = MedicalTextNormalizer()
async def process_dictation(
self,
audio_path: str,
patient_context: dict
) -> MedicalRecord:
# 1. Транскрибируем с медицинским словарём
segments, _ = self.stt.transcribe(
audio_path,
language="ru",
initial_prompt="Медицинская диктовка врача. Жалобы, анамнез, диагноз, назначения."
)
raw_text = " ".join(seg.text for seg in segments)
# 2. Нормализация медицинской лексики
normalized = self.medical_normalizer.normalize(raw_text)
# 3. Структурирование через LLM
structured = await self.structure_medical_text(normalized, patient_context)
return MedicalRecord(
patient_id=patient_context["patient_id"],
doctor_id=patient_context["doctor_id"],
sections=structured,
raw_transcript=raw_text,
created_at=datetime.utcnow().isoformat()
)
async def structure_medical_text(self, text: str, context: dict) -> dict:
response = await client.chat.completions.create(
model="gpt-4o",
messages=[{
"role": "system",
"content": """Ты медицинский редактор. Структурируй диктовку врача.
Разбей на разделы: Жалобы, Анамнез болезни, Объективный осмотр,
Диагноз (МКБ-10 код), Назначения.
Исправь медицинские термины. JSON ответ."""
}, {
"role": "user",
"content": f"Пациент: {context.get('age')} лет, {context.get('gender')}.\n{text}"
}],
response_format={"type": "json_object"}
)
return json.loads(response.choices[0].message.content)
```### Medical abbreviations```python
MEDICAL_ABBREVIATIONS = {
"ад": "артериальное давление",
"чсс": "частота сердечных сокращений",
"жкт": "желудочно-кишечный тракт",
"орви": "острая респираторная вирусная инфекция",
# Расшифровываем при диктовке, сокращаем в финальном тексте
}
```### Features of working with the HIS Integration via the FHIR R4 API or specific APIs of 1C:Medicine, Medialog. We create ClinicalDocument or DocumentReference in FHIR. ### Implementation timeframes - Basic system: 4–6 weeks - Additional training of Whisper on medical data: +4–6 weeks (if a dataset is available) - Integration with a specific HIS: +2–4 weeks