using Newtonsoft.Json.Linq; using PTMedicalInsurance.Common; using PTMedicalInsurance.Helper; using PTMedicalInsurance.Variables; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PTMedicalInsurance.Business { class PreAndInProcessAnalysis { private HisIrisServices hIS = new HisIrisServices(); private JArray patient_dtos; //患者信息集合 private JArray fsi_encounter_dtos; //就诊信息集合 private JArray fsi_diagnose_dtos; //诊断信息集合 private JArray fsi_order_dtos; //处方信息集合 private JArray fsi_operation_dtos; // 手术信息集合 MIIrisServices mis = new MIIrisServices(); public PreAndInProcessAnalysis(string inpar) { try { JObject jo = JObject.Parse(inpar); JObject joResult = JObject.FromObject(jo["result"]); patient_dtos = JArray.FromObject(joResult["patient_dtos"]); fsi_encounter_dtos = JArray.FromObject(patient_dtos[0]["fsi_encounter_dtos"]); fsi_diagnose_dtos = JArray.FromObject(fsi_encounter_dtos[0]["fsi_diagnose_dtos"]); fsi_order_dtos = JArray.FromObject(fsi_encounter_dtos[0]["fsi_order_dtos"]); fsi_operation_dtos = JArray.FromObject(fsi_encounter_dtos[0]["fsi_operation_dtos"]); } catch (Exception ex) { Global.writeLog("PreAndInProcessAnalysis构造异常:" + ex.Message); throw; } } #region 设置Patient public int setPatientByHisBaseInfo(out string msg) { string errMsg = string.Empty; msg = ""; try { if (hIS.GetHisPatBaseInfo(out errMsg) != 0) { msg = errMsg; return -1; } JObject jo = JObject.Parse(errMsg); Global.pat.name = JsonHelper.getDestValue(jo, "result.patName"); Global.pat.brdy = JsonHelper.getDestValue(jo, "result.patBirthdate"); Global.pat.gend = JsonHelper.getDestValue(jo, "result.patSex"); Global.pat.age = JsonHelper.getDestValue(jo, "result.Age"); Global.pat.naty = JsonHelper.getDestValue(jo, "result.naty"); Global.pat.certNO = JsonHelper.getDestValue(jo, "result.credNo"); Global.pat.certType = JsonHelper.getDestValue(jo, "result.credCode"); return 0; } catch (Exception ex) { msg = ex.Message; return -1; } } #endregion public JObject Get3101Inpar(string trig_scen,Patients p) { try { JObject joInpar = new JObject(); //joInpar.Add("syscode", "YBJK"); joInpar.Add("patientDtos", GetPatient_dtos(trig_scen, p)); joInpar.Add("ruleIds", ""); //joInpar.Add("task_id", GetMsgID()); joInpar.Add("trigScen", trig_scen); JObject joData = new JObject(); joData.Add("data",joInpar); return joData; } catch (Exception ex) { MessageBox.Show("Get3101Inpar:" + ex.Message); return null; } } private string GetMsgID() { return Global.inf.hospitalNO + DateTime.Now.ToString("yyyyMMddHHmmssffff"); } public JArray GetPatient_dtos(string trig_scen, Patients p) { try { string curr_mdtrt_id = p.mdtrtID; if (string.IsNullOrEmpty(curr_mdtrt_id)) { curr_mdtrt_id = Global.pat.adm_Dr.ToString(); } JObject joInpar = new JObject(); joInpar.Add("patnId", p.psn_no); joInpar.Add("patnName", p.name); string gend = p.gend; if (gend == "男") gend = "1"; if (gend == "女") gend = "2"; joInpar.Add("gend",gend); joInpar.Add("brdy", p.brdy); if (p.insuplc_admdvs == "") p.insuplc_admdvs = Global.pat.insuplc_admdvs; joInpar.Add("poolarea", p.insuplc_admdvs); joInpar.Add("currMdtrtId", curr_mdtrt_id); joInpar.Add("encounterDtos", GetFsi_encounter_dtos(trig_scen,p)); //joInpar.Add("fsi_his_data_dto", new JArray()); JArray ja = new JArray(); ja.Add(joInpar); return ja; } catch (Exception ex) { MessageBox.Show("GetPatient_dtos:" + ex.Message); return null; } } public JArray GetFsi_encounter_dtos(string trig_scen, Patients p) { try { JObject jofsi_encounter_dtos = JObject.FromObject(fsi_encounter_dtos[0]); JObject joInpar = new JObject(); string mdtrtID = p.mdtrtID; if (string.IsNullOrEmpty(mdtrtID)) mdtrtID = Global.pat.adm_Dr.ToString(); joInpar.Add("mdtrtId", mdtrtID); //就诊标识 joInpar.Add("medinsId", Global.inf.hospitalNO); //医疗服务机构标识 joInpar.Add("medinsName", Global.inf.hospitalName); //医疗机构名称 joInpar.Add("medinsAdmdvs", Global.inf.areaCode); //医疗机构行政区划编码 joInpar.Add("medinsType", "A"); //医疗服务机构类型 joInpar.Add("medinsLv", "3"); //医疗机构等级 joInpar.Add("wardareaCodg", JsonHelper.getDestValue(jofsi_encounter_dtos, "wardarea_codg")); //病区标识 joInpar.Add("wardno", JsonHelper.getDestValue(jofsi_encounter_dtos, "wardno")); //病房号 joInpar.Add("bedno", JsonHelper.getDestValue(jofsi_encounter_dtos, "bedno")); //病床号 joInpar.Add("admDate", JsonHelper.getDestValue(jofsi_encounter_dtos, "adm_date")); //入院日期 joInpar.Add("dscgDate", JsonHelper.getDestValue(jofsi_encounter_dtos, "dscg_date")); //出院日期 joInpar.Add("dscgMainDiseCodg", JsonHelper.getDestValue(jofsi_encounter_dtos, "dscg_main_dise_codg")); //主诊断编码 joInpar.Add("dscgMainDiseName", JsonHelper.getDestValue(jofsi_encounter_dtos, "dscg_main_dise_name")); //主诊断名称 joInpar.Add("diagnoseDtos", GetFsi_diagnose__dtos(trig_scen, p)); //诊断信息DTO joInpar.Add("drCodg", JsonHelper.getDestValue(jofsi_encounter_dtos, "dr_codg")); //医师标识 joInpar.Add("admDeptCodg", JsonHelper.getDestValue(jofsi_encounter_dtos, "adm_dept_codg")); //入院科室标识 joInpar.Add("admDeptName", JsonHelper.getDestValue(jofsi_encounter_dtos, "adm_dept_name")); //入院科室名称 joInpar.Add("dscgDeptCodg", JsonHelper.getDestValue(jofsi_encounter_dtos, "dscg_dept_codg")); //出院科室标识 joInpar.Add("dscgDeptName", JsonHelper.getDestValue(jofsi_encounter_dtos, "dscg_dept_name")); //出院科室名称 joInpar.Add("medMdtrtType", JsonHelper.getDestValue(jofsi_encounter_dtos, "med_mdtrt_type")); //就诊类型 string med_type = JsonHelper.getDestValue(jofsi_encounter_dtos, "med_type"); med_type = "21"; joInpar.Add("medType", med_type); //医疗类别 joInpar.Add("orderDtos", GetFsi__order_dtos(trig_scen,p)); //处方(医嘱)信息 string matn_stas = JsonHelper.getDestValue(jofsi_encounter_dtos, "matn_stas"); if (string.IsNullOrEmpty(matn_stas)) matn_stas = "0"; joInpar.Add("matnStas", matn_stas ); //生育状态 joInpar.Add("medfeeSumamt", JsonHelper.getDestValue(jofsi_encounter_dtos, "medfee_sumamt")); //总费用 joInpar.Add("ownpayAmt", JsonHelper.getDestValue(jofsi_encounter_dtos, "ownpay_amt")); //自费金额 joInpar.Add("selfpayAmt", JsonHelper.getDestValue(jofsi_encounter_dtos, "selfpay_amt")); //自付金额 joInpar.Add("acctPayamt", JsonHelper.getDestValue(jofsi_encounter_dtos, "acct_payamt")); //个人账户支付金额 joInpar.Add("maAmt", JsonHelper.getDestValue(jofsi_encounter_dtos, "ma_amt")); //救助金支付金额 joInpar.Add("hifpPayamt", JsonHelper.getDestValue(jofsi_encounter_dtos, "hifp_payamt")); //统筹金支付金额 joInpar.Add("setlTotlnum", JsonHelper.getDestValue(jofsi_encounter_dtos, "setl_totlnum")); //结算总次数 string insutype = JsonHelper.getDestValue(jofsi_encounter_dtos, "insutype"); if (insutype =="") insutype = Global.pat.insuType; insutype = "310"; joInpar.Add("insutype", insutype); //险种 string reimFlag = JsonHelper.getDestValue(jofsi_encounter_dtos, "reim_flag"); // 报销标志(必填) if (string.IsNullOrEmpty(reimFlag)) { reimFlag = "1"; } joInpar.Add("reimFlag", reimFlag); // 异地结算标志(必填) string outSetlFlag = JsonHelper.getDestValue(jofsi_encounter_dtos, "out_setl_flag"); if (string.IsNullOrEmpty(outSetlFlag)) { outSetlFlag = Utils.isOtherCity()?"1":"0"; } joInpar.Add("outSetlFlag", outSetlFlag); joInpar.Add("operationDtos", GetFsi__operation__dtos(trig_scen,p)); //手术操作集合 //济南新增 joInpar.Add("diseNo", ""); //病种编号 joInpar.Add("diseName", ""); //病种名称 joInpar.Add("sincHealLv", ""); //手术切口愈合等级 joInpar.Add("hisMdCnt", "");//历史就诊次数 JArray ja = new JArray(); ja.Add(joInpar); return ja; } catch (Exception ex) { MessageBox.Show("GetPatient_dtos:" + ex.Message); return null; } } public JArray GetFsi_diagnose__dtos(string trig_scen, Patients p) { try { JArray jaNew = new JArray(); foreach (var jo in fsi_diagnose_dtos) { JObject joTmp = new JObject(); joTmp.Add("diseId", JsonHelper.getDestValue((JObject)jo, "dise_id")); joTmp.Add("inoutDiseType", JsonHelper.getDestValue((JObject)jo, "inout_dise_type")); joTmp.Add("maindiseFlag", JsonHelper.getDestValue((JObject)jo, "maindise_flag")); joTmp.Add("diasSrtNo", JsonHelper.getDestValue((JObject)jo, "dias_srt_no")); joTmp.Add("diseCodg", JsonHelper.getDestValue((JObject)jo, "dise_codg")); joTmp.Add("diseName", JsonHelper.getDestValue((JObject)jo, "dise_name")); joTmp.Add("diseDate", JsonHelper.getDestValue((JObject)jo, "dise_date")); jaNew.Add(jo); } return jaNew; } catch (Exception ex) { MessageBox.Show("GetPatient_dtos:" + ex.Message); return null; } } public JArray GetFsi__operation__dtos(string trig_scen, Patients p) { try { JArray jaNew = new JArray(); foreach (var jo in fsi_operation_dtos) { JObject joTmp = new JObject(); joTmp.Add("setlListOprnId", JsonHelper.getDestValue((JObject)jo, "setl_list_oprn_id")); joTmp.Add("oprnCode", JsonHelper.getDestValue((JObject)jo, "oprn_code")); joTmp.Add("oprnName", JsonHelper.getDestValue((JObject)jo, "oprn_name")); joTmp.Add("mainOprnFlag", JsonHelper.getDestValue((JObject)jo, "main_oprn_flag")); joTmp.Add("oprnDate", JsonHelper.getDestValue((JObject)jo, "oprn_date")); joTmp.Add("anstWay", JsonHelper.getDestValue((JObject)jo, "anst_way")); joTmp.Add("operDrName", JsonHelper.getDestValue((JObject)jo, "oper_dr_name")); joTmp.Add("operDrCode", JsonHelper.getDestValue((JObject)jo, "oper_dr_code")); joTmp.Add("anstDrName", JsonHelper.getDestValue((JObject)jo, "anst_dr_name")); joTmp.Add("anstDrCode", JsonHelper.getDestValue((JObject)jo, "anst_dr_code")); jaNew.Add(jo); } return jaNew; } catch (Exception ex) { MessageBox.Show("GetPatient_dtos:" + ex.Message); return null; } } #region 组织入参 public JArray GetFsi__order_dtos(string trig_scen, Patients p) { string errMsg = ""; try { for (int i = 0; i < fsi_order_dtos.Count; i++) { decimal pric = decimal.Parse(fsi_order_dtos[i]["pric"].ToString()); fsi_order_dtos[i]["pric"] = pric.ToString("#0.00"); fsi_order_dtos[i]["hilist_pric"] = pric.ToString("#0.00"); } //调用医保平台进行转换 if (mis.convertFsiOrderDtos(fsi_order_dtos, out errMsg) != 0) { throw new Exception("转换FsiOrderDtos异常:" + errMsg); } else { JObject joRtn = JObject.Parse(errMsg); JArray jaFsiOrderDtos = JArray.FromObject(joRtn["data"]); JArray jaNew = new JArray(); foreach (var jo in jaFsiOrderDtos) { JObject joTmp = new JObject(); joTmp.Add("rxId", JsonHelper.getDestValue((JObject)jo, "rx_id")); joTmp.Add("rxno", JsonHelper.getDestValue((JObject)jo, "rxno")); joTmp.Add("grpno", JsonHelper.getDestValue((JObject)jo, "grpno")); joTmp.Add("longDrordFlag", JsonHelper.getDestValue((JObject)jo, "long_drord_flag")); joTmp.Add("hilistType", JsonHelper.getDestValue((JObject)jo, "hilist_type")); joTmp.Add("chrgType", JsonHelper.getDestValue((JObject)jo, "chrg_type")); joTmp.Add("drordBhvr", JsonHelper.getDestValue((JObject)jo, "drord_bhvr")); joTmp.Add("hilistCode", JsonHelper.getDestValue((JObject)jo, "hilist_code")); joTmp.Add("hilistName", JsonHelper.getDestValue((JObject)jo, "hilist_name")); joTmp.Add("hilistDosform", JsonHelper.getDestValue((JObject)jo, "hilist_dosform")); string hilistLv = JsonHelper.getDestValue((JObject)jo, "hilist_lv"); joTmp.Add("hilistLv", int.Parse(hilistLv)); joTmp.Add("hilistPric", JsonHelper.getDestValue((JObject)jo, "hilist_pric")); joTmp.Add("lv1HospItemPric", JsonHelper.getDestValue((JObject)jo, "lv1_hosp_item_pric")); joTmp.Add("lv2HospItemPric", JsonHelper.getDestValue((JObject)jo, "lv2_hosp_item_pric")); joTmp.Add("lv3HospItemPric", JsonHelper.getDestValue((JObject)jo, "lv3_hosp_item_pric")); joTmp.Add("hilistMemo", JsonHelper.getDestValue((JObject)jo, "hilist_memo")); joTmp.Add("hosplistCode", JsonHelper.getDestValue((JObject)jo, "hosplist_code")); joTmp.Add("hosplistName", JsonHelper.getDestValue((JObject)jo, "hosplist_name")); joTmp.Add("hosplistDosform", JsonHelper.getDestValue((JObject)jo, "hosplist_dosform")); joTmp.Add("cnt", JsonHelper.getDestValue((JObject)jo, "cnt")); joTmp.Add("pric", JsonHelper.getDestValue((JObject)jo, "pric")); joTmp.Add("sumamt", JsonHelper.getDestValue((JObject)jo, "sumamt")); joTmp.Add("ownpayAmt", JsonHelper.getDestValue((JObject)jo, "ownpay_amt")); joTmp.Add("selfpayAmt", JsonHelper.getDestValue((JObject)jo, "selfpay_amt")); string spec = JsonHelper.getDestValue((JObject)jo, "spec"); if (string.IsNullOrEmpty(spec)) { spec = "-"; } joTmp.Add("spec", spec); joTmp.Add("specUnt", JsonHelper.getDestValue((JObject)jo, "spec_unt")); joTmp.Add("drordBegnDate", JsonHelper.getDestValue((JObject)jo, "drord_begn_date")); joTmp.Add("drordStopDate", JsonHelper.getDestValue((JObject)jo, "drord_stop_date")); joTmp.Add("drordDeptCodg", JsonHelper.getDestValue((JObject)jo, "drord_dept_codg")); joTmp.Add("drordDeptName", JsonHelper.getDestValue((JObject)jo, "drord_dept_name")); joTmp.Add("drordDrCodg", JsonHelper.getDestValue((JObject)jo, "drord_dr_codg")); joTmp.Add("drordDrName", JsonHelper.getDestValue((JObject)jo, "drord_dr_name")); joTmp.Add("drordDrProfttl", JsonHelper.getDestValue((JObject)jo, "drord_dr_profttl")); joTmp.Add("currDrordFlag", JsonHelper.getDestValue((JObject)jo, "curr_drord_flag")); joTmp.Add("extendOrderMap", JsonHelper.getDestValue((JObject)jo, "extend_order_map")); jaNew.Add(joTmp); } return jaNew; } } catch (Exception ex) { MessageBox.Show("GetFsi__order_dtos:" + ex.Message); return null; } } #endregion } }