PreAndInProcessAnalysis.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.Common;
  3. using PTMedicalInsurance.Helper;
  4. using PTMedicalInsurance.Variables;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace PTMedicalInsurance.Business
  12. {
  13. class PreAndInProcessAnalysis
  14. {
  15. private HisIrisServices hIS = new HisIrisServices();
  16. private JArray patient_dtos; //患者信息集合
  17. private JArray fsi_encounter_dtos; //就诊信息集合
  18. private JArray fsi_diagnose_dtos; //诊断信息集合
  19. private JArray fsi_order_dtos; //处方信息集合
  20. private JArray fsi_operation_dtos; // 手术信息集合
  21. MIIrisServices mis = new MIIrisServices();
  22. public PreAndInProcessAnalysis(string inpar)
  23. {
  24. try
  25. {
  26. JObject jo = JObject.Parse(inpar);
  27. JObject joResult = JObject.FromObject(jo["result"]);
  28. patient_dtos = JArray.FromObject(joResult["patient_dtos"]);
  29. fsi_encounter_dtos = JArray.FromObject(patient_dtos[0]["fsi_encounter_dtos"]);
  30. fsi_diagnose_dtos = JArray.FromObject(fsi_encounter_dtos[0]["fsi_diagnose_dtos"]);
  31. fsi_order_dtos = JArray.FromObject(fsi_encounter_dtos[0]["fsi_order_dtos"]);
  32. fsi_operation_dtos = JArray.FromObject(fsi_encounter_dtos[0]["fsi_operation_dtos"]);
  33. }
  34. catch (Exception ex)
  35. {
  36. Global.writeLog("PreAndInProcessAnalysis构造异常:" + ex.Message);
  37. throw;
  38. }
  39. }
  40. #region 设置Patient
  41. public int setPatientByHisBaseInfo(out string msg)
  42. {
  43. string errMsg = string.Empty;
  44. msg = "";
  45. try
  46. {
  47. if (hIS.GetHisPatBaseInfo(out errMsg) != 0)
  48. {
  49. msg = errMsg;
  50. return -1;
  51. }
  52. JObject jo = JObject.Parse(errMsg);
  53. Global.pat.name = JsonHelper.getDestValue(jo, "result.patName");
  54. Global.pat.brdy = JsonHelper.getDestValue(jo, "result.patBirthdate");
  55. Global.pat.gend = JsonHelper.getDestValue(jo, "result.patSex");
  56. Global.pat.age = JsonHelper.getDestValue(jo, "result.Age");
  57. Global.pat.naty = JsonHelper.getDestValue(jo, "result.naty");
  58. Global.pat.certNO = JsonHelper.getDestValue(jo, "result.credNo");
  59. Global.pat.certType = JsonHelper.getDestValue(jo, "result.credCode");
  60. return 0;
  61. }
  62. catch (Exception ex)
  63. {
  64. msg = ex.Message;
  65. return -1;
  66. }
  67. }
  68. #endregion
  69. public JObject Get3101Inpar(string trig_scen,Patients p)
  70. {
  71. try
  72. {
  73. JObject joInpar = new JObject();
  74. //joInpar.Add("syscode", "YBJK");
  75. joInpar.Add("patientDtos", GetPatient_dtos(trig_scen, p));
  76. joInpar.Add("ruleIds", "");
  77. //joInpar.Add("task_id", GetMsgID());
  78. joInpar.Add("trigScen", trig_scen);
  79. JObject joData = new JObject();
  80. joData.Add("data",joInpar);
  81. return joData;
  82. }
  83. catch (Exception ex)
  84. {
  85. MessageBox.Show("Get3101Inpar:" + ex.Message);
  86. return null;
  87. }
  88. }
  89. private string GetMsgID()
  90. {
  91. return Global.inf.hospitalNO + DateTime.Now.ToString("yyyyMMddHHmmssffff");
  92. }
  93. public JArray GetPatient_dtos(string trig_scen, Patients p)
  94. {
  95. try
  96. {
  97. string curr_mdtrt_id = p.mdtrtID;
  98. if (string.IsNullOrEmpty(curr_mdtrt_id))
  99. {
  100. curr_mdtrt_id = Global.pat.adm_Dr.ToString();
  101. }
  102. JObject joInpar = new JObject();
  103. joInpar.Add("patnId", p.psn_no);
  104. joInpar.Add("patnName", p.name);
  105. string gend = p.gend;
  106. if (gend == "男") gend = "1";
  107. if (gend == "女") gend = "2";
  108. joInpar.Add("gend",gend);
  109. joInpar.Add("brdy", p.brdy);
  110. if (p.insuplc_admdvs == "") p.insuplc_admdvs = Global.pat.insuplc_admdvs;
  111. joInpar.Add("poolarea", p.insuplc_admdvs);
  112. joInpar.Add("currMdtrtId", curr_mdtrt_id);
  113. joInpar.Add("encounterDtos", GetFsi_encounter_dtos(trig_scen,p));
  114. //joInpar.Add("fsi_his_data_dto", new JArray());
  115. JArray ja = new JArray();
  116. ja.Add(joInpar);
  117. return ja;
  118. }
  119. catch (Exception ex)
  120. {
  121. MessageBox.Show("GetPatient_dtos:" + ex.Message);
  122. return null;
  123. }
  124. }
  125. public JArray GetFsi_encounter_dtos(string trig_scen, Patients p)
  126. {
  127. try
  128. {
  129. JObject jofsi_encounter_dtos = JObject.FromObject(fsi_encounter_dtos[0]);
  130. JObject joInpar = new JObject();
  131. string mdtrtID = p.mdtrtID;
  132. if (string.IsNullOrEmpty(mdtrtID)) mdtrtID = Global.pat.adm_Dr.ToString();
  133. joInpar.Add("mdtrtId", mdtrtID); //就诊标识
  134. joInpar.Add("medinsId", Global.inf.hospitalNO); //医疗服务机构标识
  135. joInpar.Add("medinsName", Global.inf.hospitalName); //医疗机构名称
  136. joInpar.Add("medinsAdmdvs", Global.inf.areaCode); //医疗机构行政区划编码
  137. joInpar.Add("medinsType", "A"); //医疗服务机构类型
  138. joInpar.Add("medinsLv", "3"); //医疗机构等级
  139. joInpar.Add("wardareaCodg", JsonHelper.getDestValue(jofsi_encounter_dtos, "wardarea_codg")); //病区标识
  140. joInpar.Add("wardno", JsonHelper.getDestValue(jofsi_encounter_dtos, "wardno")); //病房号
  141. joInpar.Add("bedno", JsonHelper.getDestValue(jofsi_encounter_dtos, "bedno")); //病床号
  142. joInpar.Add("admDate", JsonHelper.getDestValue(jofsi_encounter_dtos, "adm_date")); //入院日期
  143. joInpar.Add("dscgDate", JsonHelper.getDestValue(jofsi_encounter_dtos, "dscg_date")); //出院日期
  144. joInpar.Add("dscgMainDiseCodg", JsonHelper.getDestValue(jofsi_encounter_dtos, "dscg_main_dise_codg")); //主诊断编码
  145. joInpar.Add("dscgMainDiseName", JsonHelper.getDestValue(jofsi_encounter_dtos, "dscg_main_dise_name")); //主诊断名称
  146. joInpar.Add("diagnoseDtos", GetFsi_diagnose__dtos(trig_scen, p)); //诊断信息DTO
  147. joInpar.Add("drCodg", JsonHelper.getDestValue(jofsi_encounter_dtos, "dr_codg")); //医师标识
  148. joInpar.Add("admDeptCodg", JsonHelper.getDestValue(jofsi_encounter_dtos, "adm_dept_codg")); //入院科室标识
  149. joInpar.Add("admDeptName", JsonHelper.getDestValue(jofsi_encounter_dtos, "adm_dept_name")); //入院科室名称
  150. joInpar.Add("dscgDeptCodg", JsonHelper.getDestValue(jofsi_encounter_dtos, "dscg_dept_codg")); //出院科室标识
  151. joInpar.Add("dscgDeptName", JsonHelper.getDestValue(jofsi_encounter_dtos, "dscg_dept_name")); //出院科室名称
  152. joInpar.Add("medMdtrtType", JsonHelper.getDestValue(jofsi_encounter_dtos, "med_mdtrt_type")); //就诊类型
  153. string med_type = JsonHelper.getDestValue(jofsi_encounter_dtos, "med_type");
  154. med_type = "21";
  155. joInpar.Add("medType", med_type); //医疗类别
  156. joInpar.Add("orderDtos", GetFsi__order_dtos(trig_scen,p)); //处方(医嘱)信息
  157. string matn_stas = JsonHelper.getDestValue(jofsi_encounter_dtos, "matn_stas");
  158. if (string.IsNullOrEmpty(matn_stas)) matn_stas = "0";
  159. joInpar.Add("matnStas", matn_stas ); //生育状态
  160. joInpar.Add("medfeeSumamt", JsonHelper.getDestValue(jofsi_encounter_dtos, "medfee_sumamt")); //总费用
  161. joInpar.Add("ownpayAmt", JsonHelper.getDestValue(jofsi_encounter_dtos, "ownpay_amt")); //自费金额
  162. joInpar.Add("selfpayAmt", JsonHelper.getDestValue(jofsi_encounter_dtos, "selfpay_amt")); //自付金额
  163. joInpar.Add("acctPayamt", JsonHelper.getDestValue(jofsi_encounter_dtos, "acct_payamt")); //个人账户支付金额
  164. joInpar.Add("maAmt", JsonHelper.getDestValue(jofsi_encounter_dtos, "ma_amt")); //救助金支付金额
  165. joInpar.Add("hifpPayamt", JsonHelper.getDestValue(jofsi_encounter_dtos, "hifp_payamt")); //统筹金支付金额
  166. joInpar.Add("setlTotlnum", JsonHelper.getDestValue(jofsi_encounter_dtos, "setl_totlnum")); //结算总次数
  167. string insutype = JsonHelper.getDestValue(jofsi_encounter_dtos, "insutype");
  168. if (insutype =="") insutype = Global.pat.insuType;
  169. insutype = "310";
  170. joInpar.Add("insutype", insutype); //险种
  171. string reimFlag = JsonHelper.getDestValue(jofsi_encounter_dtos, "reim_flag");
  172. // 报销标志(必填)
  173. if (string.IsNullOrEmpty(reimFlag))
  174. {
  175. reimFlag = "1";
  176. }
  177. joInpar.Add("reimFlag", reimFlag);
  178. // 异地结算标志(必填)
  179. string outSetlFlag = JsonHelper.getDestValue(jofsi_encounter_dtos, "out_setl_flag");
  180. if (string.IsNullOrEmpty(outSetlFlag))
  181. {
  182. outSetlFlag = Utils.isOtherCity()?"1":"0";
  183. }
  184. joInpar.Add("outSetlFlag", outSetlFlag);
  185. joInpar.Add("operationDtos", GetFsi__operation__dtos(trig_scen,p)); //手术操作集合
  186. //济南新增
  187. joInpar.Add("diseNo", ""); //病种编号
  188. joInpar.Add("diseName", ""); //病种名称
  189. joInpar.Add("sincHealLv", ""); //手术切口愈合等级
  190. joInpar.Add("hisMdCnt", "");//历史就诊次数
  191. JArray ja = new JArray();
  192. ja.Add(joInpar);
  193. return ja;
  194. }
  195. catch (Exception ex)
  196. {
  197. MessageBox.Show("GetPatient_dtos:" + ex.Message);
  198. return null;
  199. }
  200. }
  201. public JArray GetFsi_diagnose__dtos(string trig_scen, Patients p)
  202. {
  203. try
  204. {
  205. JArray jaNew = new JArray();
  206. foreach (var jo in fsi_diagnose_dtos)
  207. {
  208. JObject joTmp = new JObject();
  209. joTmp.Add("diseId", JsonHelper.getDestValue((JObject)jo, "dise_id"));
  210. joTmp.Add("inoutDiseType", JsonHelper.getDestValue((JObject)jo, "inout_dise_type"));
  211. joTmp.Add("maindiseFlag", JsonHelper.getDestValue((JObject)jo, "maindise_flag"));
  212. joTmp.Add("diasSrtNo", JsonHelper.getDestValue((JObject)jo, "dias_srt_no"));
  213. joTmp.Add("diseCodg", JsonHelper.getDestValue((JObject)jo, "dise_codg"));
  214. joTmp.Add("diseName", JsonHelper.getDestValue((JObject)jo, "dise_name"));
  215. joTmp.Add("diseDate", JsonHelper.getDestValue((JObject)jo, "dise_date"));
  216. jaNew.Add(jo);
  217. }
  218. return jaNew;
  219. }
  220. catch (Exception ex)
  221. {
  222. MessageBox.Show("GetPatient_dtos:" + ex.Message);
  223. return null;
  224. }
  225. }
  226. public JArray GetFsi__operation__dtos(string trig_scen, Patients p)
  227. {
  228. try
  229. {
  230. JArray jaNew = new JArray();
  231. foreach (var jo in fsi_operation_dtos)
  232. {
  233. JObject joTmp = new JObject();
  234. joTmp.Add("setlListOprnId", JsonHelper.getDestValue((JObject)jo, "setl_list_oprn_id"));
  235. joTmp.Add("oprnCode", JsonHelper.getDestValue((JObject)jo, "oprn_code"));
  236. joTmp.Add("oprnName", JsonHelper.getDestValue((JObject)jo, "oprn_name"));
  237. joTmp.Add("mainOprnFlag", JsonHelper.getDestValue((JObject)jo, "main_oprn_flag"));
  238. joTmp.Add("oprnDate", JsonHelper.getDestValue((JObject)jo, "oprn_date"));
  239. joTmp.Add("anstWay", JsonHelper.getDestValue((JObject)jo, "anst_way"));
  240. joTmp.Add("operDrName", JsonHelper.getDestValue((JObject)jo, "oper_dr_name"));
  241. joTmp.Add("operDrCode", JsonHelper.getDestValue((JObject)jo, "oper_dr_code"));
  242. joTmp.Add("anstDrName", JsonHelper.getDestValue((JObject)jo, "anst_dr_name"));
  243. joTmp.Add("anstDrCode", JsonHelper.getDestValue((JObject)jo, "anst_dr_code"));
  244. jaNew.Add(jo);
  245. }
  246. return jaNew;
  247. }
  248. catch (Exception ex)
  249. {
  250. MessageBox.Show("GetPatient_dtos:" + ex.Message);
  251. return null;
  252. }
  253. }
  254. #region 组织入参
  255. public JArray GetFsi__order_dtos(string trig_scen, Patients p)
  256. {
  257. string errMsg = "";
  258. try
  259. {
  260. for (int i = 0; i < fsi_order_dtos.Count; i++)
  261. {
  262. decimal pric = decimal.Parse(fsi_order_dtos[i]["pric"].ToString());
  263. fsi_order_dtos[i]["pric"] = pric.ToString("#0.00");
  264. fsi_order_dtos[i]["hilist_pric"] = pric.ToString("#0.00");
  265. }
  266. //调用医保平台进行转换
  267. if (mis.convertFsiOrderDtos(fsi_order_dtos, out errMsg) != 0)
  268. {
  269. throw new Exception("转换FsiOrderDtos异常:" + errMsg);
  270. }
  271. else
  272. {
  273. JObject joRtn = JObject.Parse(errMsg);
  274. JArray jaFsiOrderDtos = JArray.FromObject(joRtn["data"]);
  275. JArray jaNew = new JArray();
  276. foreach (var jo in jaFsiOrderDtos)
  277. {
  278. JObject joTmp = new JObject();
  279. joTmp.Add("rxId", JsonHelper.getDestValue((JObject)jo, "rx_id"));
  280. joTmp.Add("rxno", JsonHelper.getDestValue((JObject)jo, "rxno"));
  281. joTmp.Add("grpno", JsonHelper.getDestValue((JObject)jo, "grpno"));
  282. joTmp.Add("longDrordFlag", JsonHelper.getDestValue((JObject)jo, "long_drord_flag"));
  283. joTmp.Add("hilistType", JsonHelper.getDestValue((JObject)jo, "hilist_type"));
  284. joTmp.Add("chrgType", JsonHelper.getDestValue((JObject)jo, "chrg_type"));
  285. joTmp.Add("drordBhvr", JsonHelper.getDestValue((JObject)jo, "drord_bhvr"));
  286. joTmp.Add("hilistCode", JsonHelper.getDestValue((JObject)jo, "hilist_code"));
  287. joTmp.Add("hilistName", JsonHelper.getDestValue((JObject)jo, "hilist_name"));
  288. joTmp.Add("hilistDosform", JsonHelper.getDestValue((JObject)jo, "hilist_dosform"));
  289. string hilistLv = JsonHelper.getDestValue((JObject)jo, "hilist_lv");
  290. joTmp.Add("hilistLv", int.Parse(hilistLv));
  291. joTmp.Add("hilistPric", JsonHelper.getDestValue((JObject)jo, "hilist_pric"));
  292. joTmp.Add("lv1HospItemPric", JsonHelper.getDestValue((JObject)jo, "lv1_hosp_item_pric"));
  293. joTmp.Add("lv2HospItemPric", JsonHelper.getDestValue((JObject)jo, "lv2_hosp_item_pric"));
  294. joTmp.Add("lv3HospItemPric", JsonHelper.getDestValue((JObject)jo, "lv3_hosp_item_pric"));
  295. joTmp.Add("hilistMemo", JsonHelper.getDestValue((JObject)jo, "hilist_memo"));
  296. joTmp.Add("hosplistCode", JsonHelper.getDestValue((JObject)jo, "hosplist_code"));
  297. joTmp.Add("hosplistName", JsonHelper.getDestValue((JObject)jo, "hosplist_name"));
  298. joTmp.Add("hosplistDosform", JsonHelper.getDestValue((JObject)jo, "hosplist_dosform"));
  299. joTmp.Add("cnt", JsonHelper.getDestValue((JObject)jo, "cnt"));
  300. joTmp.Add("pric", JsonHelper.getDestValue((JObject)jo, "pric"));
  301. joTmp.Add("sumamt", JsonHelper.getDestValue((JObject)jo, "sumamt"));
  302. joTmp.Add("ownpayAmt", JsonHelper.getDestValue((JObject)jo, "ownpay_amt"));
  303. joTmp.Add("selfpayAmt", JsonHelper.getDestValue((JObject)jo, "selfpay_amt"));
  304. string spec = JsonHelper.getDestValue((JObject)jo, "spec");
  305. if (string.IsNullOrEmpty(spec))
  306. {
  307. spec = "-";
  308. }
  309. joTmp.Add("spec", spec);
  310. joTmp.Add("specUnt", JsonHelper.getDestValue((JObject)jo, "spec_unt"));
  311. joTmp.Add("drordBegnDate", JsonHelper.getDestValue((JObject)jo, "drord_begn_date"));
  312. joTmp.Add("drordStopDate", JsonHelper.getDestValue((JObject)jo, "drord_stop_date"));
  313. joTmp.Add("drordDeptCodg", JsonHelper.getDestValue((JObject)jo, "drord_dept_codg"));
  314. joTmp.Add("drordDeptName", JsonHelper.getDestValue((JObject)jo, "drord_dept_name"));
  315. joTmp.Add("drordDrCodg", JsonHelper.getDestValue((JObject)jo, "drord_dr_codg"));
  316. joTmp.Add("drordDrName", JsonHelper.getDestValue((JObject)jo, "drord_dr_name"));
  317. joTmp.Add("drordDrProfttl", JsonHelper.getDestValue((JObject)jo, "drord_dr_profttl"));
  318. joTmp.Add("currDrordFlag", JsonHelper.getDestValue((JObject)jo, "curr_drord_flag"));
  319. joTmp.Add("extendOrderMap", JsonHelper.getDestValue((JObject)jo, "extend_order_map"));
  320. jaNew.Add(joTmp);
  321. }
  322. return jaNew;
  323. }
  324. }
  325. catch (Exception ex)
  326. {
  327. MessageBox.Show("GetFsi__order_dtos:" + ex.Message);
  328. return null;
  329. }
  330. }
  331. #endregion
  332. }
  333. }