183 lines
8.3 KiB
C#
183 lines
8.3 KiB
C#
using HL_FristAidPlatform_Help;
|
|
using HL_FristAidPlatform_IDataBase;
|
|
using HL_FristAidPlatform_Models;
|
|
using SqlSugar;
|
|
using System;
|
|
|
|
namespace HL_FristAidPlatform_DataBase
|
|
{
|
|
/// <summary>
|
|
/// 电子病历
|
|
/// </summary>
|
|
public class MedicalRecordTranService : BaseDB, IMedicalRecordTranService
|
|
{
|
|
public SqlSugarClient db = GetClient();
|
|
|
|
private T_Service_PatientDB patientDB = new T_Service_PatientDB();
|
|
private T_Service_ChestPain_FirstAIDInfoDB firstAIDInfoDB = new T_Service_ChestPain_FirstAIDInfoDB();
|
|
private T_Service_Apoplexy_PrehospitalDB prehospitalDB = new T_Service_Apoplexy_PrehospitalDB();
|
|
private T_Service_FirstAid_AlarmTaskInfoDB taskDB = new T_Service_FirstAid_AlarmTaskInfoDB();
|
|
|
|
/// <summary>
|
|
/// 保存病历
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <param name="systemModuleID"></param>
|
|
/// <returns></returns>
|
|
public bool SaveMedicalRecordTran(T_Service_Patient patient, T_Service_FirstAid_HealthCheckup health, T_Service_FirstAid_SpecialityCheckUp speciality, T_Service_FirstAid_AssistantExamination assistant, long creatorID,
|
|
T_Service_FirstAid_PatientInfo fp)
|
|
{
|
|
try
|
|
{
|
|
db.Ado.BeginTran();
|
|
|
|
var task = taskDB.GetPatientInfoModel(fp.TaskGUID);
|
|
|
|
//T_Service_ChestPain_FirstAIDInfo info = new T_Service_ChestPain_FirstAIDInfo();
|
|
//T_Service_EMR_Prehospital pre = new T_Service_EMR_Prehospital();
|
|
if (string.IsNullOrEmpty(patient.GUID))//直接补病历
|
|
{
|
|
|
|
patient.GUID = Guid.NewGuid().ToString();
|
|
patient.HospitalGuid = task.HospitalGuid;
|
|
patient.RegisterTime = DateTime.Now;
|
|
if (string.IsNullOrEmpty(patient.Attack_Address))
|
|
{
|
|
var taskinfo = db.Queryable<T_Service_FirstAid_AlarmTaskInfo>().Where(i => i.GUID == fp.TaskGUID).First();
|
|
|
|
if (!string.IsNullOrEmpty(taskinfo.AlarmGuid))
|
|
{
|
|
var address = db.Queryable<T_Service_FirstAid_AlarmInfo>().Where(i => i.GUID == taskinfo.AlarmGuid).First();
|
|
if (address != null)
|
|
{
|
|
patient.Attack_Address = address.CallAddress;
|
|
}
|
|
}
|
|
}
|
|
|
|
db.Insertable(patient).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
|
|
//info.GUID = Guid.NewGuid().ToString();
|
|
//info.PatientGuid = patient.GUID;
|
|
//info.CW_120_Help_Time = Convert.ToDateTime(task.CallTime);
|
|
//info.CW_ZY_First_MC_Time = Convert.ToDateTime(task.FirstTime);
|
|
//info.CW_ZY_Arrived_Hospital_Time = task.ArriveHospitalTime;
|
|
//info.CreationDate = DateTime.Now;
|
|
//info.CreatorID = creatorID;
|
|
|
|
//===
|
|
fp.GUID = Guid.NewGuid().ToString();
|
|
fp.PatientGUID = patient.GUID;
|
|
fp.CreationID = creatorID;
|
|
fp.CreationTime = DateTime.Now;
|
|
|
|
db.Insertable(fp).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
//pre.GUID = Guid.NewGuid().ToString();
|
|
//pre.PatientGuid = patient.GUID;
|
|
//pre.IsCallHelp = 1;
|
|
//pre.CallHelpWay = 1;
|
|
//pre.AdmissionRoute = 0;
|
|
//pre.HospitalMode = 0;
|
|
|
|
if (health != null)
|
|
{
|
|
health.GUID = Guid.NewGuid().ToString();
|
|
health.PatientGUID = patient.GUID;
|
|
health.CreateUser = creatorID;
|
|
health.DeleteFlag = 0;
|
|
health.CreateTime = DateTime.Now;
|
|
db.Insertable(health).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
|
|
}
|
|
if (speciality != null)
|
|
{
|
|
speciality.GUID = Guid.NewGuid().ToString();
|
|
speciality.PatientGUID = patient.GUID;
|
|
speciality.CreateUser = creatorID;
|
|
speciality.DeleteFlag = 0;
|
|
speciality.CreateTime = DateTime.Now;
|
|
db.Insertable(speciality).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
}
|
|
if (assistant != null)
|
|
{
|
|
assistant.GUID = Guid.NewGuid().ToString();
|
|
assistant.PatientGUID = patient.GUID;
|
|
assistant.CreateUser = creatorID;
|
|
assistant.DeleteFlag = 0;
|
|
assistant.CreateTime = DateTime.Now;
|
|
db.Insertable(assistant).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
//修改病历
|
|
db.Updateable(patient).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
db.Updateable(fp).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
if (!string.IsNullOrEmpty(speciality.GUID))
|
|
{
|
|
//更新专科检查
|
|
db.Updateable(speciality).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
//新增专科检查
|
|
speciality.GUID = Guid.NewGuid().ToString();
|
|
speciality.CreateUser = creatorID;
|
|
speciality.DeleteFlag = 0;
|
|
speciality.CreateTime = DateTime.Now;
|
|
db.Insertable(speciality).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
}
|
|
if (!string.IsNullOrEmpty(assistant.GUID))
|
|
{
|
|
//更新辅助检查
|
|
db.Updateable(assistant).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
//新增辅助检查
|
|
assistant.GUID = Guid.NewGuid().ToString();
|
|
assistant.CreateUser = creatorID;
|
|
assistant.DeleteFlag = 0;
|
|
assistant.CreateTime = DateTime.Now;
|
|
db.Insertable(assistant).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
}
|
|
|
|
|
|
if (health.GUID != null)
|
|
{
|
|
//更新体格检查
|
|
health.CreateUser = creatorID;
|
|
db.Updateable(health).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
//新增体格检查
|
|
assistant.GUID = Guid.NewGuid().ToString();
|
|
assistant.CreateUser = creatorID;
|
|
assistant.DeleteFlag = 0;
|
|
assistant.CreateTime = DateTime.Now;
|
|
db.Insertable(health).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
}
|
|
}
|
|
var alarmInfo = db.Queryable<T_Service_FirstAid_AlarmInfo>().Where(i => i.GUID == fp.TaskGUID).First();
|
|
if (alarmInfo != null)
|
|
{
|
|
alarmInfo.ActualPatientsNumber = alarmInfo.ActualPatientsNumber + 1;
|
|
db.Updateable(task).ExecuteCommand();
|
|
}
|
|
|
|
db.Ado.CommitTran();
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Ado.RollbackTran();
|
|
Help.WriteErrorLog("院前:保存病历(SaveMedicalRecordTran)", ex.ToString());
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|