using HL_FristAidPlatform_Help; using HL_FristAidPlatform_IDataBase; using HL_FristAidPlatform_Models; using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HL_FristAidPlatform_DataBase { /// /// 知情同意书 /// public class T_Service_InformedConsentDB : BaseDB, IT_Service_InformedConsent { public SqlSugarClient db = GetClient(); /// /// 保存患者知情告知 /// /// /// public bool SaveInformedConsent(T_Service_InformedConsent Informed) { if (SqlFunc.IsNullOrEmpty(Informed.GUID)) { Informed.CreateTime = DateTime.Now; Informed.GUID = Guid.NewGuid().ToString(); return db.Insertable(Informed).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand() == 1 ? true : false; if (string.IsNullOrEmpty(Informed.CreateTime + "") || Informed.CreateTime == Convert.ToDateTime("0001-01-01 00:00:00") || Informed.CreateTime == Convert.ToDateTime("1753-01-01 00:00:00")) { Informed.CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm")); } } else { var oneClass = db.Queryable().Where(i => i.PatientGuid == Informed.PatientGuid && i.Flag == Informed.Flag).First(); if (oneClass != null) { if (!string.IsNullOrEmpty(oneClass.FileAddress) && !string.IsNullOrEmpty(Informed.FileAddress) && (oneClass.FileAddress != Informed.FileAddress)) { string appDomain = AppDomain.CurrentDomain.BaseDirectory.Replace(@"\bin\Debug\net5.0\", ""); int index = oneClass.FileAddress.LastIndexOf('/'); string oldStr = oneClass.FileAddress.Substring(index + 1); string deleteAddress = appDomain + @"\wwwroot\Audio\" + oldStr; System.IO.File.Delete(deleteAddress); } } return db.Updateable(Informed).IgnoreColumns(ignoreAllNullColumns: true).IgnoreColumns(i => i.ID).ExecuteCommand() == 1 ? true : false; } } /// /// 根据患者唯一标识获取知情告知信息 /// /// /// public T_Service_InformedConsent GetnformedConsentByPatientGuid(string patientGuid, int flag) { return db.Queryable().Where(i => i.PatientGuid == patientGuid && i.Flag == flag && i.DeleteFlag == 0).First(); } } }