private void Schedule(List <IdsPersonAndProtocol> list)
        {
            foreach (var item in list)
            {
                var objCalendarDto = new calendarDto();
                objCalendarDto.v_PersonId          = item.PersonId;
                objCalendarDto.d_DateTimeCalendar  = dtpCalendarDate.Value;
                objCalendarDto.i_ServiceTypeId     = (int)ServiceType.Empresarial;
                objCalendarDto.i_CalendarStatusId  = (int)CalendarStatus.Agendado;
                objCalendarDto.i_ServiceId         = (int)MasterService.Eso;
                objCalendarDto.v_ProtocolId        = item.ProtocolId;
                objCalendarDto.i_NewContinuationId = 1;
                objCalendarDto.i_LineStatusId      = (int)LineStatus.EnCircuito;
                objCalendarDto.i_IsVipId           = (int)SiNo.NO;

                _calendarBl.AddShedule(ref _operationResult, objCalendarDto, Globals.ClientSession.GetAsList(), item.ProtocolId, item.PersonId, (int)MasterService.Eso, "Nuevo");
            }
        }
Пример #2
0
        private void AddAuxiliaryExam()
        {
            var findResult = lvExamenesSeleccionados.FindItemWithText(MedicalExamId);

            // El examen ya esta agregado
            if (findResult != null)
            {
                MessageBox.Show("Por favor seleccione otro examen.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var res = _ListaComponentes.Find(p => p == MedicalExamId);

            if (res != null)
            {
                var DialogResult = MessageBox.Show("El paciente ya cuenta con este examen, ¿Desea crear nuevo servicio?", "Error de Valicación", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (DialogResult == System.Windows.Forms.DialogResult.Yes)
                {
                    #region Agenda Automática
                    CalendarBL      calendarBl         = new CalendarBL();
                    OperationResult objOperationResult = new OperationResult();

                    var protocolId = Constants.Prot_Hospi_Adic;

                    var objCalendarDto = new calendarDto();
                    objCalendarDto.v_PersonId         = new PacientBL().GetPersonByNroDocument(ref objOperationResult, _dni).v_PersonId;// item.PersonId;
                    objCalendarDto.d_DateTimeCalendar = DateTime.Now;
                    objCalendarDto.d_CircuitStartDate = DateTime.Now;
                    objCalendarDto.d_EntryTimeCM      = DateTime.Now;
                    objCalendarDto.i_ServiceTypeId    = (int)ServiceType.Particular;
                    objCalendarDto.i_ServiceId        = (int)MasterService.Hospitalizacion;

                    objCalendarDto.i_CalendarStatusId  = (int)CalendarStatus.Agendado;
                    objCalendarDto.i_LineStatusId      = (int)LineStatus.EnCircuito;
                    objCalendarDto.v_ProtocolId        = protocolId;
                    objCalendarDto.i_NewContinuationId = 1;
                    objCalendarDto.i_LineStatusId      = (int)LineStatus.EnCircuito;
                    objCalendarDto.i_IsVipId           = (int)SiNo.NO;

                    var serviceId = calendarBl.AddShedule(ref objOperationResult, objCalendarDto, Globals.ClientSession.GetAsList(), protocolId, objCalendarDto.v_PersonId, (int)MasterService.Eso, "Nuevo");

                    serviceDto objServiceDto = new serviceDto();
                    objServiceDto = new ServiceBL().GetService(ref objOperationResult, serviceId);
                    objServiceDto.d_ServiceDate = DateTime.Now;

                    objServiceDto.i_ServiceStatusId = (int)Common.ServiceStatus.Iniciado;
                    new ServiceBL().UpdateService(ref objOperationResult, objServiceDto, Globals.ClientSession.GetAsList());


                    var servicesComponents = new ServiceBL().GetServiceComponents(ref objOperationResult, serviceId);

                    foreach (var servicesComponent in servicesComponents)
                    {
                        servicecomponentDto oservicecomponentDto = new servicecomponentDto();
                        oservicecomponentDto = new ServiceBL().GetServiceComponent(ref objOperationResult,
                                                                                   servicesComponent.v_ServiceComponentId);
                        oservicecomponentDto.i_MedicoTratanteId   = 11;
                        oservicecomponentDto.i_IsVisibleId        = 1;
                        oservicecomponentDto.v_ServiceComponentId = servicesComponent.v_ServiceComponentId;
                        new ServiceBL().UpdateServiceComponent(ref objOperationResult, oservicecomponentDto, Globals.ClientSession.GetAsList());
                    }



                    var oHospitalizacionserviceDto = new hospitalizacionserviceDto();

                    oHospitalizacionserviceDto.v_HopitalizacionId = _nroHospitalizacion;
                    oHospitalizacionserviceDto.v_ServiceId        = serviceId;

                    new HospitalizacionBL().AddHospitalizacionService(ref objOperationResult, oHospitalizacionserviceDto, Globals.ClientSession.GetAsList());
                    #endregion

                    MessageBox.Show("Se generó el servicio: " + serviceId, " ¡ INFORMACIÓN !", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //var DialogResult = DialogResult.OK;
                    //var frm = new frmCalendar(_nroHospitalizacion, _dni, _serviceId);
                    //frm.ShowDialog();
                }
                else
                {
                    return;
                }
            }


            var row = new ListViewItem(new[] { MedicalExamName, MedicalExamId, ServiceComponentConcatId });

            lvExamenesSeleccionados.Items.Add(row);

            gbExamenesSeleccionados.Text = string.Format("Examenes Seleccionados {0}", lvExamenesSeleccionados.Items.Count);
        }
        private void btnschedule_Click(object sender, EventArgs e)
        {
            OperationResult objOperationResult = new OperationResult();
            CalendarBL      objCalendarBL      = new CalendarBL();
            calendarDto     objCalendarDto     = new calendarDto();
            PacientBL       objPacientBL       = new PacientBL();
            pacientDto      objPacientDto      = new pacientDto();
            PacientList     PacientList        = new PacientList();
            BlackListBL     objBlackListBL     = new BlackListBL();

            if (dtpDateTimeCalendar.Value < DateTime.Now.Date)
            {
                MessageBox.Show("No se permite agendar con una fecha anterior a la actual.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string CalendarId;
            string PacientId   = "";
            string ProtocoloId = "";

            StringBuilder sbDatos = new StringBuilder();

            if (uvschedule.Validate(true, false).IsValid)
            {
                foreach (var item in _TempPacientList)
                {
                    personDto objPersonDto = new personDto();
                    //Validar si el trabajador existe
                    objPersonDto = objPacientBL.GetPersonByNroDocument(ref objOperationResult, item.v_DocNumber);
                    if (objPersonDto != null)
                    {
                        objPersonDto.v_FirstName       = item.v_FirstName.Trim();
                        objPersonDto.v_FirstLastName   = item.v_FirstLastName.Trim();
                        objPersonDto.v_SecondLastName  = item.v_SecondLastName.Trim();
                        objPersonDto.i_DocTypeId       = item.i_DocTypeId;
                        objPersonDto.v_DocNumber       = item.v_DocNumber;
                        objPersonDto.i_SexTypeId       = item.i_SexTypeId;
                        objPersonDto.d_Birthdate       = item.d_Birthdate;
                        objPersonDto.i_LevelOfId       = -1;
                        objPersonDto.i_MaritalStatusId = -1;

                        objPersonDto.i_BloodGroupId           = -1;
                        objPersonDto.i_BloodFactorId          = -1;
                        objPersonDto.i_DepartmentId           = -1;
                        objPersonDto.i_ProvinceId             = -1;
                        objPersonDto.i_DistrictId             = -1;
                        objPersonDto.i_ResidenceInWorkplaceId = -1;
                        objPersonDto.i_TypeOfInsuranceId      = -1;
                        objPersonDto.i_OccupationTypeId       = -1;
                        objPersonDto.i_AltitudeWorkId         = -1;
                        objPersonDto.i_PlaceWorkId            = -1;
                        objPersonDto.i_Relationship           = -1;

                        objPersonDto.v_CurrentOccupation = item.v_CurrentOccupation;
                        objPacientBL.UpdatePacient(ref objOperationResult, objPersonDto, Globals.ClientSession.GetAsList(), objPersonDto.v_DocNumber, "");
                        PacientId = objPersonDto.v_PersonId;
                    }
                    else
                    {
                        objPersonDto                          = new personDto();
                        objPersonDto.v_FirstName              = item.v_FirstName.Trim();
                        objPersonDto.v_FirstLastName          = item.v_FirstLastName.Trim();
                        objPersonDto.v_SecondLastName         = item.v_SecondLastName.Trim();
                        objPersonDto.i_DocTypeId              = item.i_DocTypeId;
                        objPersonDto.v_DocNumber              = item.v_DocNumber;
                        objPersonDto.i_SexTypeId              = item.i_SexTypeId;
                        objPersonDto.d_Birthdate              = item.d_Birthdate;
                        objPersonDto.i_LevelOfId              = -1;
                        objPersonDto.i_MaritalStatusId        = -1;
                        objPersonDto.i_BloodGroupId           = -1;
                        objPersonDto.i_BloodFactorId          = -1;
                        objPersonDto.i_DepartmentId           = -1;
                        objPersonDto.i_ProvinceId             = -1;
                        objPersonDto.i_DistrictId             = -1;
                        objPersonDto.i_ResidenceInWorkplaceId = -1;
                        objPersonDto.i_TypeOfInsuranceId      = -1;
                        objPersonDto.i_OccupationTypeId       = -1;
                        objPersonDto.i_AltitudeWorkId         = -1;
                        objPersonDto.i_PlaceWorkId            = -1;
                        objPersonDto.i_Relationship           = -1;
                        objPersonDto.v_Password               = item.v_DocNumber;
                        objPersonDto.v_CurrentOccupation      = item.v_CurrentOccupation;

                        PacientId = objPacientBL.AddPacient(ref objOperationResult, objPersonDto, Globals.ClientSession.GetAsList());
                    }

                    var Verificar = objBlackListBL.GetBlackList(ref objOperationResult, objPersonDto.v_PersonId);


                    if (PacientId != null && Verificar == null)  // Se grabo el paciente y se lo agenda
                    {
                        objCalendarDto.v_PersonId         = PacientId;
                        objCalendarDto.d_DateTimeCalendar = dtpDateTimeCalendar.Value;
                        objCalendarDto.i_ServiceTypeId    = Int32.Parse(ddlServiceTypeId.SelectedValue.ToString());
                        objCalendarDto.i_CalendarStatusId = Int32.Parse(ddlCalendarStatusId.SelectedValue.ToString());
                        objCalendarDto.i_ServiceId        = Int32.Parse(ddlMasterServiceId.SelectedValue.ToString());
                        //objCalendarDto.v_ProtocolId = _ProtocolId;
                        objCalendarDto.v_ProtocolId        = item.v_ProtocoloId;
                        objCalendarDto.i_NewContinuationId = Int32.Parse(ddlNewContinuationId.SelectedValue.ToString());
                        objCalendarDto.i_LineStatusId      = Int32.Parse(ddlLineStatusId.SelectedValue.ToString());
                        objCalendarDto.i_IsVipId           = Int32.Parse(ddlVipId.SelectedValue.ToString());

                        CalendarId = objCalendarBL.AddShedule(ref objOperationResult, objCalendarDto, Globals.ClientSession.GetAsList(), item.v_ProtocoloId, PacientId, Int32.Parse(ddlMasterServiceId.SelectedValue.ToString()), "Nuevo", chkIsCampania.Checked ? 1 : 0);
                    }
                    else  // no se grabro el paciente
                    {
                        sbDatos.Append("PACIENTE :  ");
                        sbDatos.Append(objPersonDto.v_FirstName + " " + objPersonDto.v_FirstLastName + " " + objPersonDto.v_SecondLastName);
                        sbDatos.Append("  DOCUMENTO :  ");
                        sbDatos.Append(objPersonDto.v_DocNumber);
                        sbDatos.Append("\n");
                    }
                }
                if (objOperationResult.Success == 1)  // Operación sin error
                {
                    if (sbDatos.ToString() != "")
                    {
                        MessageBox.Show(sbDatos.ToString(), "Estos pacientes no fueron agendados", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Close();
                    }
                }
                else// Operación con error
                {
                    if (objOperationResult.ErrorMessage != null)
                    {
                        MessageBox.Show(objOperationResult.ErrorMessage, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(sbDatos.ToString(), "Estos pacientes no fueron agendados", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        // Se queda en el formulario.
                    }
                }
            }
        }