using HL_FristAidPlatform_DataBase; using HL_FristAidPlatform_Help; using HL_FristAidPlatform_IDataBase; using HL_FristAidPlatform_Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HL_FristAidPlatform_Bussiness { public class T_Service_Apoplexy_FollowUpInfoBLL { private IT_Service_Apoplexy_FollowUpInfo IService = new T_Service_Apoplexy_FollowUpInfoDB(); IT_Service_Apoplexy_FollowUpBase FIService = new T_Service_Apoplexy_FollowUpBaseDB(); public int sum = 0; public int count = 39; public T_Service_Apoplexy_FollowUpInfo GetByFGuid(string FGuid) { return IService.GetByFGuid(FGuid); } /// /// 新增患者随访计划 /// /// /// public T_Service_Apoplexy_FollowUpInfo Add(T_Service_Apoplexy_FollowUpInfo model) { return IService.Add(model); } public MessageModel AddORUpdate(T_Service_Apoplexy_FollowUpInfo model) { //先查询有没有该患者数据 T_Service_Apoplexy_FollowUpInfo anxywb = new T_Service_Apoplexy_FollowUpInfo(); anxywb = IService.GetByFGuid(model.FGUID); model.Proportion = GetProportion(model); if (anxywb != null) //有执行修改操作 { model.GUID = anxywb.GUID; if (IService.Update(model) > 0) { DeleteFollowlist(model); return new MessageModel { Success = true, Msg = "修改成功" }; } else { return new MessageModel { Success = false, Msg = "修改失败" }; } } else { //没有执行新增操作 model.GUID = Guid.NewGuid().ToString(); if (Add(model) != null) { DeleteFollowlist(model); return new MessageModel { Success = true, Msg = "新增成功" }; } else { return new MessageModel { Success = true, Msg = "新增成功" }; } } } public void DeleteFollowlist(T_Service_Apoplexy_FollowUpInfo model) { //判断是否死亡后删除下面的随访记录 if (!string.IsNullOrEmpty(model.FIsDie) && int.Parse(model.FIsDie) == 1) { T_Service_Apoplexy_FollowUpBase FB = FIService.GetByGuid(model.FGUID); List FBPList = FIService.GetFollowUpList(FB.PatientGuid); for (int i = 0; i < FBPList.Count; i++) { int comp = DateTime.Compare(FBPList[i].NextTime, FB.NextTime); if (comp > 0) { T_Service_Apoplexy_FollowUpBase fbtemp = new T_Service_Apoplexy_FollowUpBase(); fbtemp.GUID = FBPList[i].GUID.ToString(); FIService.Delete(fbtemp); } } } } public string GetProportion(T_Service_Apoplexy_FollowUpInfo model) { if (!string.IsNullOrEmpty(model.FMode)) { sum = sum + 1; } //cbcFNurse 随访期间护理人员 if (!string.IsNullOrEmpty(model.FNurse)) { sum = sum + 1; } if (!string.IsNullOrEmpty(model.FWork)) { sum = sum + 1; } //随访期间新发事件 if (!string.IsNullOrEmpty(model.FNewDisease)) { sum = sum + 1; int temp1 = 0; int temp2 = 0; if (model.FNewDisease.Contains("01")) { if (!string.IsNullOrEmpty(model.FAType)) { temp1 = temp1 + 1; } if (!string.IsNullOrEmpty(model.FATypeDate.ToString())) { temp1 = temp1 + 1; } temp2 = temp2 + 2; } if (model.FNewDisease.Contains("02")) { if (!string.IsNullOrEmpty(model.FTIADate.ToString())) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FNewDisease.Contains("03")) { if (!string.IsNullOrEmpty(model.FMyocardialInfarctionDate.ToString())) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FNewDisease.Contains("04")) { if (!string.IsNullOrEmpty(model.FAnginaDate.ToString())) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FNewDisease.Contains("05")) { if (!string.IsNullOrEmpty(model.FHeartFailureDate.ToString())) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FNewDisease.Contains("06")) { if (!string.IsNullOrEmpty(model.FEmbolismDate.ToString())) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FNewDisease.Contains("07")) { if (!string.IsNullOrEmpty(model.FVascularDiseaseDate.ToString())) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FNewDisease.Contains("08")) { if (!string.IsNullOrEmpty(model.FMainDiagnosis)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FNewDisease.Contains("98")) { sum += 0; count += 0; } if (temp1 != 0 || temp2 != 0) { sum += temp1; count += temp2; } } //随访期间新发危险因素 cbcFNewDiseaseRisk if (!string.IsNullOrEmpty(model.FNewDiseaseRisk)) { sum = sum + 1; } //FSmokingSituation if (!string.IsNullOrEmpty(model.FSmokingSituation)) { sum = sum + 1; } if (!string.IsNullOrEmpty(model.FDrinkingSituation)) { sum = sum + 1; } if (!string.IsNullOrEmpty(model.FMovement)) { sum = sum + 1; } //FPressureRate 测量频率 if (!string.IsNullOrEmpty(model.FPressureRate)) { if (int.Parse(model.FPressureRate) != 3) { sum = sum + 1; //FSystolicPressure if (!string.IsNullOrEmpty(model.FSystolicPressure)) { sum = sum + 1; } //FDiastolicPressure if (!string.IsNullOrEmpty(model.FDiastolicPressure)) { sum = sum + 1; } count += 2; } else { sum = sum + 3; } } //FSugarRate if (!string.IsNullOrEmpty(model.FSugarRate)) { if (int.Parse(model.FSugarRate) != 3) { sum = sum + 1; //FEmptyStomachSuger if (!string.IsNullOrEmpty(model.FEmptyStomachSuger)) { sum = sum + 1; } //FAfterMealSuger if (!string.IsNullOrEmpty(model.FAfterMealSuger)) { sum = sum + 1; } count += 2; } else { sum = sum + 3; } } //是否使用抗栓药物 IsFAntithrombotic if (!string.IsNullOrEmpty(model.IsFAntithrombotic)) { if (int.Parse(model.IsFAntithrombotic) == 1) { sum = sum + 1; int temp1 = 0; int temp2 = 0; //cbcFDrugName 服用药物名称 if (!string.IsNullOrEmpty(model.FDrugName)) { sum = sum + 1; //count = count + 1; if (model.FDrugName.Contains("01")) { if (!string.IsNullOrEmpty(model.FASPLUsage)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FDrugName.Contains("02")) { if (!string.IsNullOrEmpty(model.FLBGLUsage)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FDrugName.Contains("03")) { if (!string.IsNullOrEmpty(model.FAZGLUsage)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FDrugName.Contains("04")) { if (!string.IsNullOrEmpty(model.FSBDMUsage)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FDrugName.Contains("05")) { if (!string.IsNullOrEmpty(model.FSLPDUsage)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FDrugName.Contains("06")) { if (!string.IsNullOrEmpty(model.FXLTCUsage)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FDrugName.Contains("07")) { if (!string.IsNullOrEmpty(model.FHFLUsage)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FDrugName.Contains("08")) { if (!string.IsNullOrEmpty(model.FDBJQUsage)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FDrugName.Contains("09")) { if (!string.IsNullOrEmpty(model.FLFSBUsage)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FDrugName.Contains("10")) { if (!string.IsNullOrEmpty(model.FAPSBUsage)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } if (model.FDrugName.Contains("99")) { if (!string.IsNullOrEmpty(model.FOtherDrugs)) { temp1 = temp1 + 1; } temp2 = temp2 + 1; } sum += temp1; count += temp2; } } else { sum = sum + 13; } } //FIsPressure 降压药 if (!string.IsNullOrEmpty(model.FIsPressure)) { if (int.Parse(model.FIsPressure) == 1) { sum = sum + 1; if (!string.IsNullOrEmpty(model.FPressureGroup)) { sum = sum + 1; } if (!string.IsNullOrEmpty(model.FPressureType)) { sum = sum + 1; } count += 2; } else { sum = sum + 3; } } //FIsSugar 是否使用降糖药 if (!string.IsNullOrEmpty(model.FIsSugar)) { if (int.Parse(model.FIsSugar) == 1) { sum = sum + 1; if (!string.IsNullOrEmpty(model.FSugarType)) { sum = sum + 1; } count += 1; } else { sum = sum + 2; } } //是否使用调脂药 if (!string.IsNullOrEmpty(model.FIsLipid)) { if (int.Parse(model.FIsLipid) == 1) { sum = sum + 1; if (!string.IsNullOrEmpty(model.FLipidType)) { sum = sum + 1; } count += 1; } else { sum = sum + 2; } } //是否失访 if (!string.IsNullOrEmpty(model.IsF)) { if (int.Parse(model.IsF) == 0) { sum = sum + 3; } else { sum = sum + 1; if (!string.IsNullOrEmpty(model.FNoFReason)) { sum = sum + 1; if (int.Parse(model.FNoFReason) == 2) { if (!string.IsNullOrEmpty(model.FNoFReasonOther)) { sum = sum + 1; } count += 1; } else { sum = sum + 1; } count += 1; } } } //mrs评分 if (!string.IsNullOrEmpty(model.FIsmRS)) { if (int.Parse(model.FIsmRS) == 0) { sum += 2; } else { sum += 1; if (!string.IsNullOrEmpty(model.FmRSScore)) { sum += 1; } count += 1; } } //NIHSS评分 if (!string.IsNullOrEmpty(model.FIsNIHSS)) { if (int.Parse(model.FIsNIHSS) == 0) { sum += 2; } else { sum += 1; if (!string.IsNullOrEmpty(model.FNIHSSScore)) { sum += 1; } count += 1; } } //是否死亡 if (!string.IsNullOrEmpty(model.FIsDie)) { if (int.Parse(model.FIsDie) == 0) { sum = sum + 3; } else { sum = sum + 1; if (!string.IsNullOrEmpty(model.FDieReason)) { sum = sum + 1; } if (!string.IsNullOrEmpty(model.FDieTime.ToString())) { sum = sum + 1; } count += 2; } } //体重 if (!string.IsNullOrEmpty(model.FWeight)) { sum = sum + 1; } //收缩压 if (!string.IsNullOrEmpty(model.FSystolicPressureValue)) { sum = sum + 1; } //舒张压 if (!string.IsNullOrEmpty(model.FDiastolicPressureValue)) { sum = sum + 1; } //是否检查心电图 if (!string.IsNullOrEmpty(model.FIsElectrocardiogram)) { if (int.Parse(model.FIsElectrocardiogram) == 1) { sum = sum + 1; //心电图结果 if (!string.IsNullOrEmpty(model.FElectrocardiogramResult)&& model.FElectrocardiogramResult!=";;") { sum = sum + 1; } count += 1; } else { sum = sum + 2; } } //空腹血糖 if (!string.IsNullOrEmpty(model.FEmptyStomachSugerValue)) { sum = sum + 1; } //餐后两小时血糖数值 if (!string.IsNullOrEmpty(model.FAfterMealSugerValue)) { sum = sum + 1; } //糖化血红蛋白数值 if (!string.IsNullOrEmpty(model.FGlycosylatedhemoglobinValue)) { sum = sum + 1; } //甘油三脂数值 if (!string.IsNullOrEmpty(model.FTriglycerideValue)) { sum = sum + 1; } //胆固醇数值 if (!string.IsNullOrEmpty(model.FCholesterolValue)) { sum = sum + 1; } //低密度脂蛋白胆固醇数值 if (!string.IsNullOrEmpty(model.FLowCholesterolValue)) { sum = sum + 1; } //高密度脂蛋白胆固醇数值 if (!string.IsNullOrEmpty(model.FHighCholesterolValue)) { sum = sum + 1; } //同型半胱氨酸数值 if (!string.IsNullOrEmpty(model.FHomocysteineValue)) { sum = sum + 1; } model.Proportion = "0"; if (sum != 0) { string temp = ((double)sum / (double)count).ToString("0%"); string[] t = temp.Split("%"); model.Proportion = t[0]; } if (model.IsF == "1" || model.FIsDie == "1") { model.Proportion = "100"; } return model.Proportion; } } }