예제 #1
0
        /*医生撰写邮件Doctor to User*/
        public string MessageCompose(string senderID, string receiverID, string text) {
            Message message = new Message();
            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            Doctor doctor = (from d in DEntities.Doctors
                             where d.DoctorID == senderID
                             select d).FirstOrDefault();
            if (doctor == null) {
                return "Invalid Sender DoctorID!";
            }

            User user = (from u in DEntities.Users
                         where u.UserID == receiverID
                         select u).FirstOrDefault();
            if (user == null) {
                return "Invalid Receiver UserID!";
            }

            message.MessageID = Guid.NewGuid();
            message.Sender = doctor.DoctorID;
            message.Receiver = user.UserID;
            message.Type = "D2U";
            message.Date = DateTime.Now;
            message.Text = text;

            try {
                DEntities.Messages.AddObject(message);
                DEntities.SaveChanges();
            }
            catch {
                return "Sending Failed! @Data";
            }

            return null;
        }
예제 #2
0
        /*修改病历*/
        public CaseInfoEntity ModifyCase(CaseInfoEntity newCase) {
            CaseHistory oldCase = new CaseHistory();
            CaseInfoEntity modifiedCase = new CaseInfoEntity();

            if (newCase.CaseID == null) {
                modifiedCase.ErrorMessage = "Case GUID Missing! @Data";
                return modifiedCase;
            }

            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();
            oldCase = (from c in DEntities.CaseHistories
                       where ((c.CaseID == newCase.CaseID) && (c.DoctorID == newCase.DoctorID))
                       select c).FirstOrDefault();
            if (newCase == null) {
                modifiedCase.ErrorMessage = "Invalid Case GUID! @Data";
                return modifiedCase;
            }
            if (oldCase.ModifiedDate != null) {
                modifiedCase.ErrorMessage = "Modification Denied! @Data";
                return modifiedCase;
            }

            if (oldCase.ExaminationID == null) {
                oldCase.ExaminationID = newCase.ExaminationID;
            }
            if (oldCase.PrescriptionID == null) {
                oldCase.PrescriptionID = newCase.PrescriptionID;
            }

            if (oldCase.ChiefComplaint == null) {
                oldCase.ChiefComplaint = newCase.ChiefComplaint;
            }
            if (oldCase.TentativeDiagnosis == null) {
                oldCase.TentativeDiagnosis = newCase.TentativeDiagnosis;
            }
            if (oldCase.DifferentialDiagnosis == null) {
                oldCase.DifferentialDiagnosis = newCase.DifferentialDiagnosis;
            }
            if (oldCase.TreatmentPlan == null) {
                oldCase.TreatmentPlan = newCase.TreatmentPlan;
            }

            bool IsSent = oldCase.CountercheckDate.HasValue;
            if (IsSent == false) {
                oldCase.CountercheckDate = newCase.CountercheckDate;
            }

            if (newCase.IsDraft == false) {
                oldCase.ModifiedDate = DateTime.Now;
            }

            try {
                DEntities.SaveChanges();
            }
            catch {
                modifiedCase.ErrorMessage = "Invalid Case! @Data";
                return modifiedCase;
            }

            if ((IsSent == false) && (oldCase.CountercheckDate.HasValue)) {
                Doctor doctor = (from d in DEntities.Doctors
                                 where d.DoctorID == oldCase.DoctorID
                                 select d).FirstOrDefault();
                Section section = (from s in DEntities.Sections
                                   where s.SectionID == doctor.SectionID
                                   select s).FirstOrDefault();
                User user = (from u in DEntities.Users
                             where u.UserID == oldCase.UserID
                             select u).FirstOrDefault();
                DateTime lastVisit = (DateTime)oldCase.CreatedDate;
                DateTime countercheckDate = (DateTime)oldCase.CountercheckDate;
                DateTime currentTime = DateTime.Now;

                Message message = new Message();
                message.MessageID = Guid.NewGuid();
                message.Sender = section.HospitalID;
                message.Receiver = newCase.UserID;
                message.Date = countercheckDate.AddDays(-3).AddMinutes(currentTime.Minute).AddSeconds(currentTime.Second).AddMilliseconds(currentTime.Millisecond);
                message.Type = "H2U";
                message.Text = String.Format(
                    "Dear {0}.{1} {2},\nDuring your visit on {3}, Dr.{4} {5} ({6}) suggested you pay another visit on {7}. It might be a good idea to make an appointment before it's too late.\nSincerely,\nDr.PE",
                    (user.Gender.ToLower() == "female") ? "Ms" : "Mr",
                    user.LastName, user.FirstName,
                    lastVisit.ToLongDateString(),
                    doctor.LastName, doctor.FirstName,
                    section.Name,
                    countercheckDate.ToLongDateString());

                try {
                    DEntities.Messages.AddObject(message);
                    DEntities.SaveChanges();
                }
                catch {
                    modifiedCase.ErrorMessage = "Can't Create Appointment Inform! @Data";
                    return modifiedCase;
                }
            }

            modifiedCase.CaseID = oldCase.CaseID;
            modifiedCase.ExaminationID = oldCase.ExaminationID;
            modifiedCase.PrescriptionID = oldCase.PrescriptionID;
            modifiedCase.UserID = oldCase.UserID;
            modifiedCase.DoctorID = oldCase.DoctorID;
            modifiedCase.SectionID = oldCase.SectionID;
            modifiedCase.Date = oldCase.CreatedDate;
            modifiedCase.ChiefComplaint = oldCase.ChiefComplaint;
            modifiedCase.TentativeDiagnosis = oldCase.TentativeDiagnosis;
            modifiedCase.DifferentialDiagnosis = oldCase.DifferentialDiagnosis;
            modifiedCase.TreatmentPlan = oldCase.TreatmentPlan;
            modifiedCase.CountercheckDate = oldCase.CountercheckDate;

            return modifiedCase;
        }
 /// <summary>
 /// 用于向 Messages EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToMessages(Message message)
 {
     base.AddObject("Messages", message);
 }
