Пример #1
0
        public ActionResult Edit(Application.Entities.Patient model)
        {
            if (!ModelState.IsValid)
            {
                var baseObject = GetBaseObject();

                Application.Entities.Patient patient = _patientService.Get(model.Id);

                IList <Application.EntityViews.MeasurementTool> measurementTools = _patientService.ListMeasurementTools(model.Id);
                IList <Application.EntityViews.TeamMember>      teamMembers      = _patientService.ListTeamMembers(model.Id);
                IList <Application.EntityViews.Visit>           visits           = _visitService.ListVisits(model.Id);

                if (!patient.CanAccess(baseObject.User, teamMembers, baseObject.User.Permissions))
                {
                    throw new BusinessRuleException("You are not autorized to view this patient");
                }

                return(View(new ViewObjects.Patient.Edit(baseObject)
                {
                    Patient = patient,
                    MeasurementTools = measurementTools,
                    TeamMembers = teamMembers,
                    Visits = visits,
                    TeamMember = _patientService.GetTeamMember(model.Id, baseObject.User.CurrentFacility),
                    MeasurementToolList = new SelectList(_listRepository.GetMeasurementTools().Where(x => measurementTools.Count(y => y.Id == x.Id) == 0), "Id", "Name"),
                    FrequencyList = new SelectList(_listRepository.GetFrequencies(), "Id", "Name"),
                }));
            }

            _patientService.Save(model);

            return(RedirectToAction("Edit", "Patient", new { patientId = model.Id }));
        }
Пример #2
0
        public ActionResult CreateGet(Application.Entities.Patient model)
        {
            var baseObject = GetBaseObject();

            var viewObject = new ViewObjects.Patient.Create(baseObject);

            if (!viewObject.CanCreatePatient())
            {
                throw new BusinessRuleException("You are not authorized to create patients");
            }

            if (!string.IsNullOrWhiteSpace(model.IdentificationNumber))
            {
                PatientDto patientDto = _patientGateway.Find(model.IdentificationNumber);

                if (patientDto != null)
                {
                    return(RedirectToAction("Edit", "Patient", new { patientId = patientDto.Id, modalType = (int)ModalTypes.PatientExist }));
                }
            }

            if (!string.IsNullOrWhiteSpace(model.PassportNumber))
            {
                PatientDto patientDto = _patientGateway.Find(model.PassportNumber);

                if (patientDto != null)
                {
                    return(RedirectToAction("Edit", "Patient", new { patientId = patientDto.Id, modalType = (int)ModalTypes.PatientExist }));
                }
            }

            if (!string.IsNullOrWhiteSpace(model.Firstname) && !string.IsNullOrWhiteSpace(model.Lastname) && model.DateOfBirth.HasValue)
            {
                PatientDto patientDto = _patientGateway.Find(model.Firstname, model.Lastname, model.DateOfBirth.Value);

                if (patientDto != null)
                {
                    return(RedirectToAction("Edit", "Patient", new { patientId = patientDto.Id, modalType = (int)ModalTypes.PatientExist }));
                }
            }

            string   identificationNumber = model.IdentificationNumber;
            string   passportNumber       = model.PassportNumber;
            string   firstname            = model.Firstname;
            string   lastname             = model.Lastname;
            DateTime?dateOfBrith          = model.DateOfBirth;

            model                      = _patientService.Get();
            model.Firstname            = firstname;
            model.Lastname             = lastname;
            model.IdentificationNumber = string.IsNullOrWhiteSpace(identificationNumber)? passportNumber : identificationNumber;
            model.DateOfBirth          = string.IsNullOrWhiteSpace(identificationNumber) ? dateOfBrith : model.IdentificationNumber.FromIdNumberToDateTime();

            ViewData["ModalType"] = ModalTypes.PatientNotExist;

            viewObject.Patient = model;

            return(View("Create", viewObject));
        }
