/// <summary> /// 新增血压 /// </summary> /// <param name="input">新增血压请求</param> /// <returns></returns> public async Task <OutputBase> Add(AddBloodPressureInput input) { var patient = await _patientRepository.Get((int)input.PatientId); if (patient == null) { return(OutputBase.Fail("该患者不存在")); } var entity = new BloodPressure { DataSource = input.DataSource, PatientId = input.PatientId, DiastolicPressure = input.DiastolicPressure, DiastolicPressureIsNormal = ChronicDiseaseUtility.IsDiastolicPressureNormal(input.DiastolicPressure), SystolicPressure = input.SystolicPressure, SystolicPressureIsNormal = ChronicDiseaseUtility.IsSystolicPressureNormal(input.SystolicPressure), HeartRate = input.HeartRate, HeartRateIsNormal = ChronicDiseaseUtility.IsHeartRateNormal(input.HeartRate) }; _bloodPressureRepository.Add(entity); return(_unitWork.Commit() ? OutputBase.Success("已成功录入血压") : OutputBase.Fail("录入血压失败")); }
/// <summary> /// 同步血压 /// </summary> /// <param name="sync"></param> /// <returns></returns> public async Task <OutputBase> Add(AddBloodPressureSync sync) { if (await _repository.IsExist(sync.DialysisBloodPressureId, sync.HospitalId)) { return(OutputBase.Fail("此血压数据已存在")); } var patient = await _patientRepository.Get(sync.DialysisPatientId, sync.HospitalId); if (patient == null) { return(OutputBase.Fail("此患者不存在")); } var bloodPressure = Mapper.Map <AddBloodPressureSync, BloodPressure>(sync); bloodPressure.PatientId = patient.Id; _repository.Add(bloodPressure); return(_unitWork.Commit() ? OutputBase.Success("保存成功") : OutputBase.Fail("保存失败")); }