コード例 #1
0
        public ActionResult MedicalHistory(int id)
        {
            var patient = db.Patients.Find(id);

            if (patient == null)
            {
                return(this.InvokeHttp404(HttpContext));
            }

            var history = db.MedicalHistories
                          .FirstOrDefault(mh => mh.patientID == id);

            if (history == null)
            {
                history           = new MedicalHistory();
                history.patientID = id;
                history.completed = false;
                db.MedicalHistories.Add(history);
                db.SaveChanges();
            }

            var model = new MedicalHistoryViewModel();

            model.patientID = id;
            model.Patient   = patient;
            GlobalHelpers.Transfer <MedicalHistory, MedicalHistoryViewModel>(history, model);
            model.medicalhistoryID = history.ID;
            return(View(model));
        }
コード例 #2
0
        public async Task <ActionResult <MedicalHistory> > PostMedicalHistory(MedicalHistoryViewModel medicalHistoryModel)
        {
            var medicalHistory = new MedicalHistory
            {
                BloodType         = medicalHistoryModel.BloodType,
                ApplicationUserId = medicalHistoryModel.ApplicationUserId
            };

            _context.MedicalHistory.Add(medicalHistory);
            await _context.SaveChangesAsync();

            foreach (var operation in medicalHistoryModel.Operations)
            {
                operation.MedicalHistoryId = medicalHistory.Id;
            }

            foreach (var disease in medicalHistoryModel.Diseases)
            {
                disease.MedicalHistoryId = medicalHistory.Id;
            }

            foreach (var sensitivity in medicalHistoryModel.Sensitivities)
            {
                sensitivity.MedicalHistoryId = medicalHistory.Id;
            }

            _context.Operations.AddRange(medicalHistoryModel.Operations);
            _context.Sensitivities.AddRange(medicalHistoryModel.Sensitivities);
            _context.Diseases.AddRange(medicalHistoryModel.Diseases);

            await _context.SaveChangesAsync();

            return(Ok());
        }
コード例 #3
0
        public async Task <ActionResult <MedicalHistoryViewModel> > GetMedicalHistory(string id)
        {
            if (!MedicalHistoryUserExists(id))
            {
                return(NotFound("This user doesn't have any medical history yet."));
            }

            var medicalHistoryInDb = await _context.MedicalHistory
                                     .Include(m => m.ApplicationUser)
                                     .Include(m => m.Operations)
                                     .Include(m => m.Diseases)
                                     .Include(m => m.Sensitivities)
                                     .FirstOrDefaultAsync(m => m.ApplicationUserId == id);

            var medicalHistory = new MedicalHistoryViewModel
            {
                Id                = medicalHistoryInDb.Id,
                PatientSSN        = medicalHistoryInDb.ApplicationUser.PatientSsn,
                FullName          = medicalHistoryInDb.ApplicationUser.FullName,
                BloodType         = medicalHistoryInDb.BloodType,
                Diseases          = medicalHistoryInDb.Diseases,
                Sensitivities     = medicalHistoryInDb.Sensitivities,
                Operations        = medicalHistoryInDb.Operations,
                ApplicationUserId = medicalHistoryInDb.ApplicationUserId
            };



            return(medicalHistory);
        }
コード例 #4
0
        public MedicalHistoryViewModel GetMedicalHistory(int PatientId, string UserId, bool isPharmixAdmin)
        {
            var result  = new MedicalHistoryViewModel();
            var IsAdmin = false;

            if (IsAdminUser(UserId, isPharmixAdmin))
            {
                IsAdmin = true;
            }
            else
            {
                PatientId = _repository.GetContext().Patients.Where(p => p.UserId == UserId).Select(p => p.Id).FirstOrDefault();
            }

            var medicalHistory = _repository.GetContext().MedicalHistory.Include(p => p.Pregnancy).Where(p => p.Pregnancy.PatientId == PatientId).FirstOrDefault();

            if (medicalHistory == null)
            {
                result = new MedicalHistoryViewModel();
            }
            else
            {
                result = Mapper.Map <MedicalHistoryViewModel>(medicalHistory);
            }

            result.IsAdmin   = IsAdmin;
            result.PatientId = PatientId;

            return(result);
        }
