public IActionResult Put([FromODataUri] Guid key, ClinicalHistory clinicalhistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            using (var trans = context.Database.BeginTransaction())
            {
                try
                {
                    if (context.ClinicalHistories.Find(key) == null)
                    {
                        return(NotFound());
                    }
                    //context = new ApplicationDbContext(context.Options);
                    var local = context.ClinicalHistories.Local.FirstOrDefault(it => it.ClinicalHistoryID.Equals(key));
                    if (local != null)
                    {
                        context.Entry(local).State = EntityState.Detached;
                    }


                    context.Entry(clinicalhistory).State = EntityState.Modified;
                    context.SaveChanges();
                    trans.Commit();
                    return(Ok(clinicalhistory));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(BadRequest(ex));
                }
            }
        }
Ejemplo n.º 2
0
        private ClinicalHistoryVM MapToClinicalHistoryVM(ClinicalHistory ch)
        {
            try
            {
                ClinicalHistoryVM clinicalHistoryVM = new ClinicalHistoryVM()
                {
                    UserId         = ch.UserId,
                    Age            = ch.User.Age,
                    BloodGroupType = ch.BloodGroupId is null ? BloodGroup.Unknown : (BloodGroup)ch.BloodGroupId,
                    Smoker         = ch.Smoker,
                    Drinker        = ch.Drinker.HasValue ? ((DrinkHabit)ch.Drinker).ToString() : "",
                    Excercise      = ch.Excercise.Value,
                    Sports         = (Sports)ch.Sports,

                    BloodPressure = (ch.PressureSystolic is null ? "-" : $"{ch.PressureSystolic} / {ch.PressureDiastolic}"),
                    Pulse         = ch.Pulse.ToString(),
                    Cholesterol   = ch.Cholesterol?.ToString(),
                    Diabetes      = ch.Diabetes?.ToString(),
                    Height        = ch.Height,
                    Weight        = ch.Weight?.ToString(),

                    AllergyList = ch.AllergyInfo.Split(",", StringSplitOptions.RemoveEmptyEntries),

                    ClinicalInfoLastUpdated    = ch.ClinicalInfoLastUpdated,
                    PersonalHistoryLastUpdated = ch.PersonalHistoryLastUpdated
                };

                return(clinicalHistoryVM);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(new ClinicalHistoryVM());
            }
        }
Ejemplo n.º 3
0
        //{{"last_exploration":{"temperature":18.0,"observations":null,"heart_rate":17,"breathing_frec":17,"blood_pressure":17.0},"antecedents":[{"type":"patologico ","name":"antecedent","description":"antecedent"}],"ailments":[{"symptom_location":"mucho dolor","main_symptom":"dolor","end_date":"2013-01-11","date_of_detection":"2016-01-29","colateral_symptom":"dolor"}]}
        public static ClinicalHistory GetClinicalHistory(int id)
        {
            string             url          = String.Format("/history?id_patient={0}", id);
            string             res          = RESTHelper.Execute(url, "", "GET");
            ClinicalHistory_Tr deserealized = JsonConvert.DeserializeObject <ClinicalHistory_Tr>(res);
            //ClinicalHistory_Tr transaction = new ClinicalHistory_Tr();
            ClinicalHistory History = new ClinicalHistory();

            History.ailments         = deserealized.ailments;
            History.last_exploration = deserealized.last_exploration;
            History.antecedents      = deserealized.antecedents;
            return(History);
        }
Ejemplo n.º 4
0
        public async Task <bool> UpdatePersonalHistory(PatientPersonalHistoryVM vm)
        {
            if (vm.PatientId < 1)
            {
                return(false);
            }

            ClinicalHistory ch = await _pasContext.ClinicalHistory
                                 .Include(ch => ch.User)
                                 .FirstAsync(ch => ch.UserId == vm.PatientId);

            ch.User.Age         = DateTime.Today.Year - vm.DateOfBirth.Year;
            ch.User.DateOfBirth = vm.DateOfBirth;
            ch.BloodGroupId     = (int)vm.BloodGroup;
            ch.Smoker           = vm.SmokePerDay;
            ch.Drinker          = (short)vm.Drinker;
            ch.Excercise        = vm.Excercise;
            ch.Sports           = (short)vm.Sports;

            ch.PersonalHistoryLastUpdated = DateTime.Now;

            _pasContext.ClinicalHistory.Update(ch);
            await _pasContext.SaveChangesAsync();

            //## Now Update the Cache- if the page is reloaded- show the latest info
            string redisKey = $"{CacheKey.ClinicalDetails}_{vm.PatientId}";

            var cachedResult = _cacheService.GetCacheValue <ClinicalHistoryVM>(redisKey);

            cachedResult.Age            = ch.User.Age;
            cachedResult.DateOfBirth    = vm.DateOfBirth;
            cachedResult.BloodGroupType = vm.BloodGroup;
            cachedResult.Smoker         = vm.SmokePerDay;
            cachedResult.Drinker        = vm.Drinker.ToString();
            cachedResult.Excercise      = vm.Excercise;
            cachedResult.Sports         = vm.Sports;

            ch.PersonalHistoryLastUpdated = DateTime.Now;
            _cacheService.SetCacheValue(redisKey, cachedResult);

            //TODO: Log this Event- Patient updated Personal History

            return(true);
        }
        public IActionResult Post(ClinicalHistory clinicalhistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            using (var trans = context.Database.BeginTransaction())
            {
                try
                {
                    context.ClinicalHistories.Add(clinicalhistory);
                    context.SaveChanges();
                    trans.Commit();
                    return(Ok(clinicalhistory));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(BadRequest(ex));
                }
            }
        }
Ejemplo n.º 6
0
 private void btnBuscarHist_Click(object sender, EventArgs e)
 {
     try
     {
         ClinicalHistory hist = ClinicalHistory_Ctrl.GetClinicalHistory(int.Parse(txtHistPaciente.Text));
         lblTemp.Text          = hist.last_exploration.temperature.ToString();
         lblPresion.Text       = hist.last_exploration.blood_pressure.ToString();
         lblFrecResp.Text      = hist.last_exploration.breathing_frec.ToString();
         lblFrecCard.Text      = hist.last_exploration.heart_rate.ToString();
         lblObservaciones.Text = hist.last_exploration.observations;
         foreach (var item in hist.antecedents)
         {
             lstAntecedentes.Items.Add(String.Format("{0}: {1}", item.type.ToString(), item.description.ToString()));
         }
         foreach (var item in hist.ailments)
         {
             lstPacientes.Items.Add(String.Format("Síntoma principal: {0}. ", item.main_symptom));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }