Exemplo n.º 1
0
        public bool SaveRecord(string PatID, VisitData VData)
        {
            try
            {
                VisitData     vdata = DataPreprocess(VData);
                PatBasicInfor pt    = context.PatBasicInforSet.Find(PatID);
                pt.HeadacheFamilyMember = vdata.HFamilyMember;//个人信息相关保存
                pt.OtherFamilyDisease   = vdata.OFamilyDisease;
                ObjectMapper.CopyProperties(vdata.lifestyle, pt.Lifestyle);
                pt.PreviousDrug = vdata.PDrug;
                foreach (PreviousDrug pg in pt.PreviousDrug)
                {
                    pg.PatBasicInforId = PatID;
                    if (pg.DrugCategory != null && (pg.DayAmoutnPerM == null || pg.MonthTotalAmount == null))
                    {
                    }
                }
                if (vdata.Similarfamily == "有")
                {
                    pt.SimilarFamily = true;
                }
                else
                {
                    pt.SimilarFamily = false;
                }

                pt.PreviousExam = vdata.PExam;
                if (vdata.visitrecord != null)
                {
                    VisitRecord vr = new VisitRecord();//问诊记录信息保存
                    vr = vdata.visitrecord;
                    vr.MedicationAdvice = vdata.MAdvice;
                    vr.VisitDate        = System.DateTime.Now;
                    // vr.VisitDate = DateTime.Now.Date;
                    vr.PrimaryHeadachaOverView = vdata.PHeadacheOverview;
                    vr.GADQuestionaire         = vdata.GADquestionaire;
                    vr.DisabilityEvaluation    = vdata.Disabilityevaluation;
                    vr.PHQuestionaire          = vdata.PHquestionaire;
                    vr.SleepStatus             = vdata.Sleepstatus;
                    vr.PatBasicInforId         = PatID;
                    pt.VisitRecord.Add(vr);
                }
                context.SaveChanges();
                return(true);
            }
            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);
                    }
                }
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool UpdateRecord(string PatID, string VisitID, VisitData VData)
        {
            try
            {
                VisitData     vdata = DataPreprocess(VData);
                PatBasicInfor pt    = context.PatBasicInforSet.Find(PatID);
                pt.HeadacheFamilyMember = vdata.HFamilyMember;//个人信息相关保存
                pt.OtherFamilyDisease   = vdata.OFamilyDisease;
                ObjectMapper.CopyProperties(vdata.lifestyle, pt.Lifestyle);
                pt.PreviousDrug = vdata.PDrug;
                pt.PreviousExam = vdata.PExam;
                if (vdata.Similarfamily == "有")
                {
                    pt.SimilarFamily = true;
                }
                else
                {
                    pt.SimilarFamily = false;
                }
                if (vdata.visitrecord != null)
                {
                    IEnumerable <VisitRecord> record = from p in context.VisitRecordSet.ToList()
                                                       where (p.PatBasicInfor.Id == PatID) && (p.Id == int.Parse(VisitID))
                                                       select p;
                    VisitRecord vr = record.First();

                    ObjectMapper.CopyProperties(vdata.visitrecord, vr);
                    ObjectMapper.CopyProperties(vdata.PHeadacheOverview, vr.PrimaryHeadachaOverView);

                    ObjectMapper.CopyProperties(vdata.GADquestionaire, vr.GADQuestionaire);
                    ObjectMapper.CopyProperties(vdata.PHquestionaire, vr.PHQuestionaire);
                    ObjectMapper.CopyProperties(vdata.Disabilityevaluation, vr.DisabilityEvaluation);
                    ObjectMapper.CopyProperties(vdata.Sleepstatus, vr.SleepStatus);
                    vr.PrimaryHeadachaOverView.VisitRecord = vr;
                    vr.GADQuestionaire.VisitRecord         = vr;
                    vr.PHQuestionaire.VisitRecord          = vr;
                    vr.DisabilityEvaluation.VisitRecord    = vr;
                    vr.SleepStatus.VisitRecord             = vr;


                    vr.PatBasicInforId      = PatID;
                    vr.VisitDate            = DateTime.Now.Date;
                    context.Entry(vr).State = System.Data.EntityState.Modified;
                }
                context.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public ReportData ViewDetail(string PatID, string RecordID)
        {
            ReportData    rdata = new ReportData();
            PatBasicInfor pt    = context.PatBasicInforSet.Find(PatID);

            rdata.Name      = pt.Name;
            rdata.Age       = pt.Age;
            rdata.Sex       = pt.Sex;
            rdata.Address   = pt.Address;
            rdata.Education = pt.Education;
            rdata.Job       = pt.Job;
            rdata.Phone     = pt.Phone;
            rdata.Weight    = pt.Weight;
            rdata.Height    = pt.Height;
            if (pt.SimilarFamily != null)
            {
                if (pt.SimilarFamily == true)
                {
                    rdata.SimilarFamily = true;
                }
                else
                {
                    rdata.SimilarFamily = false;
                }
            }

            if (pt.Lifestyle != null)
            {
                rdata.patlifestyle.SmokeState = pt.Lifestyle.SmokeState;
                rdata.patlifestyle.SmokeYear  = pt.Lifestyle.SmokeYear;

                rdata.patlifestyle.DrinkState = pt.Lifestyle.DrinkState;

                rdata.patlifestyle.DrinkYear     = pt.Lifestyle.DrinkYear;
                rdata.patlifestyle.TeaPerDay     = pt.Lifestyle.TeaPerDay;
                rdata.patlifestyle.CoffePerDay   = pt.Lifestyle.CoffePerDay;
                rdata.patlifestyle.ExerciseOften = pt.Lifestyle.ExerciseOften;
            }

            //if (pt.SimilarFamily!=null)
            //{
            //    rdata.SimilarFamily = pt.SimilarFamily;
            //}
            foreach (HeadacheFamilyMember hfmember in pt.HeadacheFamilyMember)
            {
                rdata.Hfamilymember.Add(hfmember.Person);
            }
            foreach (OtherFamilyDisease ofdisease in pt.OtherFamilyDisease)
            {
                rdata.Ofamilydisease.Add(ofdisease.DiseaseName);
            }
            foreach (PreviousDrug pdrug in pt.PreviousDrug)
            {
                PDrug pd = new PDrug();
                ObjectMapper.CopyProperties(pdrug, pd);
                rdata.previousdrug.Add(pd);
            }
            foreach (PreviousExam pexam in pt.PreviousExam)
            {
                Exam exam = new Exam();
                ObjectMapper.CopyProperties(pexam, exam);
                rdata.previousexam.Add(exam);
            }
            if (RecordID != "")
            {
                var record = from p in context.VisitRecordSet.ToList()
                             where (p.PatBasicInfor.Id == PatID) && (p.Id == int.Parse(RecordID))
                             select p;
                VisitRecord vr = record.First();
                if (vr != null)
                {
                    rdata.VisitDate         = vr.VisitDate;
                    rdata.CDSSDiagnosis1    = vr.CDSSDiagnosis1;
                    rdata.CDSSDiagnosis2    = vr.CDSSDiagnosis2;
                    rdata.CDSSDiagnosis3    = vr.CDSSDiagnosis3;
                    rdata.DiagnosisResult1  = vr.DiagnosisResult1;
                    rdata.DiagnosisResult2  = vr.DiagnosisResult2;
                    rdata.DiagnosisResult3  = vr.DiagnosisResult3;
                    rdata.Prescription      = vr.Prescription;
                    rdata.ChiefComplaint    = vr.ChiefComplaint;
                    rdata.PreviousDiagnosis = vr.PreviousDiagnosis;
                    rdata.PrescriptionNote  = vr.PrescriptionNote;
                    foreach (SecondaryHeadacheSymptom ss in vr.SecondaryHeadacheSymptom)
                    {
                        rdata.secondaryheadachesymptom.Add(ss.Symptom);
                    }
                    foreach (MedicationAdvice madvice in vr.MedicationAdvice)
                    {
                        HMedicine hmedicine = new HMedicine();
                        hmedicine.DrugApplication = madvice.DrugApplication;
                        hmedicine.DrugCategory    = madvice.DrugCategory;
                        hmedicine.DrugName        = madvice.DrugName;
                        hmedicine.DrugDose        = madvice.DrugDose;
                        hmedicine.DrugDoseUnit    = madvice.DrugDoseUnit;
                        rdata.medicationadvice.Add(hmedicine);
                    }

                    if (vr.PrimaryHeadachaOverView != null)
                    {
                        rdata.headacheoverview.HeadacheType   = vr.PrimaryHeadachaOverView.HeadacheType;
                        rdata.headacheoverview.HeadacheDegree = vr.PrimaryHeadachaOverView.HeadacheDegree;
                        rdata.headacheoverview.HeadcheTime    = vr.PrimaryHeadachaOverView.HeadcheTime;
                        rdata.headacheoverview.HeacheTimeUnit = vr.PrimaryHeadachaOverView.HeacheTimeUnit;

                        rdata.headacheoverview.FrequencyPerMonth = vr.PrimaryHeadachaOverView.FrequencyPerMonth;
                        rdata.headacheoverview.OnsetFixedPeriod  = vr.PrimaryHeadachaOverView.OnsetFixedPeriod;

                        rdata.headacheoverview.OnsetDate          = vr.PrimaryHeadachaOverView.OnsetDate;
                        rdata.headacheoverview.OnsetAmount        = vr.PrimaryHeadachaOverView.OnsetAmount;
                        rdata.headacheoverview.DailyAggravation   = vr.PrimaryHeadachaOverView.DailyAggravation;
                        rdata.headacheoverview.FirstOnsetContinue = vr.PrimaryHeadachaOverView.FirstOnsetContinue;

                        foreach (HeadachePlace hp in vr.PrimaryHeadachaOverView.HeadachePlace)
                        {
                            string strPlace = hp.Position + hp.SpecificPlace;
                            rdata.headacheplace.Add(strPlace);
                        }
                        foreach (HeadacheProdrome hprodrome in vr.PrimaryHeadachaOverView.HeadacheProdrome)
                        {
                            rdata.headacheprodrome.Add(hprodrome.Prodrome);
                        }
                        foreach (MitigatingFactors mfactors in vr.PrimaryHeadachaOverView.MitigatingFactors)
                        {
                            rdata.mitigatingfactors.Add(mfactors.FactorName);
                        }
                        foreach (HeadacheAccompany haccompay in vr.PrimaryHeadachaOverView.HeadacheAccompany)
                        {
                            rdata.headacheaccompany.Add(haccompay.Symptom);
                        }
                        foreach (PrecipitatingFactor pfactor in vr.PrimaryHeadachaOverView.PrecipitatingFactor)
                        {
                            Factor f = new Factor();
                            f.FName   = pfactor.FactorName;
                            f.FDetail = pfactor.FactorDetail;
                            rdata.precipitatingfactor.Add(f);
                        }
                        foreach (PremonitorySymptom psymptom in vr.PrimaryHeadachaOverView.PremonitorySymptom)
                        {
                            rdata.premonitorsymptom.Add(psymptom.Symptom);
                        }
                    }

                    //add 2013/7/23
                    if (vr.GADQuestionaire != null)
                    {
                        ObjectMapper.CopyProperties(vr.GADQuestionaire, rdata.gdaquestionaire);
                    }
                    if (vr.PHQuestionaire != null)
                    {
                        ObjectMapper.CopyProperties(vr.PHQuestionaire, rdata.phquestionaire);
                    }
                    if (vr.SleepStatus != null)
                    {
                        ObjectMapper.CopyProperties(vr.SleepStatus, rdata.sleepconditon);
                    }
                    if (vr.DisabilityEvaluation != null)
                    {
                        ObjectMapper.CopyProperties(vr.DisabilityEvaluation, rdata.disablityevaluation);
                    }
                }
            }
            else
            {
                rdata.VisitDate = DateTime.Now.Date;
                rdata.headacheoverview.OnsetDate = DateTime.Now.Date;
            }
            return(rdata);
        }
Exemplo n.º 4
0
        public bool UpdateRecord(string PatID, string VisitID, VisitData VData)
        {
            try
            {
                VisitData     vdata = DataPreprocess(VData);
                PatBasicInfor pt    = context.PatBasicInforSet.Find(PatID);
                pt.HeadacheFamilyMember = vdata.HFamilyMember;//个人信息相关保存
                pt.OtherFamilyDisease   = vdata.OFamilyDisease;
                ObjectMapper.CopyProperties(vdata.lifestyle, pt.Lifestyle);
                pt.PreviousDrug = vdata.PDrug;//需要看一下,这里的Pdrug有没有数据
                foreach (PreviousDrug pg in pt.PreviousDrug)
                {
                    pg.PatBasicInforId = PatID;
                }
                pt.PreviousExam = vdata.PExam;
                if (vdata.Similarfamily == "有")
                {
                    pt.SimilarFamily = true;
                }
                else
                {
                    pt.SimilarFamily = false;
                }
                if (vdata.visitrecord != null)
                {
                    IEnumerable <VisitRecord> record = from p in context.VisitRecordSet.ToList()
                                                       where (p.PatBasicInfor.Id == PatID) && (p.Id == int.Parse(VisitID))
                                                       select p;
                    VisitRecord vr = record.First();

                    ObjectMapper.CopyProperties(vdata.visitrecord, vr);
                    ObjectMapper.CopyProperties(vdata.PHeadacheOverview, vr.PrimaryHeadachaOverView);

                    ObjectMapper.CopyProperties(vdata.GADquestionaire, vr.GADQuestionaire);
                    ObjectMapper.CopyProperties(vdata.PHquestionaire, vr.PHQuestionaire);
                    ObjectMapper.CopyProperties(vdata.Disabilityevaluation, vr.DisabilityEvaluation);
                    ObjectMapper.CopyProperties(vdata.Sleepstatus, vr.SleepStatus);
                    vr.PrimaryHeadachaOverView.VisitRecord = vr;
                    vr.GADQuestionaire.VisitRecord         = vr;
                    vr.PHQuestionaire.VisitRecord          = vr;
                    vr.DisabilityEvaluation.VisitRecord    = vr;
                    vr.SleepStatus.VisitRecord             = vr;


                    vr.PatBasicInforId = PatID;
                    vr.VisitDate       = System.DateTime.Now;
                    //vr.VisitDate = DateTime.Now.Date;
                    //System.DateTime.Now.ToString("G");
                    context.Entry(vr).State = System.Data.EntityState.Modified;
                }
                context.SaveChanges();
                return(true);
            }
            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);
                    }
                }
                return(false);
            }
            //catch (Exception e)
            //{
            //    return false;
            //}
        }