/// <summary> /// 保存值班病人到医生病人表中 /// </summary> /// <param name="DoctorID"></param> /// <param name="NewPatientList"></param> public void SaveDutyPatientToLocal(string DoctorID, List <Patient> PatientList) { using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(iDB.DbFile)) { conn.BeginTransaction(); foreach (Patient patient in PatientList) { Data.DoctorPatients dp = new DoctorPatients(); dp.DPID = DoctorID + patient.InhosID; dp.DoctorID = DoctorID; dp.InhosID = patient.InhosID; dp.DPType = "值班病人"; dp.CreateDate = iCommon.DateNow; var dps = conn.Table <DoctorPatients>().Where(p => p.DPID == dp.DPID).SingleOrDefault(); if (dps == null) { conn.Insert(dp); } else { conn.Update(dp); } } conn.Commit(); } }
public async Task <bool> AddNewPatient(string doctorId, string patientId) { var doctor = this.db.Users.Find(doctorId); var patient = this.db.Users.Find(patientId); var doctorPatient = new DoctorPatients { DoctorId = doctorId, PatientId = patientId }; var currentDp = this.db .DoctorPatients .Where(p => p.PatientId == patientId) .FirstOrDefault(); if (currentDp != null) { this.db.DoctorPatients.Remove(currentDp); } this.db.DoctorPatients.Add(doctorPatient); patient.DoctorId = doctor.Id; await this.db.SaveChangesAsync(); return(true); }
/// <summary> /// 保存近期查房记录 /// </summary> /// <param name="InhosID">住院流水号</param> public void SaveTodayCheckPatient(string InhosID) { using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(iDB.DbFile)) { string SqlText = @"Select Count(1) From [DoctorPatients] Where [DPID]=? And [CreateDate]=? And [DPType]=?"; SQLite.SQLiteCommand cmd = conn.CreateCommand(SqlText, iCommon.DoctorID + InhosID, iCommon.Today, "近期病人"); var Count = cmd.ExecuteScalar <string>(); if (Count == "0") { Data.DoctorPatients dp = new DoctorPatients(); dp.DPID = iCommon.DoctorID + InhosID; dp.DoctorID = iCommon.DoctorID; dp.InhosID = InhosID; dp.DPType = "近期病人"; dp.CreateDate = iCommon.Today; conn.Insert(dp); } } }