Exemplo n.º 1
0
        public RecordsMedicationModel DataRowToModel(DataRow row)
        {
            RecordsMedicationModel recordsMedicationModel = new RecordsMedicationModel();

            if (row != null)
            {
                if (((row["ID"] != null) && (row["ID"] != DBNull.Value)) && (row["ID"].ToString() != ""))
                {
                    recordsMedicationModel.ID = int.Parse(row["ID"].ToString());
                }
                if ((row["PhysicalID"] != null) && (row["PhysicalID"] != DBNull.Value))
                {
                    recordsMedicationModel.PhysicalID = row["PhysicalID"].ToString();
                }
                if ((row["IDCardNo"] != null) && (row["IDCardNo"] != DBNull.Value))
                {
                    recordsMedicationModel.IDCardNo = row["IDCardNo"].ToString();
                }
                if ((row["UseAge"] != null) && (row["UseAge"] != DBNull.Value))
                {
                    recordsMedicationModel.UseAge = row["UseAge"].ToString();
                }
                if ((row["UseNum"] != null) && (row["UseNum"] != DBNull.Value))
                {
                    recordsMedicationModel.UseNum = row["UseNum"].ToString();
                }
                if ((row["StartTime"] != null) && (row["StartTime"] != DBNull.Value))
                {
                    recordsMedicationModel.StartTime = row["StartTime"].ToString();
                }
                if ((row["EndTime"] != null) && (row["EndTime"] != DBNull.Value))
                {
                    recordsMedicationModel.EndTime = row["EndTime"].ToString();
                }
                if ((row["PillDependence"] != null) && (row["PillDependence"] != DBNull.Value))
                {
                    recordsMedicationModel.PillDependence = row["PillDependence"].ToString();
                }
                if ((row["MedicinalName"] != null) && (row["MedicinalName"] != DBNull.Value))
                {
                    recordsMedicationModel.MedicinalName = row["MedicinalName"].ToString();
                }
                if ((row["drugtype"] != null) && (row["drugtype"] != DBNull.Value))
                {
                    recordsMedicationModel.DrugType = row["drugtype"].ToString();
                }
                if ((row["factory"] != null) && (row["factory"] != DBNull.Value))
                {
                    recordsMedicationModel.Factory = row["factory"].ToString();
                }
            }
            return(recordsMedicationModel);
        }