コード例 #5
0
        public static MedicalHistoryModel ToModel(this MedicalHistoryViewModel entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var model = new MedicalHistoryModel
            {
                MedicalHistoryID = entity.MedicalHistoryID,
                EncounterID      = entity.EncounterID,
                ContactID        = entity.ContactID,
                TakenBy          = entity.TakenBy,
                TakenTime        = entity.TakenTime,
                Conditions       = new List <MedicalHistoryConditionModel>(),
                ModifiedOn       = entity.ModifiedOn
            };

            if (entity.Conditions != null)
            {
                entity.Conditions.ForEach(delegate(MedicalHistoryConditionViewModel condition)
                {
                    var transformedModel = condition.ToModel();
                    model.Conditions.Add(transformedModel);
                });
            }

            return(model);
        }
コード例 #6
0
        public Response <MedicalHistoryViewModel> UpdateMedicalHistory(MedicalHistoryViewModel medicalHistory)
        {
            string apiUrl = BaseRoute + "UpdateMedicalHistory";

            var response = _communicationManager.Post <MedicalHistoryModel, Response <MedicalHistoryModel> >(medicalHistory.ToModel(), apiUrl);

            return(response.ToViewModel());
        }
コード例 #7
0
 public ActionResult MedicalHistory(MedicalHistoryViewModel model)
 {
     if (ModelState.IsValid)
     {
         var history = db.MedicalHistories.Find(model.medicalhistoryID);
         if (history == null)
         {
             return(this.InvokeHttp404(HttpContext));
         }
         GlobalHelpers.Transfer <MedicalHistoryViewModel, MedicalHistory>(model, history, "Patient");
         db.Entry(history).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
コード例 #8
0
ファイル: PatientController.cs プロジェクト: skgtrx/CMS
        public ActionResult PatientMedicalHistory()
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            var History = new MedicalHistory();
            List <MedicalHistoryViewModel> model = new List <MedicalHistoryViewModel>();
            List <Diagnosis> DiagnosisHistories  = History.GetDiagnosisHistory((int)Session["userId"]);
            var MedicineNames = new List <List <MedicineRecord> >();

            foreach (var item in DiagnosisHistories)
            {
                var MedicalHistory = new MedicalHistoryViewModel();
                MedicalHistory.DiagnosisHistories = item;
                MedicalHistory.MedicineList       = History.GetMedicineNames(item.Id);
                MedicalHistory.TestList           = History.GetTestNames(item.Id);

                model.Add(MedicalHistory);
            }

            return(View(model));
        }
コード例 #9
0
        public bool SaveMedicalHistory(MedicalHistoryViewModel model, string UserId)
        {
            var result = false;

            try
            {
                model.FolicAcidTabletDose = model.FolicAcidTabletDose == 5 ? 5 : (float)0.4;
                var pregnancy = _repository.GetContext().Pregnancy.Where(p => p.PatientId == model.PatientId).FirstOrDefault();
                if (model.Id > 0)
                {
                    //Update Existing
                    var medicalHisory = _repository.GetContext().MedicalHistory.Where(p => p.Id == model.Id).FirstOrDefault();
                    Mapper.Map(model, medicalHisory);
                    medicalHisory.SetUpdateDetails(UserId);

                    _repository.SaveExisting(medicalHisory);
                }
                else
                {
                    //Add new Record
                    var medicalHistory = new MedicalHistory();
                    Mapper.Map(model, medicalHistory);
                    medicalHistory.PregnancyId = pregnancy.Id;
                    medicalHistory.SetCreateDetails(UserId);

                    var saveNew = _repository.SaveNew(medicalHistory);
                }

                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
コード例 #10
0
 public MedicalHistoryWindow(MedicalHistoryViewModel viewModel)
 {
     InitializeComponent();
     ViewModel = viewModel;
 }
コード例 #11
0
 public Response <MedicalHistoryViewModel> SaveMedicalHistoryDetails(MedicalHistoryViewModel medicalHistory)
 {
     return(_medicalHistoryRepository.SaveMedicalHistoryDetails(medicalHistory));
 }
コード例 #12
0
 public Response <MedicalHistoryViewModel> UpdateMedicalHistory(MedicalHistoryViewModel medicalHistory)
 {
     medicalHistory.TakenTime = medicalHistory.TakenTime.ToUniversalTime();
     return(_medicalHistoryRepository.UpdateMedicalHistory(medicalHistory));
 }
コード例 #13
0
 public MedicalHistoryPage(Patient patient)
 {
     InitializeComponent();
     BindingContext = new MedicalHistoryViewModel(Navigation, patient);
 }
コード例 #14
0
        public async Task <IActionResult> PutMedicalHistory(string id, MedicalHistoryViewModel medicalHistory)
        {
            if (id != medicalHistory.ApplicationUserId)
            {
                return(BadRequest());
            }

            if (!MedicalHistoryUserExists(id))
            {
                return(NotFound("This user doesn't have any medical history yet."));
            }

            var medicalHistoryInDb = new MedicalHistory
            {
                Id                = medicalHistory.Id,
                BloodType         = medicalHistory.BloodType,
                ApplicationUserId = medicalHistory.ApplicationUserId
            };

            _context.Entry(medicalHistoryInDb).State = EntityState.Modified;

            if (medicalHistory.Operations != null)
            {
                var operations = new List <Operation>();
                operations.AddRange(medicalHistory.Operations);
                medicalHistoryInDb.Operations = operations;


                foreach (var operation in medicalHistoryInDb.Operations)
                {
                    _context.Entry(operation).State = EntityState.Modified;
                }
            }

            if (medicalHistory.Sensitivities != null)
            {
                var sensitivities = new List <Sensitivity>();
                sensitivities.AddRange(medicalHistory.Sensitivities);
                medicalHistoryInDb.Sensitivities = sensitivities;

                foreach (var sensitivity in medicalHistoryInDb.Sensitivities)
                {
                    _context.Entry(sensitivity).State = EntityState.Modified;
                }
            }

            if (medicalHistory.Diseases != null)
            {
                var diseases = new List <Disease>();
                diseases.AddRange(medicalHistory.Diseases);
                medicalHistoryInDb.Diseases = diseases;

                foreach (var disease in medicalHistoryInDb.Diseases)
                {
                    _context.Entry(disease).State = EntityState.Modified;
                }
            }


            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MedicalHistoryUserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #15
0
        public List <MedicalHistoryViewModel> GetMedicalHistory(int?id)
        {
            try {
                medicalHistoryViewModelList = new List <MedicalHistoryViewModel>();
                patientBusinessLayer        = new PatientBusinessLayer();
                doctorBusinessLayer         = new DoctorBusinessLayer();
                List <MedicalHistory> medicalHistories;
                if (id == null)
                {
                    medicalHistories = historyDataLayer.GetAllMedicalHistory();
                }
                else
                {
                    patientDataLayer = new PatientDataLayer();
                    medicalHistories = patientDataLayer.GetPatientMedicalHistory((int)id);
                }
                foreach (var medicalHistory in medicalHistories)
                {
                    appointmentList      = new List <Appointment>();
                    appointmentDataLayer = new AppointmentDataLayer();
                    appointmentList      = appointmentDataLayer.GetAppointmentsById(medicalHistory.PatientId, medicalHistory.AppointmentId);

                    if (medicalHistory.AppointmentId != 0)
                    {
                        foreach (var appointment in appointmentList)
                        {
                            medicalHistoryViewModel = new MedicalHistoryViewModel
                            {
                                AppointmentId = medicalHistory.AppointmentId,
                                PatientName   = patientBusinessLayer.GetPatientNameById(appointment.PatientId),
                                DoctorName    = doctorBusinessLayer.GetDoctorNameById(appointment.DoctorId),
                                Date          = appointment.Date.ToShortDateString(),
                                Dignosis      = medicalHistory.Dignosis,
                                Medicine      = medicalHistory.Medicine,
                                ClinicRemark  = medicalHistory.ClinicRemark
                            };
                            medicalHistoryViewModelList.Add(medicalHistoryViewModel);
                        }
                    }
                    else
                    {
                        medicalHistoryViewModel = new MedicalHistoryViewModel
                        {
                            AppointmentId = -1,
                            PatientName   = patientBusinessLayer.GetPatientNameById(medicalHistory.PatientId),
                            DoctorName    = "-",
                            Dignosis      = medicalHistory.Dignosis,
                            Medicine      = medicalHistory.Medicine,
                            ClinicRemark  = medicalHistory.ClinicRemark
                        };
                        medicalHistoryViewModelList.Add(medicalHistoryViewModel);
                    }
                }
                return(medicalHistoryViewModelList);
            }
            catch (Exception e)
            {
                ExceptionHandler.PrintException(e, new StackTrace(true));
                throw e;
            }
        }