public bool UpdateServiceForProtocol(ServiceCustom data, int userId) { bool resultServiceComponent = new ServiceComponentDal().UpdateServiceComponent(data.ServiceId, userId); if (!resultServiceComponent) { return(false); } return(new ServiceDal().UpdateServiceForProtocolo(data, userId)); }
public string SaveAndGetServiceComponentId(string serviceId, string personId, List <ServiceComponentFieldsList> oServicecomponentfields, int nodeId, int systemUserId) { var listServiceComponentDto = new List <ServiceComponentDto>(); var components = oServicecomponentfields.GroupBy(g => g.v_ComponentId).Select(s => s.FirstOrDefault()); foreach (var Component in components) { listServiceComponentDto.Add(PopulateServiceComponentTemp(serviceId, Component.v_ComponentId, nodeId, systemUserId)); } var obj = new ServiceComponentDal().AddServiceComponentInBlockTemp(listServiceComponentDto, nodeId, systemUserId); obj.Sort((x, y) => x.v_ComponentId.CompareTo(y.v_ComponentId)); // Orden obligatorio para capturar siempre el v_ServiceComponentId correcto obj.OrderBy(o1 => o1.v_ServiceComponentId).ToList(); return(obj[0].v_ServiceComponentId); }
public bool SaveAdditionalExamsForCalendar(List <AdditionalExamCreate> data, int userId, int nodeId) { try { DatabaseContext dbContext = new DatabaseContext(); using (var ts = new TransactionScope()) { foreach (var objExam in data) { if (objExam.IsNewService == (int)SiNo.No) { var unidadProductiva = GetMedicalExam(objExam.ComponentId); var newId = new Common.Utils().GetPrimaryKey(nodeId, 24, "SC");; ServiceComponentDto objServiceComponentDto = new ServiceComponentDto(); objServiceComponentDto.v_ServiceComponentId = newId; objServiceComponentDto.i_ConCargoA = -1; objServiceComponentDto.v_ServiceId = objExam.ServiceId; objServiceComponentDto.i_ExternalInternalId = (int)ComponenteProcedencia.Interno; objServiceComponentDto.i_ServiceComponentTypeId = 1; objServiceComponentDto.i_IsVisibleId = 1; objServiceComponentDto.i_IsInheritedId = (int)SiNo.No; objServiceComponentDto.d_StartDate = null; objServiceComponentDto.d_EndDate = null; objServiceComponentDto.i_index = 1; objServiceComponentDto.r_Price = objExam.Price; objServiceComponentDto.v_ComponentId = objExam.ComponentId; objServiceComponentDto.i_IsInvoicedId = (int)SiNo.No; objServiceComponentDto.i_ServiceComponentStatusId = (int)ServiceStatus.PorIniciar; objServiceComponentDto.i_QueueStatusId = (int)QueueStatusId.Libre; objServiceComponentDto.i_Iscalling = (int)Flag_Call.NoseLlamo; objServiceComponentDto.i_Iscalling_1 = (int)Flag_Call.NoseLlamo; objServiceComponentDto.i_IsManuallyAddedId = (int)SiNo.No; objServiceComponentDto.i_IsRequiredId = (int)SiNo.Si; objServiceComponentDto.v_IdUnidadProductiva = unidadProductiva; objServiceComponentDto.i_MedicoTratanteId = objExam.MedicoTratante; objServiceComponentDto.d_SaldoPaciente = 0; objServiceComponentDto.d_SaldoAseguradora = 0; objServiceComponentDto.i_IsDeleted = 0; objServiceComponentDto.d_InsertDate = DateTime.Now; dbContext.ServiceComponent.Add(objServiceComponentDto); dbContext.SaveChanges(); } else { CalendarDto _CalendarDto = new CalendarDto(); var protocolId = Constants.Prot_Hospi_Adic; _CalendarDto.v_PersonId = objExam.PersonId; _CalendarDto.d_DateTimeCalendar = DateTime.Now; _CalendarDto.d_CircuitStartDate = DateTime.Now; _CalendarDto.d_EntryTimeCM = DateTime.Now; _CalendarDto.i_ServiceTypeId = (int)ServiceType.Particular; _CalendarDto.i_ServiceId = (int)MasterService.Hospitalizacion; _CalendarDto.i_CalendarStatusId = (int)CalendarStatus.Agendado; _CalendarDto.i_LineStatusId = (int)LineStatus.EnCircuito; _CalendarDto.v_ProtocolId = protocolId; _CalendarDto.i_NewContinuationId = 1; _CalendarDto.i_LineStatusId = (int)LineStatus.EnCircuito; _CalendarDto.i_IsVipId = (int)SiNo.No; var result = AddCalendar(_CalendarDto, nodeId, userId); if (result) { ServiceDto _ServiceDto = new ServiceDto(); _ServiceDto = ctx.Service.Where(x => x.v_ServiceId == objExam.ServiceId).FirstOrDefault(); _ServiceDto.d_ServiceDate = DateTime.Now; _ServiceDto.i_ServiceStatusId = (int)ServiceStatus.Iniciado; _ServiceDto.d_UpdateDate = DateTime.Now; _ServiceDto.i_UpdateUserId = userId; ctx.SaveChanges(); var servicesComponents = new ServiceComponentDal().GetServiceComponents(objExam.ServiceId); if (servicesComponents != null) { foreach (var servicesComponent in servicesComponents) { var oservicecomponentDto = ctx.ServiceComponent.Where(x => x.v_ServiceComponentId == servicesComponent.v_ServiceComponentId).FirstOrDefault(); oservicecomponentDto.i_MedicoTratanteId = 11; oservicecomponentDto.i_IsVisibleId = 1; oservicecomponentDto.v_ServiceComponentId = servicesComponent.v_ServiceComponentId; oservicecomponentDto.i_UpdateUserId = userId; oservicecomponentDto.d_UpdateDate = DateTime.Now; ctx.SaveChanges(); } var resultHospi = new HospitalizacionDal().AddHospitalizacionService(null, objExam.ServiceId, nodeId, userId); if (!resultHospi) { throw new Exception(""); } } else { throw new Exception(""); } } else { throw new Exception(""); } } } var resultAdditional = new AdditionalExamDal().UpdateAdditionalExamByComponentIdAndServiceId(data, userId); if (!resultAdditional) { throw new Exception(""); } ts.Complete(); } return(true); } catch (Exception ex) { return(false); } }
public string CreateService(ServiceCustom data, int nodeId, int userId) { string serviceId = ""; List <ProtocolComponentCustom> ListProtocolComponent = new ProtocolComponentDal().GetProtocolComponents(data.ProtocolId); if (data.FechaCalendario == null) { data.ProtocolId = new ProtocolBL().ReturnOrDuplicateProtocol(data, nodeId, userId, ListProtocolComponent); } serviceId = new ServiceDal().CreateService(data, nodeId, userId); if (serviceId == null) { return(null); } data.ServiceId = serviceId; if (data.MasterServiceTypeId == (int)MasterServiceType.Empresarial) { bool result = new ServiceComponentDal().AddServiceComponent(ListProtocolComponent, data, nodeId, userId); if (!result) { return(null); } } else { bool result = new ServiceComponentDal().AddServiceComponent(ListProtocolComponent, data, nodeId, userId); if (!result) { return(null); } } CalendarDto _CalendarDto = new CalendarDto(); _CalendarDto.v_PersonId = data.PersonId; _CalendarDto.v_ServiceId = data.ServiceId; _CalendarDto.v_PersonId = data.PersonId; _CalendarDto.d_DateTimeCalendar = data.FechaCalendario == null ? DateTime.Now : data.FechaCalendario; _CalendarDto.d_CircuitStartDate = data.FechaCalendario == null ? DateTime.Now : data.FechaCalendario; _CalendarDto.d_EntryTimeCM = data.FechaCalendario == null ? DateTime.Now : data.FechaCalendario; _CalendarDto.i_ServiceTypeId = data.MasterServiceTypeId; _CalendarDto.i_CalendarStatusId = 1; _CalendarDto.i_ServiceId = data.MasterServiceId; _CalendarDto.v_ProtocolId = data.ProtocolId; _CalendarDto.i_NewContinuationId = 1; _CalendarDto.i_LineStatusId = 1; _CalendarDto.i_IsVipId = 0; bool calendarResult = new CalendarDal().AddCalendar(_CalendarDto, nodeId, userId); if (!calendarResult) { return(null); } int tipoEmpresa = ProtocolDal.ObtenerTipoEmpresaByProtocol(data.ProtocolId); if ((data.MasterServiceId == 19 || data.MasterServiceId == 10 || data.MasterServiceId == 15 || data.MasterServiceId == 16 || data.MasterServiceId == 17 || data.MasterServiceId == 18 || data.MasterServiceId == 19) && tipoEmpresa == 4) { bool resultHospi = new HospitalizacionDal().AddHospitalizacion(data.PersonId, data.ServiceId, nodeId, userId); if (!resultHospi) { return(null); } } return(serviceId); }
public static List <Categoria> GetAllComponentsByService(string serviceId) { return(ServiceComponentDal.GetAllComponentsByService(serviceId)); }