def post(self, process_id): patient_medical_id = request.jsondata.get("patient_medical_id") result_json = request.jsondata.get("result_json") creater_id = request.jsondata.get("creater_id") patient_medical = Query(PatientMedical).get(patient_medical_id) processes = json.loads(patient_medical.get("processes_json")) for index, process in enumerate(processes): if process.get("process_id") == process_id: medical_process = Query(MedicalProcess).get(process_id) patient_medical_process = PatientMedicalProcess() patient_medical_process.set("patient_medical", patient_medical) patient_medical_process.set("result_json", result_json) patient_medical_process.set("process", medical_process) patient_medical_process.set("creater_id", creater_id) patient_medical_process.save() process["head"] = patient_medical_process.id patient_medical.set("processes_json", json.dumps(processes)) patient_medical.save() # 如果是第0个,说明是填写的第一个过程,要去除第一张卡片的第一项作为患者需求 if index == 0: patient_requirement = json.loads(result_json).get("cards")[0].get("items")[0].get("value") patient_medical.set("patient_requirement", patient_requirement) patient_medical.save() return {} else: abort(404, message="不匹配")
def post(self, patient_medical_id): """ 创建病历过程 :param patient_id: 病历id :return: """ data = request.jsondata result_json = data.get("result_json") creater_id = data.get("creater_id") process_id = data.get("process_id") if not (creater_id.startswith("doctor-") or creater_id.startswith("patient-")): abort(400, message=u"创建者id不正确") patient_medical = Query(PatientMedical).get(patient_medical_id) process = Query(MedicalProcess).get(process_id) patient_process = PatientMedicalProcess() patient_process.set("process", process) patient_process.set("result_json", result_json) patient_process.set("patient_id", patient_medical.patient_id) patient_process.set("creater_id", creater_id) patient_process.save() # update medical record head processes_list = json.loads(patient_medical.get("processes_json")) for _process in processes_list: if _process['process_id'] == process_id: _process['head'] = patient_process.id break else: abort(400, message=u'更新过程head失败') patient_medical.set("processes_json", json.dumps(processes_list)) if processes_list[0].get("head") and processes_list[1].get("head"): patient_medical.set("finish", True) patient_medical.save() else: patient_medical.set("finish", False) patient_medical.save() patient_medical.save() return patient_process