LisPacs_MR_Bll.cs 37 KB

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