Esempio n. 1
0
        public List <Examinations> GetRecentExaminations(PatientProgram pp)
        {
            List <Examinations> exams = new List <Examinations>();

            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("DECLARE @prog INT=" + pp.Id + "; SELECT * FROM ( SELECT * FROM ( SELECT TOP(1)pe_idnt, pe_sputum_date pe_exam_date, 'SPUTUM SMEAR' pe_examination, pe_visit, ex_name, pe_labno, pe_sputum_exam, cpt_name FROM PatientExamination INNER JOIN Concept ON cpt_id=pe_sputum_exam INNER JOIN Examinations ON pe_visit=ex_idnt WHERE pe_sputum_exam<>38 AND pe_program=@prog ORDER BY pe_sputum_date DESC, pe_idnt DESC ) As Foo UNION ALL SELECT * FROM ( SELECT TOP(1)pe_idnt, pe_genexpert_date, 'GENEXPERT' pe_examination, pe_visit, ex_name, pe_labno, pe_genexpert_exam, cpt_name FROM PatientExamination INNER JOIN Concept ON cpt_id=pe_genexpert_exam INNER JOIN Examinations ON pe_visit=ex_idnt WHERE pe_genexpert_exam<>38 AND pe_program=@prog ORDER BY pe_genexpert_date DESC, pe_idnt DESC) As Foo UNION ALL SELECT * FROM (SELECT TOP(1)pe_idnt, pe_hiv_date, 'HIV/AIDS TEST' pe_examination, pe_visit, ex_name, pe_labno, pe_hiv_exam, cpt_name FROM PatientExamination INNER JOIN Concept ON cpt_id=pe_hiv_exam INNER JOIN Examinations ON pe_visit=ex_idnt WHERE pe_hiv_exam NOT IN (38,42) AND pe_program=@prog ORDER BY pe_hiv_date DESC, pe_idnt DESC) As Foo UNION ALL SELECT * FROM (SELECT TOP(1)pe_idnt, pe_xray_date, 'X-RAY EXAM' pe_examination, pe_visit, ex_name, pe_labno, pe_xray_exam, cpt_name FROM PatientExamination INNER JOIN Concept ON cpt_id=pe_xray_exam INNER JOIN Examinations ON pe_visit=ex_idnt WHERE pe_xray_exam<>38 AND pe_program=@prog ORDER BY pe_xray_date DESC, pe_idnt DESC) As Foo) As Foo ORDER BY pe_exam_date DESC");

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    exams.Add(new Examinations {
                        Id    = Convert.ToInt64(dr[0]),
                        Date  = Convert.ToDateTime(dr[1]),
                        Name  = dr[2].ToString(),
                        Visit = new Visit {
                            Id   = Convert.ToInt64(dr[3]),
                            Name = dr[4].ToString()
                        },
                        LabNo  = dr[5].ToString(),
                        Result = new Concept {
                            Id   = Convert.ToInt64(dr[6]),
                            Name = dr[7].ToString()
                        }
                    });
                }
            }

            return(exams);
        }
