示例#1
0
        public MentalExam consultMentalExam(MentalExam _mentalExam)
        {
            int    id;
            String behavior;
            String attitude;
            String alertness;
            String awareness;
            String mood;
            String language;
            String thought;

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran     = conn.BeginTransaction();
                NpgsqlCommand     command  = new NpgsqlCommand("EXAMENMENTAL_CONSULTAR(@ID)", conn);
                NpgsqlParameter   idMental = new NpgsqlParameter();

                idMental.ParameterName = "@ID";
                idMental.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Integer;
                idMental.Direction     = ParameterDirection.Input;

                idMental.Value = _mentalExam._ID;
                command.Parameters.Add(idMental);

                command.CommandType = CommandType.StoredProcedure;

                NpgsqlDataReader dr = command.ExecuteReader();

                try
                {
                    while (dr.Read())
                    {
                        id          = dr.GetInt32(0);
                        behavior    = dr.GetString(1);
                        attitude    = dr.GetString(2);
                        alertness   = dr.GetString(3);
                        awareness   = dr.GetString(4);
                        mood        = dr.GetString(5);
                        language    = dr.GetString(6);
                        thought     = dr.GetString(7);
                        _mentalExam = new MentalExam(id, behavior, attitude, alertness, awareness, mood, language, thought);
                    }
                    dr.Close();
                    tran.Commit();
                    return(_mentalExam);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["USER_ID"] == null)
                {
                    Response.Redirect("~/View/Home/index.aspx", false);
                }
                else
                {
                    String idAppointment = Request.QueryString["mentalExamID"];

                    int idInt = Convert.ToInt32(idAppointment);


                    mentalExam = new MentalExam(idInt);

                    ConsultMentalExamCommand cmd = new ConsultMentalExamCommand(mentalExam);

                    try
                    {
                        cmd.execute();
                        consultedMentalExam = cmd.getAnswer();

                        behavior_txt.Value  = consultedMentalExam._Behavior;
                        attitude_txt.Value  = consultedMentalExam._Attitude;
                        alertness_txt.Value = consultedMentalExam._Attention;
                        awareness_txt.Value = consultedMentalExam._Awareness;
                        mood_txt.Value      = consultedMentalExam._Mood;
                        language_txt.Value  = consultedMentalExam._Language;
                        thought_txt.Value   = consultedMentalExam._Thought;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
示例#3
0
        public MentalExam registerMentalExam(MentalExam _mentalExam)
        {
            int resp = 0;

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran    = conn.BeginTransaction();
                NpgsqlCommand     command = new NpgsqlCommand("examenmental_registrar(@ID, @BEHAVIOR, @ATTITUDE, @ALERTNESS, @AWARENESS, @MOOD, @LANGUAGE, @THOUGHT)", conn);

                NpgsqlParameter id        = new NpgsqlParameter();
                NpgsqlParameter behavior  = new NpgsqlParameter();
                NpgsqlParameter attitude  = new NpgsqlParameter();
                NpgsqlParameter alertness = new NpgsqlParameter();
                NpgsqlParameter awareness = new NpgsqlParameter();
                NpgsqlParameter mood      = new NpgsqlParameter();
                NpgsqlParameter language  = new NpgsqlParameter();
                NpgsqlParameter thought   = new NpgsqlParameter();


                id.ParameterName        = "@ID";
                behavior.ParameterName  = "@BEHAVIOR";
                attitude.ParameterName  = "@ATTITUDE";
                alertness.ParameterName = "@ALERTNESS";
                awareness.ParameterName = "@AWARENESS";
                mood.ParameterName      = "@MOOD";
                language.ParameterName  = "@LANGUAGE";
                thought.ParameterName   = "@THOUGHT";

                id.NpgsqlDbType        = NpgsqlTypes.NpgsqlDbType.Integer;
                behavior.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Varchar;
                attitude.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Varchar;
                alertness.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar;
                awareness.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar;
                mood.NpgsqlDbType      = NpgsqlTypes.NpgsqlDbType.Varchar;
                language.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Varchar;
                thought.NpgsqlDbType   = NpgsqlTypes.NpgsqlDbType.Varchar;


                id.Direction        = ParameterDirection.Input;
                behavior.Direction  = ParameterDirection.Input;
                attitude.Direction  = ParameterDirection.Input;
                alertness.Direction = ParameterDirection.Input;
                awareness.Direction = ParameterDirection.Input;
                mood.Direction      = ParameterDirection.Input;
                language.Direction  = ParameterDirection.Input;
                thought.Direction   = ParameterDirection.Input;

                id.Value        = _mentalExam._Appointment._ID;
                behavior.Value  = _mentalExam._Behavior;
                attitude.Value  = _mentalExam._Attitude;
                alertness.Value = _mentalExam._Attention;
                awareness.Value = _mentalExam._Awareness;
                mood.Value      = _mentalExam._Mood;
                language.Value  = _mentalExam._Language;
                thought.Value   = _mentalExam._Thought;


                command.Parameters.Add(id);
                command.Parameters.Add(behavior);
                command.Parameters.Add(attitude);
                command.Parameters.Add(alertness);
                command.Parameters.Add(awareness);
                command.Parameters.Add(mood);
                command.Parameters.Add(language);
                command.Parameters.Add(thought);

                command.CommandType = CommandType.StoredProcedure;
                //command.ExecuteNonQuery();

                NpgsqlDataReader dr = command.ExecuteReader();

                try
                {
                    while (dr.Read())
                    {
                        resp = dr.GetInt32(0);
                    }
                    if (resp == Registry.RESULTADO_CODIGO_RECURSO_CREADO)
                    {
                        _mentalExam._Error = Registry.RESULTADO_CODIGO_RECURSO_CREADO;
                    }
                    else
                    {
                        _mentalExam._Error = Registry.RESULTADO_CODIGO_FALLIDO;
                    }
                    dr.Close();
                    tran.Commit();
                    return(_mentalExam);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
            finally
            {
                conn.Close();
            }
        }
 public ConsultMentalExamCommand(MentalExam _consultMentalExam)
 {
     this.consultMentalExam = _consultMentalExam;
 }
        public override void execute()
        {
            DAOMentalExam daomental = new DAOMentalExam();

            answer = daomental.consultMentalExam(consultMentalExam);
        }
示例#6
0
        protected void btnRegisterPsychoProfile_Click(object sender, EventArgs e)
        {
            if (behavior_txt.Value.Equals("") || attitude_txt.Value.Equals("") || alertness_txt.Value.Equals("") || awareness_txt.Value.Equals("") || mood_txt.Value.Equals("") || language_txt.Value.Equals("") || thought_txt.Value.Equals(""))
            {
                string script = "BootAlert('No debe dejar campos vacíos');";
                ScriptManager.RegisterStartupScript(this, GetType(),
                                                    "ServerControlScript", script, true);
            }
            else
            {
                String idAppointment = Request.QueryString["appointmentID"];

                int idInt = Convert.ToInt32(idAppointment);

                if (idInt != 0)
                {
                    String behavior  = behavior_txt.Value;
                    String attitude  = attitude_txt.Value;
                    String alertness = alertness_txt.Value;
                    String awareness = awareness_txt.Value;
                    String mood      = mood_txt.Value;
                    String language  = language_txt.Value;
                    String thought   = thought_txt.Value;

                    appointment = new Appointment(idInt);

                    MentalExam mentalExamRegister = new MentalExam(behavior, attitude, alertness, awareness, mood, language, thought, appointment);

                    try
                    {
                        RegisterMentalExamCommand cmd = new RegisterMentalExamCommand(mentalExamRegister);

                        cmd.execute();

                        mentalExamRegistered = cmd.getAnswer();
                        if (mentalExamRegistered._Error == Registry.RESULTADO_CODIGO_RECURSO_CREADO)
                        {
                            Response.Redirect("../MedicalAppointmentModule/ConsultMedicalAppointment.aspx");
                            //ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Se registró el examen exitosamente');window.location.href='../MedicalAppointmentModule/ConsultMedicalAppointment.aspx';", true);
                        }
                        else
                        {
                            string script = "BootAlertNoRegistration('No se registró el examen');";
                            ScriptManager.RegisterStartupScript(this, GetType(),
                                                                "ServerControlScript", script, true);
                            //ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('ERROR! No se registró el examen');window.location.href='../MedicalAppointmentModule/ConsultMedicalAppointment.aspx';", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                else
                {
                    /*INICIO - Proceso para obtener el ID de la cita*/
                    String selectItem = patient_List.SelectedItem.Text;

                    //string[] Args = selectItem.Split(' / ');

                    string[] Args = Regex.Split(selectItem, " / ");

                    String firstHalf  = Args[0];
                    String secondHalf = Args[1];

                    string[] firstHalfArgs  = firstHalf.Split(' ');
                    string[] secondHalfArgs = secondHalf.Split(' ');


                    String idPatientString = firstHalfArgs[0];
                    String dateApp         = secondHalfArgs[3];
                    String hourApp         = secondHalfArgs[4];

                    int i = 1;

                    if (hourApp == "01:00")
                    {
                        hourApp = "13:00";
                    }
                    else if (hourApp == "02:00")
                    {
                        hourApp = "14:00";
                    }
                    else if (hourApp == "03:00")
                    {
                        hourApp = "15:00";
                    }
                    else if (hourApp == "04:00")
                    {
                        hourApp = "16:00";
                    }
                    else if (hourApp == "05:00")
                    {
                        hourApp = "17:00";
                    }

                    DateTime dateAppointment = DateTime.ParseExact(dateApp, "dd-MM-yyyy", CultureInfo.InvariantCulture);
                    DateTime hourAppointment = new DateTime();
                    hourAppointment = DateTime.ParseExact(hourApp, "HH:mm", null);

                    int Patient = Convert.ToInt32(idPatientString);

                    String idSession = Session["USER_ID"].ToString();
                    int    Psycho    = Convert.ToInt32(idSession);
                    int    appointmentIDConsulted;

                    Patient      consultPatient      = new Patient(Patient);
                    Psychologist consultPsychologist = new Psychologist(Psycho);

                    Appointment checkAppointmentID = new Appointment(dateAppointment, hourAppointment, consultPatient, consultPsychologist);

                    try
                    {
                        ConsultMedicalAppointmentCommand cmd = new ConsultMedicalAppointmentCommand(checkAppointmentID);

                        cmd.execute();

                        Appointment _appointment = cmd.getAnswer();

                        appointmentIDConsulted = _appointment._ID;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }

                    /*FIN - Proceso para obtener el ID de la cita*/

                    if (appointmentIDConsulted != 0)
                    {
                        String behavior  = behavior_txt.Value;
                        String attitude  = attitude_txt.Value;
                        String alertness = alertness_txt.Value;
                        String awareness = awareness_txt.Value;
                        String mood      = mood_txt.Value;
                        String language  = language_txt.Value;
                        String thought   = thought_txt.Value;

                        appointment = new Appointment(appointmentIDConsulted);

                        MentalExam mentalExamRegister = new MentalExam(behavior, attitude, alertness, awareness, mood, language, thought, appointment);

                        try
                        {
                            RegisterMentalExamCommand cmd = new RegisterMentalExamCommand(mentalExamRegister);

                            cmd.execute();

                            mentalExamRegistered = cmd.getAnswer();
                            if (mentalExamRegistered._Error == Registry.RESULTADO_CODIGO_RECURSO_CREADO)
                            {
                                Response.Redirect("../MedicalAppointmentModule/ConsultMedicalAppointment.aspx");
                                //ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Se Registro el examen exitosamente');window.location.href='../MedicalAppointmentModule/ConsultMedicalAppointment.aspx';", true);
                            }
                            else
                            {
                                string script = "BootAlertNoRegistration('No se registró el examen');";
                                ScriptManager.RegisterStartupScript(this, GetType(),
                                                                    "ServerControlScript", script, true);
                                //ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('ERROR! No se Registro');window.location.href='../MedicalAppointmentModule/ConsultMedicalAppointment.aspx';", true);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                }
            }
        }
        public override void execute()
        {
            DAOMentalExam daomental = new DAOMentalExam();

            answer = daomental.registerMentalExam(registerMentalExam);
        }
 public RegisterMentalExamCommand(MentalExam _registerMentalExam)
 {
     this.registerMentalExam = _registerMentalExam;
 }
        public Appointment consultDetailedAppointment(Appointment _appointment)
        {
            int      id;
            DateTime date;
            DateTime hour;
            String   reason;
            int      idPatient;
            String   namePatient;
            String   surnamePatient;
            int      idPsycho;
            String   namePsycho;
            String   surnamePsycho;
            int      idExam;

            Patient      _patient;
            Psychologist _psycho;
            MentalExam   _exam;

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran    = conn.BeginTransaction();
                NpgsqlCommand     command = new NpgsqlCommand("cita_consultar_detalle(@ID)", conn);

                NpgsqlParameter appointment = new NpgsqlParameter();

                appointment.ParameterName = "@ID";

                appointment.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer;

                appointment.Direction = ParameterDirection.Input;

                appointment.Value = _appointment._ID;

                command.Parameters.Add(appointment);

                command.CommandType = CommandType.StoredProcedure;

                NpgsqlDataReader dr = command.ExecuteReader();

                try
                {
                    while (dr.Read())
                    {
                        id             = dr.GetInt32(0);
                        date           = dr.GetDateTime(1);
                        hour           = dr.GetDateTime(2);
                        reason         = dr.GetString(3);
                        idPatient      = dr.GetInt32(4);
                        namePatient    = dr.GetString(5);
                        surnamePatient = dr.GetString(6);
                        idPsycho       = dr.GetInt32(7);
                        namePsycho     = dr.GetString(8);
                        surnamePsycho  = dr.GetString(9);
                        if (!dr.IsDBNull(10))
                        {
                            idExam = dr.GetInt32(10);
                        }
                        else
                        {
                            idExam = 0;
                        }

                        _patient = new Patient(idPatient, namePatient, surnamePatient);
                        _psycho  = new Psychologist(idPsycho, namePsycho, surnamePsycho);
                        _exam    = new MentalExam(idExam);

                        _appointment = new Appointment(id, date, hour, reason, _patient, _psycho, _exam);
                    }
                    dr.Close();
                    tran.Commit();
                    return(_appointment);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
            finally
            {
                conn.Close();
            }
        }
        public List <Appointment> consultRegisteredAppointments(Appointment _appointment)
        {
            int      id;
            DateTime date;
            DateTime hour;
            String   reason;
            int      idPatient;
            String   namePatient;
            String   surnamePatient;
            int      idPsycho;
            String   namePsycho;
            String   surnamePsycho;
            int      idExam;

            Patient      _patient;
            Psychologist _psycho;
            MentalExam   _exam;

            String dateString;
            String hourString;

            List <Appointment> _appointmentList = new List <Appointment>();

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran    = conn.BeginTransaction();
                NpgsqlCommand     command = new NpgsqlCommand("cita_consultar_registro(@PSYCHO)", conn);

                NpgsqlParameter psycho = new NpgsqlParameter();

                psycho.ParameterName = "@PSYCHO";

                psycho.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer;

                psycho.Direction = ParameterDirection.Input;

                psycho.Value = _appointment._Psychologist._ID;

                command.Parameters.Add(psycho);

                command.CommandType = CommandType.StoredProcedure;

                NpgsqlDataReader dr = command.ExecuteReader();

                try
                {
                    while (dr.Read())
                    {
                        id             = dr.GetInt32(0);
                        date           = dr.GetDateTime(1);
                        hour           = dr.GetDateTime(2);
                        reason         = dr.GetString(3);
                        idPatient      = dr.GetInt32(4);
                        namePatient    = dr.GetString(5);
                        surnamePatient = dr.GetString(6);
                        idPsycho       = dr.GetInt32(7);
                        namePsycho     = dr.GetString(8);
                        surnamePsycho  = dr.GetString(9);

                        if (!dr.IsDBNull(10))
                        {
                            idExam = dr.GetInt32(10);
                        }
                        else
                        {
                            idExam = 0;
                        }

                        /*Proceso para transformar date a dateString y hour a hourString*/

                        dateString = date.ToString("dd-MM-yyyy");
                        hourString = hour.ToString("hh:mm tt");

                        _patient = new Patient(idPatient, namePatient, surnamePatient);
                        _psycho  = new Psychologist(idPsycho, namePsycho, surnamePsycho);
                        _exam    = new MentalExam(idExam);

                        _appointment = new Appointment(id, dateString, hourString, reason, _patient, _psycho, _exam);

                        _appointmentList.Add(_appointment);
                    }
                    dr.Close();
                    tran.Commit();
                    return(_appointmentList);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
            finally
            {
                conn.Close();
            }
        }