Example #1
0
        public override UpdatePatientRes Execute(UpdatePatientReq pServiceRequest)
        {
            UpdatePatientRes wRes = new UpdatePatientRes();

            pServiceRequest.BusinessData.Patient.LastAccessUserId         = Guid.Parse(pServiceRequest.ContextInformation.UserId);
            pServiceRequest.BusinessData.Patient.Persona.LastAccessUserId = Guid.Parse(pServiceRequest.ContextInformation.UserId);
            PatientsDAC.Update(pServiceRequest.BusinessData.Patient);

            //Vacunas
            if (pServiceRequest.BusinessData.AnteriorFechaNacimiento.HasValue)
            {
                PatientsDAC.Update_FechaNAcimiento_PlanVacunacion(pServiceRequest.BusinessData.Patient.PatientId,
                                                                  pServiceRequest.BusinessData.AnteriorFechaNacimiento.Value,
                                                                  pServiceRequest.BusinessData.Patient.Persona.FechaNacimiento);
            }

            if (pServiceRequest.BusinessData.Mutuales != null)
            {
                if (pServiceRequest.BusinessData.Mutuales.Count != 0)
                {
                    ObraSocialDAC.Update_MutualPorPaciente(pServiceRequest.BusinessData.Mutuales, pServiceRequest.BusinessData.Patient.PatientId);
                }
            }
            return(wRes);
        }
        public override CrearPatientRes Execute(CrearPatientReq pServiceRequest)
        {
            CrearPatientRes wRes          = new CrearPatientRes();
            bool            personaExiste = PersonasDAC.Exist(pServiceRequest.BusinessData.Patient.Persona.NroDocumento);

            pServiceRequest.BusinessData.Patient.LastAccessUserId         = Guid.Parse(pServiceRequest.ContextInformation.UserId);
            pServiceRequest.BusinessData.Patient.Persona.LastAccessUserId = Guid.Parse(pServiceRequest.ContextInformation.UserId);


            if (personaExiste)
            {
                if (PatientsDAC.Persona_EstaAsociada(pServiceRequest.BusinessData.Patient.Persona.NroDocumento))
                {
                    throw new Fwk.Exceptions.FunctionalException(String.Format("El Nro documento {0} ya pertenece a otro paciente registrado",
                                                                               pServiceRequest.BusinessData.Patient.Persona.NroDocumento));
                }

                PatientsDAC.Asociar(pServiceRequest.BusinessData.Patient);
            }
            else
            {
                PatientsDAC.Create(pServiceRequest.BusinessData.Patient);
            }

            wRes.BusinessData.IdPersona = pServiceRequest.BusinessData.Patient.IdPersona;
            wRes.BusinessData.IdPatient = pServiceRequest.BusinessData.Patient.PatientId;

            if (pServiceRequest.BusinessData.Mutuales != null)
            {
                ObraSocialDAC.Create_MutualPorPaciente(pServiceRequest.BusinessData.Mutuales, pServiceRequest.BusinessData.Patient.PatientId);
            }
            return(wRes);
        }
        public override CreatePatientEventRes Execute(CreatePatientEventReq pServiceRequest)
        {
            CreatePatientEventRes wRes = new CreatePatientEventRes();

            int id = MedicalEventDAC.CreateMedicalEvent(pServiceRequest.BusinessData, Guid.Parse(pServiceRequest.ContextInformation.UserId));

            if (pServiceRequest.BusinessData.PatientMedicaments != null)
            {
                foreach (PatientMedicament_ViewBE patientMedicament in pServiceRequest.BusinessData.PatientMedicaments)
                {
                    if (patientMedicament.EntityState != Fwk.Bases.EntityState.Unchanged)
                    {
                        if (patientMedicament.PatientMedicamentId_Parent.HasValue)
                        {
                            PatientsDAC.DisablePatientMedicaments(patientMedicament.PatientMedicamentId_Parent.Value, Guid.Parse(pServiceRequest.ContextInformation.UserId), BE.Enums.MedicamentStatus.Finalizado);
                        }

                        patientMedicament.MedicalEventId = id;
                        PatientsDAC.AddPatientMedicaments(patientMedicament, Guid.Parse(pServiceRequest.ContextInformation.UserId));
                    }
                }
            }
            wRes.BusinessData.EventId = id;
            return(wRes);
        }
