Example #1
0
        public BoardPatient FilterWorkers(BoardPatient data)
        {
            var workersDa = new WorkersDal();

            Workers = workersDa.WorkesWhitServices(out int totalRecords, data);
            if (data.PlanVigilanciaId != "-1")
            {
                _filterDiseasesServices = new PlanDal().ListPlanVigilanciaDiseases(data.PlanVigilanciaId);
            }

            ProcessWorkers(ActiveWorker);
            ProcessWorkers(ResultEmoToReview);
            ProcessWorkers(ResultEmoToReviewCounter);
            ProcessWorkers(ResultControlInProgress);

            if (data.Workerstatus != -1)
            {
                Workers = FilterByState(Workers, data.Workerstatus);
            }

            data.TotalRecords = totalRecords;
            data.List         = TransformData(Workers);

            return(data);
        }
 public BoardPatient GetPendingReview_Old(BoardPatient data)
 {
     try
     {
         var isDeleted = (int)Enumeratores.SiNo.No;
         var count     = (from a in ctx.Service
                          where a.i_IsDeleted == isDeleted && a.i_MasterServiceId.Value == (int)masterService.Ocupational && a.i_IsRevisedHistoryId != 1
                          select new Patients
         {
             MasterServiceId = a.i_MasterServiceId.Value,
         }).ToList();
         data.List = count;
         return(data);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #3
0
        public ActionResult FilterPacient(BoardPatient data)
        {
            Api API = new Api();
            Dictionary <string, string> arg = new Dictionary <string, string>()
            {
                { "Patient", data.Patient },
                { "Workerstatus", data.Workerstatus.ToString() },
                { "SystemUserByOrganizationId", data.OrganizationId },
                { "PlanVigilanciaId", data.PlanVigilanciaId },
                { "OrganizationId", data.OrganizationId },
                { "SystemUserId", ViewBag.USER.SystemUserId == (int)Enums.UserId.Sa ? "-1" : ViewBag.USER.SystemUserId.ToString() },
                //{ "EmployerOrganizationId", data.EmployerOrganizationId },
                //{ "EmployerOrganizationId", "-1" },
                { "Index", data.Index.ToString() },
                { "Take", data.Take.ToString() }
            };

            ViewBag.Services      = API.Post <BoardPatient>("PatientsAssistance/FilterWorkers", arg);
            ViewBag.PendingReview = API.Get <int?>("PatientsAssistance/GetPendingReview?systemUserId=" + ViewBag.USER.SystemUserId.ToString() + "&organizationId=" + data.OrganizationId);
            return(PartialView("_BoardPatientsAssistancePartial"));
        }
        public IHttpActionResult FilterWorkers(BoardPatient data)
        {
            var result = _oFilterWorkersBl.FilterWorkers(data);

            return(Ok(result));
        }
        public List <ServiceWorkerBE> WorkesWhitServices(out int totalRecords, BoardPatient data)
        {
            int groupDocTypeId = (int)Enumeratores.DataHierarchy.TypeDoc;
            int genderId       = (int)Enumeratores.Parameters.Gender;
            int skip           = (data.Index - 1) * data.Take;

            string filterPacient = string.IsNullOrWhiteSpace(data.Patient) ? "" : data.Patient;

            //AMC____
            var protocols = (from a in _ctx.ProtocolSystemUser
                             join b in _ctx.Protocol on a.v_ProtocolId equals b.v_ProtocolId
                             where (data.SystemUserId == -1 || a.i_SystemUserId == data.SystemUserId) &&
                             (b.v_CustomerOrganizationId == data.SystemUserByOrganizationId || b.v_EmployerOrganizationId == data.SystemUserByOrganizationId || b.v_WorkingOrganizationId == data.SystemUserByOrganizationId)
                             select a.v_ProtocolId).ToList();

            protocols = protocols.GroupBy(g => g).Select(s => s.First()).ToList();

            var services = (from a in _ctx.Service
                            join b in _ctx.Person on a.v_PersonId equals b.v_PersonId
                            join c in _ctx.DataHierarchy on new { a = b.i_DocTypeId.Value, b = groupDocTypeId } equals new { a = c.i_ItemId, b = c.i_GroupId }
                            join d in _ctx.SystemParameter on new { a = b.i_SexTypeId.Value, b = genderId } equals new { a = d.i_ParameterId, b = d.i_GroupId }
                            join e in _ctx.Protocol on a.v_ProtocolId equals e.v_ProtocolId
                            join f in _ctx.Organization on e.v_EmployerOrganizationId equals f.v_OrganizationId
                            join g in _ctx.Vigilancia on a.v_PersonId equals g.v_PersonId into gJoin
                            from g in gJoin.DefaultIfEmpty()
                            join h in _ctx.PlanVigilancia on g.v_PlanVigilanciaId equals h.v_PlanVigilanciaId into hJoin
                            from h in hJoin.DefaultIfEmpty()
                            where protocols.Contains(a.v_ProtocolId) &&
                            ((b.v_FirstName + " " + b.v_FirstLastName + " " + b.v_SecondLastName).Contains(filterPacient) ||
                             b.v_DocNumber.Contains(filterPacient)) &&
                            (data.PlanVigilanciaId == "-1" || g.v_PlanVigilanciaId == data.PlanVigilanciaId) &&
                            (g.i_StateVigilanciaId != (int)Enumeratores.StateVigilancia.Finalizado)
                            select new Patients
            {
                ServiceId = a.v_ServiceId,
                PatientId = a.v_PersonId,
                PatientFullName = b.v_FirstName + " " + b.v_FirstLastName + " " + b.v_SecondLastName,
                DocumentType = c.v_Value1,
                DocumentNumber = b.v_DocNumber,
                Occupation = b.v_CurrentOccupation,
                Birthdate = b.d_Birthdate,
                Gender = d.v_Value1,
                StatusVigilanciaId = a.i_StatusVigilanciaId.Value,
                OrganizationLocation = f.v_Name,
                IsRevisedHistoryId = a.i_IsRevisedHistoryId.Value,
                ProtocolId = e.v_ProtocolId,
                ServiceDate = a.d_ServiceDate,
                PlanVigilancia = h.v_Name,
                VigilanciaId = g.v_VigilanciaId
            }).ToList();

            //.. lógica para filtar por UsuarioEmpresa

            var workers = services.GroupBy(g => g.PatientId).Select(s => s.First()).ToList();
            var list    = new List <ServiceWorkerBE>();

            totalRecords = workers.Count;

            var patientses = new List <Patients>();

            if (data.Take > 0)
            {
                patientses = workers.Skip(skip).Take(data.Take).ToList();
            }


            foreach (var worker in patientses)
            {
                var oServiceWorkerBE = new ServiceWorkerBE();

                oServiceWorkerBE.PatientId       = worker.PatientId;
                oServiceWorkerBE.PatientFullName = worker.PatientFullName;
                oServiceWorkerBE.DocumentType    = worker.DocumentType;
                oServiceWorkerBE.DocumentNumber  = worker.DocumentNumber;
                oServiceWorkerBE.Occupation      = worker.Occupation;
                oServiceWorkerBE.Birthdate       = worker.Birthdate;
                oServiceWorkerBE.Gender          = worker.Gender;
                oServiceWorkerBE.PlanVigilancia  = worker.PlanVigilancia;
                oServiceWorkerBE.VigilanciaId    = worker.VigilanciaId;
                oServiceWorkerBE.Age             = Common.Utils.GetAge(worker.Birthdate.Value);
                var servicesByWorker = services.FindAll(p => p.PatientId == worker.PatientId).ToList();

                var oServices = new List <ServiceWorker>();
                foreach (var service in servicesByWorker)
                {
                    var oServiceWorker = new ServiceWorker();
                    oServiceWorker.ServiceId           = service.ServiceId;
                    oServiceWorker.ServiceDate         = service.ServiceDate;
                    oServiceWorker.ProtocolId          = service.ProtocolId;
                    oServiceWorker.IsRevisedHistoryId  = service.IsRevisedHistoryId;
                    oServiceWorker.StatusVigilanciaId  = service.StatusVigilanciaId;
                    oServiceWorker.ListDiseasesService = (from a in _ctx.DiagnosticRepository
                                                          where a.v_ServiceId == service.ServiceId &&
                                                          a.i_FinalQualificationId == (int)Enumeratores.FinalQualification.Definitivo
                                                          select new DiseasesService
                    {
                        ServiceId = a.v_ServiceId,
                        DiseasesId = a.v_DiseasesId
                    }).ToList();
                    oServices.Add(oServiceWorker);
                }

                oServiceWorkerBE.Services = oServices;

                list.Add(oServiceWorkerBE);
            }


            //if (data.Take > 0)
            //    list = list.Skip(skip).Take(data.Take).ToList();

            return(list);
        }