Exemplo n.º 2
0
        public List <RecordsMedicationModel> DataTableToList(DataTable dt)
        {
            List <RecordsMedicationModel> list = new List <RecordsMedicationModel>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    RecordsMedicationModel item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Exemplo n.º 3
0
        public int AddServer(RecordsMedicationModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into ARCHIVE_MEDICATION(");
            builder.Append("PhysicalID,IDCardNo,UseAge,UseNum,");
            builder.Append("StartTime,EndTime,PillDependence,MedicinalName,drugtype,factory,OutKey)");
            builder.Append(" values (");
            builder.Append("@PhysicalID,@IDCardNo,@UseAge,@UseNum,@StartTime,@EndTime,@PillDependence,@MedicinalName,@OutKey");
            builder.Append("@drugtype,@factory)");
            builder.Append(";select @@IDENTITY");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@PhysicalID", MySqlDbType.String, 8),
                new MySqlParameter("@IDCardNo", MySqlDbType.String, 21),
                new MySqlParameter("@UseAge", MySqlDbType.String, 500),
                new MySqlParameter("@UseNum", MySqlDbType.String, 100),
                new MySqlParameter("@StartTime", MySqlDbType.String, 70),
                new MySqlParameter("@EndTime", MySqlDbType.String, 70),
                new MySqlParameter("@PillDependence", MySqlDbType.String, 10),
                new MySqlParameter("@MedicinalName", MySqlDbType.String, 100),
                new MySqlParameter("@drugtype", MySqlDbType.String, 100),
                new MySqlParameter("@factory", MySqlDbType.String, 100),
                new MySqlParameter("@OutKey", MySqlDbType.Int32, 4),
            };
            cmdParms[0].Value  = model.PhysicalID;
            cmdParms[1].Value  = model.IDCardNo;
            cmdParms[2].Value  = model.UseAge;
            cmdParms[3].Value  = model.UseNum;
            cmdParms[4].Value  = model.StartTime;
            cmdParms[5].Value  = model.EndTime;
            cmdParms[6].Value  = model.PillDependence;
            cmdParms[7].Value  = model.MedicinalName;
            cmdParms[8].Value  = model.DrugType;
            cmdParms[9].Value  = model.Factory;
            cmdParms[10].Value = model.OutKey;
            object single = MySQLHelper.GetSingleServer(builder.ToString(), cmdParms);

            if (single == null)
            {
                return(0);
            }
            return(Convert.ToInt32(single));
        }
Exemplo n.º 4
0
        public bool UpdateServer(RecordsMedicationModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update ARCHIVE_MEDICATION set ");
            builder.Append("PhysicalID=@PhysicalID,");
            builder.Append("IDCardNo=@IDCardNo,");
            builder.Append("UseAge=@UseAge,");
            builder.Append("UseNum=@UseNum,");
            builder.Append("StartTime=@StartTime,");
            builder.Append("EndTime=@EndTime,");
            builder.Append("PillDependence=@PillDependence,");
            builder.Append("MedicinalName=@MedicinalName,");
            builder.Append("drugtype =@drugtype,");
            builder.Append("factory =@factory ");
            builder.Append(" where IDCardNo=@IDCardNo");
            MySqlParameter[] cmdParms = new MySqlParameter[]
            {
                new MySqlParameter("@PhysicalID", MySqlDbType.String, 8),
                new MySqlParameter("@IDCardNo", MySqlDbType.String, 21),
                new MySqlParameter("@UseAge", MySqlDbType.String, 500),
                new MySqlParameter("@UseNum", MySqlDbType.String, 100),
                new MySqlParameter("@StartTime", MySqlDbType.String, 70),
                new MySqlParameter("@EndTime", MySqlDbType.String, 70),
                new MySqlParameter("@PillDependence", MySqlDbType.String, 10),
                new MySqlParameter("@MedicinalName", MySqlDbType.String, 100),
                new MySqlParameter("@drugtype", MySqlDbType.String, 100),
                new MySqlParameter("@factory", MySqlDbType.String, 100)
                //new MySqlParameter("@ID", MySqlDbType.Int32, 8)
            };
            cmdParms[0].Value = model.PhysicalID;
            cmdParms[1].Value = model.IDCardNo;
            cmdParms[2].Value = model.UseAge;
            cmdParms[3].Value = model.UseNum;
            cmdParms[4].Value = model.StartTime;
            cmdParms[5].Value = model.EndTime;
            cmdParms[6].Value = model.PillDependence;
            cmdParms[7].Value = model.MedicinalName;
            cmdParms[8].Value = model.DrugType;
            cmdParms[9].Value = model.Factory;
            // cmdParms[10].Value = model.ID;
            return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
Exemplo n.º 5
0
        public bool Add(RecordsMedicationModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("INSERT INTO ARCHIVE_MEDICATION(");
            strSql.Append("PhysicalID,IDCardNo,UseAge,UseNum,StartTime,EndTime,PillDependence,MedicinalName,drugtype,factory,");
            strSql.Append("OutKey,Num,Frequency,UseNumUnit,UseYear,UseYearUnit,OtherExplain,NumUnit,Remark,DrugYear,DrugMonth,");
            strSql.Append("DrugDay,FreUseNum,FreUseDay,UseDay,Effect,EffectDes,EachNum)");
            strSql.Append(" VALUES (");
            strSql.Append("@PhysicalID,@IDCardNo,@UseAge,@UseNum,@StartTime,@EndTime,@PillDependence,@MedicinalName,");
            strSql.Append("@drugtype,@factory,@OutKey,@Num,@Frequency,@UseNumUnit,@UseYear,@UseYearUnit,@OtherExplain,");
            strSql.Append("@NumUnit,@Remark,@DrugYear,@DrugMonth,@DrugDay,@FreUseNum,@FreUseDay,@UseDay,@Effect,@EffectDes,@EachNum)");

            MySqlParameter[] parameters =
            {
                new MySqlParameter("@PhysicalID",     MySqlDbType.VarChar, 100),
                new MySqlParameter("@IDCardNo",       MySqlDbType.VarChar,  21),
                new MySqlParameter("@UseAge",         MySqlDbType.VarChar, 100),
                new MySqlParameter("@UseNum",         MySqlDbType.VarChar, 100),
                new MySqlParameter("@StartTime",      MySqlDbType.VarChar, 100),
                new MySqlParameter("@EndTime",        MySqlDbType.VarChar, 100),
                new MySqlParameter("@PillDependence", MySqlDbType.VarChar, 100),
                new MySqlParameter("@MedicinalName",  MySqlDbType.VarChar, 100),
                new MySqlParameter("@drugtype",       MySqlDbType.VarChar, 100),
                new MySqlParameter("@factory",        MySqlDbType.VarChar, 100),
                new MySqlParameter("@OutKey",         MySqlDbType.Int32,    11),
                new MySqlParameter("@Num",            MySqlDbType.VarChar, 100),
                new MySqlParameter("@Frequency",      MySqlDbType.VarChar, 100),
                new MySqlParameter("@UseNumUnit",     MySqlDbType.VarChar, 100),
                new MySqlParameter("@UseYear",        MySqlDbType.VarChar, 100),
                new MySqlParameter("@UseYearUnit",    MySqlDbType.VarChar, 100),
                new MySqlParameter("@OtherExplain",   MySqlDbType.VarChar, 100),
                new MySqlParameter("@NumUnit",        MySqlDbType.VarChar,  10),
                new MySqlParameter("@Remark",         MySqlDbType.VarChar, 100),
                new MySqlParameter("@DrugYear",       MySqlDbType.VarChar,  10),
                new MySqlParameter("@DrugMonth",      MySqlDbType.VarChar,  10),
                new MySqlParameter("@DrugDay",        MySqlDbType.VarChar,  10),
                new MySqlParameter("@FreUseNum",      MySqlDbType.VarChar,  10),
                new MySqlParameter("@FreUseDay",      MySqlDbType.VarChar,  10),
                new MySqlParameter("@UseDay",         MySqlDbType.VarChar,  50),
                new MySqlParameter("@Effect",         MySqlDbType.VarChar,   1),
                new MySqlParameter("@EffectDes",      MySqlDbType.VarChar, 100),
                new MySqlParameter("@EachNum",        MySqlDbType.VarChar, 10)
            };

            parameters[0].Value  = model.PhysicalID;
            parameters[1].Value  = model.IDCardNo;
            parameters[2].Value  = model.UseAge;
            parameters[3].Value  = model.UseNum;
            parameters[4].Value  = model.StartTime;
            parameters[5].Value  = model.EndTime;
            parameters[6].Value  = model.PillDependence;
            parameters[7].Value  = model.MedicinalName;
            parameters[8].Value  = model.DrugType;
            parameters[9].Value  = model.Factory;
            parameters[10].Value = model.OutKey;
            parameters[11].Value = model.Num;
            parameters[12].Value = model.Frequency;
            parameters[13].Value = model.UseNumUnit;
            parameters[14].Value = model.UseYear;
            parameters[15].Value = model.UseYearUnit;
            parameters[16].Value = model.OtherExplain;
            parameters[17].Value = model.NumUnit;
            parameters[18].Value = model.Remark;
            parameters[19].Value = model.DrugYear;
            parameters[20].Value = model.DrugMonth;
            parameters[21].Value = model.DrugDay;
            parameters[22].Value = model.FreUseNum;
            parameters[23].Value = model.FreUseDay;
            parameters[24].Value = model.UseDay;
            parameters[25].Value = model.Effect;
            parameters[26].Value = model.EffectDes;
            parameters[27].Value = model.EachNum;

            int rows = MySQLHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        public void InitEveryThing()
        {
            dsRequire                 = new RequireBLL().GetList("TabName = '健康体检' AND Comment = '治疗情况' ");
            this.HospitalHistory      = new RecordsHospitalHistoryBLL().GetModelList(string.Format("IDCardNo = '{0}' and OutKey={1}", this.Model.IDCardNo, PhysicalInfoFactory.ID));
            this.FamilyBedHistoryInfo = new RecordsFamilyBedHistoryBLL().GetModelList(string.Format("IDCardNo = '{0}' and OutKey={1}", this.Model.IDCardNo, PhysicalInfoFactory.ID));


            this.Medication  = new RecordsMedicationBLL().GetModelList(string.Format("IDCardNo = '{0}' and OutKey={1}", this.Model.IDCardNo, PhysicalInfoFactory.ID));
            this.Perzhuyuans = new List <ZhuYuanUserControl> {
                this.zhuYuan1, this.zhuYuan2
            };
            this.FamZhuyuans = new List <ZhuYuanUserControl> {
                this.homezhuYuan1, this.homezhuYuan2
            };
            //新增体检时,从设备中读取的栏位设置为空
            if (PhysicalInfoFactory.falgID == 0)
            {
                if (area.Equals("威海"))
                {
                    this.Medication = new List <RecordsMedicationModel>();
                }
                this.PresetValue();
                if (community.Equals("平度云山医院") || area.Equals("威海"))//平度云山医院、威海,从高血压,糖尿病随访中获取用药
                {
                    string strYear      = DateTime.Now.Year.ToString();
                    string strHypeWhere = string.Format("  Left(FollowUpDate,4)='{0}' and IDCardNo='{1}' order by FollowUpDate desc  ", strYear, this.Model.IDCardNo);
                    List <ChronicHypertensionVisitModel> HyperModellist = new ChronicHypertensionVisitBLL().GetModelList(strHypeWhere);
                    if (HyperModellist.Count > 0)
                    {
                        List <ChronicDrugConditionModel> DrugConditions = new ChronicDrugConditionBLL().GetModelList(string.Format(" IDCardNo = '{0}' and type = '{1}' and OUTKey = '{2}' ", HyperModellist[0].IDCardNo, "1", HyperModellist[0].ID));
                        foreach (ChronicDrugConditionModel drugmodel in DrugConditions)
                        {
                            RecordsMedicationModel newModel = new RecordsMedicationModel
                            {
                                MedicinalName = drugmodel.Name,
                                UseNum        = drugmodel.DosAge,
                                IDCardNo      = this.Model.IDCardNo
                            };
                            this.Medication.Add(newModel);
                        }
                    }
                    string strDiaWhere = string.Format(" Left(VisitDate,4)='{0}'and IDCardNo='{1}' order by VisitDate desc  ", strYear, this.Model.IDCardNo);
                    List <ChronicDiadetesVisitModel> DiamodelList = new ChronicDiadetesVisitBLL().GetModelList(strDiaWhere);
                    if (DiamodelList.Count > 0)
                    {
                        List <ChronicDrugConditionModel> DiaDrugConditions = new ChronicDrugConditionBLL().GetModelList(string.Format(" IDCardNo = '{0}' and type = '{1}' and OUTKey = '{2}' ", DiamodelList[0].IDCardNo, "2", DiamodelList[0].ID));
                        foreach (ChronicDrugConditionModel drugmodel in DiaDrugConditions)
                        {
                            RecordsMedicationModel newModel = new RecordsMedicationModel
                            {
                                MedicinalName = drugmodel.Name,
                                UseNum        = drugmodel.DosAge,
                                IDCardNo      = this.Model.IDCardNo
                            };
                            this.Medication.Add(newModel);
                        }
                    }
                }
            }
            for (int i = 0; i < this.HospitalHistory.Count; i++)
            {
                this.Perzhuyuans[i].PerSource = this.HospitalHistory[i];
            }
            for (int j = 0; j < this.FamilyBedHistoryInfo.Count; j++)
            {
                this.FamZhuyuans[j].FamSource = this.FamilyBedHistoryInfo[j];
            }
            if (this.FamilyBedHistoryInfo.Count > 0)
            {
                this.homezhuYuan1.FamSource = this.FamilyBedHistoryInfo[0];
                if (this.FamilyBedHistoryInfo.Count == 2)
                {
                    this.homezhuYuan2.FamSource = this.FamilyBedHistoryInfo[1];
                }
            }

            //读取用药情况
            if (File.Exists(Application.StartupPath + "\\dose.xml"))
            {
                DataSet ds = new DataSet();

                ds.ReadXml(Application.StartupPath + "\\dose.xml");
                DataTable dt_yw = ds.Tables[0];
                doseUC1.setSource(dt_yw);
                doseUC2.setSource(DeepCopy(dt_yw));
                doseUC3.setSource(DeepCopy(dt_yw));
                doseUC4.setSource(DeepCopy(dt_yw));
                doseUC5.setSource(DeepCopy(dt_yw));
                doseUC6.setSource(DeepCopy(dt_yw));
            }

            for (int k = 0; k < this.doses.Count; k++)
            {
                if (k < this.Medication.Count)
                {
                    this.doses[k].Source = this.Medication[k];
                }
                else
                {
                    RecordsMedicationModel recordsMedicationModel = new RecordsMedicationModel
                    {
                        IDCardNo   = this.Model.IDCardNo,
                        ModelState = RecordsStateModel.NoValue
                    };
                    this.doses[k].Source = recordsMedicationModel;
                }
            }
            this.EveryThingIsOk = true;
            MustChoose();
        }
Exemplo n.º 7
0
 public int AddServer(RecordsMedicationModel model)
 {
     return(this.dal.AddServer(model));
 }
Exemplo n.º 8
0
 public bool UpdateServer(RecordsMedicationModel model)
 {
     return(this.dal.UpdateServer(model));
 }
Exemplo n.º 9
0
        public void InitEveryThing()
        {
            this.HospitalHistory      = new RecordsHospitalHistoryBLL().GetModelList(string.Format("IDCardNo = '{0}' and OutKey={1}", this.Model.IDCardNo, PhysicalInfoFactory.ID));
            this.FamilyBedHistoryInfo = new RecordsFamilyBedHistoryBLL().GetModelList(string.Format("IDCardNo = '{0}' and OutKey={1}", this.Model.IDCardNo, PhysicalInfoFactory.ID));
            this.Medication           = new RecordsMedicationBLL().GetModelList(string.Format("IDCardNo = '{0}' and OutKey={1}", this.Model.IDCardNo, PhysicalInfoFactory.ID));
            this.Perzhuyuans          = new List <ZhuYuanUserControl> {
                this.zhuYuan1, this.zhuYuan2
            };
            this.FamZhuyuans = new List <ZhuYuanUserControl> {
                this.homezhuYuan1, this.homezhuYuan2
            };
            for (int i = 0; i < this.HospitalHistory.Count; i++)
            {
                this.Perzhuyuans[i].PerSource = this.HospitalHistory[i];
            }
            for (int j = 0; j < this.FamilyBedHistoryInfo.Count; j++)
            {
                this.FamZhuyuans[j].FamSource = this.FamilyBedHistoryInfo[j];
            }
            if (this.FamilyBedHistoryInfo.Count > 0)
            {
                this.homezhuYuan1.FamSource = this.FamilyBedHistoryInfo[0];
                if (this.FamilyBedHistoryInfo.Count == 2)
                {
                    this.homezhuYuan2.FamSource = this.FamilyBedHistoryInfo[1];
                }
            }

            //读取用药情况
            if (File.Exists(Application.StartupPath + "\\dose.xml"))
            {
                DataSet ds = new DataSet();

                ds.ReadXml(Application.StartupPath + "\\dose.xml");
                DataTable dt_yw = ds.Tables[0];
                doseUC1.setSource(dt_yw);
                doseUC2.setSource(DeepCopy(dt_yw));
                doseUC3.setSource(DeepCopy(dt_yw));
                doseUC4.setSource(DeepCopy(dt_yw));
                doseUC5.setSource(DeepCopy(dt_yw));
                doseUC6.setSource(DeepCopy(dt_yw));
            }

            for (int k = 0; k < this.doses.Count; k++)
            {
                if (k < this.Medication.Count)
                {
                    this.doses[k].Source = this.Medication[k];
                }
                else
                {
                    RecordsMedicationModel recordsMedicationModel = new RecordsMedicationModel
                    {
                        IDCardNo   = this.Model.IDCardNo,
                        ModelState = RecordsStateModel.NoValue
                    };
                    this.doses[k].Source = recordsMedicationModel;
                }
            }
            this.EveryThingIsOk = true;
        }
Exemplo n.º 10
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;
            }
        }
Exemplo n.º 11
0
 public bool Add(RecordsMedicationModel model)
 {
     return(this.dal.Add(model));
 }