예제 #1
0
        public BloodPressureDto PostBloodPressure(BloodPressureDto bloodPressureDto)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var bloodPressure = Mapper.Map <BloodPressureDto, BloodPressure>(bloodPressureDto);

            _context.BloodPressure.Add(bloodPressure);
            _context.SaveChanges();

            bloodPressureDto.BloodPressureId = bloodPressure.BloodPressureId;

            return(bloodPressureDto);
        }
예제 #2
0
        public void PutBloodPressure(int id, BloodPressureDto bloodPressureDto)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            var bloodPressure = _context.BloodPressure.SingleOrDefault(b => b.BloodPressureId == id);

            if (bloodPressure == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            Mapper.Map(bloodPressureDto, bloodPressure);

            _context.SaveChanges();
        }
예제 #3
0
        private BloodPressureDto CreateBloodPressureDto(ResultDto systolicBp, ResultDto diastolicBp)
        {
            if (systolicBp.ResultType.DisplayName != SystolicBP || diastolicBp.ResultType.DisplayName != DiastolicBP)
            {
                return(null);
            }

            var bloodPressureDto = new BloodPressureDto();

            if (systolicBp != null && systolicBp.ResultValue != null && systolicBp.ResultValue.PhysicalQuantity != null)
            {
                bloodPressureDto.SystollicMeasure = GetNullableIntValue(systolicBp.ResultValue.PhysicalQuantity.Value);
            }

            if (diastolicBp != null && diastolicBp.ResultValue != null && diastolicBp.ResultValue.PhysicalQuantity != null)
            {
                bloodPressureDto.DiastollicMeasure = GetNullableIntValue(diastolicBp.ResultValue.PhysicalQuantity.Value);
            }

            return(bloodPressureDto);
        }
예제 #4
0
 private static void RemoveBloodPressure(BloodPressureDto bloodPressureDto, VitalSign vitalSign, BloodPressure bloodPressure)
 {
     vitalSign.RemoveBloodPressure(bloodPressure);
 }
예제 #5
0
 private static void ChangeBloodPressure(BloodPressureDto bloodPressureDto, VitalSign vitalSign, BloodPressure bloodPressure)
 {
     RemoveBloodPressure(bloodPressureDto, vitalSign, bloodPressure);
     AddBloodPressure(bloodPressureDto, vitalSign);
 }
예제 #6
0
 private static void AddBloodPressure(BloodPressureDto bloodPressureDto, VitalSign vitalSign)
 {
     vitalSign.AddBloodPressure(
         new BloodPressure(bloodPressureDto.SystollicMeasure.GetValueOrDefault(), bloodPressureDto.DiastollicMeasure.GetValueOrDefault()));
 }