Пример #3
0
        public ActionResult Create(Guid patientId)
        {
            var baseObject = GetBaseObject();

            Application.Entities.Patient patient = _patientService.Get(patientId);

            IList <Application.EntityViews.MeasurementTool>          measurementTools          = _visitService.GetMeasurementToolsForVisit(patientId);
            IList <Application.EntityViews.TeamMember>               teamMembers               = _patientService.ListTeamMembers(patientId);
            IList <Application.EntityViews.CompletedMeasurementTool> completedMeasurementTools = _patientService.ListCompletedMeasurementTools(patient.Id, DateTime.Now.AddYears(-1), DateTime.Now);
            IList <Application.EntityViews.EpisodeOfCare>            episodeOfCares            = _patientService.ListEpisodesOfCare(patientId, baseObject.GetCurrentFacilityId().Value);


            if (!patient.CanAccess(baseObject.User, teamMembers, baseObject.User.Permissions))
            {
                throw new BusinessRuleException("You are not autorized to view this patient");
            }


            foreach (var measurementTool in measurementTools)
            {
                var temp = completedMeasurementTools.OrderByDescending(x => x.EndDate).FirstOrDefault(x => x.Id == measurementTool.Id);
                measurementTool.LastCompletedTimestamp = temp == null ? (DateTime?)null : temp.EndDate;
            }

            if (!patient.CanAccess(baseObject.User, teamMembers, baseObject.User.Permissions))
            {
                throw new BusinessRuleException("You are not autorized to view this patient");
            }

            return(View(new ViewObjects.Visit.Create(baseObject)
            {
                Visit = new Application.Entities.Visit()
                {
                    PatientId = patientId,
                    Timestamp = DateTime.Now,
                    ImpairmentGroups = _listRepository.GetImpairmentGroups()
                },
                EpisodeOfCare = episodeOfCares.FirstOrDefault(),
                Patient = patient,
                MeasurementTools = measurementTools,
                Surveys = _patientService.ListSurveys(patientId)
            }));
        }
Пример #4
0
        public ActionResult ProvinceCombobox(Guid?patientId, Guid?countryId = null)
        {
            if (!countryId.HasValue)
            {
                return(View(new Application.Entities.Patient()));
            }

            Application.Entities.Patient patient = new Application.Entities.Patient();
            if (patientId.HasValue && patientId != Guid.Empty)
            {
                patient = _patientService.Get(patientId.Value);
            }

            List <Application.ValueObjects.ListItem> provinces = _listRepository.GetProvince(countryId.Value);

            patient.Provinces = provinces;

            return(View(patient));
        }
Пример #5
0
        public ActionResult CityCombobox(Guid?patientId, Guid?provinceId = null)
        {
            if (!provinceId.HasValue)
            {
                return(View(new Application.Entities.Patient()));
            }

            Application.Entities.Patient patient = new Application.Entities.Patient();
            if (patientId.HasValue && patientId != Guid.Empty)
            {
                patient = _patientService.Get(patientId.Value);
            }

            IList <Application.ValueObjects.ListItem> cities = _listRepository.GetCities(provinceId.Value);

            patient.Cities = cities;

            return(View(patient));
        }
Пример #6
0
        public ActionResult Edit(Guid patientId)
        {
            var baseObject = GetBaseObject();

            Application.Entities.Patient patient = _patientService.Get(patientId);

            IList <Application.EntityViews.MeasurementTool> measurementTools = _patientService.ListMeasurementTools(patientId);
            IList <Application.EntityViews.TeamMember>      teamMembers      = _patientService.ListTeamMembers(patientId);
            IList <Application.EntityViews.Visit>           visits           = _visitService.ListVisits(patientId);
            IList <Application.EntityViews.EpisodeOfCare>   episodesOfCare   = _patientService.ListEpisodesOfCare(patientId, baseObject.User.CurrentFacility.Id);

            Application.Entities.TeamMember teamMember = _patientService.GetTeamMember(patientId, baseObject.User.CurrentFacility);

            if (!patient.CanAccess(baseObject.User, teamMembers, baseObject.User.Permissions))
            {
                throw new BusinessRuleException("You are not autorized to view this patient");
            }

            return(View(new ViewObjects.Patient.Edit(baseObject)
            {
                Patient = patient,
                MeasurementTools = measurementTools,
                TeamMembers = teamMembers,
                Visits = visits,
                TeamMember = teamMember,
                EpisodesOfCare = episodesOfCare,
                EpisodeOfCare = new Application.Entities.EpisodeOfCare()
                {
                    ImpairmentGroups = _listRepository.GetImpairmentGroups(),
                    DischargeTypes = _listRepository.GetDischargeTypes(),
                    AdmissionTypes = _listRepository.GetAdmissionTypes(),
                    FacilityId = baseObject.User.CurrentFacility.Id,
                    userId = baseObject.User.Id
                },
                MeasurementToolList = new SelectList(_listRepository.GetMeasurementTools().Where(x => measurementTools.Count(y => y.Id == x.Id) == 0), "Id", "Name"),
                FrequencyList = new SelectList(_listRepository.GetFrequencies(), "Id", "Name"),
            }));
        }
Пример #7
0
        public ActionResult CreatePost(Application.Entities.Patient model)
        {
            Guid patientId = _patientService.Create(model);

            return(RedirectToAction("Edit", "Patient", new { patientId = patientId }));
        }