예제 #4
0
        /*创建病历并针对复查日期创建message*/
        public CaseInfoEntity CreateCase(CaseInfoEntity caseInfoEntity) {

            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();
            CaseHistory newCase = new CaseHistory();
            CaseInfoEntity addedCase = new CaseInfoEntity();

            newCase.CaseID = Guid.NewGuid();
            newCase.ExaminationID = caseInfoEntity.ExaminationID;
            newCase.PrescriptionID = caseInfoEntity.PrescriptionID;
            newCase.UserID = caseInfoEntity.UserID;
            newCase.DoctorID = caseInfoEntity.DoctorID;

            Doctor doctor = (from d in DEntities.Doctors
                             where d.DoctorID == newCase.DoctorID
                             select d).FirstOrDefault();
            if (doctor == null) {
                addedCase.ErrorMessage = "Invalid DoctorID! @Data";
                return addedCase;
            }
            else {
                newCase.SectionID = doctor.SectionID;
            }

            newCase.CreatedDate = DateTime.Now;
            if (caseInfoEntity.IsDraft == false) {
                newCase.ModifiedDate = newCase.CreatedDate;
            }

            newCase.ChiefComplaint = caseInfoEntity.ChiefComplaint;
            newCase.TentativeDiagnosis = caseInfoEntity.TentativeDiagnosis;
            newCase.DifferentialDiagnosis = caseInfoEntity.DifferentialDiagnosis;
            newCase.TreatmentPlan = caseInfoEntity.TreatmentPlan;
            newCase.CountercheckDate = caseInfoEntity.CountercheckDate;

            try {
                DEntities.CaseHistories.AddObject(newCase);
                DEntities.SaveChanges();
            }
            catch {
                addedCase.ErrorMessage = "Invalid Case! @Data";
                return addedCase;
            }

            if (caseInfoEntity.CountercheckDate != null) {
                Section section = (from s in DEntities.Sections
                                   where s.SectionID == doctor.SectionID
                                   select s).FirstOrDefault();
                User user = (from u in DEntities.Users
                             where u.UserID == caseInfoEntity.UserID
                             select u).FirstOrDefault();
                DateTime lastVisit = (DateTime)newCase.CreatedDate;
                DateTime countercheckDate = (DateTime)newCase.CountercheckDate;
                DateTime currentTime = DateTime.Now;

                Message message = new Message();
                message.MessageID = Guid.NewGuid();
                message.Sender = section.HospitalID;
                message.Receiver = newCase.UserID;
                message.Date = countercheckDate.AddDays(-3).AddMinutes(currentTime.Minute).AddSeconds(currentTime.Second).AddMilliseconds(currentTime.Millisecond);
                message.Type = "H2U";
                message.Text = String.Format(
                    "Dear {0}.{1} {2},\nDuring your visit on {3}, Dr.{4} {5} ({6}) suggested you pay another visit on {7}. It might be a good idea to make an appointment before it's too late.\nSincerely,\nDr.PE",
                    (user.Gender.ToLower() == "female") ? "Ms" : "Mr",
                    user.LastName, user.FirstName,
                    lastVisit.ToLongDateString(),
                    doctor.LastName, doctor.FirstName,
                    section.Name,
                    countercheckDate.ToLongDateString());

                try {
                    DEntities.Messages.AddObject(message);
                    DEntities.SaveChanges();
                }
                catch {
                    addedCase.ErrorMessage = "Can't Create Appointment Inform! @Data";
                    return addedCase;
                }
            }

            addedCase.CaseID = newCase.CaseID;
            addedCase.ExaminationID = newCase.ExaminationID;
            addedCase.PrescriptionID = newCase.PrescriptionID;
            addedCase.UserID = newCase.UserID;
            addedCase.DoctorID = newCase.DoctorID;
            addedCase.SectionID = newCase.SectionID;
            addedCase.Date = newCase.CreatedDate;
            addedCase.ChiefComplaint = newCase.ChiefComplaint;
            addedCase.TentativeDiagnosis = newCase.TentativeDiagnosis;
            addedCase.DifferentialDiagnosis = newCase.DifferentialDiagnosis;
            addedCase.TreatmentPlan = newCase.TreatmentPlan;
            addedCase.CountercheckDate = newCase.CountercheckDate;
            if (newCase.ModifiedDate == null) {
                addedCase.IsDraft = true;
            }
            else {
                addedCase.IsDraft = false;
            }

            return addedCase;
        }
 /// <summary>
 /// 创建新的 Message 对象。
 /// </summary>
 /// <param name="messageID">MessageID 属性的初始值。</param>
 /// <param name="receiver">Receiver 属性的初始值。</param>
 public static Message CreateMessage(global::System.Guid messageID, global::System.String receiver)
 {
     Message message = new Message();
     message.MessageID = messageID;
     message.Receiver = receiver;
     return message;
 }