from typing import List, Optional, Dict, Union class CDSSInt: type: str value: Union[int, float] def __init__(self, type:str='nubmer' , value: Union[int,float]=0): self.type = type self.value = value def __str__(self): return f"{self.type}:{self.value}" def value(self): return self.value class CDSSText: type: str value: Union[str, List[str]] def __init__(self, type:str='text', value: Union[str, List[str]]=""): self.type = type self.value = value def __str__(self): if isinstance(self.value, str): return f"{self.type}:{self.value}" return f"{self.type}:{','.join(self.value)}" def value(self): return self.value class CDSSDict: type: str value: Dict def __init__(self, type:str='dict', value: Dict={}): self.type = type self.value = value def __str__(self): return f"{self.type}:{self.value}" def value(self): return self.value # pat_name:患者名字,字符串,如"张三",无患者信息输出"" # pat_sex:患者性别,字符串,如"男",无患者信息输出"" # pat_age:患者年龄,数字,单位为年,如25岁,输出25,无年龄信息输出0 # clinical_department:就诊科室,字符串,如"呼吸内科",无就诊科室信息输出"" # chief_complaint:主诉,字符串列表,包括主要症状的列表,如["胸痛","发热"],无主诉输出[] # present_illness:现病史,字符串列表,包括症状发展过程、诱因、伴随症状(如疼痛性质、放射部位、缓解方式,无现病史信息输出[] # past_medical_history:既往病史,字符串列表,包括疾病史(如高血压、糖尿病)、手术史、药物过敏史、家族史等,无现病史信息输出[] # physical_examination:体格检查,字符串列表,如生命体征(血压、心率)、心肺腹部体征、实验室/影像学结果(如心电图异常、肌钙蛋白升高),无信息输出[] # lab_and_imaging:检验与检查,字符串列表,包括血常规、生化指标、心电图(ECG)、胸部X光、CT等检查项目,结果和报告等,无信息输出[] class CDSSInput: def __init__(self, **kwargs): self.pat_age = CDSSInt(type='year', value=0) self.pat_sex = CDSSInt(type='sex', value=0) self.department = CDSSText(type='department', value="") self.values = [] for key, value in kwargs.items(): if hasattr(self, key): setattr(self, key, value) else: self.values.append(CDSSText(key, value)) def get_value(self, key)->CDSSText: for value in self.values: if value.type == key: return value.value class CDSSOutput: def __init__(self): self.departments = CDSSDict(type='departments', value={}) self.diagnosis = CDSSDict(type='diagnosis', value={}) self.count_diagnosis = CDSSDict(type='diagnosis', value={}) self.checks = CDSSDict(type='checks', value={}) self.drugs = CDSSDict(type='drugs', value={})