using HL_FristAidPlatform_Help; using HL_FristAidPlatform_IDataBase; using HL_FristAidPlatform_Models; using Newtonsoft.Json; using SqlSugar; using System.Collections.Generic; using System.Data; namespace HL_FristAidPlatform_DataBase { /// /// 胸痛诊疗 /// public class T_Service_Trauma_FirstAidInfoDB : BaseDB, IT_Service_Trauma_FirstAidInfo { public SqlSugarClient db = GetClient(); /// /// 增加一条数据 /// public T_Service_Trauma_FirstAidInfo Add(T_Service_Trauma_FirstAidInfo model) { return db.Insertable(model).ExecuteReturnEntity(); } /// /// 更新一条数据 /// public bool Update(T_Service_Trauma_FirstAidInfo model) { return db.Updateable(model).ExecuteCommand() == 0 ? false : true; } /// /// 删除一条数据 /// public bool Delete(string GUID) { return db.Deleteable(it => it.GUID == GUID).ExecuteCommand() == 0 ? false : true; ; } /// /// 获得数据列表 /// public TableModel GetPageList(int pageIndex, int pageSize) { int total = 0; List data = db.Queryable().Where(it => it.DeleteFlag == 0).ToPageList(pageIndex, pageSize, ref total); TableModel t = new TableModel(); t.Code = 0; t.PageCount = data.Count; t.TotalNumber = total; t.Data = data; t.Msg = "成功"; return t; } /// /// 获得前几行数据 /// public T_Service_Trauma_FirstAidInfo Get(string GUID) { return db.Queryable().First(it => it.PatientGuid == GUID); } /// /// 根据患者编号(GUID)+所属报表类型 获取数据信息 /// /// 病人编号(GUID) /// public TableModel GetByPatientGuid(string patientGuid) { TableModel t = new TableModel(); var listMode = db.Queryable().Where(it => it.PatientGuid == patientGuid && it.DeleteFlag == 0) .OrderBy(it => it.ID, OrderByType.Desc).ToList(); t.Code = 0; t.TotalNumber = listMode.Count; t.Data = listMode; t.Msg = "成功"; return t; } /// /// /// /// /// public GUIDModel GetGUID(string GUID) { GUIDModel model = new GUIDModel(); model = db.Queryable() .Where(it => it.PatientGuid == GUID) .Select(it => new GUIDModel { GUID = it.GUID }).First(); return model; } /// /// /// /// /// 显示时间轴类型 /// public string GetTimeAxis(string patientGuid, string hospitalWay) { string SqlStr = ""; if (hospitalWay == "1") { SqlStr = @"select CallTime as 呼救时间,AmbulanceOut as 救护车出发,ArriveScene as 到达现场,LeaveScene as 离开现场,(case when ArriveEmergencyTime IS NULL then ArriveOutpatientTime else ArriveEmergencyTime end)as 到达门急诊时间,ConsultationRequestTime as 会诊请求时间,CheckInConsultationTime as 会诊签到时间, ArriveFastCTRoomTime as 到达CT室时间,FastCTEndTime as CT完成时间,ApplyBloodTransfusionTime as 申请输血时间,ImplementBloodTransfusionTime as 执行输血时间,ArriveOperatingRoomTime as 到达手术室时间,StartOperationTime as 开始手术时间, OperatingEndTime as 手术结束时间 from T_Service_Trauma_FirstAidInfo a join T_Service_Trauma_Rescue b on a.PatientGuid = b.PatientGuid join T_Service_Trauma_ReceiveInfo c on a.PatientGuid = c.PatientGuid where a.PatientGuid='{0}'"; } else if (hospitalWay == "2") { SqlStr = @"select TransferLeaveTime as 转运医院离开时间,(case when ArriveEmergencyTime IS NULL then ArriveOutpatientTime else ArriveEmergencyTime end)as 到达门急诊时间,ConsultationRequestTime as 会诊请求时间,CheckInConsultationTime as 会诊签到时间, ArriveFastCTRoomTime as 到达CT室时间,FastCTEndTime as CT完成时间,ApplyBloodTransfusionTime as 申请输血时间,ImplementBloodTransfusionTime as 执行输血时间,StartOperationTime as 开始手术时间,OperatingEndTime as 手术结束时间 from T_Service_Trauma_ReceiveInfo a join T_Service_Trauma_Rescue b on a.PatientGuid = b.PatientGuid join T_Service_Trauma_FirstAidInfo c on a.PatientGuid = c.PatientGuid where a.PatientGuid='{0}'"; } else if (hospitalWay == "3" || hospitalWay == "4" || hospitalWay == "5") { SqlStr = @"select (case when ArriveEmergencyTime IS NULL then ArriveOutpatientTime else ArriveEmergencyTime end)as 到达门急诊时间,ConsultationRequestTime as 会诊请求时间,CheckInConsultationTime as 会诊签到时间, ArriveFastCTRoomTime as 到达CT室时间,FastCTEndTime as CT完成时间,ApplyBloodTransfusionTime as 申请输血时间,ImplementBloodTransfusionTime as 执行输血时间,StartOperationTime as 开始手术时间,OperatingEndTime as 手术结束时间 from T_Service_Trauma_ReceiveInfo a join T_Service_Trauma_Rescue b on a.PatientGuid = b.PatientGuid where a.PatientGuid='{0}'"; } SqlStr = string.Format(SqlStr, patientGuid); DataTable dt = db.Ado.GetDataTable(SqlStr); string items = ""; foreach (DataRow item in dt.Rows) { string row = ""; for (int i = 0; i < dt.Columns.Count; i++) { row += JsonConvert.SerializeObject(dt.Columns[i].ColumnName) + ":"; row += JsonConvert.SerializeObject(item[i]) + ","; } row = row.Remove(row.Length - 1); items += "{" + row + "}" + ","; } items = items.Remove(items.Length - 1); items = "[" + items + "]"; return items; } } }