private static HospMst getHosp(AccDbConnection con, int id) { HospMst ret = new HospMst(); // コマンドオブジェクト生成 using (var cmd = con.CreateCommand()) { // SQL生成 // ---------------------------- // SELECT H.id, H.name, H.cd, H.seq // FROM M_Hosp As H // INNER JOIN HospUser HU // ON H.id = HU.hosp_id // WHERE user_id=id // ORDER BY H.cd ASC // ---------------------------- StringBuilder selSQL = new StringBuilder(); selSQL.Append("SELECT"); selSQL.Append(" H.id"); selSQL.Append(",H.name"); selSQL.Append(",H.cd"); selSQL.Append(",H.seq"); selSQL.Append(",H.visible"); selSQL.Append(" FROM"); selSQL.Append(" M_Hosp As H"); selSQL.Append(" INNER JOIN"); selSQL.Append(" HospUser HU"); selSQL.Append(" ON"); selSQL.Append(" H.id = HU.hosp_id"); selSQL.Append(" WHERE"); selSQL.Append(" user_id="); selSQL.Append(cmd.Add(id).ParameterName); selSQL.Append(" ORDER BY"); selSQL.Append(" H.cd"); selSQL.Append(" ASC"); cmd.CommandText = selSQL.ToString(); // SQL実行 using (var dr = cmd.ExecuteReader()) // 該当データがある場合、返却値を設定 if (dr.Read()) { ret.HospID = Convert.ToInt32(dr["id"]); ret.CD = dr["cd"].ToString(); if (dr["name"] != DBNull.Value) { ret.Name = dr["name"].ToString(); } ret.Seq = Convert.ToInt32(dr["seq"]); ret.Visible = Convert.ToInt32(dr["visible"]); } } return(ret); }
public static HospMst GetHosp(int id) { HospMst ret = new HospMst(); // DB接続 using (var con = new AccDbConnection(Conf._settings)) { ret = getHosp(con, id); } return(ret); }
private static HospMst[] getHospList(AccDbConnection con) { List <HospMst> ret = new List <HospMst>(); // コマンドオブジェクト生成 using (var cmd = con.CreateCommand()) { // SQL生成 // ---------------------------- // SELECT H.id, H.name, H.cd, H.seq // FROM M_Hosp As H // INNER JOIN HospUser HU // ON H.id = HU.hosp_id // WHERE user_id=id // ORDER BY H.cd ASC // ---------------------------- StringBuilder selSQL = new StringBuilder(); selSQL.Append("SELECT"); selSQL.Append(" H.id"); selSQL.Append(",H.name"); selSQL.Append(",H.cd"); selSQL.Append(",H.seq"); selSQL.Append(",H.visible"); selSQL.Append(" FROM"); selSQL.Append(" M_Hosp As H"); selSQL.Append(" ORDER BY"); selSQL.Append(" H.cd"); selSQL.Append(" ASC"); cmd.CommandText = selSQL.ToString(); // SQL実行 using (var dr = cmd.ExecuteReader()) // 該当データがある場合、返却値を設定 while (dr.Read()) { HospMst tmp = new HospMst(); tmp.HospID = Convert.ToInt32(dr["id"]); tmp.CD = dr["cd"].ToString(); if (dr["name"] != DBNull.Value) { tmp.Name = dr["name"].ToString(); } tmp.Seq = Convert.ToInt32(dr["seq"]); tmp.Visible = Convert.ToInt32(dr["visible"]); ret.Add(tmp); } } return(ret.ToArray()); }
/// <summary> /// 所属施設取得 /// </summary> /// <param name="id">ユーザID</param> /// <param name="usrMst">o:施設情報クラス</param> /// <returns>処理結果クラス</returns> public ResultData GetHosp_Serv(int id, out HospMst hosMst) { var ret = new ResultData(); hosMst = new HospMst(); try { // 施設情報取得メソッド呼び出し(内部関数) hosMst = Hosp.GetHosp(id); ret.Result = true; } catch (Exception e) { LogControl.WriteLog(LogType.ERR, "GetHosp_Serv", e.Message); ret.Message = e.Message; } return(ret); }
private void WriteCSV(PreOrder order, string msg1, string msg2, string msg3, string msg4, string cntA, string cntB) { string mstPath = ""; string outPath = ""; string orderPath = ""; string outPath_back = ""; string orderPath_back = ""; ServiceIF serv = new ServiceIF(); HospMst[] hospList; HospMst hospMst = new HospMst(); serv.GetHospList_Serv(out hospList); foreach (var hosp in hospList) { if (order.HospID == hosp.HospID) { hospMst = hosp; break; } } mstPath = System.IO.Path.Combine(ConfigurationManager.AppSettings["MastDir"], hospMst.CD + ".csv"); outPath = System.IO.Path.Combine(ConfigurationManager.AppSettings["CsvDir"], hospMst.CD); string backDef = System.IO.Path.Combine(ConfigurationManager.AppSettings["BackDir"], hospMst.CD); backDef = System.IO.Path.Combine(backDef, DateTime.Now.ToString("yyyyMMdd")); if (!System.IO.Directory.Exists(backDef)) { System.IO.Directory.CreateDirectory(backDef); } outPath_back = System.IO.Path.Combine(backDef, "CSV"); if (!System.IO.Directory.Exists(outPath_back)) { System.IO.Directory.CreateDirectory(outPath_back); } if (order.IsEmergency == 1) { orderPath = System.IO.Path.Combine(ConfigurationManager.AppSettings["OrderDir"], "☆緊急☆" + hospMst.Name + "_" + order.OrderID + ".txt"); } else { orderPath = System.IO.Path.Combine(ConfigurationManager.AppSettings["OrderDir"], "【依頼】" + hospMst.Name + "_" + order.OrderID + ".txt"); } orderPath_back = System.IO.Path.Combine(backDef, System.IO.Path.GetFileName(orderPath)); var csvValue = ""; using (var sr = new System.IO.StreamReader(mstPath, System.Text.Encoding.GetEncoding("Shift-JIS"))) { csvValue = sr.ReadLine(); } csvValue = csvValue.Replace("@00", order.PatID); csvValue = csvValue.Replace("@01", order.PatName); csvValue = csvValue.Replace("@02", order.PatName_H); switch (order.Sex) { case 0: csvValue = csvValue.Replace("@03", "O"); break; case 1: csvValue = csvValue.Replace("@03", "M"); break; case 2: csvValue = csvValue.Replace("@03", "F"); break; } csvValue = csvValue.Replace("@04", order.BirthDay); csvValue = csvValue.Replace("@05", order.PatAge.ToString()); csvValue = csvValue.Replace("@06", order.Date); csvValue = csvValue.Replace("@07", order.Time); csvValue = csvValue.Replace("@08", order.Modality); csvValue = csvValue.Replace("@09", order.IsEmergency.ToString()); csvValue = csvValue.Replace("@10", order.Comment); // csvValue = csvValue.Replace("@11", msg + " " + msg3); csvValue = csvValue.Replace("@11", msg3); csvValue = csvValue.Replace("@12", msg4); csvValue = csvValue.Replace("@13", order.IsMail.ToString()); csvValue = csvValue.Replace("@14", hospMst.CD); csvValue = csvValue.Replace("@15", hospMst.Name); csvValue = csvValue.Replace("@16", order.BodyPart); csvValue = csvValue.Replace("@17", order.Type); csvValue = csvValue.Replace("@18", order.OrderID.ToString()); csvValue = csvValue.Replace("@19", cntA); if (string.IsNullOrEmpty(cntB) || string.IsNullOrEmpty(cntB.Trim())) { csvValue = csvValue.Replace("@20", "none"); } else { csvValue = csvValue.Replace("@20", cntB); } var fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff"); using (var sw = new System.IO.StreamWriter(System.IO.Path.Combine(outPath, fileName) + ".csv", false, System.Text.Encoding.GetEncoding("Shift-JIS"))) { sw.WriteLine(csvValue); } var dat = System.IO.File.Create(System.IO.Path.Combine(outPath, fileName) + ".txt"); dat.Close(); if (!string.IsNullOrEmpty(msg3)) { var checkDir = ConfigurationManager.AppSettings["CheckDir"]; var idxFile = System.IO.Path.Combine(checkDir, hospMst.CD + ".txt"); if (!System.IO.File.Exists(idxFile)) { msg3 = ConfigurationManager.AppSettings["CheckVal"] + " " + msg3; using (var sw = new System.IO.StreamWriter(idxFile, false, System.Text.Encoding.GetEncoding("Shift-JIS"))) sw.Close(); } } using (var sw = new System.IO.StreamWriter(orderPath, false, System.Text.Encoding.GetEncoding("Shift-JIS"))) { sw.WriteLine(order.PatID); sw.WriteLine(""); sw.WriteLine("" + order.PatName + "(" + order.PatName_H + ")"); sw.WriteLine(""); sw.WriteLine(order.Modality); sw.WriteLine(""); sw.WriteLine(order.Date); sw.WriteLine(""); sw.WriteLine(msg2); sw.WriteLine(""); sw.WriteLine(msg3); } using (var sw = new System.IO.StreamWriter(System.IO.Path.Combine(outPath_back, fileName) + ".csv", false, System.Text.Encoding.GetEncoding("Shift-JIS"))) { sw.WriteLine(csvValue); } using (var sw = new System.IO.StreamWriter(orderPath_back, false, System.Text.Encoding.GetEncoding("Shift-JIS"))) { sw.WriteLine(order.PatID); sw.WriteLine(""); sw.WriteLine("" + order.PatName + "(" + order.PatName_H + ")"); sw.WriteLine(""); sw.WriteLine(order.Modality); sw.WriteLine(""); sw.WriteLine(order.Date); sw.WriteLine(""); sw.WriteLine(msg2); sw.WriteLine(""); sw.WriteLine(msg3); } }
public ResultData SetEditOrder(string[] values) { ResultData ret = new ResultData(); try { ServiceIF serv = new ServiceIF(); HospMst[] hospList; HospMst hospMst = new HospMst(); serv.GetHospList_Serv(out hospList); foreach (var hosp in hospList) { if (values[0] == hosp.HospID.ToString()) { hospMst = hosp; break; } } LogControl.WriteLog(LogType.ORE, "SetEditOrder", "【変更依頼】 施設ID:" + hospMst.Name + " オーダーID:" + values[1] + " 患者ID:" + values[2] + " モダリティ:" + values[5] + " 検査日:" + values[6]); var fileName = "【変更】" + hospMst.Name + "_" + values[1] + ".txt"; string backDef = System.IO.Path.Combine(ConfigurationManager.AppSettings["BackDir"], hospMst.CD); backDef = System.IO.Path.Combine(backDef, DateTime.Now.ToString("yyyyMMdd")); if (!System.IO.Directory.Exists(backDef)) { System.IO.Directory.CreateDirectory(backDef); } using (var sw = new System.IO.StreamWriter(System.IO.Path.Combine(ConfigurationManager.AppSettings["OrderDir"], fileName))) { sw.WriteLine(values[2]); sw.WriteLine(""); sw.WriteLine("【" + values[3] + "(" + values[4] + ")】"); sw.WriteLine(""); sw.WriteLine(values[5]); sw.WriteLine(""); sw.WriteLine(values[6]); } using (var sw = new System.IO.StreamWriter(System.IO.Path.Combine(backDef, fileName))) { sw.WriteLine(values[2]); sw.WriteLine(""); sw.WriteLine("【" + values[3] + "(" + values[4] + ")】"); sw.WriteLine(""); sw.WriteLine(values[5]); sw.WriteLine(""); sw.WriteLine(values[6]); } ret.Result = true; } catch (Exception e) { ret.Result = false; ret.Message = "処理中に障害が発生いたしました。\nシステム管理者にお問い合わせください。"; LogControl.WriteLog(LogType.ERR, "SetEditOrder", e.Message); } return(ret); }