Пример #1
0
        //public static void Update_MedicalEventAlert(int alertId, int medicalEventId_Update, string description, bool enabled)
        //{

        //    using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
        //    {

        //        var wMedicalEventAlert = dc.MedicalEventAlerts.Where(p => p.AlertId.Equals(alertId)).FirstOrDefault();
        //        if (wMedicalEventAlert != null)
        //        {
                    
        //            wMedicalEventAlert.Description = description;
        //            wMedicalEventAlert.Enabled = enabled;

        //            dc.SaveChanges();
        //        }
        //    }
        //}

        /// <summary>
        /// 
        /// </summary>
        /// <param name="patientId"></param>
        /// <param name="startDate"></param>
        /// <param name="retriveHistory"></param>
        /// <returns></returns>
        public static MedicalEventAlert_ViewList Retrive_MedicalEventAlerts(int patientId, DateTime? startDate, bool retriveHistory)
        {
            Database wDatabase = null;
            DbCommand wCmd = null;
            MedicalEventAlert_View wMedicalEven = null;


            MedicalEventAlert_ViewList list = new MedicalEventAlert_ViewList();
            ///TODO: Mejorar este sp para q traifga segun el tipo de alerta
            wDatabase = DatabaseFactory.CreateDatabase(Common.CnnStringName);
            wCmd = wDatabase.GetStoredProcCommand("MedicalEventAlerts_s_params");
            wDatabase.AddInParameter(wCmd, "@PatientId", System.Data.DbType.Int32, patientId);
            if (startDate.HasValue)
                wDatabase.AddInParameter(wCmd, "@StartDate", System.Data.DbType.DateTime, startDate);
            //Si retriveHistory== true  CheckEnabled deberia ser =false por lo tanto el NEGADO
            wDatabase.AddInParameter(wCmd, "@CheckEnabled", System.Data.DbType.Boolean, !retriveHistory);

            //wDatabase.AddInParameter(wCmd, "@AlertType", System.Data.DbType.Int32, 1);
            
            IDataReader reader = wDatabase.ExecuteReader(wCmd);

            #region Fill IDataReader with DIAGNOSIS
            while (reader.Read())
            {
              
                wMedicalEven = new MedicalEventAlert_View();

                if (reader["AlertId"] != DBNull.Value)
                    wMedicalEven.AlertType = Convert.ToInt32(reader["AlertType"]);

                wMedicalEven.AlertId = Convert.ToInt32(reader["AlertId"]);

                wMedicalEven.ReferenceId = Convert.ToInt32(reader["ReferenceId"]);

                if (reader["MedicalEventId"] != DBNull.Value)
                    wMedicalEven.MedicalEventId = Convert.ToInt32(reader["MedicalEventId"]);
               if (reader["CreationDate"] != DBNull.Value)
                    wMedicalEven.CreationDate = Convert.ToDateTime(reader["CreationDate"]);

                wMedicalEven.Profesional = reader["Profesional"].ToString();
         
                wMedicalEven.InstitucionRazonSocial = reader["RazonSocial"].ToString();
                if (reader["HealthInstitutionId"] != DBNull.Value)
                    wMedicalEven.HealthInstitutionId = new Guid(reader["HealthInstitutionId"].ToString());


                wMedicalEven.Description = reader["Description"].ToString();
                list.Add(wMedicalEven);
            }

            //reader.NextResult();

            //wMedicalEven.PatientMedicaments = new PatientMedicament_ViewList();
            //PatientMedicament_ViewBE wPatientMedicament_View = null;
            //while (reader.Read())
            //{

            //    if (reader["AlertId"] != DBNull.Value)
            //        wMedicalEven.AlertId = Convert.ToInt32(reader["AlertId"]);
            //    if (reader["MedicalEventIdCreation"] != DBNull.Value)
            //        wMedicalEven.MedicalEventIdCreation = Convert.ToInt32(reader["MedicalEventIdCreation"]);

            //    if (reader["CreatedDate"] != DBNull.Value)
            //        wMedicalEven.CreatedDate = Convert.ToDateTime(reader["CreatedDate"]);
            //    wMedicalEven.NombreApellidoProfesional = reader["Profesional"].ToString();

            //    wMedicalEven.InstitucionRazonSocial = reader["RazonSocial"].ToString();
            //    if (reader["HealthInstitutionId"] != DBNull.Value)
            //        wMedicalEven.HealthInstitutionId = new Guid(reader["HealthInstitutionId"].ToString());

            //    wMedicalEven.Diagnosis = reader["Diagnosis"].ToString();
            //    if (reader["CEI10_Code"] != DBNull.Value)
            //        wMedicalEven.CEI10_Code = reader["CEI10_Code"].ToString().Trim();

            //    wMedicalEven.PatientMedicaments.Add(wPatientMedicament_View);
            //}
            #endregion

            reader.Dispose();

            return list;
        }