Ejemplo n.º 1
0
        public IActionResult Profile(string uuid, PatientProfileViewModel model, PatientService ps, ConceptService cs, long program = 0)
        {
            CoreService core = new CoreService(HttpContext);

            model.Patient = ps.GetPatient(uuid);

            if (program.Equals(0))
            {
                model.Program = ps.GetPatientProgram(model.Patient);
            }
            else
            {
                model.Program = ps.GetPatientProgram(program);
            }

            if (model.Program.DotsBy.Id.Equals(0))
            {
                return(LocalRedirect("/registration/intake/" + model.Program.Id));
            }

            if (!model.Program.DateCompleted.HasValue)
            {
                model.Regimens = core.GetRegimensIEnumerable(model.Program.Program);
                model.ExamOpts = cs.GetConceptAnswersIEnumerable(new Concept(Constants.SPUTUM_SMEAR));
                model.Outcomes = cs.GetConceptAnswersIEnumerable(new Concept(Constants.TREATMENT_OUTCOME));
                model.Centers  = core.GetAllOtherCentersIEnumerable(model.Program.Facility);
                model.Facility = core.GetFacilitiesIEnumerable();
            }

            model.Regimen     = core.GetPatientRegimen(model.Program);
            model.DateOfBirth = model.Patient.Person.DateOfBirth.ToString("dd/MM/yyyy");
            model.RegimenDate = model.Regimen.StartedOn.ToString("dd/MM/yyyy");

            model.Program.Facility = core.GetFacility(model.Program.Facility.Id);
            model.LatestVitals     = ps.GetLatestVitals(model.Patient);
            model.Examinations     = core.GetRecentExaminations(model.Program);
            model.Contacts         = ps.GetContacts(model.Patient);

            return(View(model));
        }