def get_new_list(start_date, end_date): result = [] p_data = { "Base_StartDate": start_date, "Base_EndDate": end_date, } post_data = req_to_xml(req_key="patientlst1req", req_data=p_data) json_data = post_request(api_uri=orca.patient_new, res_key="patientlst1res", post_data=post_data) if "Patient_Information" in json_data.keys(): for data in json_data["Patient_Information"]: name = data["WholeName"].split(" ") name_kana = data["WholeName_inKana"].split(" ") result.append({ "birth": data["BirthDate"], "pati_id": data["Patient_ID"], "sex": data["Sex"], "sei": name[0] if len(name) > 0 else "", "mei": name[1] if len(name) > 1 else "", "sei_kana": name_kana[0] if len(name_kana) > 0 else "", "mei_kana": name_kana[1] if len(name_kana) > 1 else "", "reg_date": data["CreateDate"], "mod_date": data["UpdateDate"], }) return result
def send_receipt(data): print(data) data_default = data["default"] data_perform = data["perform"] data_medical = data["medical"] p_data = { "Patient_ID": data_default["Patient_Information"]["Patient_ID"], "Perform_Date": data_perform["Perform_Date"], "Perform_Time": data_perform["Perform_Time"], "Diagnosis_Information": { "Department_Code": data_default["Department_Code"], "Physician_Code": data_default["Physician_Code"], "HealthInsurance_Information": data_default[ "HealthInsurance_Information" ], "Medical_Information": data_medical["Medical_Information"], "Disease_Information": data_medical["Disease_Information"], }, } post_data = req_to_xml(req_key="medicalreq", req_data=p_data) result = {} error = "" json_data = post_request( api_uri=orca.regist_receipt, res_key="medicalres", post_data=post_data ) if json_data["Api_Result"] == "00": result = json_data error = "00" else: error = json_data["Api_Result"] + " : " + json_data["Api_Result_Message"] result = {"data": json_data, "error": error} return result
def cancel(self, acc_time, acc_id, pati_id): post_data = req_to_xml( req_key="acceptreq", req_data={ "Request_Number": "02", "Acceptance_Date": self.acc_date, "Acceptance_Time": acc_time, "Acceptance_Id": acc_id, "Patient_ID": pati_id, }, ) result = {} error = "" json_data = post_request( api_uri=orca.acceptance_cancel, res_key="acceptres", post_data=post_data ) if json_data["Api_Result"] == "K3": result = json_data error = "K3" else: error = json_data["Api_Result"] + " : " + json_data["Api_Result_Message"] result = {"data": json_data, "error": error} return result
def get_info(self): p_data = { "Request_Number": self.system_code, "Base_Date": date_to_string(datetime.now()), } api_uri = (orca.department_info if self.system_code == "01" else orca.physician_info) post_data = req_to_xml(req_key="system01_managereq", req_data=p_data) res_key = "departmentres" if self.system_code == "01" else "physicianres" json_data = post_request(api_uri=api_uri, res_key=res_key, post_data=post_data) result = ([ { "code": dd["Code"], "name": dd["WholeName"] } for dd in json_data["Department_Information"] ] if self.system_code == "01" else [{ "code": dd["Code"], "name": dd["WholeName"], "depart_code1": dd["Department_Code1"] if "Department_Code1" in dd.keys() else "", "depart_code2": dd["Department_Code2"] if "Department_Code2" in dd.keys() else "", } for dd in json_data["Physician_Information"]]) return result
def list_all(self): post_data = req_to_xml( "acceptlstreq", req_data={"Acceptance_Date": self.acc_date} ) results = [] error = [] for class_num in reversed(range(2)): json_data = post_request( api_uri=orca.acceptance_info(class_num=class_num + 1), res_key="acceptlstres", post_data=post_data, ) if json_data["Api_Result"] == "00": acc_date = json_data["Acceptance_Date"] for data in json_data["Acceptlst_Information"]: acc_data = { "Acceptance_ID": data["Acceptance_Id"], "Acceptance_Date": acc_date, "Acceptance_Time": data["Acceptance_Time"], "Status": str(class_num + 1) if class_num == 1 else str(class_num), "Patient_Information": data["Patient_Information"], "InsuranceProvider_WholeName": ( data["HealthInsurance_Information"][ "InsuranceProvider_WholeName" ] if "InsuranceProvider_WholeName" in data["HealthInsurance_Information"].keys() else "" ) if "HealthInsurance_Information" in data.keys() else "", "Department_WholeName": data["Department_WholeName"], "Physician_WholeName": data["Physician_WholeName"], "Patient_Memo": "", "Acceptance_Memo": "", "BigData": data, } results.append(acc_data) error.append("00") else: error.append( json_data["Api_Result"] + " : " + json_data["Api_Result_Message"] ) error_msg = "" for e in error: if e != "00": error_msg += e + "\n" result = {"data": results, "error": error_msg} return result
def get_list(): result = [] for d in range(10): d = d * 100 p_data = { "Patient_ID_Information": [{ "Patient_ID": str(dd) } for dd in range(d, d + 100)] } post_data = req_to_xml(req_key="patientlst2req", req_data=p_data) json_data = post_request(api_uri=orca.patient_list, res_key="patientlst2res", post_data=post_data) if int(json_data["Target_Patient_Count"]) == 0: break for data in json_data["Patient_Information"]: if "WholeName_inKana" in data.keys(): name = data["WholeName"].split(" ") name_kana = data["WholeName_inKana"].split(" ") result.append({ "birth": data["BirthDate"], "pati_id": data["Patient_ID"], "sex": data["Sex"], "sei": name[0], "mei": name[1] if len(name) > 1 else "", "sei_kana": name_kana[0], "mei_kana": name_kana[1] if len(name_kana) > 1 else "", "reg_date": date_to_string(datetime.now()), "mod_date": date_to_string(datetime.now()), }) return result
def resolve_acceptances(self, info, status=["診療待ち", "会計待ち", "会計済み"], **kwargs): query = Acceptance.get_query(info) wait_post_d = req_to_xml( req_key="tmedicalgetreq", req_data={ "Perform_Date": "", }, ) wait_json_d = post_request( api_uri=orca.wait_accounting, res_key="tmedicalgetres", post_data=wait_post_d, ) if "Tmedical_List_Information" in wait_json_d: pprint(wait_json_d) for dd in wait_json_d["Tmedical_List_Information"]: query.filter(AcceptanceModel.date == date_to_string( datetime.now())).filter( AcceptanceModel.pati_id == dd["Patient_Information"] ["Patient_ID"]).filter( AcceptanceModel.depart_code == dd["Department_Code"]).filter( AcceptanceModel.physic_code == dd["Physician_Code"]).update( {"status": "会計待ち"}) all_data = ( query.filter(AcceptanceModel.status.in_(status), ).filter( AcceptanceModel.date == date_to_string(datetime.now())).all() if len(status) != 0 else query.filter( AcceptanceModel.date == date_to_string(datetime.now())).all()) result = [dd for dd in all_data if dd.status != "会計済み"] for rslt in result: ended_json_d = post_request( api_uri=orca.ended_account, res_key="medicalget01res", post_data=req_to_xml( req_key="medicalgetreq", req_data={ "Patient_ID": rslt.pati_id, "Perform_Date": "", }, ), ) if ended_json_d["Api_Result"] == "K1": # rslt.status = "会計済み" today = date_to_string(datetime.now()) pati_id = ended_json_d["Patient_Information"]["Patient_ID"] for medi in ended_json_d["Medical_List_Information"]: if medi["Perform_Date"] == today: query.filter(AcceptanceModel.date == today).filter( AcceptanceModel.pati_id == pati_id).filter( AcceptanceModel.depart_code == medi["Department_Code"]).update( {"status": "会計済み"}) database.SessionLocal.commit() return all_data
async def sendaccount(data: AccountData): res_data = data.data receip_data = { "Patient_ID": res_data["patiId"], "Perform_Date": res_data["date"], "Perform_Time": res_data["time"], "Diagnosis_Information": { "Department_Code": res_data["departCode"], "Physician_Code": res_data["physicCode"], }, } orp = ORPatient(pati_id=res_data["patiId"]) p_info = orp.get_info() receip_data["Diagnosis_Information"][ "HealthInsurance_Information"] = p_info["Patient_Information"][ "HealthInsurance_Information"][0] receip_data["Diagnosis_Information"]["Medical_Information"] = [ { "Medical_Class": "120", "Medical_Class_Name": "再診", "Medical_Class_Number": "1", "Medication_info": [ { "Medication_Code": "112007410", "Medication_Name": "再診", "Medication_Number": "1", "Medication_Generic_Flg": "", }, ], }, { "Medical_Class": "210", "Medical_Class_Name": "内服薬剤", "Medical_Class_Number": "1", "Medication_info": [ { "Medication_Code": "620001402", "Medication_Name": "グリセリン", "Medication_Number": "2", "Medication_Generic_Flg": "yes", }, ], }, { "Medical_Class": "500", "Medical_Class_Name": "手術", "Medical_Class_Number": "1", "Medication_info": [ { "Medication_Code": "150003110", "Medication_Name": "皮膚、皮下腫瘍摘出術(露出部)(長径2cm未満)", "Medication_Number": "1", "Medication_Generic_Flg": "", }, { "Medication_Code": "641210099", "Medication_Name": "キシロカイン注射液1%", "Medication_Number": "3", "Medication_Generic_Flg": "", }, { "Medication_Code": "840000042", "Medication_Name": "手術○日", "Medication_Number": "15", "Medication_Generic_Flg": "", }, ], }, ] receip_data["Disease_Information"] = [ { "Disease_Code": "8830052", "Disease_Name": "ACバイパス術後機械的合併症", "Disease_SuspectedFlag": "S", "Disease_StartDate": "2020-08-23", "Disease_EndDate": "2020-08-24", "Disease_OutCome": "D", }, { "Disease_InOut": "0", "Disease_Single": [ { "Disease_Single_Code": "830417", "Disease_Single_Name": "" }, { "Disease_Single_Code": "ZZZ8002", "Disease_Single_Name": "の疑い" }, ], "Disease_StartDate": "2020-07-23", "Disease_EndDate": "2020-07-24", "Disease_OutCome": "D", }, ] post_data = req_to_xml(req_key="medicalreq", req_data=receip_data) result = {} error = "" json_data = post_request(api_uri=orca.regist_receipt, res_key="medicalres", post_data=post_data) if json_data["Api_Result"] == "00": result = json_data error = "00" else: error = json_data["Api_Result"] + " : " + json_data[ "Api_Result_Message"] result = {"data": json_data, "error": error} print(result) return result