123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886 |
- using ADODB;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using ZLPlugin_MR.Domain.Units;
- using ZLPlugin_MR.Model;
- using static System.Windows.Forms.AxHost;
- namespace ZLPlugin_MR.ServerImpl
- {
- public class LisPacs_MR_Bll
- {
- /// <summary>
- /// lis是否有互认项目
- /// </summary>
- /// <returns></returns>
- public static void IsLisProject(string zlid, out string code, out int total)
- {
- code = "";
- total = 0;
- string sql = @"Select to_char(Replace(wm_concat(distinct(l.医保编码)),',','#')) Code,Count(1) total
- From 诊疗项目目录 x,诊疗收费关系 y,收费项目目录 z,保险支付项目 m,ZLLPMR.互认项目清单 l
- Where y.诊疗项目id = x.Id
- And z.Id = y.收费项目id
- And m.收费细目id = z.Id
- And l.医保通用编码 = m.项目编码
- And m.险类 = 111
- and x.类别 = 'C'
- And x.Id = {0}";
- sql = string.Format(sql, zlid);
- Log.Info("sql1:" + sql);
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- if (!rd.EOF)
- {
- rd.MoveFirst();
- code = rd.Fields["CODE"].Value.ToString();
- total = int.Parse(rd.Fields["TOTAL"].Value.ToString());
- }
- }
- public static void IsPacsProject(string zlid, out int total, out string type)
- {
- total = 0;
- type = "";
- string sql = @"Select Count(1) As total,b.代码 code From 诊疗项目目录 a,ZLLPMR.字典对码表 b
- Where 分类 ='检查互认项目'
- and a.类别 = 'D' And b.编码 = '{0}'
- group by b.代码";
- sql = string.Format(sql, zlid);
- Log.Info("sql2:" + sql);
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- if (!rd.EOF)
- {
- rd.MoveFirst();
- total = int.Parse(rd.Fields["TOTAL"].Value.ToString());
- type = rd.Fields["CODE"].Value.ToString();
- }
- }
- /// <summary>
- /// 返回诊疗项目ID
- /// </summary>
- /// <param name="rsAdvice"></param>
- /// <returns></returns>
- public static void GetTreatmentId(List<YZData> list, out string codeNo, out List<Codes> listlis, out List<Codes> listPacs, out string billProjectNames)
- {
- //lis = "";
- //lis_id = "";
- //pacs = "";
- //pacs_id = "";
- codeNo = "";
- billProjectNames = "";
- listlis = new List<Codes>();
- listPacs = new List<Codes>();
- for (var i = 0; i < list.Count; i++)
- {
- Log.Info("list.Count " + i);
- if (list[i].诊疗类别 == "C" && list[i].相关ID != "0.0")
- {
- string code = "";
- int total = 0;
- IsLisProject(list[i].诊疗项目ID, out code, out total);
- Log.Info("IsLisProject " + total);
- if (total > 0)
- {
- Codes codes = new Codes();
- codes.id = list[i].相关ID; //原先是 取id 不行
- codes.code = code;
- codes.yzid = list[i].ID;
- codes.zlxmid = list[i].诊疗项目ID;
- listlis.Add(codes);
- //lis += list[i].诊疗项目ID + ",";
- //lis_id += list[i].ID + ",";
- codeNo += code + "#";
- Log.Info("codeNo " + codeNo);
- billProjectNames += list[i].医嘱内容 + "、";
- }
- }
- else if (list[i].诊疗类别 == "D" && list[i].相关ID != "0.0")
- {
- //pacs = list[i].诊疗项目ID + ",";
- //pacs_id = list[i].ID + ",";
- int total = 0;
- string type = "";
- //IsPacsProject(list[i].诊疗项目ID, out total, out type);
- String param = list[i].诊疗项目ID + "_" + list[i].标本部位 + "_" + list[i].检查方法;
- Log.Info("param==" + param);
- IsPacsProject(param, out total, out type);
- if (total > 0)
- {
- Codes codes = new Codes();
- codes.id = list[i].相关ID;
- codes.type = type;
- codes.code = type;
- codes.yzid = list[i].ID;
- codes.zlxmid = list[i].诊疗项目ID;
- codes.zxksid = list[i].执行科室ID;
- codes.part = list[i].标本部位;
- codes.method = list[i].检查方法;
- listPacs.Add(codes);
- codeNo += type + "#";
- Log.Info("codeNo " + codeNo);
- billProjectNames += list[i].医嘱内容 + "_" + list[i].标本部位 + "_" + list[i].检查方法 + "、";
- }
- }
- }
- //lis = lis.Length > 0 ? lis.Substring(0, lis.Length - 1) : lis;
- codeNo = codeNo.Length > 0 ? codeNo.Substring(0, codeNo.Length - 1) : codeNo;
- billProjectNames = billProjectNames.Length > 0 ? billProjectNames.Substring(0, billProjectNames.Length - 1) : billProjectNames;
- //pacs = pacs.Length > 0 ? pacs.Substring(0, pacs.Length - 1) : pacs;
- //lis_id = lis_id.Length > 0 ? lis_id.Substring(0, lis_id.Length - 1) : lis_id;
- //pacs_id = pacs_id.Length > 0 ? pacs_id.Substring(0, pacs_id.Length - 1) : pacs_id;
- }
- /// <summary>
- /// 住院
- /// </summary>
- /// <param name="lngPatientID"></param>
- /// <param name="ZYID"></param>
- /// <param name="standardItemId"></param>
- /// <returns></returns>
- public static Recordset GetZYPostJson(long lngPatientID, long ZYID, string no, int type,string totalPrice,string xgid)
- {
- string sql = @"Select distinct a.姓名 ""PatientName"",
- b.身份证号 ""PatientIdCard"",
- e.机构编码 ""jzOrgCode"",
- e.机构名称 ""jzOrgName"",
- c.编号 ""jzDoctorCode"",
- c.姓名 ""jzDoctorName"",
- d.编码 ""jzDeptCode"",
- d.名称 ""jzDeptName"",
- a.住院号 ""businessNumber"",
- '{2}' ""standardItemId"",
- TO_CHAR(SYSDATE-30, 'YYYY-MM-DD HH24:MI:SS') ""reportStartTime"",
- TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') ""reportEndTime"",
- '{3}' ""hrType"",
- TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') ""applyTime"",
- '{4}' ""hisApplyCode"",
- '2' ""patientType"",
- '{5}' ""totalAmount""
- From 病案主页 a,病人信息 b, 人员表 c,部门表 d,ZLLPMR.互认配置表 e
- Where b.病人id = a.病人id
- And c.姓名 = a.住院医师
- And d.Id = a.入院科室id
- And a.病人id = {0} And a.主页id = {1}";
- sql = string.Format(sql, lngPatientID, ZYID, no, type, xgid, totalPrice);
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- return rd;
- }
- /// <summary>
- /// 插入互认开单项目数据
- /// </summary>
- /// <param name="computerName"></param>
- /// <param name="lngPatientID"></param>
- /// <param name="billName"></param>
- /// <param name="lngSendID"></param>
- /// <param name="ip"></param>
- /// <param name="no"></param>
- /// <param name="yzID"></param>
- /// <param name="type"></param>
- /// <param name="operatorName"></param>
- /// <returns></returns>
- public static int InsertHuRenBillProject(string computerName, long lngPatientID, string billName, long lngSendID, string ip, string no, string yzXgID, string type, string operatorName, string patientSource)
- {
- string sql = @"Insert Into 互认开单项目(计算机名,患者id,开单项目,开单时间,发送号,计算机IP,单据号,相关id,类别,开单人,病人来源)
- Values('{0}','{1}','{2}',to_date('{3}','yyyy-mm-dd hh24:mi:ss'),{4},'{5}','{6}','{7}','{8}','{9}','{10}')";
- sql = string.Format(sql, computerName, lngPatientID, billName, DateTime.Now, lngSendID, ip, no, yzXgID, type, operatorName, patientSource);
- Log.Info("InsertLis:" + sql);
- int res = Tools.ExecuteSql(sql);
- return res;
- }
- public static string GetZYTotalPrice(string zlxmid)
- {
- string sql = @"Select sum(现价) 金额 from 收费价目 where 收费细目id in (select 收费项目id from 诊疗收费关系 where 诊疗项目id = {0} )";
- sql = string.Format(sql, zlxmid);
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- if (!rd.EOF)
- {
- rd.MoveFirst();
- return rd.Fields["金额"].Value.ToString();
- }
- return "";
- }
- public static string GetMZTotalPrice(long lngPatientID, string YZID)
- {
- string sql = @"Select nvl(sum(a.实收金额),'0') 金额 from 门诊费用记录 a,病人医嘱记录 b where a.医嘱序号 = b.id and b.病人id ={0} and b.id = {1}";
- sql = string.Format(sql, lngPatientID, YZID);
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- if (!rd.EOF)
- {
- rd.MoveFirst();
- return rd.Fields["金额"].Value.ToString();
- }
- return "";
- }
- public static string GetTotalPriceForLisByZLXM(string zlxmid)
- {
- string sql = @"Select nvl(sum(现价),'0') 金额 from 收费价目 where 终止日期 > sysdate and 收费细目id in (select 收费项目id from 诊疗收费关系 where 诊疗项目id = {0} )";
- sql = string.Format(sql, zlxmid);
- Log.Info("GetTotalPriceForLisByZLXM==" + sql);
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- if (!rd.EOF)
- {
- rd.MoveFirst();
- return rd.Fields["金额"].Value.ToString();
- }
- return "0";
- }
- public static decimal GetTotalPriceForLisByZlxmIds(string zlxmids)
- {
- string sql = @"Select nvl(sum(现价),'0') 金额 from 收费价目 where 终止日期 > sysdate and 收费细目id in (select 收费项目id from 诊疗收费关系 where 诊疗项目id in ({0}) )";
- sql = string.Format(sql, zlxmids);
- Log.Info("GetTotalPriceForLisByZLXM==" + sql);
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- if (!rd.EOF)
- {
- rd.MoveFirst();
- decimal amount = Convert.ToDecimal(rd.Fields["金额"].Value.ToString());
- return amount;
- }
- return 0;
- }
- //获取诊疗项目ids
- public static string GetZlxmIdFromList(List<Codes> list)
- {
- string zlxmids = "";
- for (var i = 0; i < list.Count; i++)
- {
- zlxmids += list[i].zlxmid + ",";
- }
- zlxmids = zlxmids.Length > 0 ? zlxmids.Substring(0, zlxmids.Length - 1) : zlxmids;
- return zlxmids;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="zlxmid"> 诊疗项目id</param>
- /// <param name="zlksid"> 执行科室id</param>
- /// <param name="part"> 部位</param>
- /// <param name="method"> 方法</param>
- /// <param name="patientResource"> 病人来源 门诊 1 还是住院 2 0 所有</param>
- /// <returns></returns>
- public static decimal GetTotalPriceForPacsByZLXM(string zlxmid, string zlksid, string part, string method, int patientResource)
- {
- string sql = @"select nvl(sum(a.现价* b.收费数量),'0') 金额 from 收费价目 a,(
- select * from 诊疗收费关系 where 诊疗项目id = {0} and ( 适用科室id is null or 适用科室id = {1} )and 检查部位 = '{2}' and 检查方法 = '{3}' and 病人来源 <> {4}
- union all
- select * from 诊疗收费关系 where 诊疗项目id = {0} and 固有对照 = 1 and 适用科室id = {1} and 病人来源 <> {4}
- ) b where a.收费细目id = b.收费项目id and a.终止日期 > sysdate ";
- sql = string.Format(sql, zlxmid, zlksid, part, method, patientResource);
- Log.Info("GetTotalPriceForPacsByZLXM==" + sql);
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- if (!rd.EOF)
- {
- rd.MoveFirst();
- decimal amount = Convert.ToDecimal(rd.Fields["金额"].Value.ToString());
- return amount;
- }
- return 0;
- }
- /// <summary>
- /// 门诊
- /// </summary>
- /// <param name="lngPatientID"></param>
- /// <param name="ZYID"></param>
- /// <param name="standardItemId"></param>
- /// <param name="totalAmount"> 金额</param>
- /// <param name="xgid">相关</param>
- /// <returns></returns>
- public static Recordset GetMZPostJson(long ZYID, string code, int type,string totalAmount, string xgid)
- {
- string sql = @"Select distinct a.姓名 ""PatientName"",
- b.身份证号 ""PatientIdCard"",
- e.机构编码 ""jzOrgCode"",
- e.机构名称 ""jzOrgName"",
- c.编号 ""jzDoctorCode"",
- c.姓名 ""jzDoctorName"",
- d.编码 ""jzDeptCode"",
- d.名称 ""jzDeptName"",
- a.门诊号 ""businessNumber"",
- '{1}' ""standardItemId"",
- TO_CHAR(SYSDATE-30, 'YYYY-MM-DD HH24:MI:SS') ""reportStartTime"",
- TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') ""reportEndTime"",
- '{2}' ""hrType"",
- TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') ""applyTime"",
- '{3}' ""hisApplyCode"",
- '1' ""patientType"",
- '{4}' ""totalAmount""
- From 病人挂号记录 a,病人信息 b, 人员表 c,部门表 d,ZLLPMR.互认配置表 e
- Where b.病人id = a.病人id
- And c.姓名 = a.执行人
- And d.Id = a.执行部门id
- And a.id = {0}";
- sql = string.Format(sql, ZYID, code, type, xgid,totalAmount);
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- return rd;
- }
- public static int InsertLis(LISItem lis, long lngPatientID, long lngClinicID, string date, string no, string yzid)
- {
- string sql = @"Insert Into ZLLPMR.互认_LIS(LISCHECKREPORTID,REPORTNAME,ORGNAME,REPORTTIME,病人ID,主页ID,TIME,OPERATORNO,医嘱id)
- 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}')";
- sql = string.Format(sql, lis.LisCheckReportId, lis.ReportName, lis.OrgName, lis.ReportTime, lngPatientID, lngClinicID, date, no, yzid);
- Log.Info("InsertLis:" + sql);
- int res = Tools.ExecuteSql(sql);
- return res;
- }
- public static void InsertLisItem(ItemListItem item, string id, long lngPatientID, long lngClinicID, string date)
- {
- string sql = @"Insert Into ZLLPMR.互认_LISITEMS(LISCHECKREPORTID,ITEMCODE,ITEMNAME,RESULT,UNIT,HINT,RANGE,STANDARDITEMID,TIME)
- Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',to_date('{8}','yyyy/mm/dd hh24:mi:ss'))";
- sql = string.Format(sql, id, item.ItemCode, item.ItemName, item.Result, item.Unit, item.Hint, item.Range, item.StandardItemId, date);
- Log.Info("InsertLisItem:" + sql);
- Tools.ExecuteSql(sql);
- }
- public static int InsertPacs(PACSItem item, long lngPatientID, long lngClinicID, string no, long yzid)
- {
- string sql = @"Insert Into ZLLPMR.互认_PACS(PACSCHECKREPORTID,ITEMNAME,REPORTTIME,CHECKTYPENAME,POSITIONNAME,STANDARDITEMID,DIAGNOSRESULT,ORGNAME,病人ID,主页ID,TIME,OPERATORNO,医嘱id,REPORTTYPECODE)
- Values('{0}','{1}',to_date('{2}','yyyy/mm/dd hh24:mi:ss'),'{3}','{4}','{5}','{6}','{7}',{8},{9},sysdate,'{10}','{11}','{12}')";
- //var lis = result.ResultText[0].LIS[0];
- 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);
- return Tools.ExecuteSql(sql);
- }
- public static int GetLis(string id)
- {
- int total = 0;
- string sql = @"Select Count(1) as TOTAL From ZLLPMR.互认_LIS Where LISCHECKREPORTID = '{0}'";
- sql = string.Format(sql, id);
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- if (!rd.EOF)
- {
- rd.MoveFirst();
- total = int.Parse(rd.Fields["TOTAL"].Value.ToString());
- }
- return total;
- }
- 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)
- {
- Log.Info("entered SaveData");
- lis_id = -1;
- pacs_id = -1;
- //Log.Info("666");
- var lis = result.ResultText[0].LIS;
- var pacs = result.ResultText[0].PACS;
- bool state = true;
- if (lis != null)
- {
- //Log.Info("777");
- for (int i = 0; i < lis.Count; i++)
- {
- //long yzid = null;
- //string code = lis[i].ItemList[0].StandardItemId;
- for (int j = 0; j < lis[i].ItemList.Count; j++)
- {
- //Log.Info("state:" + state);
- if (!state)
- {
- break;
- }
- foreach (var items in listlis)
- {
- //Log.Info("state666");
- if (items.code.Contains(lis[i].ItemList[j].StandardItemId))
- {
- // Log.Info("items.code:" + items.code);
- //Log.Info("items.id:" + items.id);
- string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- //Log.Info("items.code:" + items.code);
- Log.Info("items.id:" + items.id);
- int res = InsertLis(lis[i], lngPatientID, lngClinicID, date, no, items.id);
- //Log.Info("res:" + res);
- if (res > 0)
- {
- if (lis_id == -1)
- {
- lis_id = long.Parse(items.id);
- }
- //Log.Info("res1");
- for (int k = 0; k < lis[i].ItemList.Count; k++)
- {
- //Log.Info("8888");
- InsertLisItem(lis[i].ItemList[k], lis[i].LisCheckReportId, lngPatientID, lngClinicID, date);
- }
- }
- state = false;
- }
- }
- }
- }
- }
- if (pacs != null)
- {
- long id = long.Parse(listpacs[0].id);
- for (int i = 0; i < pacs.Count; i++)
- {
- foreach (var items in listpacs)
- {
- if (pacs[i].reportTypeCode == items.type)
- {
- id = long.Parse(items.id);
- break;
- }
- }
- int res = InsertPacs(pacs[i], lngPatientID, lngClinicID, no, id);
- if (res > 0)
- {
- if (pacs_id == -1)
- {
- pacs_id = id;
- }
- }
- }
- }
- Log.Info("end SaveData");
- }
- public static void SaveDataNew2(Results result, long lngPatientID, long lngClinicID, string no, List<Codes> listlis, List<Codes> listpacs, out List<long> lis_ids, out List<long> pacs_ids)
- {
- lis_ids = new List<long>();
- pacs_ids = new List<long>();
- var lis = result.ResultText[0].LIS;
- var pacs = result.ResultText[0].PACS;
-
- if (lis != null)
- {
- Log.Info("lis.Count=" + lis.Count);
- foreach (var items in listlis)
- {
- Log.Info("items.id="+ items.id);
- bool state = true;
- for (int i = 0; i < lis.Count; i++)
- {
- Log.Info("state=" + state);
- if (!state)
- {
- break;
- }
- bool flag = true;
- for (int j = 0; j < lis[i].ItemList.Count; j++)
- {
- Log.Info("flag=" + flag);
- //这里判断指标不能循环多次
- if (!flag)
- {
- break;
- }
- if (items.code.Contains(lis[i].ItemList[j].StandardItemId))
- {
- string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- string xgid = items.id;
- int res = InsertLis(lis[i], lngPatientID, lngClinicID, date, no, xgid);
- if (res > 0)
- {
- lis_ids.Add(long.Parse(xgid));
- for (int k = 0; k < lis[i].ItemList.Count; k++)
- {
- InsertLisItem(lis[i].ItemList[k], lis[i].LisCheckReportId, lngPatientID, lngClinicID, date);
- }
- }
- flag = false;
- state = false;
- }
- }
-
- }
- }
- }
- if (pacs != null)
- {
- Log.Info("pacs.Count=" + pacs.Count);
- foreach (var items in listpacs)
- {
- for (int i = 0; i < pacs.Count; i++)
- {
- long id = long.Parse(items.id);
- if (pacs[i].StandardItemId.Contains(items.code))
- {
- int res = InsertPacs(pacs[i], lngPatientID, lngClinicID, no, id);
- if (res > 0)
- {
- pacs_ids.Add(id);
- }
- break;
- }
- }
- }
- }
- }
- /// <summary>
- /// 保存互认数据 原来只支持一单
- /// </summary>
- /// <param name="result"></param>
- /// <param name="lngPatientID"></param>
- /// <param name="lngClinicID"></param>
- /// <param name="no"></param>
- /// <param name="listlis"></param>
- /// <param name="listpacs"></param>
- /// <param name="lis_id"></param>
- /// <param name="pacs_id"></param>
- public static void SaveDataNew(Results result, long lngPatientID, long lngClinicID, string no, List<Codes> listlis, List<Codes> listpacs, out List<long> lis_ids, out List<long> pacs_ids)
- {
- lis_ids = new List<long>();
- pacs_ids = new List<long>();
- var lis = result.ResultText[0].LIS;
- var pacs = result.ResultText[0].PACS;
-
- if (lis != null)
- {
- for (int i = 0; i < lis.Count; i++)
- {
- bool state = true;
- for (int j = 0; j < lis[i].ItemList.Count; j++)
- {
- if (!state)
- {
- break;
- }
- foreach (var items in listlis)
- {
- if (items.code.Contains(lis[i].ItemList[j].StandardItemId))
- {
- //insert 互认_lis
- string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- string xgid = items.id;
- int res = InsertLis(lis[i], lngPatientID, lngClinicID, date, no, xgid);
- if (res > 0)
- {
- lis_ids.Add(long.Parse(xgid));
- for (int k = 0; k < lis[i].ItemList.Count; k++)
- {
- InsertLisItem(lis[i].ItemList[k], lis[i].LisCheckReportId, lngPatientID, lngClinicID, date);
- }
- }
- state = false;
- }
- }
- }
- }
- }
- if (pacs != null)
- {
- long id = long.Parse(listpacs[0].id);
- for (int i = 0; i < pacs.Count; i++)
- {
- id = long.Parse(listpacs[i].id);
- foreach (var items in listpacs)
- {
- if (pacs[i].reportTypeCode == items.type)
- {
- id = long.Parse(items.id);
- break;
- }
- }
- int res = InsertPacs(pacs[i], lngPatientID, lngClinicID, no, id);
- if (res > 0)
- {
- pacs_ids.Add(id);
- }
- }
- }
- }
- /// <summary>
- /// 是否互认
- /// </summary>
- /// <returns></returns>
- public static void IsAgree(out int res, out int date, out int yzzState)
- {
- res = 1;
- date = 20000;
- yzzState = 0;
- try
- {
- string sql = @"Select 互认 As AGREE,WAITINGDATE ,一张纸 From zllpmr.互认配置表";
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- if (!rd.EOF)
- {
- rd.MoveFirst();
- res = int.Parse(rd.Fields["AGREE"].Value.ToString());
- date = int.Parse(rd.Fields["WAITINGDATE"].Value.ToString());
- yzzState = int.Parse(rd.Fields["一张纸"].Value.ToString());
- }
- }
- catch (Exception ex)
- {
- Log.Info(ex.Message);
- Log.Info(ex.StackTrace);
- }
- }
- public static void getUrlYzzCancelMedical(out string url)
- {
- url = "";
- try
- {
- string sql = @"Select 一张纸URL From zllpmr.互认配置表";
- Recordset rd = new Recordset();
- Tools.QueryTable(sql, out rd);
- if (!rd.EOF)
- {
- rd.MoveFirst();
- url = rd.Fields["一张纸URL"].Value.ToString();
- }
- }
- catch (Exception ex)
- {
- Log.Info(ex.Message);
- Log.Info(ex.StackTrace);
- }
- }
- /// <summary>
- /// 仅一张纸使用,查询发送的医嘱
- /// </summary>
- /// <param name="ZYID"></param>
- /// <param name="no"></param>
- /// <param name="type"></param>
- /// <returns></returns>
- public static List<YZData> GetYZList(long fsh)
- {
- string sql = @"select
- to_char(b.ID) as id ,
- decode(b.相关id,null,'0.0',to_char(b.相关id)) as 相关id,
- to_char(b.前提id ) as 前提id,
- to_char(b.病人来源 ) as 病人来源,
- to_char(b.病人id )as 病人id,
- to_char(b.主页id )as 主页id,
- to_char(b.挂号单 )as 挂号单,
- to_char(b.婴儿 )as 婴儿,
- to_char(b.姓名 )as 姓名,
- to_char(b.性别 )as 性别,
- to_char(b.年龄 )as 年龄,
- to_char(b.病人科室id )as 病人科室id,
- to_char(b.序号 )as 序号,
- to_char(b.医嘱状态 )as 医嘱状态,
- to_char(b.医嘱期效 )as 医嘱期效,
- to_char(b.诊疗类别 )as 诊疗类别,
- to_char(b.诊疗项目ID )as 诊疗项目ID,
- to_char(b.标本部位 )as 标本部位,
- to_char(b.检查方法 )as 检查方法,
- to_char(b.收费细目id )as 收费细目id,
- to_char(b.天数 )as 天数,
- to_char(b.单次用量 )as 单次用量,
- to_char(b.总给予量 )as 总给予量,
- to_char(b.医嘱内容 )as 医嘱内容,
- to_char(b.医生嘱托 )as 医生嘱托,
- to_char(b.执行科室ID )as 执行科室ID,
- to_char(b.执行频次 )as 执行频次,
- to_char(b.频率次数 )as 频率次数,
- to_char(b.频率间隔 )as 频率间隔,
- to_char(b.间隔单位 )as 间隔单位,
- to_char(b.执行时间方案 )as 执行时间方案,
- to_char(b.计价特性 )as 计价特性,
- to_char(b.执行性质 )as 执行性质,
- to_char(b.执行标记 )as 执行标记,
- to_char(b.可否分零 )as 可否分零,
- to_char(b.紧急标志 )as 紧急标志,
- to_char(b.开始执行时间,'yyyy-mm-dd hh24:mi:ss' )as 开始执行时间,
- to_char(b.执行终止时间 ,'yyyy-mm-dd hh24:mi:ss' )as 执行终止时间,
- to_char(b.开嘱科室ID )as 开嘱科室ID,
- to_char(b.开嘱医生 )as 开嘱医生,
- to_char(b.开嘱时间 ,'yyyy-mm-dd hh24:mi:ss' )as 开嘱时间,
- to_char(b.摘要) as 摘要
- from 病人医嘱发送 a,病人医嘱记录 b
- where b.id = a.医嘱id and 发送号 = {0} and 诊疗类别 in('D','C')
- ";
- //and NOT EXISTS(select 1 from 病人医嘱记录 where id = b.id and 诊疗类别 = 'D' and 相关id is not null)
- sql = string.Format(sql, fsh);
- Log.Info("医嘱记录=》》"+sql);
- Recordset recordset = new Recordset();
- Tools.QueryTable(sql, out recordset);
- List<YZData> list = new List<YZData>();
- while (!recordset.EOF)
- {
- YZData yz = new YZData();
- yz.ID = recordset.Fields["ID"].Value.ToString();
- yz.相关ID = recordset.Fields["相关ID"].Value.ToString();// yz.3767642yz.,
- yz.前提ID = recordset.Fields["前提ID"].Value.ToString();// yz.0.0yz.,
- yz.病人来源 = recordset.Fields["病人来源"].Value.ToString();// yz.2yz.,
- yz.病人ID = recordset.Fields["病人ID"].Value.ToString();// yz.46688yz.,
- yz.主页ID = recordset.Fields["主页ID"].Value.ToString();// yz.1yz.,
- yz.挂号单 = recordset.Fields["挂号单"].Value.ToString();// yz.yz.,
- yz.婴儿 = recordset.Fields["婴儿"].Value.ToString();// yz.0.0yz.,
- yz.姓名 = recordset.Fields["姓名"].Value.ToString();// yz.王少清yz.,
- yz.性别 = recordset.Fields["性别"].Value.ToString();// yz.男yz.,
- yz.年龄 = recordset.Fields["年龄"].Value.ToString();// yz.86yz.,
- yz.病人科室ID = recordset.Fields["病人科室ID"].Value.ToString();// yz.232yz.,
- yz.序号 = recordset.Fields["序号"].Value.ToString();// yz.87yz.,
- yz.医嘱状态 = recordset.Fields["医嘱状态"].Value.ToString();// yz.-1yz.,
- yz.医嘱期效 = recordset.Fields["医嘱期效"].Value.ToString();// yz.1yz.,
- yz.诊疗类别 = recordset.Fields["诊疗类别"].Value.ToString();// yz.Cyz.,
- yz.诊疗项目ID = recordset.Fields["诊疗项目ID"].Value.ToString();// yz.1890yz.,
- yz.标本部位 = recordset.Fields["标本部位"].Value.ToString();// yz.静脉血yz.,
- yz.检查方法 = recordset.Fields["检查方法"].Value.ToString();// yz.yz.,
- yz.收费细目ID = recordset.Fields["收费细目ID"].Value.ToString();// yz.0.0yz.,
- yz.天数 = recordset.Fields["天数"].Value.ToString();// yz.0.0yz.,
- yz.单次用量 = recordset.Fields["单次用量"].Value.ToString();// yz.0.0yz.,
- yz.总给予量 = recordset.Fields["总给予量"].Value.ToString();// yz.1yz.,
- yz.医嘱内容 = recordset.Fields["医嘱内容"].Value.ToString();// yz.肝功能yz.,
- yz.医生嘱托 = recordset.Fields["医生嘱托"].Value.ToString();// yz.yz.,
- yz.执行科室ID = recordset.Fields["执行科室ID"].Value.ToString();// yz.167yz.,
- list.Add(yz);
- recordset.MoveNext();
- }
- return list;
- }
- public static void CancelYzzNew(long 病人id, long 主医嘱id, int lis, int pacs)
- {
- string sql = @"select c.no ,wm_concat(c.id) FEE_IDS
- from 病人医嘱记录 a, 病人医嘱发送 b, 门诊费用记录 c
- where b.医嘱id = a.id
- and c.医嘱序号 = b.医嘱id
- and a.病人id = {0}
- and (a.id = {1} or a.相关id = {1})
- group by c.no
- ";
- sql = string.Format(sql, 病人id, 主医嘱id);
- Recordset recordset = new Recordset();
- Tools.QueryTable(sql, out recordset);
- string json = "{\"input\":{\"operator_name\":\"\",\"operator_code\":\"\",\"operator_time\":\"\",\"del_list\":[";
- while (!recordset.EOF)
- {
- string no = recordset.Fields["NO"].Value.ToString();
- string fee_ids = recordset.Fields["FEE_IDS"].Value.ToString();
- json += "{\"fee_source\":1,\"fee_bill_type\":1,\"fee_no\":\"" + no + "\",\"del_type\":1,\"serial_num\":\"\",\"exe_sta_nums\":\"\",\"fee_ids\":\""+ fee_ids +"\"},";
- recordset.MoveNext();
- }
- json = json.Substring(0, json.Length - 1);
- json += "]}}";
- //原始调用过程没有作用 改用数据处理平台中转
- //Tools.ExecuteStoredProc(病人id, 主医嘱id, json, lis, pacs);
- int lisMessage = 0;
- int pacsMessage = 0;
- if (lis > 0)
- {
- lisMessage = 1;
- }
- if (pacs > 0)
- {
- pacsMessage = 1;
- }
- YZZCancelDTO zZCancelDTO = new YZZCancelDTO();
- zZCancelDTO.patientId = 病人id.ToString();
- zZCancelDTO.medicalOrderId = 主医嘱id.ToString();
- zZCancelDTO.jsonIn = json;
- zZCancelDTO.lisMessage = lisMessage.ToString();
- zZCancelDTO.pacsMessage = pacsMessage.ToString();
- string url = "http://172.30.0.66:7000/cancelMedicalForYzz";
- getUrlYzzCancelMedical(out url);
- Log.Info("url=" + url);
- string body = JSON.ObjectToJson<YZZCancelDTO>(zZCancelDTO, Encoding.UTF8);
- Log.Info("body==" + body);
- string resultString = HttpUtils.WSCenterData(url, body);
- Log.Info("resultString==" + resultString);
- }
- /// <summary>
- /// 作废医嘱
- /// </summary>
- public static void CancelYz(long 病人id, long 主医嘱id, int lis, int pacs)
- {
- string sql = @"select distinct c.no
- from 病人医嘱记录 a, 病人医嘱发送 b, 门诊费用记录 c
- where b.医嘱id = a.id
- and c.医嘱序号 = b.医嘱id
- and a.病人id = {0}
- and (a.id = {1} or a.相关id = {1})";
- sql = string.Format(sql, 病人id, 主医嘱id);
- Recordset recordset = new Recordset();
- Tools.QueryTable(sql, out recordset);
- string json = "{\"input\":{\"operator_name\":\"\",\"operator_code\":\"\",\"operator_time\":\"\",\"del_list\":[";
- while (!recordset.EOF)
- {
- string no = recordset.Fields["NO"].Value.ToString();
- json += "{\"fee_source\":1,\"fee_bill_type\":1,\"fee_no\":\"" + no + "\",\"del_type\":2,\"serial_num\":\"\",\"exe_sta_nums\":\"\",\"fee_ids\":\"\"},";
- recordset.MoveNext();
- }
- json = json.Substring(0, json.Length - 1);
- json += "]}}";
- //原始调用过程没有作用 改用数据处理平台中转
- //Tools.ExecuteStoredProc(病人id, 主医嘱id, json, lis, pacs);
- int lisMessage = 0;
- int pacsMessage = 0;
- //调有 http
- /* Dictionary<string, string> body = new Dictionary<string, string>();
- body.Add("patientId", 病人id.ToString());
- body.Add("medicalOrderId", 主医嘱id.ToString());
- body.Add("jsonIn", json);
- if (lis > 0)
- {
- lisMessage = 1;
- }
- if (pacs > 0)
- {
- pacsMessage = 1;
- }
- body.Add("lisMessage", lisMessage.ToString());
- body.Add("pacsMessage", pacsMessage.ToString());*/
- if (lis > 0)
- {
- lisMessage = 1;
- }
- if (pacs > 0)
- {
- pacsMessage = 1;
- }
- YZZCancelDTO zZCancelDTO = new YZZCancelDTO();
- zZCancelDTO.patientId = 病人id.ToString();
- zZCancelDTO.medicalOrderId = 主医嘱id.ToString();
- zZCancelDTO.jsonIn = json;
- zZCancelDTO.lisMessage = lisMessage.ToString();
- zZCancelDTO.pacsMessage = pacsMessage.ToString();
- string url = "http://172.30.0.66:7000/cancelMedicalForYzz";
- getUrlYzzCancelMedical(out url);
- Log.Info("url=" + url);
- string body = JSON.ObjectToJson<YZZCancelDTO>(zZCancelDTO, Encoding.UTF8);
- Log.Info("body==" + body);
- string resultString = HttpUtils.WSCenterData(url, body);
- Log.Info("resultString==" + resultString);
- }
- }
- }
|