from cdss.capbility import CDSSCapability
from cdss.models.schemas import CDSSInput, CDSSOutput, CDSSInt
import logging

logging.basicConfig(level=logging.INFO)

handler = logging.FileHandler('cdss.log', mode='w',encoding="utf-8")
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logging.getLogger().addHandler(handler)

capability = CDSSCapability()

record = CDSSInput(
    pat_age=CDSSInt(type="month", value=21), 
    pat_sex=CDSSInt(type="sex", value=1),
    chief_complaint=["嗓子疼", "流鼻涕", "打喷嚏", "低烧", "全身没力气"]
    #chief_complaint=["腹痛", "发热", "腹泻"],
    )

output = capability.process(input=record)
for item in output.diagnosis.value:
    print(f"DIAG {item}  {output.diagnosis.value[item]} ")
for item in output.checks.value:
    print(f"CHECK {item}  {output.checks.value[item]} ")
for item in output.drugs.value:
    print(f"DRUG {item}  {output.drugs.value[item]} ")