Пример #1
0
        public static ResponseAttachmentsList GetAllAttachments(string identification)
        {
            List <AttachmentsModel> attachments = new List <AttachmentsModel>();

            using (MySqlConnection conn = ConecctionModel.conn)
            {
                conn.Open();
                string       SP  = AppManagement.SP_GetAll_Attachments;
                MySqlCommand cmd = new MySqlCommand(SP, conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@pidentification", identification);

                MySqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    AttachmentsModel attachment = new AttachmentsModel();
                    attachment.Identification = rdr["id_patient"].ToString();
                    attachment.FileName       = rdr["file_name"].ToString();
                    attachment.Content        = rdr["content"].ToString();
                    attachment.Extension      = rdr["extension"].ToString();
                    attachment.Description    = rdr["description"].ToString();

                    attachments.Add(attachment);
                }

                rdr.Close();

                return(new ResponseAttachmentsList {
                    IsSuccessful = true, ResponseMessage = AppManagement.MSG_GetAllAttachments_Success, ResponseAttachments = attachments
                });
            }
        }
Пример #2
0
        public static Response DeleteAttachment(AttachmentsModel attachment)
        {
            using (MySqlConnection conn = ConecctionModel.conn)
            {
                conn.Open();

                string       SP  = AppManagement.SP_Delete_Attachments;
                MySqlCommand cmd = new MySqlCommand(SP, conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@pidentification", attachment.Identification);
                cmd.Parameters.AddWithValue("@pfilename", attachment.FileName);


                MySqlDataReader rdr = cmd.ExecuteReader();

                rdr.Close();

                if (rdr.RecordsAffected != 0)
                {
                    return new Response {
                               IsSuccessful = true, ResponseMessage = AppManagement.MSG_DeleteAttachment_Success
                    }
                }
                ;

                return(new Response {
                    IsSuccessful = false, ResponseMessage = AppManagement.MSG_DeleteAttachment_Failure
                });
            }
        }

        #endregion
    }
Пример #3
0
        public static ResponsePatient GetPatient(string identification)
        {
            PatientModel patient = null;

            using (MySqlConnection conn = ConecctionModel.conn)
            {
                conn.Open();
                string       SP  = AppManagement.SP_GetPatient;
                MySqlCommand cmd = new MySqlCommand(SP, conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@p_id_patient", identification);

                using (MySqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        patient = new PatientModel()
                        {
                            Identification = rdr["id_patient"].ToString(),
                            IdParent       = rdr["id_parent"].ToString(),
                            Name           = rdr["name"].ToString(),
                            BirthDate      = Convert.ToDateTime(rdr["birth_date"]),
                            Age            = Convert.ToInt32(rdr["age"]),
                            Ethnic         = new EthnicModel()
                            {
                                Id   = Convert.ToInt32(rdr["id_ethnic_group"]),
                                Name = rdr["ethnic_name"].ToString()
                            },
                            Gender = rdr["gender"].ToString()
                        };
                    }
                }
            }

            if (patient.IsNotNull())
            {
                patient.Treatments = PatientTreatmentDeseaseModel.GetAllTreatmentDeseasest(patient.Identification).PatientTreatmentDeseases;


                patient.Attachments = AttachmentsModel.GetAllAttachments(patient.Identification).ResponseAttachments;

                patient.Cases = PatientCaseModel.GetAllPatientCases(patient.Identification).PatientCases;
            }

            return(new ResponsePatient {
                IsSuccessful = true, ResponseMessage = AppManagement.MSG_GetPatient_Success, Patient = patient
            });
        }
Пример #4
0
        public static Response SaveAttachment(AttachmentsModel attachments)
        {
            try
            {
                using (MySqlConnection conn = ConecctionModel.conn)
                {
                    conn.Open();
                    int idresult = 0;

                    string SP = AppManagement.SP_Save_Patient_Attachments;

                    MySqlCommand cmd = new MySqlCommand(SP, conn);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@pidentification", attachments.Identification);
                    cmd.Parameters.AddWithValue("@pfilename", attachments.FileName);
                    cmd.Parameters.AddWithValue("@pcontent", attachments.Content);
                    cmd.Parameters.AddWithValue("@pextension", attachments.Extension);
                    cmd.Parameters.AddWithValue("@pdescription", attachments.Description);


                    MySqlParameter NroIdInvoice = new MySqlParameter("@result", idresult);
                    NroIdInvoice.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(NroIdInvoice);

                    cmd.ExecuteNonQuery();


                    idresult = Int32.Parse(cmd.Parameters["@result"].Value.ToString());
                    if (idresult != 0)
                    {
                        if (idresult == 1)//mas de 20 archivos
                        {
                            return new Response {
                                       IsSuccessful = false, ResponseMessage = AppManagement.MSG_SaveAttachment_Failure20
                            }
                        }
                        ;

                        else
                        {
                            return new Response {
                                       IsSuccessful = false, ResponseMessage = AppManagement.MSG_SaveAttachment_FailureDefault
                            }
                        };
                    }

                    else
                    {
                        return new Response {
                                   IsSuccessful = true, ResponseMessage = AppManagement.MSG_SaveAttachment_Success
                        }
                    };
                }
            }
            catch (Exception ex)
            {
                return(new Response {
                    IsSuccessful = false, ResponseMessage = AppManagement.MSG_SaveAttachment_FailureDefault
                });
            }
        }