Example #1
0
        public string Medication(mp_medical_history mp_medical_history, IFormCollection collections)
        {
            if (ModelState.IsValid)
            {
                //var profile = _profileService.GetByUserId(Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)));
                mp_medical_history.created_at     = DateTime.Now;
                mp_medical_history.created_by     = User.FindFirstValue(ClaimTypes.NameIdentifier);
                mp_medical_history.profile_id     = Guid.Parse(collections["profile_id"]);
                mp_medical_history.appointment_id = Guid.Parse(collections["appointment_id"]);
                _pschosocialService.AddMedicalHistory(mp_medical_history);

                List <mp_medication> mp_medications = new List <mp_medication>();
                var medication = collections["medication"];
                //save medication
                if (medication.Count > 0 && medication[0].Trim() != "")
                {
                    for (int i = 0; i < medication.Count; i++)
                    {
                        mp_medications.Add(new mp_medication
                        {
                            medication = medication[i],
                            dosage     = collections["dosage"][i],
                            //last_dose = DateTime.Parse(collections["last_dose"][i]),
                            physician            = collections["physician"][i],
                            taking_as_prescribed = int.Parse(collections["taking_as_prescribed"][i]),
                            created_at           = DateTime.Now,
                            created_by           = User.FindFirstValue(ClaimTypes.NameIdentifier),
                            profile_id           = Guid.Parse(collections["profile_id"])
                        });
                    }
                    if (mp_medications.Count() > 0)
                    {
                        _pschosocialService.AddMedication(mp_medications);
                    }
                }


                List <mp_surgical_history> surgical_Histories = new List <mp_surgical_history>();
                var surgical_type = collections["surgery_type"];
                //save medication
                if (surgical_type.Count > 0 && surgical_type[0].Trim() != "")
                {
                    for (int i = 0; i < surgical_type.Count; i++)
                    {
                        surgical_Histories.Add(new mp_surgical_history
                        {
                            surgery_type = int.Parse(surgical_type[i]),
                            date         = DateTime.Parse(collections["date"][i]),
                            comments     = collections["comment"],
                            created_at   = DateTime.Now,
                            created_by   = User.FindFirstValue(ClaimTypes.NameIdentifier),
                            profile_id   = Guid.Parse(collections["profile_id"])
                        });
                    }
                    if (surgical_Histories.Count() > 0)
                    {
                        _pschosocialService.AddSurgicalHistories(surgical_Histories);
                    }
                }
                return("success");
            }

            return("failure");
        }
Example #2
0
 public int AddMedicalHistory(mp_medical_history history)
 {
     _context.Add(history);
     return(_context.SaveChanges());
 }