Example #4
0
        public override GetPatientRes Execute(GetPatientReq pServiceRequest)
        {
            GetPatientRes wRes = new GetPatientRes();

            wRes.BusinessData.Patient  = PatientsDAC.GetById(pServiceRequest.BusinessData.Id);
            wRes.BusinessData.Mutuales = ObraSocialDAC.RetriveByIdPatient(pServiceRequest.BusinessData.Id);
            return(wRes);
        }
Example #5
0
        public override GetPlanVacunacionRes Execute(GetPlanVacunacionReq pServiceRequest)
        {
            GetPlanVacunacionRes wRes = new GetPlanVacunacionRes();

            wRes.BusinessData = PatientsDAC.GetPlanVacunacion(pServiceRequest.BusinessData.IdPatient);


            return(wRes);
        }
        public override UpdatePlanVacunacionRes Execute(UpdatePlanVacunacionReq pServiceRequest)
        {
            UpdatePlanVacunacionRes wRes = new UpdatePlanVacunacionRes();
            Guid wLastAccessUserId       = Guid.Parse(pServiceRequest.ContextInformation.UserId);

            PatientsDAC.UpdatePlanVacunacion(pServiceRequest.BusinessData, wLastAccessUserId);


            return(wRes);
        }
Example #7
0
        public override RetrivePatientMedicamentsRes Execute(RetrivePatientMedicamentsReq pServiceRequest)
        {
            RetrivePatientMedicamentsRes wRes = new RetrivePatientMedicamentsRes();
            PatientMedicament_ViewList   wPatientMedicament_ViewBE = new PatientMedicament_ViewList();

            if (pServiceRequest.BusinessData.RetriveHistory)
            {
                wRes.BusinessData = PatientsDAC.RetrivePatientMedicamentsAlls(pServiceRequest.BusinessData.PatientId);
                return(wRes);
            }
            else
            {
                if (pServiceRequest.BusinessData.MedicalEventId.HasValue)
                {
                    wPatientMedicament_ViewBE = PatientsDAC.RetrivePatientMedicaments(pServiceRequest.BusinessData.PatientId, pServiceRequest.BusinessData.MedicalEventId.Value, true);
                }
                else
                {
                    wPatientMedicament_ViewBE = PatientsDAC.RetrivePatientMedicaments(pServiceRequest.BusinessData.PatientId);
                }
            }

            DateTime currentDate = Fwk.HelperFunctions.DateFunctions.GetStartDateTime(DateTime.Now);

            if (wPatientMedicament_ViewBE.Count != 0)
            {
                wRes.BusinessData = new PatientMedicament_ViewList();
            }

            //Realizar aqui actualizacion de medicacion NO permanente que sobrepaso dias resetados por el medico. Enabled = FALSE
            foreach (PatientMedicament_ViewBE item in wPatientMedicament_ViewBE)
            {
                ///Ignorar si la consulta es por id . Por que si viene el id del requetst es por que se esta creando en este momento
                if (!(pServiceRequest.BusinessData.MedicalEventId.HasValue && item.MedicalEventId.Equals(pServiceRequest.BusinessData.MedicalEventId)))
                {
                    if (currentDate > Fwk.HelperFunctions.DateFunctions.GetStartDateTime(item.CreatedDate).AddDays(item.DaysCount) && !item.Status.Equals((int)MedicamentStatus.Permanente))
                    {
                        PatientsDAC.DisablePatientMedicaments(item.PatientMedicamentId, Guid.Parse(pServiceRequest.ContextInformation.UserId), MedicamentStatus.Finalizado);
                        //wRes.BusinessData.Remove(item);
                    }
                    else
                    {
                        wRes.BusinessData.Add(item);
                    }
                }
                else
                {
                    wRes.BusinessData.Add(item);
                }
            }

            return(wRes);
        }
        public override GetPatientAllergyRes Execute(GetPatientAllergyReq pServiceRequest)
        {
            GetPatientAllergyRes wRes = new GetPatientAllergyRes();

            wRes.BusinessData = PatientsDAC.GetPatientAllergy(pServiceRequest.BusinessData.PatientId);

            if (wRes.BusinessData == null)
            {
                wRes.BusinessData           = new PatientAllergyBE();
                wRes.BusinessData.AllergyId = -1;
            }
            return(wRes);
        }
        public override RetrivePatientsRes Execute(RetrivePatientsReq pServiceRequest)
        {
            RetrivePatientsRes wRes = new RetrivePatientsRes();

            if (String.IsNullOrEmpty(pServiceRequest.BusinessData.Nombre) && String.IsNullOrEmpty(pServiceRequest.BusinessData.Apellido) && pServiceRequest.BusinessData.Id.HasValue)
            {
                PatientBE p = PatientsDAC.GetById(pServiceRequest.BusinessData.Id.Value);
                wRes.BusinessData.Add(p);
            }
            else
            {
                wRes.BusinessData.AddRange(PatientsDAC.SearchByParams(pServiceRequest.BusinessData.Nombre, pServiceRequest.BusinessData.Apellido));
            }
            return(wRes);
        }
