public int Add(RecordsMediPhysDistModel model) { StringBuilder builder = new StringBuilder(); builder.Append("INSERT INTO ARCHIVE_MEDI_PHYS_DIST("); builder.Append("PhysicalID,IDCardNo,Mild,Faint,Yang,Yin,PhlegmDamp,Muggy,BloodStasis,QiConstraint,Characteristic,OutKey,MedicineID,MedicineResultID)"); builder.Append(" VALUES ("); builder.Append("@PhysicalID,@IDCardNo,@Mild,@Faint,@Yang,@Yin,@PhlegmDamp,@Muggy,@BloodStasis,@QiConstraint,@Characteristic,@OutKey,@MedicineID,@MedicineResultID)"); builder.Append(";SELECT @@IDENTITY"); MySqlParameter[] cmdParms = new MySqlParameter[] { new MySqlParameter("@PhysicalID", MySqlDbType.String, 8), new MySqlParameter("@IDCardNo", MySqlDbType.String, 21), new MySqlParameter("@Mild", MySqlDbType.String, 1), new MySqlParameter("@Faint", MySqlDbType.String, 1), new MySqlParameter("@Yang", MySqlDbType.String, 1), new MySqlParameter("@Yin", MySqlDbType.String, 1), new MySqlParameter("@PhlegmDamp", MySqlDbType.String, 1), new MySqlParameter("@Muggy", MySqlDbType.String, 1), new MySqlParameter("@BloodStasis", MySqlDbType.String, 1), new MySqlParameter("@QiConstraint", MySqlDbType.String, 1), new MySqlParameter("@Characteristic", MySqlDbType.String, 1), new MySqlParameter("@OutKey", MySqlDbType.Int32, 4), new MySqlParameter("@MedicineID", MySqlDbType.Int32, 4), new MySqlParameter("@MedicineResultID", MySqlDbType.Int32, 11) }; cmdParms[0].Value = model.PhysicalID; cmdParms[1].Value = model.IDCardNo; cmdParms[2].Value = model.Mild; cmdParms[3].Value = model.Faint; cmdParms[4].Value = model.Yang; cmdParms[5].Value = model.Yin; cmdParms[6].Value = model.PhlegmDamp; cmdParms[7].Value = model.Muggy; cmdParms[8].Value = model.BloodStasis; cmdParms[9].Value = model.QiConstraint; cmdParms[10].Value = model.Characteristic; cmdParms[11].Value = model.OutKey; cmdParms[12].Value = model.MedicineID; cmdParms[13].Value = model.MedicineResultID; object single = MySQLHelper.GetSingle(builder.ToString(), cmdParms); if (single == null) { return(0); } return(Convert.ToInt32(single)); }
public bool UpdateServer(RecordsMediPhysDistModel model) { StringBuilder builder = new StringBuilder(); builder.Append("update ARCHIVE_MEDI_PHYS_DIST set "); builder.Append("PhysicalID=@PhysicalID,"); builder.Append("IDCardNo=@IDCardNo,"); builder.Append("Mild=@Mild,"); builder.Append("Faint=@Faint,"); builder.Append("Yang=@Yang,"); builder.Append("Yin=@Yin,"); builder.Append("PhlegmDamp=@PhlegmDamp,"); builder.Append("Muggy=@Muggy,"); builder.Append("BloodStasis=@BloodStasis,"); builder.Append("QiConstraint=@QiConstraint,"); builder.Append("Characteristic=@Characteristic,"); builder.Append("MedicineID=@MedicineID,"); builder.Append("MedicineResultID=@MedicineResultID "); builder.Append(" where IDCardNo=@IDCardNo"); MySqlParameter[] cmdParms = new MySqlParameter[] { new MySqlParameter("@PhysicalID", MySqlDbType.String, 8), new MySqlParameter("@IDCardNo", MySqlDbType.String, 21), new MySqlParameter("@Mild", MySqlDbType.String, 1), new MySqlParameter("@Faint", MySqlDbType.String, 1), new MySqlParameter("@Yang", MySqlDbType.String, 1), new MySqlParameter("@Yin", MySqlDbType.String, 1), new MySqlParameter("@PhlegmDamp", MySqlDbType.String, 1), new MySqlParameter("@Muggy", MySqlDbType.String, 1), new MySqlParameter("@BloodStasis", MySqlDbType.String, 1), new MySqlParameter("@QiConstraint", MySqlDbType.String, 1), new MySqlParameter("@Characteristic", MySqlDbType.String, 1), new MySqlParameter("@MedicineID", MySqlDbType.Int32, 4), new MySqlParameter("@MedicineResultID", MySqlDbType.Int32, 4) // new MySqlParameter("@ID", MySqlDbType.Int32, 8) }; cmdParms[0].Value = model.PhysicalID; cmdParms[1].Value = model.IDCardNo; cmdParms[2].Value = model.Mild; cmdParms[3].Value = model.Faint; cmdParms[4].Value = model.Yang; cmdParms[5].Value = model.Yin; cmdParms[6].Value = model.PhlegmDamp; cmdParms[7].Value = model.Muggy; cmdParms[8].Value = model.BloodStasis; cmdParms[9].Value = model.QiConstraint; cmdParms[10].Value = model.Characteristic; cmdParms[11].Value = model.MedicineID; cmdParms[12].Value = model.MedicineResultID; //cmdParms[11].Value = model.ID; return(MySQLHelper.ExecuteSqlServer(builder.ToString(), cmdParms) > 0); }
public List <RecordsMediPhysDistModel> DataTableToList(DataTable dt) { List <RecordsMediPhysDistModel> list = new List <RecordsMediPhysDistModel>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { RecordsMediPhysDistModel item = this.dal.DataRowToModel(dt.Rows[i]); if (item != null) { list.Add(item); } } } return(list); }
public int AddServer(RecordsMediPhysDistModel model) { return(this.dal.AddServer(model)); }
public bool UpdateServer(RecordsMediPhysDistModel model) { return(this.dal.UpdateServer(model)); }
public int Add(RecordsMediPhysDistModel model) { return(dal.Add(model)); }
public RecordsMediPhysDistModel DataRowToModel(DataRow row) { RecordsMediPhysDistModel recordsMediPhysDistModel = new RecordsMediPhysDistModel(); if (row != null) { if (((row["ID"] != null) && (row["ID"] != DBNull.Value)) && (row["ID"].ToString() != "")) { recordsMediPhysDistModel.ID = int.Parse(row["ID"].ToString()); } if ((row["PhysicalID"] != null) && (row["PhysicalID"] != DBNull.Value)) { recordsMediPhysDistModel.PhysicalID = row["PhysicalID"].ToString(); } if ((row["IDCardNo"] != null) && (row["IDCardNo"] != DBNull.Value)) { recordsMediPhysDistModel.IDCardNo = row["IDCardNo"].ToString(); } if ((row["Mild"] != null) && (row["Mild"] != DBNull.Value)) { recordsMediPhysDistModel.Mild = row["Mild"].ToString(); } if ((row["Faint"] != null) && (row["Faint"] != DBNull.Value)) { recordsMediPhysDistModel.Faint = row["Faint"].ToString(); } if ((row["Yang"] != null) && (row["Yang"] != DBNull.Value)) { recordsMediPhysDistModel.Yang = row["Yang"].ToString(); } if ((row["Yin"] != null) && (row["Yin"] != DBNull.Value)) { recordsMediPhysDistModel.Yin = row["Yin"].ToString(); } if ((row["PhlegmDamp"] != null) && (row["PhlegmDamp"] != DBNull.Value)) { recordsMediPhysDistModel.PhlegmDamp = row["PhlegmDamp"].ToString(); } if ((row["Muggy"] != null) && (row["Muggy"] != DBNull.Value)) { recordsMediPhysDistModel.Muggy = row["Muggy"].ToString(); } if ((row["BloodStasis"] != null) && (row["BloodStasis"] != DBNull.Value)) { recordsMediPhysDistModel.BloodStasis = row["BloodStasis"].ToString(); } if ((row["QiConstraint"] != null) && (row["QiConstraint"] != DBNull.Value)) { recordsMediPhysDistModel.QiConstraint = row["QiConstraint"].ToString(); } if ((row["Characteristic"] != null) && (row["Characteristic"] != DBNull.Value)) { recordsMediPhysDistModel.Characteristic = row["Characteristic"].ToString(); } if (((row["MedicineID"] != null) && (row["MedicineID"] != DBNull.Value)) && (row["MedicineID"].ToString() != "")) { recordsMediPhysDistModel.MedicineID = int.Parse(row["MedicineID"].ToString()); } if (((row["MedicineResultID"] != null) && (row["MedicineResultID"] != DBNull.Value)) && (row["MedicineResultID"].ToString() != "")) { recordsMediPhysDistModel.MedicineResultID = int.Parse(row["MedicineResultID"].ToString()); } } return(recordsMediPhysDistModel); }
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; } }