Beispiel #1
0
        public bool UpdateByTJMiniPad(RecordsLifeStyleModel model, string checkDate) //Ìå¼ìÎÊѯͬ²½
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(@"UPDATE 
                                    ARCHIVE_LIFESTYLE  D
                             SET 
                                     ExerciseRate=@ExerciseRate,ExerciseTimes=@ExerciseTimes,ExcisepersistTime=@ExcisepersistTime,
                                     ExerciseExistense=@ExerciseExistense,DietaryHabit=@DietaryHabit,SmokeCondition=@SmokeCondition,SmokeDayNum=@SmokeDayNum,
                                     SmokeAgeStart=@SmokeAgeStart,SmokeAgeForbiddon=@SmokeAgeForbiddon,DrinkRate=@DrinkRate,
                                     DayDrinkVolume=@DayDrinkVolume,IsDrinkForbiddon=@IsDrinkForbiddon,DrinkStartAge=@DrinkStartAge,
                                     DrinkThisYear=@DrinkThisYear,DrinkType=@DrinkType,ExerciseExistenseOther=@ExerciseExistenseOther,
                                     DrinkTypeOther=@DrinkTypeOther,ForbiddonAge=@ForbiddonAge  
                             WHERE
                                    EXISTS
                                    (
                                        SELECT 
                                            ID 
                                        FROM
                                        ARCHIVE_CUSTOMERBASEINFO M
                                        WHERE M.ID = D.OutKey
                                        AND M.IDCardNo = @IDCardNo
                                        AND M.CheckDate = @CheckDate
                                    )
                            ");

            MySqlParameter[] cmdParms = new MySqlParameter[] {
                new MySqlParameter("@IDCardNo", model.IDCardNo),
                new MySqlParameter("@CheckDate", checkDate),
                new MySqlParameter("@ExerciseRate", model.ExerciseRate),
                new MySqlParameter("@ExerciseTimes", model.ExerciseTimes),
                new MySqlParameter("@ExcisepersistTime", model.ExcisepersistTime),
                new MySqlParameter("@ExerciseExistense", model.ExerciseExistense),
                new MySqlParameter("@DietaryHabit", model.DietaryHabit),
                new MySqlParameter("@SmokeCondition", model.SmokeCondition),
                new MySqlParameter("@SmokeDayNum", model.SmokeDayNum),
                new MySqlParameter("@SmokeAgeStart", model.SmokeAgeStart),
                new MySqlParameter("@SmokeAgeForbiddon", model.SmokeAgeForbiddon),
                new MySqlParameter("@DrinkRate", model.DrinkRate),
                new MySqlParameter("@DayDrinkVolume", model.DayDrinkVolume),
                new MySqlParameter("@IsDrinkForbiddon", model.IsDrinkForbiddon),
                new MySqlParameter("@DrinkStartAge", model.DrinkStartAge),
                new MySqlParameter("@DrinkThisYear", model.DrinkThisYear),
                new MySqlParameter("@DrinkType", model.DrinkType),
                new MySqlParameter("@ExerciseExistenseOther", model.ExerciseExistenseOther),
                new MySqlParameter("@DrinkTypeOther", model.DrinkTypeOther),
                new MySqlParameter("@ForbiddonAge", model.ForbiddonAge)
            };

            return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
        public List <RecordsLifeStyleModel> DataTableToList(DataTable dt)
        {
            List <RecordsLifeStyleModel> list = new List <RecordsLifeStyleModel>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    RecordsLifeStyleModel item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Beispiel #3
0
        private void btndataupload_Click(object sender, EventArgs e)
        {
            string strwhere = "";

            if (this.ckbcheckdate.Checked)
            {
                strwhere = string.Format(" CheckDate BETWEEN '{0}' and '{1}' ",
                                         this.dtpstart.Value.Date.ToString("yyyy-MM-dd"), this.dtpend.Value.Date.ToString("yyyy-MM-dd"));
            }

            DataSet customds = new RecordsCustomerBaseInfoBLL().GetList(strwhere);

            int amount = 0;

            progressBar1.Visible   = true;
            progressBar1.Minimum   = 0;
            progressBar1.Maximum   = customds.Tables[0].Rows.Count;
            progressBar1.BackColor = Color.Green;
            labCountnum.Text       = customds.Tables[0].Rows.Count.ToString();

            foreach (DataRow row in customds.Tables[0].Rows)
            {
                int OutKey = Convert.ToInt32(row["ID"].ToString());

                if (string.IsNullOrEmpty(row["IDCardNo"].ToString()))
                {
                    continue;
                }

                // 基本信息
                RecordsBaseInfoModel Model = new RecordsBaseInfoBLL().GetModel(row["IDCardNo"].ToString());
                if (Model == null)
                {
                    Model = new RecordsBaseInfoModel();
                }

                // 一般状况
                RecordsGeneralConditionModel generalConditionModel = new RecordsGeneralConditionBLL().GetModelByOutKey(OutKey);
                if (generalConditionModel == null)
                {
                    generalConditionModel = new RecordsGeneralConditionModel();
                }

                ChronicDiadetesVisitModel diabetesModel = new ChronicDiadetesVisitModel();

                diabetesModel.IDCardNo     = row["IDCardNo"].ToString();
                diabetesModel.Hypertension = generalConditionModel.RightHeight;
                diabetesModel.Hypotension  = generalConditionModel.RightPre;
                diabetesModel.BMI          = generalConditionModel.BMI;
                diabetesModel.Weight       = generalConditionModel.Weight;
                diabetesModel.Hight        = generalConditionModel.Height;

                if (diabetesModel.BMI != null)
                {
                    if (diabetesModel.BMI >= 24)
                    {
                        diabetesModel.TargetWeight = diabetesModel.Weight - 5;
                    }
                }

                // 生活方式
                RecordsLifeStyleModel lifeModel = new RecordsLifeStyleBLL().GetModelByOutKey(OutKey);
                if (lifeModel == null)
                {
                    lifeModel = new RecordsLifeStyleModel();
                }

                if (lifeModel.SmokeCondition == "3")
                {
                    diabetesModel.DailySmokeNum = lifeModel.SmokeDayNum;
                }
                else
                {
                    diabetesModel.DailySmokeNum = 0;
                }

                if (lifeModel.DrinkRate == "2" || lifeModel.DrinkRate == "3" || lifeModel.DrinkRate == "4")
                {
                    diabetesModel.DailyDrinkNum = lifeModel.DayDrinkVolume;
                }
                else
                {
                    diabetesModel.DailyDrinkNum = 0;
                }

                diabetesModel.DailySmokeNumTarget      = 0;
                diabetesModel.DailyDrinkNumTarget      = 0;
                diabetesModel.SportTimePerWeekTarget   = 7;
                diabetesModel.SportPerMinuteTimeTarget = 60;

                // 辅助检查
                RecordsAssistCheckModel AssistCheck = new RecordsAssistCheckBLL().GetModelByOutKey(OutKey);
                if (AssistCheck == null)
                {
                    AssistCheck = new RecordsAssistCheckModel();
                }

                diabetesModel.FPG   = AssistCheck.FPGL;
                diabetesModel.HbAlc = AssistCheck.HBALC;

                new ChronicDiadetesVisitBLL().UpdateDate(diabetesModel);

                ChronicHypertensionVisitModel hypertensionModel = new ChronicHypertensionVisitModel();
                hypertensionModel.Hypertension = generalConditionModel.RightHeight;
                hypertensionModel.Hypotension  = generalConditionModel.RightPre;
                hypertensionModel.BMI          = generalConditionModel.BMI;
                hypertensionModel.Weight       = generalConditionModel.Weight;
                hypertensionModel.Hight        = generalConditionModel.Height;

                if (hypertensionModel.BMI != null)
                {
                    if (hypertensionModel.BMI >= 24)
                    {
                        hypertensionModel.WeightTarGet = hypertensionModel.Weight - 5;
                    }
                }
                if (AssistCheck.FPGL != null)
                {
                    hypertensionModel.AssistantExam = $"空腹血糖:{AssistCheck.FPGL}mmol/L";
                }

                // 查体
                RecordsPhysicalExamModel physicalModel = new RecordsPhysicalExamBLL().GetModelByOutKey(OutKey);
                if (physicalModel == null)
                {
                    physicalModel = new RecordsPhysicalExamModel();
                }

                decimal dd = 0;
                if (!string.IsNullOrEmpty(physicalModel.HeartRate))
                {
                    if (decimal.TryParse(physicalModel.HeartRate, out dd))
                    {
                        hypertensionModel.HeartRate = dd;
                    }
                }

                if (lifeModel.SmokeCondition == "3")
                {
                    hypertensionModel.DailySmokeNum = lifeModel.SmokeDayNum;
                }
                else
                {
                    hypertensionModel.DailySmokeNum = 0;
                }

                if (lifeModel.DrinkRate == "2" || lifeModel.DrinkRate == "3" || lifeModel.DrinkRate == "4")
                {
                    hypertensionModel.DailyDrinkNum = lifeModel.DayDrinkVolume;
                }
                else
                {
                    hypertensionModel.DailyDrinkNum = 0;
                }

                hypertensionModel.DailySmokeNumTarget       = 0;
                hypertensionModel.DailyDrinkNumTarget       = 0;
                hypertensionModel.SportTimeSperWeekTarget   = 7;
                hypertensionModel.SportPerMinutesTimeTarget = 60;
                hypertensionModel.IDCardNo = row["IDCardNo"].ToString();

                new ChronicHypertensionVisitBLL().UpdateDate(hypertensionModel);

                amount++;
                labUploadnum.Text  = amount.ToString();
                progressBar1.Value = amount;
            }

            MessageBox.Show("成功匹配:" + amount + "条数据!", "提示");
            progressBar1.Visible = false;
        }
        public int Add(RecordsLifeStyleModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("INSERT INTO ARCHIVE_LIFESTYLE(");
            builder.Append("PhysicalID,IDCardNo,SmokeDayNum,SmokeAgeStart,SmokeAgeForbiddon,ExerciseRate,ExerciseTimes,DietaryHabit,ExerciseExistense,ExcisepersistTime,SmokeCondition,DrinkRate,DayDrinkVolume,IsDrinkForbiddon,ForbiddonAge,DrinkStartAge,DrinkThisYear,DrinkType,CareerHarmFactorHistory,Dust,DustProtect,Radiogen,RadiogenProtect,Physical,PhysicalProtect,Chem,ChemProtect,Other,OtherProtect,WorkType,WorkTime,DustProtectEx,RadiogenProtectEx,PhysicalProtectEx,ChemProtectEx,OtherProtectEx,DrinkTypeOther,OutKey,ExerciseExistenseOther)");
            builder.Append(" VALUES (");
            builder.Append("@PhysicalID,@IDCardNo,@SmokeDayNum,@SmokeAgeStart,@SmokeAgeForbiddon,@ExerciseRate,@ExerciseTimes,@DietaryHabit,@ExerciseExistense,@ExcisepersistTime,@SmokeCondition,@DrinkRate,@DayDrinkVolume,@IsDrinkForbiddon,@ForbiddonAge,@DrinkStartAge,@DrinkThisYear,@DrinkType,@CareerHarmFactorHistory,@Dust,@DustProtect,@Radiogen,@RadiogenProtect,@Physical,@PhysicalProtect,@Chem,@ChemProtect,@Other,@OtherProtect,@WorkType,@WorkTime,@DustProtectEx,@RadiogenProtectEx,@PhysicalProtectEx,@ChemProtectEx,@OtherProtectEx,@DrinkTypeOther,@OutKey,@ExerciseExistenseOther)");
            builder.Append(";SELECT @@IDENTITY");

            MySqlParameter[] cmdParms = new MySqlParameter[] {
                new MySqlParameter("@PhysicalID", MySqlDbType.String, 100),
                new MySqlParameter("@IDCardNo", MySqlDbType.String, 21),
                new MySqlParameter("@SmokeDayNum", MySqlDbType.Decimal),
                new MySqlParameter("@SmokeAgeStart", MySqlDbType.Decimal),
                new MySqlParameter("@SmokeAgeForbiddon", MySqlDbType.Decimal),
                new MySqlParameter("@ExerciseRate", MySqlDbType.String, 1),
                new MySqlParameter("@ExerciseTimes", MySqlDbType.Decimal),
                new MySqlParameter("@DietaryHabit", MySqlDbType.String, 100),
                new MySqlParameter("@ExerciseExistense", MySqlDbType.String, 100),
                new MySqlParameter("@ExcisepersistTime", MySqlDbType.Decimal),
                new MySqlParameter("@SmokeCondition", MySqlDbType.String, 1),
                new MySqlParameter("@DrinkRate", MySqlDbType.String, 1),
                new MySqlParameter("@DayDrinkVolume", MySqlDbType.Decimal),
                new MySqlParameter("@IsDrinkForbiddon", MySqlDbType.String, 1),
                new MySqlParameter("@ForbiddonAge", MySqlDbType.Decimal),
                new MySqlParameter("@DrinkStartAge", MySqlDbType.Decimal),
                new MySqlParameter("@DrinkThisYear", MySqlDbType.String, 1),
                new MySqlParameter("@DrinkType", MySqlDbType.String, 100),
                new MySqlParameter("@CareerHarmFactorHistory", MySqlDbType.String, 1),
                new MySqlParameter("@Dust", MySqlDbType.String, 100),
                new MySqlParameter("@DustProtect", MySqlDbType.String, 1),
                new MySqlParameter("@Radiogen", MySqlDbType.String, 100),
                new MySqlParameter("@RadiogenProtect", MySqlDbType.String, 1),
                new MySqlParameter("@Physical", MySqlDbType.String, 100),
                new MySqlParameter("@PhysicalProtect", MySqlDbType.String, 1),
                new MySqlParameter("@Chem", MySqlDbType.String, 100),
                new MySqlParameter("@ChemProtect", MySqlDbType.String, 1),
                new MySqlParameter("@Other", MySqlDbType.String, 100),
                new MySqlParameter("@OtherProtect", MySqlDbType.String, 1),
                new MySqlParameter("@WorkType", MySqlDbType.String, 100),
                new MySqlParameter("@WorkTime", MySqlDbType.Decimal),
                new MySqlParameter("@DustProtectEx", MySqlDbType.String, 100),
                new MySqlParameter("@RadiogenProtectEx", MySqlDbType.String, 100),
                new MySqlParameter("@PhysicalProtectEx", MySqlDbType.String, 100),
                new MySqlParameter("@ChemProtectEx", MySqlDbType.String, 100),
                new MySqlParameter("@OtherProtectEx", MySqlDbType.String, 100),
                new MySqlParameter("@DrinkTypeOther", MySqlDbType.String, 100),
                new MySqlParameter("@OutKey", MySqlDbType.Int32, 11),
                new MySqlParameter("@ExerciseExistenseOther", MySqlDbType.Int32, 100)
            };
            cmdParms[0].Value  = model.PhysicalID;
            cmdParms[1].Value  = model.IDCardNo;
            cmdParms[2].Value  = model.SmokeDayNum;
            cmdParms[3].Value  = model.SmokeAgeStart;
            cmdParms[4].Value  = model.SmokeAgeForbiddon;
            cmdParms[5].Value  = model.ExerciseRate;
            cmdParms[6].Value  = model.ExerciseTimes;
            cmdParms[7].Value  = model.DietaryHabit;
            cmdParms[8].Value  = model.ExerciseExistense;
            cmdParms[9].Value  = model.ExcisepersistTime;
            cmdParms[10].Value = model.SmokeCondition;
            cmdParms[11].Value = model.DrinkRate;
            cmdParms[12].Value = model.DayDrinkVolume;
            cmdParms[13].Value = model.IsDrinkForbiddon;
            cmdParms[14].Value = model.ForbiddonAge;
            cmdParms[15].Value = model.DrinkStartAge;
            cmdParms[16].Value = model.DrinkThisYear;
            cmdParms[17].Value = model.DrinkType;
            cmdParms[18].Value = model.CareerHarmFactorHistory;
            cmdParms[19].Value = model.Dust;
            cmdParms[20].Value = model.DustProtect;
            cmdParms[21].Value = model.Radiogen;
            cmdParms[22].Value = model.RadiogenProtect;
            cmdParms[23].Value = model.Physical;
            cmdParms[24].Value = model.PhysicalProtect;
            cmdParms[25].Value = model.Chem;
            cmdParms[26].Value = model.ChemProtect;
            cmdParms[27].Value = model.Other;
            cmdParms[28].Value = model.OtherProtect;
            cmdParms[29].Value = model.WorkType;
            cmdParms[30].Value = model.WorkTime;
            cmdParms[31].Value = model.DustProtectEx;
            cmdParms[32].Value = model.RadiogenProtectEx;
            cmdParms[33].Value = model.PhysicalProtectEx;
            cmdParms[34].Value = model.ChemProtectEx;
            cmdParms[35].Value = model.OtherProtectEx;
            cmdParms[36].Value = model.DrinkTypeOther;
            cmdParms[37].Value = model.OutKey;
            cmdParms[38].Value = model.ExerciseExistenseOther;
            object single = MySQLHelper.GetSingle(builder.ToString(), cmdParms);

            if (single == null)
            {
                return(0);
            }
            return(Convert.ToInt32(single));
        }
Beispiel #5
0
        /// <summary>
        /// 糖尿病
        /// </summary>
        /// <param name="IDCardNo"></param>
        /// <param name="CheckDate"></param>
        /// <param name="VersionNo"></param>
        /// <param name="Model"></param>
        public void SaveDiadetes(string IDCardNo, DateTime CheckDate, string VersionNo, RecordsBaseInfoModel Model, RecordsCustomerBaseInfoModel CustomerModel)
        {
            try
            {
                DataView dv = dsRequire.DefaultView;

                // 获取最后一次随访数据
                ChronicDiadetesVisitModel diadetesOldModel = DiadetesVisitBLL.GetMaxModel(IDCardNo);
                if (diadetesOldModel == null)
                {
                    diadetesOldModel = new ChronicDiadetesVisitModel();
                }
                ChronicDiadetesVisitModel diadetesNewModel = new ChronicDiadetesVisitModel();

                // 取得体检一般情况资料
                RecordsGeneralConditionModel conditionModel = new RecordsGeneralConditionBLL().GetModelByOutKey(CustomerModel.ID);

                // 取得体检生活方式资料
                RecordsLifeStyleModel lifeModel = new RecordsLifeStyleBLL().GetModelByOutKey(CustomerModel.ID);
                if (lifeModel == null)
                {
                    lifeModel = new RecordsLifeStyleModel();
                }

                // 取得体检查体资料
                RecordsPhysicalExamModel physicalModel = new RecordsPhysicalExamBLL().GetModelByOutKey(CustomerModel.ID);
                if (physicalModel == null)
                {
                    physicalModel = new RecordsPhysicalExamModel();
                }

                // 取得体检辅助检查资料
                RecordsAssistCheckModel checkModel = new RecordsAssistCheckBLL().GetModelByOutKey(CustomerModel.ID);

                #region 糖尿病基本信息

                dv.RowFilter = null;
                dv.RowFilter = "TabName='糖尿病随访' AND Comment='糖尿病基本信息' AND (IsSetValue='是' OR IsSetValue='预设上次随访') ";
                DataTable dt = dv.ToTable();

                // 是否有基本信息
                int count = DiadetesVisitBLL.GetBaseDataCount(IDCardNo);

                if (count < 1)
                {
                    // 新增糖尿病基本信息
                    ChronicDiabetesBaseInfoModel baseModel = new ChronicDiabetesBaseInfoModel()
                    {
                        IDCardNo       = IDCardNo,
                        RecordID       = Model.RecordID,
                        CreateBy       = ConfigHelper.GetNodeDec("doctor"),
                        CreateDate     = DateTime.Now,
                        LastUpdateBy   = ConfigHelper.GetNodeDec("doctor"),
                        LastUpdateDate = DateTime.Now
                    };

                    baseModel = EntityAssignment <ChronicDiabetesBaseInfoModel>(baseModel, baseModel, dt);

                    DiadetesVisitBLL.Add(baseModel, VersionNo);
                }

                #endregion

                #region 随访信息

                dv.RowFilter = null;
                dv.RowFilter = "TabName='糖尿病随访' AND Comment='糖尿病随访信息' AND (IsSetValue='是' OR IsSetValue='预设上次随访') AND ChinName<>'用药情况'  ";
                dt           = dv.ToTable();

                diadetesNewModel = EntityAssignment <ChronicDiadetesVisitModel>(diadetesOldModel, diadetesNewModel, dt);

                diadetesNewModel.IDCardNo           = IDCardNo;
                diadetesNewModel.RecordID           = Model.RecordID;
                diadetesNewModel.CustomerName       = StringPlus.toString(diadetesNewModel.CustomerName) == "" ? Model.CustomerName : diadetesNewModel.CustomerName;
                diadetesNewModel.Hypertension       = conditionModel.LeftHeight;
                diadetesNewModel.Hypotension        = conditionModel.LeftPre;
                diadetesNewModel.Weight             = conditionModel.Weight;
                diadetesNewModel.Height             = conditionModel.Height;
                diadetesNewModel.BMI                = conditionModel.BMI;
                diadetesNewModel.DorsalisPedispulse = StringPlus.toString(physicalModel.FootBack) != "" ? (int.Parse(physicalModel.FootBack) - 1).ToString() : null;
                diadetesNewModel.DailySmokeNum      = lifeModel.SmokeDayNum;
                diadetesNewModel.DailyDrinkNum      = lifeModel.DayDrinkVolume;
                diadetesNewModel.FPG                = checkModel.FPGL;
                diadetesNewModel.HbAlc              = checkModel.HBALC;
                diadetesNewModel.VisitDate          = CheckDate;
                diadetesNewModel.NextVisitDate      = CheckDate.AddMonths(3);
                diadetesNewModel.VisitDoctor        = ConfigHelper.GetNode("doctorName");
                diadetesNewModel.CreateBy           = ConfigHelper.GetNode("doctor");
                diadetesNewModel.CreateDate         = DateTime.Now;
                diadetesNewModel.LastUpdateBy       = ConfigHelper.GetNode("doctor");
                diadetesNewModel.LastUpdateDate     = DateTime.Now;

                #endregion

                #region 保存默认值

                // 随访信息存档
                int id = DiadetesVisitBLL.Add(diadetesNewModel, VersionNo);

                #endregion

                // 保存用药
                SaveMedication(IDCardNo, "2", id);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
                throw ex;
            }
        }
Beispiel #6
0
        /// <summary>
        /// 高血压
        /// </summary>
        /// <param name="IDCardNo"></param>
        /// <param name="CheckDate"></param>
        /// <param name="VersionNo"></param>
        /// <param name="Model"></param>
        public void SaveHypertension(string IDCardNo, DateTime CheckDate, string VersionNo, RecordsBaseInfoModel Model, RecordsCustomerBaseInfoModel CustomerModel)
        {
            try
            {
                DataView dv = dsRequire.DefaultView;

                // 获取最后一次随访数据
                ChronicHypertensionVisitModel hypertensionOldModel = HypertensionVisitBLL.GetMaxModel(IDCardNo, VersionNo);
                if (hypertensionOldModel == null)
                {
                    hypertensionOldModel = new ChronicHypertensionVisitModel();
                }
                ChronicHypertensionVisitModel hypertensionNewModel = new ChronicHypertensionVisitModel();

                // 取得体检一般情况资料
                RecordsGeneralConditionModel conditionModel = new RecordsGeneralConditionBLL().GetModelByOutKey(CustomerModel.ID);

                // 取得体检生活方式资料
                RecordsLifeStyleModel lifeModel = new RecordsLifeStyleBLL().GetModelByOutKey(CustomerModel.ID);
                if (lifeModel == null)
                {
                    lifeModel = new RecordsLifeStyleModel();
                }

                // 取得体检查体资料
                RecordsPhysicalExamModel physicalModel = new RecordsPhysicalExamBLL().GetModelByOutKey(CustomerModel.ID);
                if (physicalModel == null)
                {
                    physicalModel = new RecordsPhysicalExamModel();
                }

                #region 高血压基本信息

                dv.RowFilter = null;
                dv.RowFilter = "TabName='高血压随访' AND Comment='高血压基本信息' AND (IsSetValue='是' OR IsSetValue='预设上次随访') ";
                DataTable dt = dv.ToTable();

                // 是否有基本信息
                int count = HypertensionVisitBLL.GetDataCount(IDCardNo);

                if (count < 1)
                {
                    // 新增高血压基本信息
                    ChronicHypertensionBaseInfoModel baseModel = new ChronicHypertensionBaseInfoModel()
                    {
                        IDCardNo       = IDCardNo,
                        RecordID       = Model.RecordID,
                        CreatedBy      = ConfigHelper.GetNodeDec("doctor"),
                        CreatedDate    = DateTime.Now,
                        LastUpdateBy   = ConfigHelper.GetNodeDec("doctor"),
                        LastUpdateDate = DateTime.Now
                    };

                    baseModel = EntityAssignment <ChronicHypertensionBaseInfoModel>(baseModel, baseModel, dt);

                    HypertensionVisitBLL.Add(baseModel, VersionNo);
                }

                #endregion

                #region 随访信息

                dv.RowFilter = null;
                dv.RowFilter = "TabName='高血压随访' AND Comment='高血压随访信息' AND (IsSetValue='是' OR IsSetValue='预设上次随访') AND ChinName<>'用药情况' ";
                dt           = dv.ToTable();

                hypertensionNewModel = EntityAssignment <ChronicHypertensionVisitModel>(hypertensionOldModel, hypertensionNewModel, dt);

                hypertensionNewModel.IDCardNo         = IDCardNo;
                hypertensionNewModel.RecordID         = Model.RecordID;
                hypertensionNewModel.CustomerName     = StringPlus.toString(hypertensionNewModel.CustomerName) == "" ? Model.CustomerName : hypertensionNewModel.CustomerName;
                hypertensionNewModel.Hypertension     = conditionModel.LeftHeight;
                hypertensionNewModel.Hypotension      = conditionModel.LeftPre;
                hypertensionNewModel.Weight           = conditionModel.Weight;
                hypertensionNewModel.Height           = conditionModel.Height;
                hypertensionNewModel.BMI              = conditionModel.BMI;
                hypertensionNewModel.HeartRate        = physicalModel.HeartRate;
                hypertensionNewModel.DailySmokeNum    = lifeModel.SmokeDayNum;
                hypertensionNewModel.DailyDrinkNum    = lifeModel.DayDrinkVolume;
                hypertensionNewModel.FollowUpDate     = CheckDate;
                hypertensionNewModel.NextFollowUpDate = CheckDate.AddMonths(3);
                hypertensionNewModel.FollowUpDoctor   = ConfigHelper.GetNode("doctorName");
                hypertensionNewModel.CreatedBy        = ConfigHelper.GetNode("doctor");
                hypertensionNewModel.CreatedDate      = DateTime.Now;
                hypertensionNewModel.LastUpdateBy     = ConfigHelper.GetNode("doctor");
                hypertensionNewModel.LastUpdateDate   = DateTime.Now;

                #endregion

                #region 保存默认值

                if (VersionNo.Contains("3.0"))
                {
                    hypertensionNewModel.FollowUpType = hypertensionNewModel.VisitType;
                    hypertensionNewModel.FollowUpWay  = hypertensionNewModel.VisitWay;
                }

                // 随访信息存档
                int id = HypertensionVisitBLL.Add(hypertensionNewModel, VersionNo);

                #endregion

                // 保存用药
                SaveMedication(IDCardNo, "1", id);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
                throw ex;
            }
        }
Beispiel #7
0
        public bool UpdateServer(RecordsLifeStyleModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update ARCHIVE_LIFESTYLE set ");
            builder.Append("PhysicalID=@PhysicalID,");
            builder.Append("IDCardNo=@IDCardNo,");
            builder.Append("SmokeDayNum=@SmokeDayNum,");
            builder.Append("SmokeAgeStart=@SmokeAgeStart,");
            builder.Append("SmokeAgeForbiddon=@SmokeAgeForbiddon,");
            builder.Append("ExerciseRate=@ExerciseRate,");
            builder.Append("ExerciseTimes=@ExerciseTimes,");
            builder.Append("DietaryHabit=@DietaryHabit,");
            builder.Append("ExerciseExistense=@ExerciseExistense,");
            builder.Append("ExcisepersistTime=@ExcisepersistTime,");
            builder.Append("SmokeCondition=@SmokeCondition,");
            builder.Append("DrinkRate=@DrinkRate,");
            builder.Append("DayDrinkVolume=@DayDrinkVolume,");
            builder.Append("IsDrinkForbiddon=@IsDrinkForbiddon,");
            builder.Append("ForbiddonAge=@ForbiddonAge,");
            builder.Append("DrinkStartAge=@DrinkStartAge,");
            builder.Append("DrinkThisYear=@DrinkThisYear,");
            builder.Append("DrinkType=@DrinkType,");
            builder.Append("CareerHarmFactorHistory=@CareerHarmFactorHistory,");
            builder.Append("Dust=@Dust,");
            builder.Append("DustProtect=@DustProtect,");
            builder.Append("Radiogen=@Radiogen,");
            builder.Append("RadiogenProtect=@RadiogenProtect,");
            builder.Append("Physical=@Physical,");
            builder.Append("PhysicalProtect=@PhysicalProtect,");
            builder.Append("Chem=@Chem,");
            builder.Append("ChemProtect=@ChemProtect,");
            builder.Append("Other=@Other,");
            builder.Append("OtherProtect=@OtherProtect,");
            builder.Append("WorkType=@WorkType,");
            builder.Append("WorkTime=@WorkTime,");
            builder.Append("DustProtectEx=@DustProtectEx,");
            builder.Append("RadiogenProtectEx=@RadiogenProtectEx,");
            builder.Append("PhysicalProtectEx=@PhysicalProtectEx,");
            builder.Append("ChemProtectEx=@ChemProtectEx,");
            builder.Append("OtherProtectEx=@OtherProtectEx,");
            builder.Append("DrinkTypeOther=@DrinkTypeOther,");
            builder.Append("ExerciseExistenseOther=@ExerciseExistenseOther ");
            builder.Append(" where IDCardNo=@IDCardNo");
            MySqlParameter[] cmdParms = new MySqlParameter[] {
                new MySqlParameter("@PhysicalID", MySqlDbType.String, 8),
                new MySqlParameter("@IDCardNo", MySqlDbType.String, 21),
                new MySqlParameter("@SmokeDayNum", MySqlDbType.Decimal),
                new MySqlParameter("@SmokeAgeStart", MySqlDbType.Decimal),
                new MySqlParameter("@SmokeAgeForbiddon", MySqlDbType.Decimal),
                new MySqlParameter("@ExerciseRate", MySqlDbType.String, 1),
                new MySqlParameter("@ExerciseTimes", MySqlDbType.Decimal),
                new MySqlParameter("@DietaryHabit", MySqlDbType.String, 30),
                new MySqlParameter("@ExerciseExistense", MySqlDbType.String, 50),
                new MySqlParameter("@ExcisepersistTime", MySqlDbType.Decimal),
                new MySqlParameter("@SmokeCondition", MySqlDbType.String, 1),
                new MySqlParameter("@DrinkRate", MySqlDbType.String, 1),
                new MySqlParameter("@DayDrinkVolume", MySqlDbType.Decimal),
                new MySqlParameter("@IsDrinkForbiddon", MySqlDbType.String, 1),
                new MySqlParameter("@ForbiddonAge", MySqlDbType.Decimal),
                new MySqlParameter("@DrinkStartAge", MySqlDbType.Decimal),
                new MySqlParameter("@DrinkThisYear", MySqlDbType.String, 1),
                new MySqlParameter("@DrinkType", MySqlDbType.String, 13),
                new MySqlParameter("@CareerHarmFactorHistory", MySqlDbType.String, 1),
                new MySqlParameter("@Dust", MySqlDbType.String, 30),
                new MySqlParameter("@DustProtect", MySqlDbType.String, 1),
                new MySqlParameter("@Radiogen", MySqlDbType.String, 50),
                new MySqlParameter("@RadiogenProtect", MySqlDbType.String, 1),
                new MySqlParameter("@Physical", MySqlDbType.String, 50),
                new MySqlParameter("@PhysicalProtect", MySqlDbType.String, 1),
                new MySqlParameter("@Chem", MySqlDbType.String, 50),
                new MySqlParameter("@ChemProtect", MySqlDbType.String, 1),
                new MySqlParameter("@Other", MySqlDbType.String, 200),
                new MySqlParameter("@OtherProtect", MySqlDbType.String, 1),
                new MySqlParameter("@WorkType", MySqlDbType.String, 30),
                new MySqlParameter("@WorkTime", MySqlDbType.Decimal),
                new MySqlParameter("@DustProtectEx", MySqlDbType.String, 500),
                new MySqlParameter("@RadiogenProtectEx", MySqlDbType.String, 500),
                new MySqlParameter("@PhysicalProtectEx", MySqlDbType.String, 500),
                new MySqlParameter("@ChemProtectEx", MySqlDbType.String, 500),
                new MySqlParameter("@OtherProtectEx", MySqlDbType.String, 500),
                new MySqlParameter("@DrinkTypeOther", MySqlDbType.String, 20),
                new MySqlParameter("@ExerciseExistenseOther", MySqlDbType.String, 500)
                //new MySqlParameter("@ID", MySqlDbType.Int32, 8)
            };
            cmdParms[0].Value  = model.PhysicalID;
            cmdParms[1].Value  = model.IDCardNo;
            cmdParms[2].Value  = model.SmokeDayNum;
            cmdParms[3].Value  = model.SmokeAgeStart;
            cmdParms[4].Value  = model.SmokeAgeForbiddon;
            cmdParms[5].Value  = model.ExerciseRate;
            cmdParms[6].Value  = model.ExerciseTimes;
            cmdParms[7].Value  = model.DietaryHabit;
            cmdParms[8].Value  = model.ExerciseExistense;
            cmdParms[9].Value  = model.ExcisepersistTime;
            cmdParms[10].Value = model.SmokeCondition;
            cmdParms[11].Value = model.DrinkRate;
            cmdParms[12].Value = model.DayDrinkVolume;
            cmdParms[13].Value = model.IsDrinkForbiddon;
            cmdParms[14].Value = model.ForbiddonAge;
            cmdParms[15].Value = model.DrinkStartAge;
            cmdParms[16].Value = model.DrinkThisYear;
            cmdParms[17].Value = model.DrinkType;
            cmdParms[18].Value = model.CareerHarmFactorHistory;
            cmdParms[19].Value = model.Dust;
            cmdParms[20].Value = model.DustProtect;
            cmdParms[21].Value = model.Radiogen;
            cmdParms[22].Value = model.RadiogenProtect;
            cmdParms[23].Value = model.Physical;
            cmdParms[24].Value = model.PhysicalProtect;
            cmdParms[25].Value = model.Chem;
            cmdParms[26].Value = model.ChemProtect;
            cmdParms[27].Value = model.Other;
            cmdParms[28].Value = model.OtherProtect;
            cmdParms[29].Value = model.WorkType;
            cmdParms[30].Value = model.WorkTime;
            cmdParms[31].Value = model.DustProtectEx;
            cmdParms[32].Value = model.RadiogenProtectEx;
            cmdParms[33].Value = model.PhysicalProtectEx;
            cmdParms[34].Value = model.ChemProtectEx;
            cmdParms[35].Value = model.OtherProtectEx;
            cmdParms[36].Value = model.DrinkTypeOther;
            cmdParms[37].Value = model.ExerciseExistenseOther;
            //cmdParms[37].Value = model.ID;
            return(MySQLHelper.ExecuteSqlServer(builder.ToString(), cmdParms) > 0);
        }
Beispiel #8
0
        public RecordsLifeStyleModel DataRowToModel(DataRow row)
        {
            RecordsLifeStyleModel recordsLifeStyleModel = new RecordsLifeStyleModel();

            if (row != null)
            {
                if (((row["ID"] != null) && (row["ID"] != DBNull.Value)) && (row["ID"].ToString() != ""))
                {
                    recordsLifeStyleModel.ID = int.Parse(row["ID"].ToString());
                }
                if ((row["PhysicalID"] != null) && (row["PhysicalID"] != DBNull.Value))
                {
                    recordsLifeStyleModel.PhysicalID = row["PhysicalID"].ToString();
                }
                if ((row["IDCardNo"] != null) && (row["IDCardNo"] != DBNull.Value))
                {
                    recordsLifeStyleModel.IDCardNo = row["IDCardNo"].ToString();
                }
                if (((row["SmokeDayNum"] != null) && (row["SmokeDayNum"] != DBNull.Value)) && (row["SmokeDayNum"].ToString() != ""))
                {
                    recordsLifeStyleModel.SmokeDayNum = new decimal?(decimal.Parse(row["SmokeDayNum"].ToString()));
                }
                if (((row["SmokeAgeStart"] != null) && (row["SmokeAgeStart"] != DBNull.Value)) && (row["SmokeAgeStart"].ToString() != ""))
                {
                    recordsLifeStyleModel.SmokeAgeStart = new decimal?(decimal.Parse(row["SmokeAgeStart"].ToString()));
                }
                if (((row["SmokeAgeForbiddon"] != null) && (row["SmokeAgeForbiddon"] != DBNull.Value)) && (row["SmokeAgeForbiddon"].ToString() != ""))
                {
                    recordsLifeStyleModel.SmokeAgeForbiddon = new decimal?(decimal.Parse(row["SmokeAgeForbiddon"].ToString()));
                }
                if ((row["ExerciseRate"] != null) && (row["ExerciseRate"] != DBNull.Value))
                {
                    recordsLifeStyleModel.ExerciseRate = row["ExerciseRate"].ToString();
                }
                if (((row["ExerciseTimes"] != null) && (row["ExerciseTimes"] != DBNull.Value)) && (row["ExerciseTimes"].ToString() != ""))
                {
                    recordsLifeStyleModel.ExerciseTimes = new decimal?(decimal.Parse(row["ExerciseTimes"].ToString()));
                }
                if ((row["DietaryHabit"] != null) && (row["DietaryHabit"] != DBNull.Value))
                {
                    recordsLifeStyleModel.DietaryHabit = row["DietaryHabit"].ToString();
                }
                if ((row["ExerciseExistense"] != null) && (row["ExerciseExistense"] != DBNull.Value))
                {
                    recordsLifeStyleModel.ExerciseExistense = row["ExerciseExistense"].ToString();
                }
                if (((row["ExcisepersistTime"] != null) && (row["ExcisepersistTime"] != DBNull.Value)) && (row["ExcisepersistTime"].ToString() != ""))
                {
                    recordsLifeStyleModel.ExcisepersistTime = new decimal?(decimal.Parse(row["ExcisepersistTime"].ToString()));
                }
                if ((row["SmokeCondition"] != null) && (row["SmokeCondition"] != DBNull.Value))
                {
                    recordsLifeStyleModel.SmokeCondition = row["SmokeCondition"].ToString();
                }
                if ((row["DrinkRate"] != null) && (row["DrinkRate"] != DBNull.Value))
                {
                    recordsLifeStyleModel.DrinkRate = row["DrinkRate"].ToString();
                }
                if (((row["DayDrinkVolume"] != null) && (row["DayDrinkVolume"] != DBNull.Value)) && (row["DayDrinkVolume"].ToString() != ""))
                {
                    recordsLifeStyleModel.DayDrinkVolume = new decimal?(decimal.Parse(row["DayDrinkVolume"].ToString()));
                }
                if ((row["IsDrinkForbiddon"] != null) && (row["IsDrinkForbiddon"] != DBNull.Value))
                {
                    recordsLifeStyleModel.IsDrinkForbiddon = row["IsDrinkForbiddon"].ToString();
                }
                if (((row["ForbiddonAge"] != null) && (row["ForbiddonAge"] != DBNull.Value)) && (row["ForbiddonAge"].ToString() != ""))
                {
                    recordsLifeStyleModel.ForbiddonAge = new decimal?(decimal.Parse(row["ForbiddonAge"].ToString()));
                }
                if (((row["DrinkStartAge"] != null) && (row["DrinkStartAge"] != DBNull.Value)) && (row["DrinkStartAge"].ToString() != ""))
                {
                    recordsLifeStyleModel.DrinkStartAge = new decimal?(decimal.Parse(row["DrinkStartAge"].ToString()));
                }
                if ((row["DrinkThisYear"] != null) && (row["DrinkThisYear"] != DBNull.Value))
                {
                    recordsLifeStyleModel.DrinkThisYear = row["DrinkThisYear"].ToString();
                }
                if ((row["DrinkType"] != null) && (row["DrinkType"] != DBNull.Value))
                {
                    recordsLifeStyleModel.DrinkType = row["DrinkType"].ToString();
                }
                if ((row["CareerHarmFactorHistory"] != null) && (row["CareerHarmFactorHistory"] != DBNull.Value))
                {
                    recordsLifeStyleModel.CareerHarmFactorHistory = row["CareerHarmFactorHistory"].ToString();
                }
                if ((row["Dust"] != null) && (row["Dust"] != DBNull.Value))
                {
                    recordsLifeStyleModel.Dust = row["Dust"].ToString();
                }
                if ((row["DustProtect"] != null) && (row["DustProtect"] != DBNull.Value))
                {
                    recordsLifeStyleModel.DustProtect = row["DustProtect"].ToString();
                }
                if ((row["Radiogen"] != null) && (row["Radiogen"] != DBNull.Value))
                {
                    recordsLifeStyleModel.Radiogen = row["Radiogen"].ToString();
                }
                if ((row["RadiogenProtect"] != null) && (row["RadiogenProtect"] != DBNull.Value))
                {
                    recordsLifeStyleModel.RadiogenProtect = row["RadiogenProtect"].ToString();
                }
                if ((row["Physical"] != null) && (row["Physical"] != DBNull.Value))
                {
                    recordsLifeStyleModel.Physical = row["Physical"].ToString();
                }
                if ((row["PhysicalProtect"] != null) && (row["PhysicalProtect"] != DBNull.Value))
                {
                    recordsLifeStyleModel.PhysicalProtect = row["PhysicalProtect"].ToString();
                }
                if ((row["Chem"] != null) && (row["Chem"] != DBNull.Value))
                {
                    recordsLifeStyleModel.Chem = row["Chem"].ToString();
                }
                if ((row["ChemProtect"] != null) && (row["ChemProtect"] != DBNull.Value))
                {
                    recordsLifeStyleModel.ChemProtect = row["ChemProtect"].ToString();
                }
                if ((row["Other"] != null) && (row["Other"] != DBNull.Value))
                {
                    recordsLifeStyleModel.Other = row["Other"].ToString();
                }
                if ((row["OtherProtect"] != null) && (row["OtherProtect"] != DBNull.Value))
                {
                    recordsLifeStyleModel.OtherProtect = row["OtherProtect"].ToString();
                }
                if ((row["WorkType"] != null) && (row["WorkType"] != DBNull.Value))
                {
                    recordsLifeStyleModel.WorkType = row["WorkType"].ToString();
                }
                if (((row["WorkTime"] != null) && (row["WorkTime"] != DBNull.Value)) && (row["WorkTime"].ToString() != ""))
                {
                    recordsLifeStyleModel.WorkTime = new decimal?(decimal.Parse(row["WorkTime"].ToString()));
                }
                if ((row["DustProtectEx"] != null) && (row["DustProtectEx"] != DBNull.Value))
                {
                    recordsLifeStyleModel.DustProtectEx = row["DustProtectEx"].ToString();
                }
                if ((row["RadiogenProtectEx"] != null) && (row["RadiogenProtectEx"] != DBNull.Value))
                {
                    recordsLifeStyleModel.RadiogenProtectEx = row["RadiogenProtectEx"].ToString();
                }
                if ((row["PhysicalProtectEx"] != null) && (row["PhysicalProtectEx"] != DBNull.Value))
                {
                    recordsLifeStyleModel.PhysicalProtectEx = row["PhysicalProtectEx"].ToString();
                }
                if ((row["ChemProtectEx"] != null) && (row["ChemProtectEx"] != DBNull.Value))
                {
                    recordsLifeStyleModel.ChemProtectEx = row["ChemProtectEx"].ToString();
                }
                if ((row["OtherProtectEx"] != null) && (row["OtherProtectEx"] != DBNull.Value))
                {
                    recordsLifeStyleModel.OtherProtectEx = row["OtherProtectEx"].ToString();
                }
                if ((row["DrinkTypeOther"] != null) && (row["DrinkTypeOther"] != DBNull.Value))
                {
                    recordsLifeStyleModel.DrinkTypeOther = row["DrinkTypeOther"].ToString();
                }
                if ((row["ExerciseExistenseOther"] != null) && (row["ExerciseExistenseOther"] != DBNull.Value)) //ExerciseExistenseOther
                {
                    recordsLifeStyleModel.ExerciseExistenseOther = row["ExerciseExistenseOther"].ToString();
                }
            }
            return(recordsLifeStyleModel);
        }
Beispiel #9
0
        public void SavePhysical(string IDCardNo, DateTime CheckDate, string VersionNo, string barCode = "")
        {
            try
            {
                DataTable dsRequire = new RequireBLL().GetList("TabName = '健康体检' ").Tables[0];
                DataView  dv        = dsRequire.DefaultView;

                // 获取最后一次体检数据
                RecordsCustomerBaseInfoModel customerOldModel = CustomerBaseInfoBLL.GetMaxModel(IDCardNo);
                if (customerOldModel == null)
                {
                    customerOldModel = new RecordsCustomerBaseInfoModel();
                }
                RecordsCustomerBaseInfoModel customerNewModel = new RecordsCustomerBaseInfoModel();

                customerNewModel.IDCardNo       = IDCardNo;
                customerNewModel.CheckDate      = CheckDate;
                customerNewModel.CustomerID     = barCode;
                customerNewModel.Doctor         = ConfigHelper.GetNode("doctorName");
                customerNewModel.CreateBy       = ConfigHelper.GetNodeDec("doctor");
                customerNewModel.CreateDate     = DateTime.Now;
                customerNewModel.LastUpdateBy   = ConfigHelper.GetNodeDec("doctor");
                customerNewModel.LastUpdateDate = DateTime.Now;

                #region 一般状况

                dv.RowFilter = "Comment='一般状况' AND (IsSetValue='是' OR IsSetValue='预设上次体检') AND OptionName='Symptom' ";
                DataTable dt = dv.ToTable();

                // 栏位名遍历默认项配置
                foreach (DataRow item in dt.Rows)
                {
                    if (item["IsSetValue"].ToString() == "是")
                    {
                        customerNewModel.Symptom = item["ItemValue"].ToString();
                    }
                    else
                    {
                        customerNewModel.Symptom = customerOldModel.Symptom;
                        customerNewModel.Other   = customerOldModel.Other;
                    }
                }

                dv.RowFilter = null;
                dv.RowFilter = "Comment='一般状况' AND (IsSetValue='是' OR IsSetValue='预设上次体检') AND OptionName<>'Symptom' ";
                dt           = dv.ToTable();
                RecordsGeneralConditionModel gerneralOldModel = GeneralConditionBLL.GetModelByOutKey(customerOldModel.ID);
                RecordsGeneralConditionModel gerneralNewModel = new RecordsGeneralConditionModel();

                gerneralNewModel = EntityAssignment <RecordsGeneralConditionModel>(gerneralOldModel, gerneralNewModel, dt);

                #endregion

                #region 生活方式

                dv.RowFilter = null;
                dv.RowFilter = "Comment='生活方式' AND (IsSetValue='是' OR IsSetValue='预设上次体检') ";
                dt           = dv.ToTable();
                RecordsLifeStyleModel lifeStyleOldModel = LifeStyleBLL.GetModelByOutKey(customerOldModel.ID);
                RecordsLifeStyleModel lifeStyleNewModel = new RecordsLifeStyleModel();
                if (lifeStyleOldModel == null)
                {
                    lifeStyleOldModel = new RecordsLifeStyleModel();
                }

                lifeStyleNewModel = EntityAssignment <RecordsLifeStyleModel>(lifeStyleOldModel, lifeStyleNewModel, dt);

                #endregion

                #region 查体信息

                dv.RowFilter = null;
                dv.RowFilter = "Comment='查体信息' AND (IsSetValue='是' OR IsSetValue='预设上次体检') ";
                dt           = dv.ToTable();
                RecordsPhysicalExamModel physicalExamOldModel = PhysicalExamBLL.GetModelByOutKey(customerOldModel.ID);
                RecordsPhysicalExamModel physicalExamNewModel = new RecordsPhysicalExamModel();
                if (physicalExamOldModel == null)
                {
                    physicalExamOldModel = new RecordsPhysicalExamModel();
                }

                physicalExamNewModel = EntityAssignment <RecordsPhysicalExamModel>(physicalExamOldModel, physicalExamNewModel, dt);

                #endregion

                #region 辅助检查

                dv.RowFilter = null;
                dv.RowFilter = "Comment='辅助检查' AND (IsSetValue='是' OR IsSetValue='预设上次体检') ";
                dt           = dv.ToTable();
                RecordsAssistCheckModel assistCheckOldModel = AssistCheckBLL.GetModelByOutKey(customerOldModel.ID);
                RecordsAssistCheckModel assistCheckNewModel = new RecordsAssistCheckModel();
                if (assistCheckOldModel == null)
                {
                    assistCheckOldModel = new RecordsAssistCheckModel();
                }

                assistCheckNewModel = EntityAssignment <RecordsAssistCheckModel>(assistCheckOldModel, assistCheckNewModel, dt);

                #endregion

                #region 脏器功能

                dv.RowFilter = null;
                dv.RowFilter = "Comment='脏器功能' AND (IsSetValue='是' OR IsSetValue='预设上次体检') ";
                dt           = dv.ToTable();
                RecordsVisceraFunctionModel visceraOldModel = VisceraFunctionBLL.GetModelByOutKey(customerOldModel.ID);
                RecordsVisceraFunctionModel visceraNewModel = new RecordsVisceraFunctionModel();
                if (visceraOldModel == null)
                {
                    visceraOldModel = new RecordsVisceraFunctionModel();
                }

                visceraNewModel = EntityAssignment <RecordsVisceraFunctionModel>(visceraOldModel, visceraNewModel, dt);

                #endregion

                #region 中医体质

                RecordsMediPhysDistModel mediPhysDistModel = new RecordsMediPhysDistModel();

                #endregion

                #region 健康评价

                RecordsAssessmentGuideModel assessmentGuideModel = new RecordsAssessmentGuideModel();

                #endregion

                #region 健康问题

                dv.RowFilter = null;
                dv.RowFilter = "Comment='健康问题' AND (IsSetValue='是' OR IsSetValue='预设上次体检') ";
                dt           = dv.ToTable();
                RecordsHealthQuestionModel questionOldModel = HealthQuestionBLL.GetModelByOutKey(customerOldModel.ID);
                RecordsHealthQuestionModel questionNewModel = new RecordsHealthQuestionModel();
                if (questionOldModel == null)
                {
                    questionOldModel = new RecordsHealthQuestionModel();
                }

                questionNewModel = EntityAssignment <RecordsHealthQuestionModel>(questionOldModel, questionNewModel, dt);

                #endregion

                #region 住院史、用药情况

                dv.RowFilter = null;
                dv.RowFilter = "Comment='治疗情况' AND (IsSetValue='是' OR IsSetValue='预设上次体检' OR IsSetValue='预设随访用药') ";
                dt           = dv.ToTable();

                // 获取list model对象,用来获取最后一次体检数据的值
                List <RecordsHospitalHistoryModel> hospitalHistoryOld = HospitalHistoryBLL.GetModelList(
                    string.Format("IDCardNo='{0}' AND OutKey={1}", IDCardNo, customerOldModel.ID));
                List <RecordsFamilyBedHistoryModel> familyBedHistoryInfoOld = FamilyBedHistoryBLL.GetModelList(
                    string.Format("IDCardNo='{0}' AND OutKey={1}", IDCardNo, customerOldModel.ID));
                List <RecordsMedicationModel> medicationOld = MedicationBLL.GetModelList(
                    string.Format("IDCardNo='{0}' AND OutKey={1}", IDCardNo, customerOldModel.ID));

                if (hospitalHistoryOld == null)
                {
                    hospitalHistoryOld = new List <RecordsHospitalHistoryModel>();
                }
                if (familyBedHistoryInfoOld == null)
                {
                    familyBedHistoryInfoOld = new List <RecordsFamilyBedHistoryModel>();
                }
                if (medicationOld == null)
                {
                    medicationOld = new List <RecordsMedicationModel>();
                }

                #region 随访用药

                List <RecordsMedicationModel> medicationFollowUp = new List <RecordsMedicationModel>();

                // 高血压随访
                ChronicHypertensionVisitModel HyperModel = new ChronicHypertensionVisitBLL().GetMaxModel(IDCardNo, VersionNo);

                if (HyperModel != null)
                {
                    List <ChronicDrugConditionModel> DrugConditions = new ChronicDrugConditionBLL().GetModelList(
                        string.Format(" IDCardNo='{0}' AND Type='{1}' AND OutKey='{2}' ", IDCardNo, "1", HyperModel.ID));

                    foreach (ChronicDrugConditionModel drugModel in DrugConditions)
                    {
                        RecordsMedicationModel newModel = new RecordsMedicationModel
                        {
                            MedicinalName = drugModel.Name,
                            UseNum        = drugModel.DosAge,
                            IDCardNo      = IDCardNo
                        };

                        medicationFollowUp.Add(newModel);
                    }
                }

                // 糖尿病随访
                ChronicDiadetesVisitModel DiaModel = new ChronicDiadetesVisitBLL().GetMaxModel(IDCardNo);

                if (DiaModel != null)
                {
                    List <ChronicDrugConditionModel> DiaDrugConditions = new ChronicDrugConditionBLL().GetModelList(
                        string.Format(" IDCardNo='{0}' AND Type='{1}' AND OutKey='{2}' ", IDCardNo, "2", DiaModel.ID));

                    foreach (ChronicDrugConditionModel drugModel in DiaDrugConditions)
                    {
                        RecordsMedicationModel newModel = new RecordsMedicationModel
                        {
                            MedicinalName = drugModel.Name,
                            UseNum        = drugModel.DosAge,
                            IDCardNo      = IDCardNo
                        };

                        medicationFollowUp.Add(newModel);
                    }
                }

                #endregion

                // 用于存储需存档的体检数据
                List <RecordsHospitalHistoryModel>  hospitalHistoryNew      = new List <RecordsHospitalHistoryModel>();
                List <RecordsFamilyBedHistoryModel> familyBedHistoryInfoNew = new List <RecordsFamilyBedHistoryModel>();
                List <RecordsMedicationModel>       medicationNew           = new List <RecordsMedicationModel>();

                // 临时存储住院史的默认值
                RecordsHospitalHistoryModel hModel = new RecordsHospitalHistoryModel();

                //通过栏位名,遍历默认项配置
                foreach (DataRow item in dt.Rows)
                {
                    switch (item["ChinName"].ToString())
                    {
                    case "住院史":
                        if (item["IsSetValue"].ToString() == "是")
                        {
                            if (!string.IsNullOrEmpty(item["ItemValue"].ToString()))
                            {
                                string[] resList = item["ItemValue"].ToString().Split(';');

                                if (resList.Length > 4)
                                {
                                    hModel.InHospitalDate  = Convert.ToDateTime(resList[0].ToString());
                                    hModel.OutHospitalDate = Convert.ToDateTime(resList[1].ToString());
                                    hModel.Reason          = resList[2].ToString();
                                    hModel.HospitalName    = resList[3].ToString();
                                    hModel.IllcaseNum      = resList[4].ToString();
                                }
                                else if (resList.Length == 1)
                                {
                                    hModel.Reason = resList[0].ToString();
                                }

                                hospitalHistoryNew.Add(hModel);
                            }
                        }
                        else
                        {
                            hospitalHistoryNew = hospitalHistoryOld;
                        }
                        break;

                    case "家庭病床史":
                        if (item["IsSetValue"].ToString() == "预设上次体检")
                        {
                            familyBedHistoryInfoNew = familyBedHistoryInfoOld;
                        }
                        break;

                    case "用药情况":
                        if (item["IsSetValue"].ToString() == "预设上次体检")
                        {
                            medicationNew = medicationOld;
                        }
                        else if (item["IsSetValue"].ToString() == "预设随访用药")
                        {
                            medicationNew = medicationFollowUp;
                        }
                        break;

                    default:
                        break;
                    }
                }

                #endregion

                #region 预防接种史

                dv.RowFilter = null;
                dv.RowFilter = "Comment='健康评价' AND (IsSetValue='是' OR IsSetValue='预设上次体检') ";
                dt           = dv.ToTable();
                List <RecordsInoculationHistoryModel> inoculationHistoryOld = InoculationHistoryBLL.GetModelList(
                    string.Format("IDCardNo='{0}' AND OutKey={1}", IDCardNo, customerOldModel.ID));
                if (inoculationHistoryOld == null)
                {
                    inoculationHistoryOld = new List <RecordsInoculationHistoryModel>();
                }

                List <RecordsInoculationHistoryModel> inoculationHistoryNew = new List <RecordsInoculationHistoryModel>();

                foreach (DataRow item in dt.Rows)
                {
                    switch (item["ChinName"].ToString())
                    {
                    case "非免疫预防接种史":
                        if (item["IsSetValue"].ToString() == "预设上次体检")
                        {
                            inoculationHistoryNew = inoculationHistoryOld;
                        }
                        break;
                    }
                }

                #endregion

                #region 保存默认值

                // 体检主档保存
                int id = CustomerBaseInfoBLL.Add(customerNewModel);

                if (id > 0)
                {
                    // 一般状况
                    gerneralNewModel.IDCardNo = IDCardNo;
                    gerneralNewModel.OutKey   = id;
                    GeneralConditionBLL.Add(gerneralNewModel, VersionNo);

                    // 生活方式
                    lifeStyleNewModel.IDCardNo = IDCardNo;
                    lifeStyleNewModel.OutKey   = id;
                    LifeStyleBLL.Add(lifeStyleNewModel);

                    // 查体信息
                    physicalExamNewModel.IDCardNo = IDCardNo;
                    physicalExamNewModel.OutKey   = id;
                    PhysicalExamBLL.Add(physicalExamNewModel);

                    // 辅助检查
                    assistCheckNewModel.IDCardNo = IDCardNo;
                    assistCheckNewModel.OutKey   = id;
                    AssistCheckBLL.Add(assistCheckNewModel);

                    // 脏器功能
                    visceraNewModel.IDCardNo = IDCardNo;
                    visceraNewModel.OutKey   = id;
                    VisceraFunctionBLL.Add(visceraNewModel);

                    // 中医体质
                    mediPhysDistModel.IDCardNo = IDCardNo;
                    mediPhysDistModel.OutKey   = id;
                    MediPhysDistBLL.Add(mediPhysDistModel);

                    // 健康问题
                    questionNewModel.IDCardNo = IDCardNo;
                    questionNewModel.OutKey   = id;
                    HealthQuestionBLL.Add(questionNewModel);

                    // 健康评价
                    assessmentGuideModel.IDCardNo = IDCardNo;
                    assessmentGuideModel.OutKey   = id;
                    AssessmentGuideBLL.Add(assessmentGuideModel);

                    // 住院史
                    if (hospitalHistoryNew.Count > 0)
                    {
                        foreach (RecordsHospitalHistoryModel recordsInoculationHistoryModel in hospitalHistoryNew)
                        {
                            recordsInoculationHistoryModel.OutKey   = id;
                            recordsInoculationHistoryModel.IDCardNo = IDCardNo;
                        }

                        HospitalHistoryBLL.AddList(hospitalHistoryNew);
                    }

                    // 家庭住院史
                    if (familyBedHistoryInfoNew.Count > 0)
                    {
                        foreach (RecordsFamilyBedHistoryModel model in familyBedHistoryInfoNew)
                        {
                            model.OutKey   = id;
                            model.IDCardNo = IDCardNo;
                        }

                        FamilyBedHistoryBLL.AddList(familyBedHistoryInfoNew);
                    }

                    // 用药
                    if (medicationNew.Count > 0)
                    {
                        foreach (RecordsMedicationModel model in medicationNew)
                        {
                            model.OutKey   = id;
                            model.IDCardNo = IDCardNo;
                        }

                        MedicationBLL.AddList(medicationNew);
                    }

                    // 接种史
                    if (inoculationHistoryNew.Count > 0)
                    {
                        foreach (RecordsInoculationHistoryModel model in inoculationHistoryNew)
                        {
                            model.OutKey   = id;
                            model.IDCardNo = IDCardNo;
                        }

                        InoculationHistoryBLL.AddList(inoculationHistoryNew);
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
                throw ex;
            }
        }
Beispiel #10
0
 public int Add(RecordsLifeStyleModel model)
 {
     return(this.dal.Add(model));
 }
 public bool UpdateByTJMiniPad(RecordsLifeStyleModel model, string checkDate)
 {
     return(this.dal.UpdateByTJMiniPad(model, checkDate));
 }
 public bool UpdateServer(RecordsLifeStyleModel model)
 {
     return(this.dal.UpdateServer(model));
 }