Пример #1
0
        public void InsertPat(PatBasicInfor pat, string PID, string HID,string User)
        {
            try
            {
                pat.Id = System.Guid.NewGuid().ToString().Replace("-", "");
                pat.DoctorAccountId = 1;
                PatPhysicalExam pexam = new PatPhysicalExam();
                // pexam.Id = 1;
                //pexam.PatBasicInforId = pat.Id;
                pat.PatPhysicalExam = pexam;
                PatDisease pdisease = new PatDisease();
                // pdisease.Id = 1;
                pdisease.PatBasicInforId = pat.Id;
                pat.PatDisease = pdisease;

                VisitRecord r = new VisitRecord();
                r.PatBasicInforId = pat.Id;
                r.HospitalID = HID;
                r.OutpatientID = PID;
                r.VisitRecordID = "1";
                r.VisitDate = DateTime.Now.Date;
                pat.VisitRecord.Add(r);
                //context.PatBasicInforSet.Add(pat);
                var students = from s in context.DoctorAccountSet.ToList() select s;
                DoctorAccount student = students.Where(s => s.UserName == User).FirstOrDefault();
                student.PatBasicInfor.Add(pat);

                context.SaveChanges();
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                    }
                }
            }
        }
Пример #2
0
 public void InsertPatDisease(PatDisease pdisease, string ID)
 {
     try
     {
         PatBasicInfor pt = context.PatBasicInforSet.Find(ID);
         pdisease.PatBasicInforId = "123";
         pdisease.PatBasicInforId = ID;
         pdisease.Id = pt.PatDisease.Id;
         ObjectMapper.CopyProperties(pdisease, pt.PatDisease);
         //  pt.PatDisease = pdisease;
         context.SaveChanges();
     }
     catch (Exception e)
     {
         string a = e.InnerException.Message;
     }
 }