Example #10
0
        public void GetPatientAllergy_ReturnNull()
        {
            string strErrorResut = string.Empty;

            try
            {
                var patien = PatientsDAC.GetPatientAllergy(12312);
                Assert.AreEqual(patien, null, "no retorna nulo");
            }
            catch (Exception e)
            {
                strErrorResut = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(e);
            }
            Assert.AreEqual <String>(strErrorResut, String.Empty, strErrorResut);
        }
Example #11
0
        public override CreateUpdatePatientMedicamentRes Execute(CreateUpdatePatientMedicamentReq pServiceRequest)
        {
            CreateUpdatePatientMedicamentRes wRes = new CreateUpdatePatientMedicamentRes();

            if (pServiceRequest.BusinessData.EntityState == EntityState.Added)
            {
                PatientsDAC.AddPatientMedicaments(pServiceRequest.BusinessData, Guid.Parse(pServiceRequest.ContextInformation.UserId));
            }
            else
            {
                PatientsDAC.UpdatePatientMedicaments_histoy(pServiceRequest.BusinessData, Guid.Parse(pServiceRequest.ContextInformation.UserId));
            }


            return(wRes);
        }
        public override RetrivePatientAppoimentsRes Execute(RetrivePatientAppoimentsReq pServiceRequest)
        {
            RetrivePatientAppoimentsRes wRes = new RetrivePatientAppoimentsRes();
            PatientMedicament_ViewList  wPatientMedicament_ViewBE = new PatientMedicament_ViewList();

            wRes.BusinessData = PatientsDAC.Retrive_Appointment(pServiceRequest.BusinessData.PatientId, pServiceRequest.BusinessData.StartDate, pServiceRequest.BusinessData.Status);

            //DateTime currentDate = Fwk.HelperFunctions.DateFunctions.GetStartDateTime(DateTime.Now);

            if (wPatientMedicament_ViewBE.Count != 0)
            {
                wRes.BusinessData = new Patient_Appointments_ViewList();
            }

            return(wRes);
        }
        public override AsociarPatientAPersonaRes Execute(AsociarPatientAPersonaReq pServiceRequest)
        {
            AsociarPatientAPersonaRes wRes = new AsociarPatientAPersonaRes();

            pServiceRequest.BusinessData.Patient.LastAccessUserId         = Guid.Parse(pServiceRequest.ContextInformation.UserId);
            pServiceRequest.BusinessData.Patient.Persona.LastAccessUserId = Guid.Parse(pServiceRequest.ContextInformation.UserId);

            if (PatientsDAC.Persona_EstaAsociada(pServiceRequest.BusinessData.Patient.Persona.NroDocumento))
            {
                throw new Fwk.Exceptions.FunctionalException(String.Format("El Nro documento {0} ya pertenece a otro paciente registrado",
                                                                           pServiceRequest.BusinessData.Patient.Persona.NroDocumento));
            }
            else
            {
                PatientsDAC.Asociar(pServiceRequest.BusinessData.Patient);
            }



            ///Mutuales
            if (pServiceRequest.BusinessData.Mutuales != null)
            {
                ObraSocialDAC.Create_MutualPorPaciente(pServiceRequest.BusinessData.Mutuales, pServiceRequest.BusinessData.Patient.PatientId);
            }

            //Verifica si la persona asociada requiere actualizacion
            if (pServiceRequest.BusinessData.PersonaNeedsUpdate)
            {
                PersonasDAC.Update(pServiceRequest.BusinessData.Patient.Persona);
            }

            //Vacunas
            //if (pServiceRequest.BusinessData.AnteriorFechaNacimiento.HasValue)
            //    PatientsDAC.Update_FechaNAcimiento_PlanVacunacion(pServiceRequest.BusinessData.Patient.PatientId,
            //        pServiceRequest.BusinessData.AnteriorFechaNacimiento.Value,
            //pServiceRequest.BusinessData.Patient.Persona.FechaNacimiento   );
            return(wRes);
        }
        public override UpdatePatientEventRes Execute(UpdatePatientEventReq pServiceRequest)
        {
            UpdatePatientEventRes wRes = new UpdatePatientEventRes();

            MedicalEventDAC.UpdateMedicalEvent(pServiceRequest.BusinessData, Guid.Parse(pServiceRequest.ContextInformation.UserId));

            int currentMedicalEventId = pServiceRequest.BusinessData.MedicalEventId;



            if (pServiceRequest.BusinessData.MedicalEventDetailList != null)
            {
                foreach (MedicalEventDetailBE medicalEventDetail in pServiceRequest.BusinessData.MedicalEventDetailList)
                {
                    medicalEventDetail.MedicalEventId = currentMedicalEventId;


                    if (medicalEventDetail.EntityState == EntityState.Added)
                    {
                        MedicalEventDAC.Insert_MedicalEventDetail(medicalEventDetail, Guid.Parse(pServiceRequest.ContextInformation.UserId));

                        if (medicalEventDetail.DetailType.Equals(AlertTypeEnum.Diagnosis))
                        {
                            if (medicalEventDetail.RelevanceType.HasValue)
                            {
                                MedicalEventDAC.Create_MedicalEventAlert(currentMedicalEventId, medicalEventDetail.Description, (AlertTypeEnum)medicalEventDetail.DetailType, medicalEventDetail.Id);
                            }
                        }
                    }

                    //Si en medio de la atencion gravo y luego el profesional se arrepiente y decide quitar el medicamento este debe se eliminado fisicamente
                    if (medicalEventDetail.EntityState == EntityState.Deleted)
                    {
                        MedicalEventDAC.Remove_MedicalEventDetail(medicalEventDetail.Id);
                    }
                }
            }

            if (pServiceRequest.BusinessData.PatientMedicaments != null)
            {
                //Selecciono medicamentos generados en otros eventos medicos
                var otherMedicaments = pServiceRequest.BusinessData.PatientMedicaments.Where(p =>
                                                                                             !p.MedicalEventId.Equals(currentMedicalEventId) &&
                                                                                             p.EntityState == EntityState.Changed);

                ///Si cambio algun medicamento de unevento anterior este es deshbilitado y se genera uno nuevo en el actual evento medico
                ///Logrando asi un hstorial
                foreach (PatientMedicament_ViewBE patientMedicament in otherMedicaments)
                {
                    PatientsDAC.DisablePatientMedicaments(patientMedicament.PatientMedicamentId,
                                                          Guid.Parse(pServiceRequest.ContextInformation.UserId),
                                                          BE.Enums.MedicamentStatus.Deshabilitado);
                }

                //|| p.PatientMedicamentId.Equals(-1)
                var currentMedicaments = pServiceRequest.BusinessData.PatientMedicaments.Where(p =>
                                                                                               p.MedicalEventId.Equals(currentMedicalEventId));

                foreach (PatientMedicament_ViewBE patientMedicament in currentMedicaments)
                {
                    patientMedicament.MedicalEventId = currentMedicalEventId;


                    if (patientMedicament.EntityState == EntityState.Added)
                    {
                        PatientsDAC.AddPatientMedicaments(patientMedicament, Guid.Parse(pServiceRequest.ContextInformation.UserId));
                    }

                    //Si modifique del mismo event Id (Esto se da por que el medico desidio guardar y luego modifico el evento si cerrar pantall
                    // y nuevamente preciona gurdar )
                    if (patientMedicament.EntityState == EntityState.Changed)
                    {
                        PatientsDAC.UpdatePatientMedicaments(patientMedicament, Guid.Parse(pServiceRequest.ContextInformation.UserId));
                    }

                    //Si en medio de la atencion gravo y luego el profesional se arrepiente y decide quitar el medicamento este debe se eliminado fisicamente
                    if (patientMedicament.EntityState == EntityState.Deleted)
                    {
                        PatientsDAC.RemovePatientMedicaments(patientMedicament.PatientMedicamentId);
                    }
                }
            }

            return(wRes);
        }