StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_InformedConsentDB.cs

67 lines
2.9 KiB
C#

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
{
/// <summary>
/// 知情同意书
/// </summary>
public class T_Service_InformedConsentDB : BaseDB, IT_Service_InformedConsent
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 保存患者知情告知
/// </summary>
/// <param name="Informed"></param>
/// <returns></returns>
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<T_Service_InformedConsent>().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;
}
}
/// <summary>
/// 根据患者唯一标识获取知情告知信息
/// </summary>
/// <param name="patientGuid"></param>
/// <returns></returns>
public T_Service_InformedConsent GetnformedConsentByPatientGuid(string patientGuid, int flag)
{
return db.Queryable<T_Service_InformedConsent>().Where(i => i.PatientGuid == patientGuid && i.Flag == flag && i.DeleteFlag == 0).First();
}
}
}