ShowDischargeAuditForm.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.Business.Core.Forms.DischargeAudit;
  3. using PTMedicalInsurance.Helper;
  4. using PTMedicalInsurance.Variables;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace PTMedicalInsurance.Business.Core.SelfServiceMachine.Process.InPat
  13. {
  14. class ShowDischargeAuditForm : AbstractProcess
  15. {
  16. AuditForm auditFrm = new AuditForm();
  17. private PTMedicalInsurance.Forms.PatientInsuInfo frmPatientInfo;
  18. private PTMedicalInsurance.Business.Core.Forms.DischargeAudit.AdmissionRegistration admRegForm;
  19. private PTMedicalInsurance.Business.Core.Forms.DischargeAudit.DischargeRegistration disRegForm;
  20. private PTMedicalInsurance.Business.Core.Forms.DischargeAudit.OutpatRegistration outpatRegForm;
  21. private PTMedicalInsurance.Business.Core.Forms.DischargeAudit.GridViewSetter grdSetter = new GridViewSetter();
  22. private PTMedicalInsurance.Business.Core.Forms.DischargeAudit.FeeDetail feeDetailForm = new FeeDetail();
  23. private DataTable dtDisease;
  24. private DataTable dtDiseaseType;
  25. private DataTable dtInsuranceType;
  26. private DataTable dtMedicalType;
  27. private DataTable dtOperation;
  28. private DataTable dtSettelmentWay;
  29. JObject joAuditInfo;
  30. private JArray jaFinalDiagnoses;
  31. private JArray jaAdmRegAuditDetail;
  32. private JArray jaDisRegAuditDetail;
  33. private JArray jaOutpatRegAuditDetail;
  34. private JArray jaFeeDetail;
  35. int admRegAuditDetailCount = 0;
  36. int disRegAuditDetailCount = 0;
  37. int outpatRegAuditDetailCount = 0;
  38. private JObject joHisDiagnoseInfo;
  39. private int auditMethod = 1;
  40. public override CallResult Process(JObject input)
  41. {
  42. Global.writeLog($"billid:{Global.pat.billID}");
  43. auditFrm.tcAudit.TabPages.Remove(auditFrm.tpOutpatRegistration);
  44. if (InitPatienInfoForm(out errMsg) != 0)
  45. {
  46. return Exception(errMsg);
  47. }
  48. GetDBLKComBoxDatasource();
  49. if (GetDiagnoses(out errMsg) !=0)
  50. {
  51. return Exception(errMsg);
  52. }
  53. if (GetDischargeAuditInfo(out errMsg) != 0)
  54. {
  55. return Exception(errMsg);
  56. }
  57. if (InitAdmissionRegistrationForm(out errMsg) !=0)
  58. {
  59. return Exception(errMsg);
  60. }
  61. if (InitDischargeRegistrationForm(out errMsg) !=0)
  62. {
  63. return Exception(errMsg);
  64. }
  65. InitFeeDetailForm();
  66. auditFrm.ConfirmClicked += (sender, e) => { ConfirmClicked(sender, e); };
  67. auditFrm.ShowDialog();
  68. var jo = new { auditStatus = auditFrm.auditStatus ,memo= auditFrm.memo};
  69. outParam = JObject.FromObject(jo).ToString();
  70. if (auditFrm.auditStatus == 1)
  71. {
  72. return Success("审核通过");
  73. }
  74. else if (auditFrm.auditStatus == 0)
  75. {
  76. return Success("暂未审核");
  77. }
  78. else
  79. {
  80. return Success("审核被拒");
  81. }
  82. }
  83. #region 获取数据源
  84. //获取登记界面Combox的数据源
  85. private void GetDBLKComBoxDatasource()
  86. {
  87. //获取通用目录
  88. string sTYML = mIS.GetCommonInterface_Dr(Global.inf.interfaceDr.ToString(), "");
  89. if (sTYML == "")
  90. Global.inf.interfaceDr_TY = Global.inf.interfaceDr;
  91. else
  92. Global.inf.interfaceDr_TY = int.Parse(sTYML);
  93. string sqlCondition = " and A.Interface_Dr = '" + Global.inf.interfaceDr_TY.ToString() + "'";
  94. string sqlStr = "SELECT B.Code,B.Descripts AS Name FROM HB_Dictionary A JOIN HB_DictionaryDataDetail B ON A.ID = B.HBDictionary_Dr WHERE A.InsuCode = 'insutype'" + sqlCondition;
  95. dtInsuranceType = grdSetter.GetDBLKComboxTable(sqlStr);
  96. sqlStr = "select A.Code, A.Name FROM HB_MedInsuDirectory A where A.UseFlag='1' And A.HisType=7" + sqlCondition;
  97. dtDisease = grdSetter.GetDBLKComboxTable(sqlStr);
  98. sqlStr = "select A.Code, A.Name FROM HB_MedInsuDirectory A where A.UseFlag='1' And A.HisType=8" + sqlCondition;
  99. dtOperation = grdSetter.GetDBLKComboxTable(sqlStr);
  100. sqlStr = "SELECT B.Code,B.Descripts AS Name FROM HB_Dictionary A JOIN HB_DictionaryDataDetail B ON A.ID = B.HBDictionary_Dr WHERE A.InsuCode = 'psn_setlway'" + sqlCondition;
  101. dtSettelmentWay = grdSetter.GetDBLKComboxTable(sqlStr);
  102. sqlStr = "SELECT B.Code,B.Descripts AS Name FROM HB_Dictionary A JOIN HB_DictionaryDataDetail B ON A.ID = B.HBDictionary_Dr WHERE A.InsuCode = 'med_type'" + sqlCondition;
  103. dtMedicalType = grdSetter.GetDBLKComboxTable(sqlStr);
  104. }
  105. /// <summary>
  106. /// 获取审核信息,并赋值给全局变量,供其它方法公用
  107. /// </summary>
  108. /// <param name="err"></param>
  109. /// <returns></returns>
  110. private int GetDischargeAuditInfo(out string err)
  111. {
  112. //查询费用核查信息 regType -1表示查询全部明细
  113. if (mIS.queryDischargeAuditInfo(out err) != 0)
  114. {
  115. return -1;
  116. }
  117. else
  118. {
  119. JObject joRtn = JObject.Parse(err);
  120. joAuditInfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "result.AuditInfo"));
  121. jaAdmRegAuditDetail = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.AdmReg"));
  122. jaDisRegAuditDetail = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.DisReg"));
  123. jaOutpatRegAuditDetail = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.OutpatReg"));
  124. admRegAuditDetailCount = int.Parse(JsonHelper.getDestValue(joRtn, "result.AdmRegCount"));
  125. disRegAuditDetailCount = int.Parse(JsonHelper.getDestValue(joRtn, "result.DisRegCount"));
  126. outpatRegAuditDetailCount = int.Parse(JsonHelper.getDestValue(joRtn, "result.OutpatRegCount"));
  127. return 0;
  128. }
  129. }
  130. /// <summary>
  131. /// 获取His的诊断数据,并进行过滤筛选
  132. /// </summary>
  133. /// <param name="err"></param>
  134. /// <returns></returns>
  135. private int GetDiagnoses(out string err)
  136. {
  137. err = "";
  138. //调用服务获取门诊诊断信息
  139. if (hIS.getPatDiagnoses(Global.pat, out err) != 0)
  140. {
  141. return -1;
  142. }
  143. JObject joHisRtnInfo = JObject.Parse(err);
  144. //组织登记入参
  145. JObject joReg = new JObject();
  146. JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joHisRtnInfo, "diseinfo"));
  147. // 对诊断数组进行转换 转换下主要诊断
  148. JArray jaConvertedDiagnoses = new JArray();
  149. JArray jaInPatDiagnoses = new JArray();
  150. JArray jaOutPatDiagnoses = new JArray();
  151. for (int i = 0; i < jaDiagnoses.Count; i++)
  152. {
  153. string diag_type = JsonHelper.getDestValue((JObject)jaDiagnoses[i], "diag_type");
  154. switch (diag_type)
  155. {
  156. case "1":
  157. {
  158. jaDiagnoses[i]["diag_type_name"] = new JObject();
  159. jaDiagnoses[i]["diag_type_name"] = "西医主要诊断";
  160. break;
  161. }
  162. case "2":
  163. {
  164. jaDiagnoses[i]["diag_type_name"] = new JObject();
  165. jaDiagnoses[i]["diag_type_name"] = "西医其他诊断";
  166. break;
  167. }
  168. case "3":
  169. {
  170. jaDiagnoses[i]["diag_type_name"] = new JObject();
  171. jaDiagnoses[i]["diag_type_name"] = "中医主病诊断";
  172. break;
  173. }
  174. case "4":
  175. {
  176. jaDiagnoses[i]["diag_type_name"] = new JObject();
  177. jaDiagnoses[i]["diag_type_name"] = "中医主证诊断";
  178. break;
  179. }
  180. }
  181. if (jaDiagnoses[i]["diaTypeCode"].ToString() == "ADD") //ADD 入院 OPD 门诊
  182. {
  183. jaInPatDiagnoses.Add(jaDiagnoses[i]);
  184. }
  185. if (jaDiagnoses[i]["diaTypeCode"].ToString() == "OPD") //ADD 入院 OPD 门诊
  186. {
  187. jaOutPatDiagnoses.Add(jaDiagnoses[i]);
  188. }
  189. }
  190. if (jaInPatDiagnoses.Count > 0)
  191. {
  192. jaConvertedDiagnoses = (JArray)jaInPatDiagnoses.DeepClone();
  193. }
  194. else
  195. {
  196. jaConvertedDiagnoses = (JArray)jaOutPatDiagnoses.DeepClone();
  197. }
  198. for (int i = 0; i < jaConvertedDiagnoses.Count; i++)
  199. {
  200. jaConvertedDiagnoses[i]["diag_srt_no"] = i + 1;
  201. }
  202. jaFinalDiagnoses = (JArray)jaConvertedDiagnoses.DeepClone();
  203. joHisDiagnoseInfo = (JObject)joHisRtnInfo.DeepClone();
  204. return 0;
  205. }
  206. /// <summary>
  207. /// 获取当前界面的审核明细
  208. /// </summary>
  209. /// <param name="regType"></param>
  210. /// <returns></returns>
  211. private JArray GetAuditDetail(dynamic frm, int regType)
  212. {
  213. var details = new List<object>();
  214. // 添加所有需要的节点
  215. details.Add(new
  216. {
  217. AdmID = Global.pat.adm_Dr,
  218. DetailCode = "insutype",
  219. DetailName = "险种类型",
  220. Value = frm.insuType,
  221. ValueDesc = "",
  222. RegType = regType
  223. });
  224. details.Add(new
  225. {
  226. AdmID = Global.pat.adm_Dr,
  227. DetailCode = "med_type",
  228. DetailName = "医疗类别",
  229. Value = frm.med_type,
  230. ValueDesc = "",
  231. RegType = regType
  232. });
  233. details.Add(new
  234. {
  235. AdmID = Global.pat.adm_Dr,
  236. DetailCode = "dise_codg",
  237. DetailName = "病种编码",
  238. Value = frm.diseCodg,
  239. ValueDesc = "",
  240. RegType = regType
  241. });
  242. details.Add(new
  243. {
  244. AdmID = Global.pat.adm_Dr,
  245. DetailCode = "dise_name",
  246. DetailName = "病种名称",
  247. Value = frm.diseName,
  248. ValueDesc = "",
  249. RegType = regType
  250. });
  251. details.Add(new
  252. {
  253. AdmID = Global.pat.adm_Dr,
  254. DetailCode = "oprn_oprt_code",
  255. DetailName = "手术操作代码",
  256. Value = frm.oprn_oprt_code,
  257. ValueDesc = "",
  258. RegType = regType
  259. });
  260. details.Add(new
  261. {
  262. AdmID = Global.pat.adm_Dr,
  263. DetailCode = "oprn_oprt_name",
  264. DetailName = "手术操作名称",
  265. Value = frm.oprn_oprt_name,
  266. ValueDesc = "",
  267. RegType = regType
  268. });
  269. details.Add(new
  270. {
  271. AdmID = Global.pat.adm_Dr,
  272. DetailCode = "dise_type_code",
  273. DetailName = "病种类型",
  274. Value = frm.dise_type_code,
  275. ValueDesc = "",
  276. RegType = regType
  277. });
  278. details.Add(new
  279. {
  280. AdmID = Global.pat.adm_Dr,
  281. DetailCode = "exp_content",
  282. DetailName = "字段扩展",
  283. Value = frm.dise_type_name,
  284. ValueDesc = "",
  285. RegType = regType
  286. });
  287. details.Add(new
  288. {
  289. AdmID = Global.pat.adm_Dr,
  290. DetailCode = "psn_setlway",
  291. DetailName = "个人结算方式",
  292. Value = frm.psn_setlway,
  293. ValueDesc = "",
  294. RegType = regType
  295. });
  296. // 根据regType决定是否添加最后两个节点
  297. if (regType == 3)
  298. {
  299. details.Add(new
  300. {
  301. AdmID = Global.pat.adm_Dr,
  302. DetailCode = "acct_used_flag",
  303. DetailName = "个人账户使用标志",
  304. Value = frm.personAccountUsedFlag ?? "",
  305. ValueDesc = "",
  306. RegType = regType
  307. });
  308. details.Add(new
  309. {
  310. AdmID = Global.pat.adm_Dr,
  311. DetailCode = "mid_setl_flag",
  312. DetailName = "中途结算标志",
  313. Value = frm.halfwaySettlementFlag,
  314. ValueDesc = "",
  315. RegType = regType
  316. });
  317. }
  318. // 将列表转换为JArray并返回
  319. return JArray.FromObject(details);
  320. }
  321. private int GetFeeDetail(out string err)
  322. {
  323. //调用HIS费用查询信息
  324. if (hIS.getHisFee(Global.pat, out err) != 0)
  325. {
  326. return -1;
  327. }
  328. //调用医保平台转换
  329. JObject joHisFee = JObject.Parse(err);
  330. if (mIS.convertHisFeeWithInsuCode(joHisFee, out err) != 0)
  331. {
  332. return -1;
  333. }
  334. else
  335. {
  336. jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(err), "data"));
  337. return 0;
  338. }
  339. }
  340. #endregion
  341. #region 初始化界面
  342. /// <summary>
  343. /// 初始化患者信息界面
  344. /// </summary>
  345. /// <param name="err"></param>
  346. /// <returns></returns>
  347. private int InitPatienInfoForm(out string err)
  348. {
  349. //获取全量表数据
  350. string sqlStr = $" SELECT * FROM BS_MIPatFullInsuInfo WHERE AdmID = {Global.pat.adm_Dr}";
  351. JObject joRtn = mIS.DynamicQuery(sqlStr, "查询全量信息表");
  352. if (JsonHelper.parseIrisRtnValue(joRtn, out err) != 0)
  353. {
  354. return -1;
  355. }
  356. if (JsonHelper.getDestValue(joRtn, "result.total") == "0")
  357. {
  358. err = "全量信息表为空";
  359. return -1;
  360. }
  361. //转换患者信息
  362. JObject joOutparam = JObject.Parse(JsonHelper.getDestValue(joRtn, "result.data[0].FullInfo"));
  363. JObject joOutput = JObject.Parse(JsonHelper.getDestValue(joOutparam, "output"));
  364. //编码转换
  365. JArray jaConvertCode = new JArray();
  366. JObject joConvertCodeParam = new JObject();
  367. joConvertCodeParam.Add("hospitalDr", Global.inf.hospitalDr);
  368. joConvertCodeParam.Add("interfaceDr", Global.inf.interfaceDr);
  369. joConvertCodeParam.Add("output", joOutput);
  370. jaConvertCode.Add(joConvertCodeParam);
  371. JObject joConvertCode = new JObject();
  372. joConvertCode.Add("code", "09010054");
  373. joConvertCode.Add("params", jaConvertCode);
  374. InvokeHelper invoker = new InvokeHelper();
  375. JObject joConvertCodeRtn = invoker.invokeInsuService(joConvertCode.ToString(), "患者信息编码转换");
  376. frmPatientInfo = new PTMedicalInsurance.Forms.PatientInsuInfo(joConvertCodeRtn, auditFrm);
  377. frmPatientInfo.pnlBottom.Visible = false;
  378. auditFrm.AddForm(auditFrm.tpPatientInfo, frmPatientInfo);
  379. return 0;
  380. }
  381. /// <summary>
  382. /// 初始化入院登记
  383. /// </summary>
  384. /// <param name="err"></param>
  385. /// <returns></returns>
  386. private int InitAdmissionRegistrationForm(out string err)
  387. {
  388. admRegForm = new Forms.DischargeAudit.AdmissionRegistration(auditFrm);
  389. return InitRegistrationForm(2, out err);
  390. }
  391. /// <summary>
  392. /// 初始化出院登记界面
  393. /// </summary>
  394. /// <param name="err"></param>
  395. /// <returns></returns>
  396. private int InitDischargeRegistrationForm(out string err)
  397. {
  398. disRegForm = new Forms.DischargeAudit.DischargeRegistration(auditFrm);
  399. return InitRegistrationForm(3, out err);
  400. }
  401. private int InitFeeDetailForm()
  402. {
  403. GetFeeDetail(out errMsg);
  404. feeDetailForm = new Forms.DischargeAudit.FeeDetail(auditFrm);
  405. feeDetailForm.GetFeeClicked += (sender, e) => GetFeeClicked();
  406. feeDetailForm.UploadFeeClicked += (sender, e) => UploadFeeClicked();
  407. auditFrm.AddForm(auditFrm.tpFeeDetail, feeDetailForm);
  408. return 0;
  409. }
  410. #endregion
  411. #region 初始化界面的细节方法封装
  412. private void DynamicInit(int regType,out int count, out dynamic frm, out dynamic ja)
  413. {
  414. int countTmp;
  415. dynamic jaTmp;
  416. switch (regType)
  417. {
  418. case 1: //门诊登记
  419. frm = outpatRegForm;
  420. ja = jaOutpatRegAuditDetail;
  421. count = outpatRegAuditDetailCount;
  422. break;
  423. case 0://通用
  424. case 2://入院登记
  425. default:
  426. frm = admRegForm;
  427. jaTmp =ja = jaAdmRegAuditDetail;
  428. count = countTmp = admRegAuditDetailCount;
  429. admRegForm.SaveClicked += (sender, e) => HandleSaveClicked(countTmp, jaTmp, admRegForm, regType);
  430. admRegForm.UpdateClicked += (sender, e) => UpdateCenterIpRegInfo();
  431. auditFrm.AddForm(auditFrm.tpAdmissionRegistration, admRegForm);
  432. break;
  433. case 3://出院登记
  434. frm = disRegForm;
  435. jaTmp =ja = jaDisRegAuditDetail;
  436. countTmp =count = disRegAuditDetailCount;
  437. disRegForm.SaveClicked += (sender, e) => HandleSaveClicked(countTmp, jaTmp, disRegForm, regType);
  438. auditFrm.AddForm(auditFrm.tpDischargeRegistration, disRegForm);
  439. break;
  440. }
  441. }
  442. /// <summary>
  443. /// ///初始化登记界面公共方法
  444. /// 事件 场景类型 0.窗口门诊 1.窗口住院 2.自助机门诊 3.自助机住院 4.线上支付门诊 5.线上支付住院
  445. /// 登记类型 0.通用 部分地区门诊出入院都一样 1.门诊登记 2.入院登记 3.出院登记
  446. /// </summary>
  447. /// <param name="regType"></param>
  448. /// <param name="err"></param>
  449. /// <returns></returns>
  450. private int InitRegistrationForm(int regType, out string err)
  451. {
  452. err = "";
  453. dynamic frm;
  454. dynamic ja;
  455. int count = 0;
  456. DynamicInit(regType,out count,out frm,out ja);
  457. frm.DtDisease = dtDisease?.Copy();
  458. frm.DtDiseaseType = dtDiseaseType?.Copy();
  459. frm.DtInsuranceType = dtInsuranceType?.Copy();
  460. frm.DtMedicalType = dtMedicalType?.Copy();
  461. frm.DtOperation = dtOperation?.Copy();
  462. frm.DtSettlementWay = dtSettelmentWay?.Copy();
  463. frm.InitComboxDatasource();
  464. frm.DtDiagnose = (DataTable)jaFinalDiagnoses.ToObject(typeof(DataTable));
  465. return MatchCombox(frm, count, ja, out err);
  466. }
  467. /// <summary>
  468. /// 根据费用核查表返回的数据,加载并匹配到登记界面
  469. /// </summary>
  470. /// <param name="frm"></param>
  471. /// <param name="count"></param>
  472. /// <param name="ja"></param>
  473. /// <param name="err"></param>
  474. /// <returns></returns>
  475. private int MatchCombox(dynamic frm, int count, dynamic ja, out string err)
  476. {
  477. string insuType = "";
  478. string medType = "";
  479. string diseaseCode = "";
  480. string diseaseType = "";
  481. string settlementWay = "";
  482. string operationCode = "";
  483. string acct_used_flag = "-1";
  484. string mid_setl_flag = "-1";
  485. err = "";
  486. //不存在信息则提示
  487. frm.IsHintVisible = count == 0;
  488. //frm.dblkcbxSettelmentWay.Enabled = false;
  489. foreach (JObject jo in ja)
  490. {
  491. if (jo["DetailCode"].ToString() == "insutype")
  492. {
  493. insuType = jo["Value"].ToString();
  494. }
  495. if (jo["DetailCode"].ToString() == "med_type")
  496. {
  497. medType = jo["Value"].ToString();
  498. }
  499. if (jo["DetailCode"].ToString() == "dise_codg")
  500. {
  501. diseaseCode = jo["Value"].ToString();
  502. }
  503. if (jo["DetailCode"].ToString() == "oprn_oprt_code")
  504. {
  505. operationCode = jo["Value"].ToString();
  506. }
  507. if (jo["DetailCode"].ToString() == "dise_type_code")
  508. {
  509. diseaseType = jo["Value"].ToString();
  510. }
  511. if (jo["DetailCode"].ToString() == "mid_setl_flag")
  512. {
  513. mid_setl_flag = jo["Value"].ToString();
  514. }
  515. if (jo["DetailCode"].ToString() == "acct_used_flag")
  516. {
  517. acct_used_flag = jo["Value"].ToString();
  518. }
  519. if (jo["DetailCode"].ToString() == "psn_setlway")
  520. {
  521. settlementWay = jo["Value"].ToString();
  522. }
  523. }
  524. //DataTable dt = (DataTable)frm.dblkcbxInsuranceType.DataSource;
  525. //int selectedIndex = 0;
  526. //for (int i = 0; i < dt.Rows.Count; i++)
  527. //{
  528. // if (dt.Rows[i]["Code"].ToString() == insuType)
  529. // {
  530. // selectedIndex = i;
  531. // frm.dblkcbxInsuranceType.Text = dt.Rows[i]["Name"].ToString();
  532. // frm.insuType = dt.Rows[i]["Code"].ToString();
  533. // }
  534. //}
  535. //DataTable dtMedType = (DataTable)frm.dblkcbxMedicalType.DataSource;
  536. //for (int i = 0; i < dtMedType.Rows.Count; i++)
  537. //{
  538. // if (dtMedType.Rows[i]["Code"].ToString() == medType)
  539. // {
  540. // frm.dblkcbxMedicalType.Text = dtMedType.Rows[i]["Name"].ToString();
  541. // frm.med_type = dtMedType.Rows[i]["Code"].ToString();
  542. // }
  543. //}
  544. MatchCombox(frm, "dblkcbxInsuranceType", "insuType", insuType);
  545. MatchCombox(frm, "dblkcbxMedicalType", "med_type", medType);
  546. MatchCombox(frm, "dblkcbxSettelmentWay", "psn_setlway", settlementWay);
  547. //if (frm is DischargeRegistration)
  548. //{
  549. // DataTable dtPsnSettlWay = (DataTable)frm.dblkcbxSettelmentWay.DataSource;
  550. // for (int i = 0; i < dtPsnSettlWay.Rows.Count; i++)
  551. // {
  552. // if (dtPsnSettlWay.Rows[i]["Code"].ToString() == settlementWay)
  553. // {
  554. // frm.dblkcbxSettelmentWay.Text = dtPsnSettlWay.Rows[i]["Name"].ToString();
  555. // frm.psn_setlway = dtPsnSettlWay.Rows[i]["Code"].ToString();
  556. // }
  557. // }
  558. //}
  559. frm.personAccountUsedFlag = acct_used_flag;
  560. frm.halfwaySettlementFlag = mid_setl_flag;
  561. //审核状态匹配
  562. auditFrm.auditStatus = int.Parse(JsonHelper.getDestValue(joAuditInfo, "AuditStatus"));
  563. auditFrm.memo = JsonHelper.getDestValue(joAuditInfo, "Memo");
  564. return 0;
  565. }
  566. private void MatchCombox(dynamic frm, string comboxName,string propertyName, string value)
  567. {
  568. if (!frm.Controls["panel1"].Controls.ContainsKey(comboxName))
  569. {
  570. return;
  571. }
  572. var cbx = frm.Controls["panel1"].Controls[comboxName];
  573. DataTable dt = (DataTable)cbx.DataSource;
  574. for (int i = 0; i < dt.Rows.Count; i++)
  575. {
  576. if (dt.Rows[i]["Code"].ToString() == value)
  577. {
  578. cbx.Text = dt.Rows[i]["Name"].ToString();
  579. //frm.insuType = dt.Rows[i]["Code"].ToString();
  580. var propertyInfo = frm.GetType().GetProperty(propertyName);
  581. if (propertyInfo != null && propertyInfo.CanWrite)
  582. {
  583. propertyInfo.SetValue(frm, Convert.ChangeType(value, propertyInfo.PropertyType));
  584. }
  585. else
  586. {
  587. throw new ArgumentException($"无法设置属性 '{propertyName}' 或该属性不可写。");
  588. }
  589. }
  590. }
  591. }
  592. #endregion
  593. #region Button事件封装
  594. private void UpdateCenterIpRegInfo()
  595. {
  596. }
  597. /// <summary>
  598. /// 登记界面的保存事件委托
  599. /// </summary>
  600. /// <param name="sender"></param>
  601. /// <param name="e"></param>
  602. /// <param name="frm"></param>
  603. /// <param name="regType"></param>
  604. private void HandleSaveClicked(int count, dynamic ja, dynamic frm, int regType)
  605. {
  606. string errMsg;
  607. if (SaveAuditInfo(frm, regType, out errMsg) != 0)
  608. {
  609. MessageBox.Show(errMsg);
  610. }
  611. else
  612. {
  613. GetDischargeAuditInfo(out errMsg);
  614. DynamicInit(regType, out count, out frm, out ja);
  615. MatchCombox(frm, count, ja, out errMsg);
  616. MessageBox.Show("保存成功");
  617. }
  618. }
  619. /// <summary>
  620. /// 保存审核信息
  621. /// </summary>
  622. /// <param name="regType"></param>
  623. /// <param name="err"></param>
  624. /// <returns></returns>
  625. private int SaveAuditInfo(dynamic frm, int regType, out string err)
  626. {
  627. err = "";
  628. //组织入参
  629. JObject joAudit = new JObject();
  630. joAudit.Add("HospitalDr", Global.inf.hospitalDr);
  631. joAudit.Add("InterfaceDr", Global.inf.interfaceDr);
  632. joAudit.Add("AdmID", Global.pat.adm_Dr);
  633. joAudit.Add("BillID", Global.pat.billID);
  634. joAudit.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  635. //joAudit.Add("Scene", scene);
  636. joAudit.Add("AuditStatus", auditFrm.auditStatus);
  637. joAudit.Add("Memo", auditFrm.rtbMemo.Text);
  638. joAudit.Add("ValidFlag", 1);
  639. joAudit.Add("AuditMethod", auditMethod); //审核方式 0.Manual (人工) 1.Automated (自动审核)
  640. joAudit.Add("AuditorNO", Global.user.ID);
  641. joAudit.Add("Auditor", Global.user.name);
  642. joAudit.Add("RegType", regType);
  643. JArray jaAuditDetail = GetAuditDetail(frm, regType);
  644. joAudit.Add("AuditDetail", jaAuditDetail);
  645. return mIS.saveDischargeAudit(joAudit, out err);
  646. //保存
  647. }
  648. private void ConfirmClicked(object sender, EventArgs e)
  649. {
  650. if ((auditFrm.auditStatus == -1) && (string.IsNullOrEmpty(auditFrm.memo)))
  651. {
  652. MessageBox.Show("审核被拒时审核意见不能为空!");
  653. return;
  654. }
  655. //再次查询审核信息,如果出院意见未有则提示
  656. if (auditFrm.auditStatus == 1)
  657. {
  658. GetDischargeAuditInfo(out errMsg);
  659. if (jaDisRegAuditDetail.Count == 0)
  660. {
  661. MessageBox.Show("检测到出院登记信息未正确保存,请点击保存或联系关联员!");
  662. return;
  663. }
  664. }
  665. //更新费用明细审核表主表
  666. JObject joAudit = new JObject();
  667. joAudit.Add("HospitalDr", Global.inf.hospitalDr);
  668. joAudit.Add("InterfaceDr", Global.inf.interfaceDr);
  669. joAudit.Add("AdmID", Global.pat.adm_Dr);
  670. joAudit.Add("BillID", Global.pat.billID);
  671. joAudit.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  672. joAudit.Add("AuditStatus", auditFrm.auditStatus);
  673. joAudit.Add("AuditMethod", auditMethod); //审核方式 0.Manual (人工) 1.Automated (自动审核)
  674. joAudit.Add("AuditorNO", Global.user.ID);
  675. joAudit.Add("Auditor", Global.user.name);
  676. joAudit.Add("Memo", auditFrm.memo);
  677. joAudit.Add("ValidFlag", 1);
  678. if (mIS.saveDischargeAuditMaintable(joAudit, out outParam) != 0)
  679. {
  680. MessageBox.Show("出院审核表更新失败!");
  681. return;
  682. }
  683. auditFrm.DialogResult = DialogResult.OK;
  684. }
  685. private void GetFeeClicked()
  686. {
  687. if (jaFeeDetail == null)
  688. {
  689. if(GetFeeDetail(out errMsg) !=0)
  690. {
  691. MessageBox.Show(errMsg);
  692. }
  693. }
  694. else
  695. {
  696. feeDetailForm.jaFeeDetail = jaFeeDetail ;
  697. }
  698. }
  699. private void UploadFeeClicked()
  700. {
  701. //按指定条数分割后上传,保存,更新
  702. if (jaFeeDetail == null)
  703. {
  704. MessageBox.Show("费用明细为空,请重新获取费用明细或联系管理员!");
  705. return;
  706. }
  707. if (hBus.uploadFeeToCenter(TradeEnum.InpatientFeeUpload, 10, jaFeeDetail, out errMsg) != 0)
  708. {
  709. MessageBox.Show(errMsg);
  710. }
  711. else
  712. {
  713. MessageBox.Show("上传成功");
  714. }
  715. }
  716. #endregion
  717. }
  718. }