Exemplo n.º 1
0
 public Patient()
 {
     _patientId = -1;
     _patientInfo = new PatientInformation();
     _monitoring = new List<Monitoring>();
     _bloodwork = new Bloodwork();
     _clinicalFindings = new ClinicalFindings();
     _anestheticPlan = new AnestheticPlan();
     _maintenance = new Maintenance();
 }
Exemplo n.º 2
0
        public PatientInformation GetPatientInformation(int patientId, params PatientInformation.LazyComponents[] lazyComponents)
        {
            PatientInformation patientInfo = new PatientInformation();
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string sql = BuildPatientInformationSQL();

                string from = @"FROM dbo.Patient AS a";

                string where = @" WHERE a.PatientId = @PatientId ";

                foreach (PatientInformation.LazyComponents a in lazyComponents)
                {
                    if (a == PatientInformation.LazyComponents.LOAD_CLINICIAN_DETAIL)
                    {
                        sql += @", b.Username as 'b.Username', b.FullName as 'b.FullName', b.Email as 'b.Email' ";
                        from += @" LEFT OUTER JOIN dbo.ASF_User as b ON a.ClinicianId = b.Username ";
                    }
                    else if (a == PatientInformation.LazyComponents.LOAD_STUDENT_DETAIL)
                    {
                        sql += @", c.Username as 'c.Username', c.FullName as 'c.FullName', c.Email as 'c.Email' ";
                        from += @" LEFT OUTER JOIN dbo.ASF_User as c ON a.StudentId = c.Username ";
                    }
                    else if (a == PatientInformation.LazyComponents.LOAD_POSTOP_PAIN_DETAIL)
                    {
                        sql += @", d.CategoryId as 'd.CategoryId', d.Label as 'd.Label', d.OtherFlag as 'd.OtherFlag', d.Description as 'd.Description',
                                    d.Concentration as 'd.Concentration' ";
                        from += @" LEFT OUTER JOIN dbo.Dropdown_Types as d ON a.PostOpPainAssessmentId = d.Id ";
                    }
                    else if (a == PatientInformation.LazyComponents.LOAD_PREOP_PAIN_DETAIL)
                    {
                        sql += @", e.CategoryId as 'e.CategoryId', e.Label as 'e.Label', e.OtherFlag as 'e.OtherFlag', e.Description as 'e.Description',
                                    e.Concentration as 'e.Concentration' ";
                        from += @" LEFT OUTER JOIN dbo.Dropdown_Types as e ON a.PreOpPainAssessmentId = e.Id ";
                    }

                    else if (a == PatientInformation.LazyComponents.LOAD_TEMPERAMENT_DETAIL)
                    {
                        sql += @", f.CategoryId as 'f.CategoryId', f.Label as 'f.Label', f.OtherFlag as 'f.OtherFlag', f.Description as 'f.Description',
                                    f.Concentration as 'f.Concentration' ";
                        from += @" LEFT OUTER JOIN dbo.Dropdown_Types as f ON a.TemperamentId = f.Id ";
                    }

                    else if (a == PatientInformation.LazyComponents.LOAD_PROCEDURE_DETAIL)
                    {
                        sql += @", g.CategoryId as 'g.CategoryId', g.Label as 'g.Label', g.OtherFlag as 'g.OtherFlag', g.Description as 'g.Description',
                                    g.Concentration as 'g.Concentration' ";
                        from += @" LEFT OUTER JOIN dbo.Dropdown_Types as g ON a.ProcedureId = g.Id ";
                    }
                }

                sql = sql + from + where;

                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add("@PatientId", SqlDbType.Int).Value = patientId;
                try
                {
                    conn.Open();
                    SqlDataReader read = cmd.ExecuteReader();
                    while (read.Read())
                    {
                        patientInfo = new PatientInformationCallback().ProcessRow(read, lazyComponents);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    conn.Close();
                }
            }
            return patientInfo;
        }