einargs / tnhimss-bill

Mtsu Bill Team repository for the 2023 TNHIMSS hackathon.
1 stars 3 forks source link

Server handles patient selection #7

Closed einargs closed 1 year ago

einargs commented 1 year ago

Server handles the start-chat event that sets up that chat session and communicates which patient has been chosen.

@sio.on('start-chat')
async def async handle_client_msg(sid, patient_id):
  async with sio.session(sid) as session:
    session['patient_id'] = patient_id
    // async load FHIR file. We'll need to make sure that patient_id is an actual id
    // and then switch on it to determine which file is loaded.
    fhir_file = await load_file_for_patient_id(patient_id)
    // parses the JSON in the file into the FHIR classes.
    parsed_fhir = Bundle.parse(file)
    // format the fhir for the chatbot
    // send to the chatbot with a prompt to ask for a summary
    summary = await send_to_chatbot_and_get_summary(parsed_fhir)
    session['chatlog'] = [summary]

    sio.emit('sever-msg', data=summary, to=sid)