Ejemplo n.º 1
0
        public override RetriveMedicalEventAlertsRes Execute(RetriveMedicalEventAlertsReq pServiceRequest)
        {
            RetriveMedicalEventAlertsRes wRes = new RetriveMedicalEventAlertsRes();

            MedicalEventAlert_ViewList wList = new MedicalEventAlert_ViewList();

            wRes.BusinessData = MedicalEventDAC.Retrive_MedicalEventAlerts(pServiceRequest.BusinessData.PatientId, pServiceRequest.BusinessData.StartDate, pServiceRequest.BusinessData.RetriveHistory);
            return(wRes);
        }
        /// <summary>
        /// Carga Dominios relacionados entre al objeto _RelatedDomains que esta bindiado a la grilla
        /// </summary>
        void Populate(out Exception ex)
        {
            ex = null;

            try
            {
                _PatientAllergy             = ServiceCalls.GetPatientAllergy(ServiceCalls.CurrentPatient.PatientId);
                _PatientMedicament_ViewList = ServiceCalls.RetrivePatientMedicaments(ServiceCalls.CurrentPatient.PatientId, null);
                _MedicalEventAlert_ViewList = ServiceCalls.RetriveMedicalEventAlert(ServiceCalls.CurrentPatient.PatientId, null, false);
                if (MedicalEvent == null)
                {
                    MedicalEvent = new MedicalEventBE();
                    MedicalEvent.MedicalEventId = -1;
                    if (this._Appointment != null)
                    {
                        MedicalEvent.AppointmentId = this._Appointment.AppointmentId;
                    }


                    MedicalEvent.ProfesionalId       = ServiceCalls.CurrentProfesional.IdProfesional;
                    MedicalEvent.IdEspesialidad      = ServiceCalls.CurrentProfesional.IdEspecialidad.Value;
                    MedicalEvent.PatientId           = ServiceCalls.CurrentPatient.PatientId;
                    MedicalEvent.PatientMedicaments  = _PatientMedicament_ViewList;
                    MedicalEvent.HealthInstitutionId = ServiceCalls.CurrentHealthInstitution.HealthInstitutionId;

                    MedicalEvent.MedicalEventId = ServiceCalls.CreateMedicalEvent(MedicalEvent);
                }
                else
                {
                    MedicalEvent.PatientMedicaments = _PatientMedicament_ViewList;
                }
            }
            catch (Exception err)
            {
                err.Source = "Origen de datos";
                ex         = err;
            }
        }
Ejemplo n.º 3
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);
        }
        /// <summary>
        /// Carga Dominios relacionados entre al objeto _RelatedDomains que esta bindiado a la grilla
        /// </summary>
        void Populate(out Exception ex)
        {
            ex = null;

            try
            {
                _PatientAllergy = Controller.GetPatientAllergy(Controller.CurrentPatient.PatientId);
                _PatientMedicament_ViewList = Controller.RetrivePatientMedicaments(Controller.CurrentPatient.PatientId, null);
                _MedicalEventAlert_ViewList = Controller.RetriveMedicalEventAlert(Controller.CurrentPatient.PatientId,null, false);
                if (MedicalEvent == null)
                {
                    MedicalEvent = new MedicalEventBE();
                    MedicalEvent.MedicalEventId = -1;
                    if (this._Appointment != null)
                        MedicalEvent.AppointmentId = this._Appointment.AppointmentId;


                    MedicalEvent.ProfesionalId = Controller.CurrentProfesional.IdProfesional;
                    MedicalEvent.IdEspesialidad = Controller.CurrentProfesional.IdEspecialidad.Value;
                    MedicalEvent.PatientId = Controller.CurrentPatient.PatientId;
                    MedicalEvent.PatientMedicaments = _PatientMedicament_ViewList;
                    MedicalEvent.HealthInstitutionId = Controller.CurrentHealthInstitution.HealthInstitutionId;

                    MedicalEvent.MedicalEventId = Controller.CreateMedicalEvent(MedicalEvent);
                }
                else
                {
                    MedicalEvent.PatientMedicaments = _PatientMedicament_ViewList;
                }

            }
            catch (Exception err)
            {
                err.Source = "Origen de datos";
                ex = err;
            }
        }
Ejemplo n.º 5
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;
        }