Esempio n. 2
0
        public IActionResult UpdatePatientOutcome()
        {
            DateTime date = DateTime.ParseExact(ProfileModel.OutcomeDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            PatientProgram     pp = ProfileModel.Program;
            PatientExamination px = ProfileModel.Examination;
            Patient            pt = ProfileModel.Patient;

            pp.DateCompleted    = date;
            pp.LaboratoryNumber = px.LabNo;
            pp.UpdateOutcome();

            px.SputumSmearDate = date;
            px.Visit           = new Visit(25);
            px.Program         = pp;
            px.Save(HttpContext);

            if (pp.Outcome.Id.Equals(Constants.PATIENT_DIED))
            {
                pt.isDead(true);
                pt.DiedOn       = date;
                pt.CauseOfDeath = new Concept(pp.Program.Id);
                pt.Update();
            }

            return(LocalRedirect("/patients/profile/" + pt.GetUuid()));
        }
Esempio n. 3
0
        public IActionResult RegisterNewIntake()
        {
            PatientProgram pp = IntakeModel.Program;

            pp.ArtStartedOn = DateTime.Parse(IntakeModel.ArtStartedOn);
            pp.CptStartedOn = DateTime.Parse(IntakeModel.CptStartedOn);
            pp.UpdateIntake();

            PatientRegimen pr = IntakeModel.Regimen;

            pr.Program = pp;
            pr.Save(HttpContext);

            PatientExamination px = IntakeModel.Examination;

            px.Program         = pp;
            px.Visit           = new Visit(1);
            px.LabNo           = pp.LaboratoryNumber;
            px.SputumSmearDate = DateTime.Parse(IntakeModel.SputumSmearDate);
            px.GeneXpertDate   = DateTime.Parse(IntakeModel.GeneXpertDate);
            px.HivExamDate     = DateTime.Parse(IntakeModel.HivExamDate);
            px.XrayExamDate    = DateTime.Parse(IntakeModel.XrayExamDate);
            px.Save(HttpContext);

            return(LocalRedirect("/patients/profile/" + pp.Patient.GetUuid()));
        }
Esempio n. 4
0
        //Examinations (Model)
        public Examinations GetRecentHivExamination(PatientProgram pp)
        {
            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("DECLARE @prog INT=" + pp.Id + "; SELECT TOP(1) pe_idnt, pe_hiv_date, 'HIV/AIDS TEST' pe_examination, pe_visit, ex_name, pe_labno, pe_hiv_exam, cpt_name FROM PatientExamination INNER JOIN Concept ON cpt_id=pe_hiv_exam INNER JOIN Examinations ON pe_visit=ex_idnt WHERE pe_program=@prog ORDER BY pe_hiv_date DESC, pe_idnt DESC");

            if (dr.Read())
            {
                return(new Examinations {
                    Id = Convert.ToInt64(dr[0]),
                    Date = Convert.ToDateTime(dr[1]),
                    Name = dr[2].ToString(),
                    Visit = new Visit {
                        Id = Convert.ToInt64(dr[3]),
                        Name = dr[4].ToString()
                    },
                    LabNo = dr[5].ToString(),
                    Result = new Concept {
                        Id = Convert.ToInt64(dr[6]),
                        Name = dr[7].ToString()
                    }
                });
            }

            return(null);
        }
Esempio n. 5
0
        public PatientExamination GetPatientExamination(PatientProgram pp, Visit visit)
        {
            PatientExamination  px   = null;
            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("SELECT pe_idnt, pe_weight, pe_height, pe_muac, pe_bmi, pe_program, pe_visit, pe_sputum_exam, sp.cpt_name, pe_sputum_date, pe_genexpert_exam, gx.cpt_name, pe_genexpert_date, pe_hiv_exam, hv.cpt_name, pe_hiv_date, pe_xray_exam, xr.cpt_name, pe_xray_date, pe_created_on, pe_created_by, pe_notes FROM PatientExamination INNER JOIN Concept sp ON pe_sputum_exam=sp.cpt_id INNER JOIN Concept gx ON pe_genexpert_exam=gx.cpt_id INNER JOIN Concept hv ON pe_hiv_exam=hv.cpt_id INNER JOIN Concept xr ON pe_xray_exam=xr.cpt_id WHERE pe_program=" + pp.Id + " AND pe_visit=" + visit.Id);

            if (dr.Read())
            {
                px = new PatientExamination {
                    Id              = Convert.ToInt64(dr[0]),
                    Weight          = Convert.ToDouble(dr[1]),
                    Height          = Convert.ToDouble(dr[2]),
                    MUAC            = Convert.ToDouble(dr[3]),
                    BMI             = Convert.ToDouble(dr[4]),
                    Program         = new PatientProgram(Convert.ToInt64(dr[5])),
                    Visit           = new Visit(Convert.ToInt64(dr[6])),
                    SputumSmear     = new Concept(Convert.ToInt64(dr[7]), dr[8].ToString()),
                    SputumSmearDate = Convert.ToDateTime(dr[9]),
                    GeneXpert       = new Concept(Convert.ToInt64(dr[10]), dr[11].ToString()),
                    GeneXpertDate   = Convert.ToDateTime(dr[12]),
                    HivExam         = new Concept(Convert.ToInt64(dr[13]), dr[14].ToString()),
                    HivExamDate     = Convert.ToDateTime(dr[15]),
                    XrayExam        = new Concept(Convert.ToInt64(dr[16]), dr[17].ToString()),
                    XrayExamDate    = Convert.ToDateTime(dr[18]),
                    CreatedOn       = Convert.ToDateTime(dr[19]),
                    CreatedBy       = new Users(Convert.ToInt64(dr[20])),
                    Notes           = dr[21].ToString()
                };
            }

            return(px);
        }
Esempio n. 6
0
        public PatientRegimen GetPatientRegimen(PatientProgram pp)
        {
            PatientRegimen regimen = null;

            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("SELECT pr_idnt, pr_default, pr_program, pr_started_on, pr_added_on, pr_added_by, pr_notes, rg_idnt, rg_name, rg_description, prg_idnt, prg_description FROM PatientRegimens INNER JOIN Regimen ON pr_regimen=rg_idnt INNER JOIN Program ON rg_program=prg_idnt WHERE pr_default=1 AND pr_program=" + pp.Id);

            if (dr.Read())
            {
                regimen = new PatientRegimen {
                    Id        = Convert.ToInt64(dr[0]),
                    Default   = Convert.ToBoolean(dr[1]),
                    Program   = new PatientProgram(Convert.ToInt64(dr[2])),
                    StartedOn = Convert.ToDateTime(dr[3]),
                    CreatedOn = Convert.ToDateTime(dr[4]),
                    CreatedBy = new Users(Convert.ToInt64(dr[5])),
                    Notes     = dr[6].ToString()
                };

                regimen.Regimen = new Regimen {
                    Id          = Convert.ToInt64(dr[7]),
                    Name        = dr[8].ToString(),
                    Description = dr[9].ToString(),
                    Program     = new Programs(Convert.ToInt64(dr[10]), dr[11].ToString())
                };
            }

            return(regimen);
        }
Esempio n. 7
0
        public PatientProfileViewModel()
        {
            Transfer    = new PatientTransfer();
            Patient     = new Patient();
            Program     = new PatientProgram();
            Regimen     = new PatientRegimen();
            Examination = new PatientExamination();

            DateOfBirth  = DateTime.Now.ToString("dd/MM/yyyy");
            RegimenDate  = DateTime.Now.ToString("dd/MM/yyyy");
            OutcomeDate  = DateTime.Now.ToString("dd/MM/yyyy");
            TransferDate = DateTime.Now.ToString("dd/MM/yyyy");

            Centers  = new List <SelectListItem>();
            Facility = new List <SelectListItem>();
            Outcomes = new List <SelectListItem>();
            ExamOpts = new List <SelectListItem>();
            Regimens = new List <SelectListItem>();

            LatestVitals = new Vitals();
            Examinations = new List <Examinations>();
            Contacts     = new List <Contacts>();

            Gender = new PatientService().InitializeGender();
        }
Esempio n. 8
0
        public IActionResult AddVisits()
        {
            PatientProgram pp = VisitModel.Program;

            pp.ArtStartedOn = DateTime.Parse(VisitModel.ArtStartedOn);
            pp.CptStartedOn = DateTime.Parse(VisitModel.CptStartedOn);
            pp.UpdateVisit();

            //Test If Regimen has Changed, then Update
            PatientRegimen pr = VisitModel.Regimen;

            pr.Program = pp;
            pr.Save(HttpContext);

            //Post Visit
            PatientExamination px = VisitModel.Examination;

            px.Program         = pp;
            px.LabNo           = pp.LaboratoryNumber;
            px.SputumSmearDate = DateTime.Parse(VisitModel.SputumSmearDate);
            px.GeneXpertDate   = DateTime.Parse(VisitModel.GeneXpertDate);
            px.HivExamDate     = DateTime.Parse(VisitModel.HivExamDate);
            px.XrayExamDate    = DateTime.Parse(VisitModel.XrayExamDate);
            px.Save(HttpContext);

            return(LocalRedirect("/patients/profile/" + pp.Patient.GetUuid()));
        }
Esempio n. 9
0
 public PatientSearch()
 {
     Patient  = new Patient();
     Program  = new PatientProgram();
     Status   = "";
     Facility = "";
     Age      = "";
     AddedOn  = DateTime.Now.ToString("dd/MM/yyyy");
 }
Esempio n. 10
0
        public PatientModel()
        {
            PatientProgram = new PatientProgram();
            Examination    = new PatientExamination();

            Date    = DateTime.Now.ToString("d MMMM, yyyy");
            Age     = "";
            Weight  = "";
            Address = "";
        }
Esempio n. 11
0
        public IActionResult RegisterMultiple()
        {
            Facility facility = new Facility {
                Id = MultipleModel.Facility
            };

            foreach (var line in MultipleModel.PatientModel)
            {
                if (string.IsNullOrEmpty(line.PatientProgram.Patient.Person.Name))
                {
                    continue;
                }

                Patient patient = line.PatientProgram.Patient;
                patient.Person.DateOfBirth = DateTime.Now.AddYears(0 - Convert.ToInt32(line.Age));
                patient.Save();

                patient.Person.Address = new PersonAddress {
                    Telephone = line.Address,
                    Person    = patient.Person
                }.Save(HttpContext);

                PatientProgram pp = line.PatientProgram;
                pp.Facility     = facility;
                pp.Patient      = patient;
                pp.DateEnrolled = DateTime.Parse(line.Date);
                pp.Create(HttpContext);

                //Update Intake
                pp.ArtStartedOn = DateTime.Parse(line.Date);
                pp.CptStartedOn = DateTime.Parse(line.Date);
                pp.UpdateIntake();

                //Regimen
                new PatientRegimen {
                    Regimen = new Regimen {
                        Id = Constants.REG_SHORT_ADULT
                    },
                    Program = pp
                }.Save(HttpContext);

                //Examinations
                PatientExamination px = line.Examination;
                px.Program         = pp;
                px.Visit           = new Visit(1);
                px.LabNo           = "N/A";
                px.SputumSmearDate = DateTime.Parse(line.Date);
                px.GeneXpertDate   = DateTime.Parse(line.Date);
                px.HivExamDate     = DateTime.Parse(line.Date);
                px.XrayExamDate    = DateTime.Parse(line.Date);
                px.Save(HttpContext);
            }

            return(LocalRedirect("/patients/register/tb?fac=" + MultipleModel.Facility));
        }
Esempio n. 12
0
        public int GetPatientExaminationVisitsCount(PatientProgram pp)
        {
            SqlServerConnection conn = new SqlServerConnection();
            SqlDataReader       dr   = conn.SqlServerConnect("SELECT COUNT(pe_program)x FROM PatientExamination WHERE pe_program=" + pp.Id);

            if (dr.Read())
            {
                return(Convert.ToInt32(dr[0]));
            }
            return(0);
        }
Esempio n. 13
0
        //Data Write
        public PatientProgram CreatePatientProgram(PatientProgram pp)
        {
            SqlServerConnection conn = new SqlServerConnection();

            pp.Id = conn.SqlServerUpdate("INSERT INTO PatientProgram (pp_tbmu, pp_patient, pp_facility, pp_progam, pp_category, pp_type, pp_confirmation, pp_enrolled_on, pp_created_by) output INSERTED.pp_idnt VALUES ('" + pp.TbmuNumber + "', " + pp.Patient.Id + ", " + pp.Facility.Id + ", " + pp.Program.Id + ", " + pp.Category.Id + ", " + pp.Type.Id + ", " + pp.Confirmation.Id + ", '" + pp.DateEnrolled.Date + "', " + Actor + ")");

            conn = new SqlServerConnection();
            conn.SqlServerUpdate("UPDATE PatientProgram SET pp_default=0 WHERE pp_patient=" + pp.Patient.Id + " AND pp_idnt<>" + pp.Id);

            return(pp);
        }
Esempio n. 14
0
        public IActionResult EnrollExistingPatient()
        {
            Patient patient = RegisterModel.Patient;

            PatientProgram program = RegisterModel.Program;

            program.Patient      = patient;
            program.DateEnrolled = DateTime.Parse(RegisterModel.DateEnrolled);
            program.Create(HttpContext);

            return(LocalRedirect("/registration/intake/" + program.Id));
        }
Esempio n. 15
0
        public ContactAddViewModel()
        {
            Contact     = new Contacts();
            Program     = new PatientProgram();
            Examination = new ContactsExamination();

            Contact.Person.Address = new PersonAddress();

            DateOfBirth = "";
            NextVisit   = DateTime.Now.AddMonths(6).ToString("d MMM, yyyy");

            Gender = new PatientService().InitializeGender();
        }
Esempio n. 16
0
        //Read: Visits
        public List <SelectListItem> GetProgramVisitsIEnumerable(PatientProgram pp, Regimen regimen, bool includeVisited = false, bool includeLastVisit = false)
        {
            string query = "WHERE px_program=" + pp.Program.Id + " AND ex_regimen LIKE '%" + regimen.Id + "%'";

            if (!includeVisited)
            {
                query += " AND ex_idnt NOT IN (SELECT pe_visit FROM PatientExamination WHERE pe_program=" + pp.Id + ")";
            }

            if (!includeLastVisit)
            {
                query += " AND ex_idnt<>25";
            }

            return(GetIEnumerable("SELECT ex_idnt, ex_name FROM ProgramExaminations INNER JOIN Examinations ON px_exam=ex_idnt " + query));
        }
Esempio n. 17
0
        public PatientIntakeViewModel()
        {
            Program     = new PatientProgram();
            Patient     = new Patient();
            Regimen     = new PatientRegimen();
            Examination = new PatientExamination();

            RegimenStartedOn = DateTime.Now.ToString("d MMMM, yyyy");
            SputumSmearDate  = DateTime.Now.ToString("d MMMM, yyyy");
            GeneXpertDate    = DateTime.Now.ToString("d MMMM, yyyy");
            HivExamDate      = DateTime.Now.ToString("d MMMM, yyyy");
            XrayExamDate     = DateTime.Now.ToString("d MMMM, yyyy");
            ArtStartedOn     = DateTime.Now.ToString("d MMMM, yyyy");
            CptStartedOn     = DateTime.Now.ToString("d MMMM, yyyy");

            InitiazeBoolOpts();
        }
Esempio n. 18
0
        public IActionResult TransferPatient()
        {
            DateTime date = DateTime.ParseExact(ProfileModel.TransferDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            PatientProgram pp = ProfileModel.Program;

            pp.DateCompleted = date;
            pp.UpdateTransfer();

            PatientTransfer tf = ProfileModel.Transfer;

            tf.Date    = date;
            tf.Program = pp;
            tf.Save(HttpContext);

            return(LocalRedirect("/patients/profile/" + ProfileModel.Patient.GetUuid()));
        }
        public PatientRegisterViewModel()
        {
            Address = new PersonAddress();
            Patient = new Patient();
            Program = new PatientProgram();

            Gender = new PatientService().InitializeGender();

            Facilities        = new List <SelectListItem>();
            TBCategory        = new List <SelectListItem>();
            TBTypes           = new List <SelectListItem>();
            TBConfirmation    = new List <SelectListItem>();
            ResistanceProfile = new List <SelectListItem>();

            DateOfBirth  = "";
            DateEnrolled = DateTime.Now.ToString("d MMMM, yyyy");
        }
Esempio n. 20
0
        public IActionResult UpdatePatientDetails()
        {
            Patient pt = ProfileModel.Patient;
            Person  ps = pt.Person;

            ps.DateOfBirth = DateTime.ParseExact(ProfileModel.DateOfBirth, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            ps.Save(HttpContext);

            PersonAddress pa = ps.Address;

            pa.Person = ps;
            pa.Save(HttpContext);

            PatientProgram pp = ProfileModel.Program;

            pp.UpdateFacility();

            return(LocalRedirect("/patients/profile/" + pt.GetUuid()));
        }
Esempio n. 21
0
        public IActionResult RegisterNewPatient()
        {
            Patient patient = RegisterModel.Patient;

            patient.Person.DateOfBirth = DateTime.ParseExact(RegisterModel.DateOfBirth, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            patient.Save();

            PersonAddress address = RegisterModel.Address;

            address.Person = patient.Person;
            address.Save(HttpContext);

            PatientProgram program = RegisterModel.Program;

            program.Patient      = patient;
            program.DateEnrolled = DateTime.Parse(RegisterModel.DateEnrolled);
            program.Create(HttpContext);

            return(LocalRedirect("/registration/intake/" + program.Id));
        }
Esempio n. 22
0
        public PatientVisitsViewModel()
        {
            Patient = new Patient();
            Program = new PatientProgram();

            Visits   = new List <SelectListItem>();
            Regimens = new List <SelectListItem>();

            HivRecent   = new Examinations();
            Regimen     = new PatientRegimen();
            Examination = new PatientExamination();

            RegimenStartedOn = DateTime.Now.ToString("d MMMM, yyyy");
            SputumSmearDate  = DateTime.Now.ToString("d MMMM, yyyy");
            GeneXpertDate    = DateTime.Now.ToString("d MMMM, yyyy");
            HivExamDate      = DateTime.Now.ToString("d MMMM, yyyy");
            XrayExamDate     = DateTime.Now.ToString("d MMMM, yyyy");

            ArtStartedOn = DateTime.Now.ToString("d MMMM, yyyy");
            CptStartedOn = DateTime.Now.ToString("d MMMM, yyyy");

            InitiazeBoolOpts();
        }
Esempio n. 23
0
        public void UpdateVisit(PatientProgram pp)
        {
            SqlServerConnection conn = new SqlServerConnection();

            conn.SqlServerUpdate("UPDATE PatientProgram SET pp_laboratory_no='" + pp.LaboratoryNumber + "', pp_art_started=" + pp.ArtStarted + ", pp_art_started_on='" + pp.ArtStartedOn + "', pp_cpt_started=" + pp.CptStarted + ", pp_cpt_started_on='" + pp.CptStartedOn + "' WHERE pp_idnt=" + pp.Id);
        }
Esempio n. 24
0
        public void UpdateFacility(PatientProgram pp)
        {
            SqlServerConnection conn = new SqlServerConnection();

            conn.SqlServerUpdate("UPDATE PatientProgram SET pp_facility=" + pp.Facility.Id + " WHERE pp_idnt=" + pp.Id);
        }
Esempio n. 25
0
        public void UpdateOutcome(PatientProgram pp)
        {
            SqlServerConnection conn = new SqlServerConnection();

            conn.SqlServerUpdate("UPDATE PatientProgram SET pp_laboratory_no='" + pp.LaboratoryNumber + "', pp_completed_on='" + pp.DateCompleted + "', pp_outcome=" + pp.Outcome.Id + " WHERE pp_idnt=" + pp.Id);
        }
Esempio n. 26
0
        public void UpdateIntake(PatientProgram pp)
        {
            SqlServerConnection conn = new SqlServerConnection();

            conn.SqlServerUpdate("UPDATE PatientProgram SET pp_registeer_no='" + pp.RegisterNumber + "', pp_laboratory_no='" + pp.LaboratoryNumber + "', pp_dots_by=" + pp.DotsBy.Id + ", pp_referred_by=" + pp.ReferredBy.Id + ", pp_facility=" + pp.Facility.Id + ", pp_supporter='" + pp.TreatmentSupporter + "', pp_supporter_contacts='" + pp.SupporterContacts + "', pp_art_started=" + pp.ArtStarted + ", pp_art_started_on='" + pp.ArtStartedOn + "', pp_cpt_started=" + pp.CptStarted + ", pp_cpt_started_on='" + pp.CptStartedOn + "' WHERE pp_idnt=" + pp.Id);
        }
Esempio n. 27
0
        public void UpdateTransfer(PatientProgram pp)
        {
            SqlServerConnection conn = new SqlServerConnection();

            conn.SqlServerUpdate("UPDATE PatientProgram SET pp_completed_on='" + pp.DateCompleted + "', pp_outcome=79 WHERE pp_idnt=" + pp.Id);
        }