LisPacs_MR_Bll.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. using ADODB;
  2. using System;
  3. using System.Collections.Generic;
  4. using ZLPlugin_LisPacs_MR.Domain.Units;
  5. using ZLPlugin_LisPacs_MR.Model;
  6. namespace ZLPlugin_LisPacs_MR
  7. {
  8. public class LisPacs_MR_Bll
  9. {
  10. /// <summary>
  11. /// lis是否有互认项目
  12. /// </summary>
  13. /// <returns></returns>
  14. public static void IsLisProject(string zlid, out string code, out int total)
  15. {
  16. code = "";
  17. total = 0;
  18. string sql = @"Select to_char(Replace(wm_concat(distinct(l.医保编码)),',','#')) Code,Count(1) total
  19. From 诊疗项目目录 x,诊疗收费关系 y,收费项目目录 z,保险支付项目 m,ZLLPMR.互认项目清单 l
  20. Where y.诊疗项目id = x.Id
  21. And z.Id = y.收费项目id
  22. And m.收费细目id = z.Id
  23. And l.医保通用编码 = m.项目编码
  24. And m.险类 = 111
  25. and x.类别 = 'C'
  26. And x.Id = {0}";
  27. sql = string.Format(sql, zlid);
  28. //Log.Info("sql1:" + sql);
  29. Recordset rd = new Recordset();
  30. Tools.QueryTable(sql, out rd);
  31. if (!rd.EOF)
  32. {
  33. rd.MoveFirst();
  34. code = rd.Fields["CODE"].Value.ToString();
  35. total = int.Parse(rd.Fields["TOTAL"].Value.ToString());
  36. }
  37. }
  38. public static void IsPacsProject(string zlid, out int total,out string type)
  39. {
  40. total = 0;
  41. type = "";
  42. string sql = @"Select Count(1) As total,b.代码 code From 诊疗项目目录 a,ZLLPMR.字典对码表 b
  43. Where 分类 ='检查互认项目'
  44. and a.类别 = 'D' And b.编码 = '{0}'
  45. group by b.代码";
  46. sql = string.Format(sql, zlid);
  47. Log.Info("sql2:" + sql);
  48. Recordset rd = new Recordset();
  49. Tools.QueryTable(sql, out rd);
  50. if (!rd.EOF)
  51. {
  52. rd.MoveFirst();
  53. total = int.Parse(rd.Fields["TOTAL"].Value.ToString());
  54. type = rd.Fields["CODE"].Value.ToString();
  55. }
  56. }
  57. public static void HandleYzData(List<YZData> list, long patientId,long limit_day ,out string message)
  58. {
  59. Log.Info("enter HandleYzData = "+ list.Count);
  60. message = "";
  61. //存在互认的医嘱
  62. int existHuRemYz = 0;
  63. for (var i = 0; i < list.Count; i++)
  64. {
  65. if (list[i].诊疗类别 == "C" && list[i].相关ID != "0.0")
  66. {
  67. LisPacs_MR_Bll.GetHuRenYzData(patientId, list[i].诊疗项目ID, list[i].诊疗类别, limit_day,out existHuRemYz);
  68. if (existHuRemYz>=1)
  69. {
  70. message = list[i].医嘱内容;
  71. //return message;
  72. }
  73. }
  74. else if (list[i].诊疗类别 == "D" && list[i].相关ID == "0.0")
  75. {
  76. LisPacs_MR_Bll.GetHuRenYzData(patientId, list[i].诊疗项目ID, list[i].诊疗类别, limit_day, out existHuRemYz);
  77. if (existHuRemYz >= 1)
  78. {
  79. message = list[i].医嘱内容;
  80. //return message;
  81. }
  82. }
  83. }
  84. Log.Info("end HandleYzData = " + message);
  85. //return message;
  86. }
  87. /// <summary>
  88. /// 返回诊疗项目ID
  89. /// </summary>
  90. /// <param name="rsAdvice"></param>
  91. /// <returns></returns>
  92. public static void GetTreatmentId(List<YZData> list,out string codeNo,out List<Codes> listlis, out List<Codes> listPacs)
  93. {
  94. //lis = "";
  95. //lis_id = "";
  96. //pacs = "";
  97. //pacs_id = "";
  98. codeNo = "";
  99. listlis = new List<Codes>();
  100. listPacs = new List<Codes>();
  101. for (var i = 0; i < list.Count; i++)
  102. {
  103. if (list[i].诊疗类别 == "C" && list[i].相关ID != "0.0")
  104. {
  105. string code = "";
  106. int total = 0;
  107. IsLisProject(list[i].诊疗项目ID, out code, out total);
  108. if (total > 0)
  109. {
  110. Codes codes = new Codes();
  111. codes.id = list[i].相关ID; //原先是 取id 不行
  112. codes.code = code;
  113. codes.yzid = list[i].ID;
  114. codes.zlxmid = list[i].诊疗项目ID;
  115. codes.yzContent = list[i].医嘱内容;
  116. codes.doctorName = list[i].开嘱医生;
  117. listlis.Add(codes);
  118. //lis += list[i].诊疗项目ID + ",";
  119. //lis_id += list[i].ID + ",";
  120. codeNo += code + "#";
  121. }
  122. }
  123. else if (list[i].诊疗类别 == "D" && list[i].相关ID != "0.0")
  124. {
  125. //pacs = list[i].诊疗项目ID + ",";
  126. //pacs_id = list[i].ID + ",";
  127. int total = 0;
  128. string type = "";
  129. //IsPacsProject(list[i].诊疗项目ID, out total, out type);
  130. String param = list[i].诊疗项目ID + "_" + list[i].标本部位 + "_" + list[i].检查方法;
  131. IsPacsProject(param, out total, out type);
  132. if (total >0)
  133. {
  134. Codes codes = new Codes();
  135. codes.id = list[i].相关ID;
  136. codes.type = type;
  137. codes.yzid = list[i].ID;
  138. codes.zlxmid = list[i].诊疗项目ID;
  139. codes.zxksid = list[i].执行科室ID;
  140. codes.part = list[i].标本部位;
  141. codes.method = list[i].检查方法;
  142. codes.yzContent = list[i].医嘱内容 + "_" + list[i].标本部位 + "_" + list[i].检查方法;
  143. codes.doctorName = list[i].开嘱医生;
  144. listPacs.Add(codes);
  145. codeNo += type + "#";
  146. }
  147. }
  148. }
  149. //lis = lis.Length > 0 ? lis.Substring(0, lis.Length - 1) : lis;
  150. codeNo = codeNo.Length > 0 ? codeNo.Substring(0, codeNo.Length - 1) : codeNo;
  151. //pacs = pacs.Length > 0 ? pacs.Substring(0, pacs.Length - 1) : pacs;
  152. //lis_id = lis_id.Length > 0 ? lis_id.Substring(0, lis_id.Length - 1) : lis_id;
  153. //pacs_id = pacs_id.Length > 0 ? pacs_id.Substring(0, pacs_id.Length - 1) : pacs_id;
  154. }
  155. /// <summary>
  156. /// 住院
  157. /// </summary>
  158. /// <param name="lngPatientID"></param>
  159. /// <param name="ZYID"></param>
  160. /// <param name="standardItemId"></param>
  161. /// <returns></returns>
  162. public static Recordset GetZYPostJson(long lngPatientID, long ZYID, string no,int type,string totalPrice, string xgid)
  163. {
  164. string sql = @"select * from (Select distinct a.姓名 ""PatientName"",
  165. b.身份证号 ""PatientIdCard"",
  166. e.机构编码 ""jzOrgCode"",
  167. e.机构名称 ""jzOrgName"",
  168. c.编号 ""jzDoctorCode"",
  169. c.姓名 ""jzDoctorName"",
  170. d.编码 ""jzDeptCode"",
  171. d.名称 ""jzDeptName"",
  172. a.住院号 ""businessNumber"",
  173. '{2}' ""standardItemId"",
  174. '' ""reportStartTime"",
  175. '' ""reportEndTime"",
  176. '{3}' ""hrType"",
  177. sysdate ""applyTime"",
  178. '{4}' ""hisApplyCode"",
  179. '2' ""patientType"",
  180. '{5}' ""totalAmount""
  181. From 病案主页 a,病人信息 b, 人员表 c,部门表 d,ZLLPMR.互认配置表 e
  182. Where b.病人id = a.病人id
  183. And c.姓名 = a.住院医师
  184. And d.Id = a.入院科室id
  185. And a.病人id = {0} And a.主页id = {1} ) ";
  186. sql = string.Format(sql, lngPatientID, ZYID, no,type, xgid, totalPrice);
  187. Log.Info("GetZYPostJson==" + sql);
  188. Recordset rd = new Recordset();
  189. Tools.QueryTable(sql, out rd);
  190. return rd;
  191. }
  192. /// <summary>
  193. /// 门诊
  194. /// </summary>
  195. /// <param name="lngPatientID"></param>
  196. /// <param name="ZYID"></param>
  197. /// <param name="standardItemId"></param>
  198. /// <returns></returns>
  199. public static Recordset GetMZPostJson(long ZYID, string no,int type, string totalAmount, string xgId)
  200. {
  201. string sql = @"Select distinct a.姓名 ""PatientName"",
  202. b.身份证号 ""PatientIdCard"",
  203. e.机构编码 ""jzOrgCode"",
  204. e.机构名称 ""jzOrgName"",
  205. c.编号 ""jzDoctorCode"",
  206. c.姓名 ""jzDoctorName"",
  207. d.编码 ""jzDeptCode"",
  208. d.名称 ""jzDeptName"",
  209. a.门诊号 ""businessNumber"",
  210. '{1}' ""standardItemId"",
  211. '' ""reportStartTime"",
  212. '' ""reportEndTime"",
  213. '{2}' ""hrType"",
  214. sysdate ""applyTime"",
  215. '{3}' ""hisApplyCode"",
  216. '1' ""patientType"",
  217. '{4}' ""totalAmount""
  218. From 病人挂号记录 a,病人信息 b, 人员表 c,部门表 d,ZLLPMR.互认配置表 e
  219. Where b.病人id = a.病人id
  220. And c.姓名 = a.执行人
  221. And d.Id = a.执行部门id
  222. And a.id = {0}";
  223. sql = string.Format(sql, ZYID, no,type, xgId, totalAmount);
  224. Log.Info("GetMZPostJson==" + sql);
  225. Recordset rd = new Recordset();
  226. Tools.QueryTable(sql, out rd);
  227. return rd;
  228. }
  229. public static string GetMZTotalPrice(long lngPatientID, string YZID)
  230. {
  231. string sql = @"Select sum(a.实收金额) 金额 from 门诊费用记录 a,病人医嘱记录 b where a.医嘱序号 = b.id and b.病人id ={0} and b.id = {1}";
  232. sql = string.Format(sql, lngPatientID, YZID);
  233. Log.Info("GetMZTotalPrice==" + sql);
  234. Recordset rd = new Recordset();
  235. Tools.QueryTable(sql, out rd);
  236. if (!rd.EOF)
  237. {
  238. rd.MoveFirst();
  239. return rd.Fields["金额"].Value.ToString();
  240. }
  241. return "";
  242. }
  243. public static string GetTotalPriceForLisByZLXM(string zlxmid)
  244. {
  245. string sql = @"Select nvl(sum(现价),'0') 金额 from 收费价目 where 终止日期 > sysdate and 收费细目id in (select 收费项目id from 诊疗收费关系 where 诊疗项目id = {0} )";
  246. sql = string.Format(sql, zlxmid);
  247. Log.Info("GetTotalPriceForLisByZLXM==" + sql);
  248. Recordset rd = new Recordset();
  249. Tools.QueryTable(sql, out rd);
  250. if (!rd.EOF)
  251. {
  252. rd.MoveFirst();
  253. return rd.Fields["金额"].Value.ToString();
  254. }
  255. return "0";
  256. }
  257. /// <summary>
  258. ///
  259. /// </summary>
  260. /// <param name="zlxmid"> 诊疗项目id</param>
  261. /// <param name="zlksid"> 执行科室id</param>
  262. /// <param name="part"> 部位</param>
  263. /// <param name="method"> 方法</param>
  264. /// <param name="patientResource"> 病人来源 门诊 1 还是住院 2 0 所有</param>
  265. /// <returns></returns>
  266. public static string GetTotalPriceForPacsByZLXM(string zlxmid,string zlksid ,string part,string method, int patientResource)
  267. {
  268. string sql = @"select nvl(sum(a.现价* b.收费数量),'0') 金额 from 收费价目 a,(
  269. select * from 诊疗收费关系 where 诊疗项目id = {0} and ( 适用科室id is null or 适用科室id = {1} )and 检查部位 = '{2}' and 检查方法 = '{3}' and 病人来源 <> {4}
  270. union all
  271. select * from 诊疗收费关系 where 诊疗项目id = {0} and 固有对照 = 1 and 适用科室id = {1} and 病人来源 <> {4}
  272. ) b where a.收费细目id = b.收费项目id and a.终止日期 > sysdate ";
  273. sql = string.Format(sql, zlxmid,zlksid, part, method, patientResource);
  274. Log.Info("GetTotalPriceForPacsByZLXM==" + sql);
  275. Recordset rd = new Recordset();
  276. Tools.QueryTable(sql, out rd);
  277. if (!rd.EOF)
  278. {
  279. rd.MoveFirst();
  280. return rd.Fields["金额"].Value.ToString();
  281. }
  282. return "0";
  283. }
  284. public static string GetZYTotalPrice(string zlxmid)
  285. {
  286. string sql = @"Select sum(现价) 金额 from 收费价目 where 收费细目id in (select 收费项目id from 诊疗收费关系 where 诊疗项目id = {0} )";
  287. sql = string.Format(sql, zlxmid);
  288. Recordset rd = new Recordset();
  289. Tools.QueryTable(sql, out rd);
  290. if (!rd.EOF)
  291. {
  292. rd.MoveFirst();
  293. return rd.Fields["金额"].Value.ToString();
  294. }
  295. return "";
  296. }
  297. /// <summary>
  298. /// 判断之前是否开个互认医嘱
  299. /// </summary>
  300. /// <param name="patientId"></param>
  301. /// <param name="zlId"></param>
  302. /// <param name="zlType"></param>
  303. /// <param name="limitDay"></param>
  304. /// <param name="existHuRemYz"></param>
  305. public static void GetHuRenYzData( long patientId ,string zlId,string zlType, long limitDay,out int existHuRemYz)
  306. {
  307. Log.Info("GetHuRenYzData");
  308. existHuRemYz = 0;
  309. try
  310. {
  311. string sql = @"Select count(1) count
  312. From 病人医嘱记录 where 病人id={0} and 诊疗项目id = {1} and 诊疗类别 ='{2}' and 开嘱时间 > sysdate -{3} and 医嘱内容 like '%【互认】' ";
  313. sql = string.Format(sql, patientId, zlId, zlType, limitDay);
  314. Log.Info(sql);
  315. Recordset rd = new Recordset();
  316. Tools.QueryTable(sql, out rd);
  317. if (!rd.EOF)
  318. {
  319. rd.MoveFirst();
  320. existHuRemYz = int.Parse(rd.Fields["count"].Value.ToString());
  321. }
  322. }catch(Exception ex)
  323. {
  324. Log.Info("GetHuRenYzData Exception" + ex.Message);
  325. existHuRemYz = 0;
  326. }
  327. }
  328. /// <summary>
  329. /// 插入互认开单项目数据
  330. /// </summary>
  331. /// <param name="computerName"></param>
  332. /// <param name="lngPatientID"></param>
  333. /// <param name="billName"></param>
  334. /// <param name="lngSendID"></param>
  335. /// <param name="ip"></param>
  336. /// <param name="no"></param>
  337. /// <param name="yzID"></param>
  338. /// <param name="type"></param>
  339. /// <param name="operatorName"></param>
  340. /// <returns></returns>
  341. public static int InsertHuRenBillProject(string computerName, long lngPatientID, string billName,long lngSendID, string ip, string no, string yzXgID, string type, string operatorName)
  342. {
  343. string sql = @"Insert Into 互认开单项目(计算机名,患者id,开单项目,开单时间,发送号,计算机IP,单据号,相关id,类别,开单人)
  344. Values('{0}','{1}','{2}',to_date('{3}','yyyy/mm/dd hh24:mi:ss'),'{4}','{5}','{6}','{7}','{8}','{9}')";
  345. sql = string.Format(sql, computerName, lngPatientID, billName, DateTime.Now, lngSendID, ip, no, yzXgID, type, operatorName);
  346. Log.Info("InsertLis:" + sql);
  347. int res = Tools.ExecuteSql(sql);
  348. return res;
  349. }
  350. public static int InsertLis(LISItem lis, long lngPatientID, long lngClinicID, string date, string no,long yzXgID)
  351. {
  352. string sql = @"Insert Into ZLLPMR.互认_LIS(LISCHECKREPORTID,REPORTNAME,ORGNAME,REPORTTIME,病人ID,主页ID,TIME,OPERATORNO,医嘱id)
  353. Values('{0}','{1}','{2}',to_date('{3}','yyyy/mm/dd hh24:mi:ss'),{4},{5},to_date('{6}','yyyy/mm/dd hh24:mi:ss'),'{7}',{8})";
  354. sql = string.Format(sql, lis.LisCheckReportId, lis.ReportName, lis.OrgName, lis.ReportTime, lngPatientID, lngClinicID, date, no, yzXgID);
  355. Log.Info("InsertLis:" + sql);
  356. int res = Tools.ExecuteSql(sql);
  357. return res;
  358. }
  359. public static void InsertLisItem(ItemListItem item, string id, long lngPatientID, long lngClinicID, string date)
  360. {
  361. string sql = @"Insert Into ZLLPMR.互认_LISITEMS(LISCHECKREPORTID,ITEMCODE,ITEMNAME,RESULT,UNIT,HINT,RANGE,STANDARDITEMID,TIME)
  362. Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',to_date('{8}','yyyy/mm/dd hh24:mi:ss'))";
  363. sql = string.Format(sql, id, item.ItemCode, item.ItemName, item.Result, item.Unit, item.Hint, item.Range, item.StandardItemId, date);
  364. //Log.Info("InsertLisItem:" + sql);
  365. Tools.ExecuteSql(sql);
  366. }
  367. public static int InsertPacs(PACSItem item, long lngPatientID, long lngClinicID, string no,long yzid)
  368. {
  369. string sql = @"Insert Into ZLLPMR.互认_PACS(PACSCHECKREPORTID,ITEMNAME,REPORTTIME,CHECKTYPENAME,POSITIONNAME,STANDARDITEMID,DIAGNOSRESULT,ORGNAME,病人ID,主页ID,TIME,OPERATORNO,医嘱id,REPORTTYPECODE)
  370. Values('{0}','{1}',to_date('{2}','yyyy/mm/dd hh24:mi:ss'),'{3}','{4}','{5}','{6}','{7}',{8},{9},sysdate,'{10}','{11}','{12}')";
  371. //var lis = result.ResultText[0].LIS[0];
  372. sql = string.Format(sql, item.PacsCheckReportId, item.ItemName, item.ReportTime, item.CheckTypeName, item.PositionName, item.StandardItemId, Tools.FormatStr(item.DiagnosResult), item.OrgName, lngPatientID, lngClinicID, no, yzid, item.reportTypeCode);
  373. Log.Info("InsertPacs==>"+sql);
  374. return Tools.ExecuteSql(sql);
  375. }
  376. public static int GetLis(string id)
  377. {
  378. int total = 0;
  379. string sql = @"Select Count(1) as TOTAL From ZLLPMR.互认_LIS Where LISCHECKREPORTID = '{0}'";
  380. sql = string.Format(sql, id);
  381. Recordset rd = new Recordset();
  382. Tools.QueryTable(sql, out rd);
  383. if (!rd.EOF)
  384. {
  385. rd.MoveFirst();
  386. total = int.Parse(rd.Fields["TOTAL"].Value.ToString());
  387. }
  388. return total;
  389. }
  390. public static void SaveData(Results result, long lngPatientID, long lngClinicID, string no, List<Codes> listlis, List<Codes> listpacs,out long lis_id,out long pacs_id)
  391. {
  392. lis_id = -1;
  393. pacs_id = -1;
  394. //Log.Info("666");
  395. var lis = result.ResultText[0].LIS;
  396. var pacs = result.ResultText[0].PACS;
  397. bool state = true;
  398. if (lis != null)
  399. {
  400. //Log.Info("777");
  401. for (int i = 0; i < lis.Count; i++)
  402. {
  403. //long yzid = null;
  404. //string code = lis[i].ItemList[0].StandardItemId;
  405. for (int j = 0; j < lis[i].ItemList.Count; j++)
  406. {
  407. //Log.Info("state:" + state);
  408. if (!state)
  409. {
  410. break;
  411. }
  412. foreach (var items in listlis)
  413. {
  414. //Log.Info("state666");
  415. // if (items.code.Contains(lis[i].ItemList[j].StandardItemId))
  416. //{
  417. // Log.Info("items.code:" + items.code);
  418. //Log.Info("items.id:" + items.id);
  419. string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  420. //Log.Info("items.code:" + items.code);
  421. //Log.Info("items.id:" + items.id);
  422. int res = InsertLis(lis[i], lngPatientID, lngClinicID, date, no, long.Parse(items.id));
  423. //Log.Info("res:" + res);
  424. if (res > 0)
  425. {
  426. if (lis_id == -1)
  427. {
  428. lis_id = long.Parse(items.id);
  429. }
  430. //Log.Info("res1");
  431. for (int k = 0; k < lis[i].ItemList.Count; k++)
  432. {
  433. //Log.Info("8888");
  434. InsertLisItem(lis[i].ItemList[k], lis[i].LisCheckReportId, lngPatientID, lngClinicID, date);
  435. }
  436. }
  437. state = false;
  438. // }
  439. }
  440. }
  441. }
  442. }
  443. if (pacs != null)
  444. {
  445. long id =long.Parse(listpacs[0].id);
  446. for (int i = 0; i < pacs.Count; i++)
  447. {
  448. foreach (var items in listpacs)
  449. {
  450. if (pacs[i].reportTypeCode == items.type)
  451. {
  452. id = long.Parse(items.id);
  453. break;
  454. }
  455. }
  456. int res = InsertPacs(pacs[i], lngPatientID, lngClinicID, no, id);
  457. if (res > 0)
  458. {
  459. if (pacs_id == -1)
  460. {
  461. pacs_id = id;
  462. }
  463. }
  464. }
  465. }
  466. }
  467. /// <summary>
  468. /// 是否互认
  469. /// </summary>
  470. /// <returns></returns>
  471. public static void IsAgree(out int res,out int date,out int yzzState)
  472. {
  473. res = 1;
  474. date = 20000;
  475. yzzState = 0;
  476. try
  477. {
  478. string sql = @"Select 互认 As AGREE,WAITINGDATE From zllpmr.互认配置表";
  479. Recordset rd = new Recordset();
  480. Tools.QueryTable(sql, out rd);
  481. if (!rd.EOF)
  482. {
  483. rd.MoveFirst();
  484. res = int.Parse(rd.Fields["AGREE"].Value.ToString());
  485. date = int.Parse(rd.Fields["WAITINGDATE"].Value.ToString());
  486. //yzzState = int.Parse(rd.Fields["一张纸"].Value.ToString());
  487. }
  488. }
  489. catch (Exception ex)
  490. {
  491. Log.Info(ex.Message);
  492. Log.Info(ex.StackTrace);
  493. }
  494. }
  495. public static void getUrlYzzCancelMedical(out string url)
  496. {
  497. url = "";
  498. try
  499. {
  500. string sql = @"Select 一张纸URL From zllpmr.互认配置表";
  501. Recordset rd = new Recordset();
  502. Tools.QueryTable(sql, out rd);
  503. if (!rd.EOF)
  504. {
  505. rd.MoveFirst();
  506. url = int.Parse(rd.Fields["一张纸URL"].Value.ToString());
  507. }
  508. }
  509. catch (Exception ex)
  510. {
  511. Log.Info(ex.Message);
  512. Log.Info(ex.StackTrace);
  513. }
  514. }
  515. /// <summary>
  516. /// 是否互认
  517. /// </summary>
  518. /// <returns></returns>
  519. public static void ExistHuRemYz(out long limit_day)
  520. {
  521. limit_day = 1;
  522. try
  523. {
  524. string sql = @"Select limit_day From zllpmr.互认配置表";
  525. Recordset rd = new Recordset();
  526. Tools.QueryTable(sql, out rd);
  527. if (!rd.EOF)
  528. {
  529. rd.MoveFirst();
  530. limit_day = long.Parse(rd.Fields["limit_day"].Value.ToString());
  531. }
  532. }
  533. catch (Exception ex)
  534. {
  535. Log.Info(ex.Message);
  536. Log.Info(ex.StackTrace);
  537. }
  538. }
  539. /// <summary>
  540. /// 仅一张纸使用,查询发送的医嘱
  541. /// </summary>
  542. /// <param name="ZYID"></param>
  543. /// <param name="no"></param>
  544. /// <param name="type"></param>
  545. /// <returns></returns>
  546. public static List<YZData> GetYZList(long fsh)
  547. {
  548. string sql = @"select
  549. to_char(b.ID) as id ,
  550. decode(b.相关id,null,'0.0',to_char(b.相关id)) as 相关id,
  551. to_char(b.前提id ) as 前提id,
  552. to_char(b.病人来源 ) as 病人来源,
  553. to_char(b.病人id )as 病人id,
  554. to_char(b.主页id )as 主页id,
  555. to_char(b.挂号单 )as 挂号单,
  556. to_char(b.婴儿 )as 婴儿,
  557. to_char(b.姓名 )as 姓名,
  558. to_char(b.性别 )as 性别,
  559. to_char(b.年龄 )as 年龄,
  560. to_char(b.病人科室id )as 病人科室id,
  561. to_char(b.序号 )as 序号,
  562. to_char(b.医嘱状态 )as 医嘱状态,
  563. to_char(b.医嘱期效 )as 医嘱期效,
  564. to_char(b.诊疗类别 )as 诊疗类别,
  565. to_char(b.诊疗项目ID )as 诊疗项目ID,
  566. to_char(b.标本部位 )as 标本部位,
  567. to_char(b.检查方法 )as 检查方法,
  568. to_char(b.收费细目id )as 收费细目id,
  569. to_char(b.天数 )as 天数,
  570. to_char(b.单次用量 )as 单次用量,
  571. to_char(b.总给予量 )as 总给予量,
  572. to_char(b.医嘱内容 )as 医嘱内容,
  573. to_char(b.医生嘱托 )as 医生嘱托,
  574. to_char(b.执行科室ID )as 执行科室ID,
  575. to_char(b.执行频次 )as 执行频次,
  576. to_char(b.频率次数 )as 频率次数,
  577. to_char(b.频率间隔 )as 频率间隔,
  578. to_char(b.间隔单位 )as 间隔单位,
  579. to_char(b.执行时间方案 )as 执行时间方案,
  580. to_char(b.计价特性 )as 计价特性,
  581. to_char(b.执行性质 )as 执行性质,
  582. to_char(b.执行标记 )as 执行标记,
  583. to_char(b.可否分零 )as 可否分零,
  584. to_char(b.紧急标志 )as 紧急标志,
  585. to_char(b.开始执行时间,'yyyy-mm-dd hh24:mi:ss' )as 开始执行时间,
  586. to_char(b.执行终止时间 ,'yyyy-mm-dd hh24:mi:ss' )as 执行终止时间,
  587. to_char(b.开嘱科室ID )as 开嘱科室ID,
  588. to_char(b.开嘱医生 )as 开嘱医生,
  589. to_char(b.开嘱时间 ,'yyyy-mm-dd hh24:mi:ss' )as 开嘱时间,
  590. to_char(b.摘要) as 摘要
  591. from 病人医嘱发送 a,病人医嘱记录 b
  592. where b.id = a.医嘱id and 发送号 = {0} and 诊疗类别 in('D','C')
  593. and NOT EXISTS(select 1 from 病人医嘱记录 where id = b.id and 诊疗类别 = 'D' and 相关id is null)";
  594. // and NOT EXISTS(select 1 from 病人医嘱记录 where id = b.id and 诊疗类别 = 'D' and 相关id is not null)
  595. sql = string.Format(sql, fsh);
  596. Recordset recordset = new Recordset();
  597. Tools.QueryTable(sql, out recordset);
  598. List<YZData> list = new List<YZData>();
  599. while (!recordset.EOF)
  600. {
  601. YZData yz = new YZData();
  602. yz.ID = recordset.Fields["ID"].Value.ToString();
  603. yz.相关ID = recordset.Fields["相关ID"].Value.ToString();// yz.3767642yz.,
  604. yz.前提ID = recordset.Fields["前提ID"].Value.ToString();// yz.0.0yz.,
  605. yz.病人来源 = recordset.Fields["病人来源"].Value.ToString();// yz.2yz.,
  606. yz.病人ID = recordset.Fields["病人ID"].Value.ToString();// yz.46688yz.,
  607. yz.主页ID = recordset.Fields["主页ID"].Value.ToString();// yz.1yz.,
  608. yz.挂号单 = recordset.Fields["挂号单"].Value.ToString();// yz.yz.,
  609. yz.婴儿 = recordset.Fields["婴儿"].Value.ToString();// yz.0.0yz.,
  610. yz.姓名 = recordset.Fields["姓名"].Value.ToString();// yz.王少清yz.,
  611. yz.性别 = recordset.Fields["性别"].Value.ToString();// yz.男yz.,
  612. yz.年龄 = recordset.Fields["年龄"].Value.ToString();// yz.86yz.,
  613. yz.病人科室ID = recordset.Fields["病人科室ID"].Value.ToString();// yz.232yz.,
  614. yz.序号 = recordset.Fields["序号"].Value.ToString();// yz.87yz.,
  615. yz.医嘱状态 = recordset.Fields["医嘱状态"].Value.ToString();// yz.-1yz.,
  616. yz.医嘱期效 = recordset.Fields["医嘱期效"].Value.ToString();// yz.1yz.,
  617. yz.诊疗类别 = recordset.Fields["诊疗类别"].Value.ToString();// yz.Cyz.,
  618. yz.诊疗项目ID = recordset.Fields["诊疗项目ID"].Value.ToString();// yz.1890yz.,
  619. yz.标本部位 = recordset.Fields["标本部位"].Value.ToString();// yz.静脉血yz.,
  620. yz.检查方法 = recordset.Fields["检查方法"].Value.ToString();// yz.yz.,
  621. yz.收费细目ID = recordset.Fields["收费细目ID"].Value.ToString();// yz.0.0yz.,
  622. yz.天数 = recordset.Fields["天数"].Value.ToString();// yz.0.0yz.,
  623. yz.单次用量 = recordset.Fields["单次用量"].Value.ToString();// yz.0.0yz.,
  624. yz.总给予量 = recordset.Fields["总给予量"].Value.ToString();// yz.1yz.,
  625. yz.医嘱内容 = recordset.Fields["医嘱内容"].Value.ToString();// yz.肝功能yz.,
  626. yz.医生嘱托 = recordset.Fields["医生嘱托"].Value.ToString();// yz.yz.,
  627. yz.执行科室ID = recordset.Fields["执行科室ID"].Value.ToString();// yz.167yz.,
  628. list.Add(yz);
  629. recordset.MoveNext();
  630. }
  631. return list;
  632. }
  633. /// <summary>
  634. /// 作废医嘱
  635. /// </summary>
  636. public static void CancelYz(long 病人id, long 主医嘱id, int lis, int pacs)
  637. {
  638. string sql = @"select distinct c.no
  639. from 病人医嘱记录 a, 病人医嘱发送 b, 门诊费用记录 c
  640. where b.医嘱id = a.id
  641. and c.医嘱序号 = b.医嘱id
  642. and a.病人id = {0}
  643. and (a.id = {1} or a.相关id = {1})";
  644. sql = string.Format(sql, 病人id, 主医嘱id);
  645. Recordset recordset = new Recordset();
  646. Tools.QueryTable(sql, out recordset);
  647. string json = "{\"input\":{\"operator_name\":\"\",\"operator_code\":\"\",\"operator_time\":\"\",\"del_list\":[";
  648. while (!recordset.EOF)
  649. {
  650. string no = recordset.Fields["NO"].Value.ToString();
  651. json += "{\"fee_source\":1,\"fee_bill_type\":1,\"fee_no\":\""+ no + "\",\"del_type\":2,\"serial_num\":\"\",\"exe_sta_nums\":\"\",\"fee_ids\":\"\"},";
  652. recordset.MoveNext();
  653. }
  654. json = json.Substring(0,json.Length - 1);
  655. json += "]}}";
  656. //原始调用过程没有作用 改用数据处理平台中转
  657. //Tools.ExecuteStoredProc(病人id, 主医嘱id, json, lis, pacs);
  658. int lisMessage = 0;
  659. int pacsMessage = 0;
  660. //调有 http
  661. Dictionary<string, string> body = new Dictionary<string, string>();
  662. body.Add("patientId", 病人id.ToString());
  663. body.Add("medicalOrderId", 主医嘱id.ToString());
  664. body.Add("jsonIn", json);
  665. if (lis>0)
  666. {
  667. lisMessage = 1;
  668. }
  669. if (pacs>0)
  670. {
  671. pacsMessage = 1;
  672. }
  673. body.Add("lisMessage", lisMessage.ToString());
  674. body.Add("pacsMessage", pacsMessage.ToString());
  675. string url = "http://172.30.0.66:7000/cancelMedicalForYzz";
  676. getUrlYzzCancelMedical(out url);
  677. Log.Info("url="+ url);
  678. string resultString = HttpUtils.WSCenterData(url, body.ToString());
  679. Log.Info("resultString==" + resultString);
  680. }
  681. /*public List<BillProjectUpload> GetBillProjects(long lngSendID,string hostName,string patientId)
  682. {
  683. List<BillProjectUpload> billList = new List<BillProjectUpload>();
  684. List<YZData> list = GetYZList(lngSendID);
  685. for (var i = 0; i < list.Count; i++)
  686. {
  687. if (list[i].诊疗类别 == "C" && list[i].相关ID != "0.0")
  688. {
  689. string code = "";
  690. int total = 0;
  691. IsLisProject(list[i].诊疗项目ID, out code, out total);
  692. if (total > 0)
  693. {
  694. //进来才说明是互认项目
  695. BillProjectUpload billProject = new BillProjectUpload();
  696. billProject.billProjectName = list[i].医嘱内容;
  697. billProject.billName = list[i].开嘱医生;
  698. billProject.billTime = DateTime.Now.ToString("yyyy-MM-DD HH:mm:ss");
  699. billProject.billType = "C";
  700. billProject.computerName = hostName;
  701. billProject.patientId = patientId;
  702. billProject.medicId = list[i].ID;
  703. billList.Add(billProject);
  704. }
  705. }
  706. else if (list[i].诊疗类别 == "D" && list[i].相关ID != "0.0")
  707. {
  708. int total = 0;
  709. string type = "";
  710. String param = list[i].诊疗项目ID + "_" + list[i].标本部位 + "_" + list[i].检查方法;
  711. IsPacsProject(param, out total, out type);
  712. if (total > 0)
  713. {
  714. //进来才说明是互认项目
  715. BillProjectUpload billProject = new BillProjectUpload();
  716. billProject.billProjectName = list[i].医嘱内容;
  717. billProject.billName = Infos.UserInfo.编号;
  718. billProject.billTime = DateTime.Now.ToString("yyyy-MM-DD HH:mm:ss");
  719. billProject.billType = "D";
  720. billProject.computerName = hostName;
  721. billProject.patientId = patientId;
  722. billProject.medicId = list[i].ID;
  723. billList.Add(billProject);
  724. }
  725. }
  726. }
  727. if(billList.Count>0)
  728. {
  729. //保存开单数据
  730. }
  731. return billList;
  732. }*/
  733. }
  734. }