private Task <IEnumerable <IncidenciaModulo> > GetIncidenciasModulos(decimal idPaciente) { IEnumerable <decimal> selectedAreasIds = SelectedAreas.Select(x => x.ID); IEnumerable <decimal> selectedProfesionalsIds = SelectedProfesionales.Select(x => x.ID); return(Task.Run(() => plantillasService.GetIncidenciasModulos(PlantillaSelected, idPaciente, selectedProfesionalsIds, selectedAreasIds, FechaInicio, FechaFin, TipoFechaCreacion ? 1 : 0))); }
private Task <IEnumerable <Paciente> > GetPacientesPlantilla() { IEnumerable <decimal> selectedAreasIds = SelectedAreas.Select(x => x.ID); IEnumerable <decimal> selectedProfesionalsIds = SelectedProfesionales.Select(x => x.ID); return(Task.Run(() => plantillasService.GetPacientesPlantilla(PlantillaSelected, selectedProfesionalsIds, selectedAreasIds, FechaInicio, FechaFin, TipoFechaCreacion ? 1 : 0))); }
private async void MostrarListadoPacientesDiagnosticados(decimal?indicador) { try { IsBusyLoadingIndicadores = true; IEnumerable <decimal> selectedAreasIds = SelectedAreas.Select(x => x.ID); IEnumerable <decimal> selectedProfesionalsIds = SelectedProfesionales.Select(x => x.ID); var pacientes = await Task.Run(() => indicadoresService.GetPacientesDiagnosticados(selectedProfesionalsIds, selectedAreasIds, FechaInicio, FechaFin, indicador.Value)); var resp = modalDialogHelper.ShowModalDialog("Estadisticas.PacientesDiagnosticados", 0, 0, System.Windows.ResizeMode.NoResize, System.Windows.SizeToContent.WidthAndHeight, pacientes); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { IsBusyLoadingIndicadores = false; } }
private async void ObtenerPlantillas() { try { IsBusyLoadingPlantillas = true; IEnumerable <decimal> selectedAreasIds = SelectedAreas.Select(x => x.ID); IEnumerable <decimal> selectedProfesionalsIds = SelectedProfesionales.Select(x => x.ID); var plantillasFromService = await Task.Run(() => plantillasService.GetPlantillas(selectedProfesionalsIds, selectedAreasIds, FechaInicio, FechaFin, (TipoFechaCreacion) ? (TipoFecha.Creacion) : (TipoFecha.UltimaModificacion))); if (!plantillasFromService.HasElements()) { Plantillas = null; PlantillaSelected = 0; Plantilla = null; PlantillaPlana = null; return; } Plantillas = new ObservableCollection <PlantillaEstadistica>(plantillasFromService.OrderBy(p => p.Descripcion)); if (Plantillas.HasElements()) { PlantillaSelected = Plantillas.FirstOrDefault().Codigo; Plantilla = await Task.Run(() => plantillasService.GetPlantilla(PlantillaSelected)); PlantillaPlana = PlantillaPlana.AplanarPlantilla(Plantilla); } } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { IsBusyLoadingPlantillas = false; } }
private async void OnIndicadorPacientes(object data) { try { IsBusyLoadingIndicadores = true; IEnumerable <decimal> selectedAreasIds = SelectedAreas.Select(x => x.ID); IEnumerable <decimal> selectedProfesionalsIds = SelectedProfesionales.Select(x => x.ID); var indicadoresMisPacientes = await Task.Run(() => indicadoresService.GetIndicadoresPacientes(selectedProfesionalsIds, selectedAreasIds, FechaInicio, FechaFin)); // var indicadores = await Task.Run(() => indicadoresService.GetIndicadoresPacientesAtendidos(selectedProfesionalsIds, selectedAreasIds, FechaInicio, FechaFin)); if (indicadoresMisPacientes != null) { MisPacientes = new ObservableCollection <IndicadorItem>(new IndicadorItem[] { new IndicadorItem() { Indicador = "Atendidos", Valor = (int)indicadoresMisPacientes.Atendidos }, new IndicadorItem() { Indicador = "Etiquetados", Valor = (int)indicadoresMisPacientes.Etiquetados } }); } } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { IsBusyLoadingIndicadores = false; } }
protected bool CreateSMExtract(double priority) { bool ret = false; bool txtExtract = false; var imgExtracts = new List <PDFImageExtract>(); var contents = new List <ContentBase>(); var selImages = SelectedImages; var selImageAreas = SelectedAreas.Where(a => a.Type == PDFAreaSelection.AreaType.Normal); var selTextAreas = SelectedAreas.Where(a => a.Type == PDFAreaSelection.AreaType.Ocr).ToList(); var pageIndices = new HashSet <int>(); if (priority < 0 || priority > 100) { priority = PDFConst.DefaultSMExtractPriority; } string extractTitle = null; // Image extract foreach (var selImage in selImages) { var imgExtract = new PDFImageExtract { BoundingBox = selImage.BoundingBox, ObjectIndex = selImage.ObjectIndex, PageIndex = selImage.PageIndex, }; var imgObj = (PdfImageObject)Document.Pages[selImage.PageIndex].PageObjects[selImage.ObjectIndex]; var imgRegistryTitle = TitleOrFileName + $": {selImage}"; var content = CreateImageContent(imgObj.Bitmap.Image, imgRegistryTitle); if (content != null) { imgExtracts.Add(imgExtract); contents.Add(content); pageIndices.Add(selImage.PageIndex); } } // Area extract foreach (var selArea in selImageAreas) { var imgExtract = new PDFImageExtract { BoundingBox = selArea.Normalized(), ObjectIndex = -1, PageIndex = selArea.PageIndex, }; var(lt, rb) = selArea.NormalizedPoints(); var img = RenderArea(imgExtract.PageIndex, lt, rb); var imgRegistryTitle = TitleOrFileName + $": {selArea}"; var content = CreateImageContent(img, imgRegistryTitle); if (content != null) { imgExtracts.Add(imgExtract); contents.Add(content); pageIndices.Add(selArea.PageIndex); } } // Text extract var hasTextSelection = string.IsNullOrWhiteSpace(SelectedText) == false; var hasTextOcr = selTextAreas.Any(); if (hasTextSelection) { txtExtract = true; foreach (var selInfo in SelectInfos) { for (int p = selInfo.StartPage; p <= selInfo.EndPage; p++) { pageIndices.Add(p); } } } if (hasTextOcr) { foreach (var selArea in selTextAreas) { pageIndices.Add(selArea.PageIndex); } } if (hasTextSelection || hasTextOcr) { string text = GetSelectedTextAsHtml(); contents.Add(new TextContent(true, text)); } else if (imgExtracts.Count > 0) { var parentEl = Svc.SM.Registry.Element[PDFElement.ElementId]; var titleString = $"{parentEl.Title} -- Image extract:"; var imageString = $"{imgExtracts.Count} image{(imgExtracts.Count == 1 ? "" : "s")}"; var pageString = "p" + string.Join(", p", pageIndices.Select(p => p + 1)); extractTitle = $"{titleString} {imageString} from {pageString}"; if (Config.ImageExtractAddHtml) { contents.Add(new TextContent(true, string.Empty)); } } // Generate extract if (contents.Count > 0) { Save(false); var bookmarks = pageIndices.Select(FindBookmark) .Where(b => b != null) .Distinct() .Select(b => $"({b.ToHierarchyString()})"); var bookmarksStr = StringEx.Join(" ; ", bookmarks); var parentEl = Svc.SM.Registry.Element[PDFElement.ElementId]; var templateId = imgExtracts.Count > 0 ? Config.ImageTemplate : Config.TextTemplate; var template = Svc.SM.Registry.Template[templateId]; ret = Svc.SM.Registry.Element.Add( out _, ElemCreationFlags.CreateSubfolders, new ElementBuilder(ElementType.Topic, contents.ToArray()) .WithParent(parentEl) .WithConcept(parentEl.Concept) .WithLayout(Config.Layout) .WithTemplate(template) .WithPriority(priority) .WithReference(r => PDFElement.ConfigureSMReferences(r, bookmarks: bookmarksStr)) .WithTitle(extractTitle) .DoNotDisplay() ); Window.GetWindow(this)?.Activate(); if (ret) { SelectInfo lastSelInfo = default; foreach (var imgExtract in imgExtracts) { PDFElement.SMImgExtracts.Add(imgExtract); AddImgExtractHighlight(imgExtract.PageIndex, imgExtract.BoundingBox); } if (txtExtract) { foreach (var selInfo in SelectInfos) { PDFElement.SMExtracts.Add(selInfo); AddSMExtractHighlight(selInfo); } lastSelInfo = SelectInfo; } Save(false); DeselectAll(); if (txtExtract) { _selectInfo.StartPage = _selectInfo.EndPage = lastSelInfo.StartPage; _selectInfo.StartIndex = _selectInfo.EndIndex = lastSelInfo.StartIndex; } } } return(ret); }
protected bool CreateSMExtract() { bool ret = false; bool txtExtract = false; var imgExtracts = new List <PDFImageExtract>(); var contents = new List <ContentBase>(); var selImages = SelectedImages; var selImageAreas = SelectedAreas.Where(a => a.Type == PDFAreaSelection.AreaType.Normal); var selTextAreas = SelectedAreas.Where(a => a.Type == PDFAreaSelection.AreaType.Ocr).ToList(); var pageIndices = new HashSet <int>(); // Image extract foreach (var selImage in selImages) { var imgExtract = new PDFImageExtract { BoundingBox = selImage.BoundingBox, ObjectIndex = selImage.ObjectIndex, PageIndex = selImage.PageIndex, }; var imgObj = (PdfImageObject)Document.Pages[selImage.PageIndex].PageObjects[selImage.ObjectIndex]; var imgRegistryTitle = TitleOrFileName + $": {selImage}"; var content = CreateImageContent(imgObj.Bitmap.Image, imgRegistryTitle); if (content != null) { imgExtracts.Add(imgExtract); contents.Add(content); pageIndices.Add(selImage.PageIndex); } } // Area extract foreach (var selArea in selImageAreas) { var imgExtract = new PDFImageExtract { BoundingBox = selArea.Normalized(), ObjectIndex = -1, PageIndex = selArea.PageIndex, }; var(lt, rb) = selArea.NormalizedPoints(); var img = RenderArea(imgExtract.PageIndex, lt, rb); var imgRegistryTitle = TitleOrFileName + $": {selArea}"; var content = CreateImageContent(img, imgRegistryTitle); if (content != null) { imgExtracts.Add(imgExtract); contents.Add(content); pageIndices.Add(selArea.PageIndex); } } // Text extract if (string.IsNullOrWhiteSpace(SelectedText) == false) { string text = GetSelectedTextHtml(); contents.Add(new TextContent(true, text)); txtExtract = true; foreach (var selInfo in SelectInfos) { for (int p = selInfo.StartPage; p <= selInfo.EndPage; p++) { pageIndices.Add(p); } } } if (selTextAreas.Any()) { var text = string.Join("\r\n<br/>[...] ", selTextAreas.Select(a => a.OcrText)); contents.Add(new TextContent(true, text)); foreach (var selArea in selTextAreas) { pageIndices.Add(selArea.PageIndex); } } // Generate extract if (contents.Count > 0) { Save(false); var bookmarks = pageIndices.Select(FindBookmark) .Where(b => b != null) .Distinct() .Select(b => $"({b.ToHierarchyString()})"); var bookmarksStr = StringEx.Join(" ; ", bookmarks); ret = Svc.SMA.Registry.Element.Add( out _, ElemCreationFlags.CreateSubfolders, new ElementBuilder(ElementType.Topic, contents.ToArray()) .WithParent(Svc.SMA.Registry.Element[PDFElement.ElementId]) .WithLayout(Config.Layout) .WithPriority(Config.SMExtractPriority) .WithReference(r => PDFElement.ConfigureSMReferences(r, bookmarks: bookmarksStr)) .WithForcedGeneratedTitle() .DoNotDisplay() ); Window.GetWindow(this)?.Activate(); if (ret) { foreach (var imgExtract in imgExtracts) { PDFElement.SMImgExtracts.Add(imgExtract); AddImgExtractHighlight(imgExtract.PageIndex, imgExtract.BoundingBox); } if (txtExtract) { foreach (var selInfo in SelectInfos) { PDFElement.SMExtracts.Add(selInfo); AddSMExtractHighlight(selInfo); } } Save(false); DeselectAll(); } } return(ret); }
private async void BuscarIndicadores() { try { IsBusyLoadingIndicadores = true; IEnumerable <decimal> selectedAreasIds = SelectedAreas.Select(x => x.ID); IEnumerable <decimal> selectedProfesionalsIds = SelectedProfesionales.Select(x => x.ID); var taskIndicadoresMisPacientes = Task.Run(() => indicadoresService.GetIndicadoresPacientes(selectedProfesionalsIds, selectedAreasIds, FechaInicio, FechaFin)); var taskIndicadoresCanalesVirtuales = Task.Run(() => indicadoresService.GetIndicadoresCanalesVirtuales(selectedProfesionalsIds, selectedAreasIds, FechaInicio, FechaFin)); var taskIndicadoresIndicaciones = Task.Run(() => indicadoresService.GetIndicadores(selectedProfesionalsIds, selectedAreasIds, FechaInicio, FechaFin)); var taskIndicadoresDiagnosticos = Task.Run(() => indicadoresService.GetIndicadoresDiagnostico(selectedProfesionalsIds, selectedAreasIds, FechaInicio, FechaFin)); var indicadoresMisPacientes = await taskIndicadoresMisPacientes; MisPacientes = new ObservableCollection <IndicadorItem>( new IndicadorItem[] { new IndicadorItem() { Indicador = "Atendidos", Valor = (int)indicadoresMisPacientes.Atendidos }, new IndicadorItem() { Indicador = "Etiquetados", Valor = (int)indicadoresMisPacientes.Etiquetados } }); var indicadoresCanalesVirtuales = await taskIndicadoresCanalesVirtuales; CanalesVirtuales = new ObservableCollection <IndicadorItem>( new IndicadorItem[] { new IndicadorItem() { Indicador = "Total Mensajes", Valor = (int)indicadoresCanalesVirtuales.TotalMensajes, ValorAuxiliar = indicadoresCanalesVirtuales.TotalMensajesRespuesta }, new IndicadorItem() { Indicador = "CRM", Valor = (int)indicadoresCanalesVirtuales.CRM, ValorAuxiliar = indicadoresCanalesVirtuales.CRMRespuesta }, new IndicadorItem() { Indicador = "RCE", Valor = (int)indicadoresCanalesVirtuales.RCE, ValorAuxiliar = indicadoresCanalesVirtuales.RCERespuesta }, new IndicadorItem() { Indicador = "Portal Pacientes", Valor = (int)indicadoresCanalesVirtuales.PortalPacientes, ValorAuxiliar = indicadoresCanalesVirtuales.PortalPacientesRespuesta } }); var indicadoresIndicaciones = await taskIndicadoresIndicaciones; Indicaciones = new ObservableCollection <IndicadorItem>( new IndicadorItem[] { new IndicadorItem() { Indicador = "Farmacológicas", Valor = (int)indicadoresIndicaciones.Farmacologia }, new IndicadorItem() { Indicador = "Imagenología", Valor = (int)indicadoresIndicaciones.Imagenologia }, new IndicadorItem() { Indicador = "Laboratorio", Valor = (int)indicadoresIndicaciones.Laboratorio } }); var indicadoresDiagnosticos = await taskIndicadoresDiagnosticos; Diagnosticos = new ObservableCollection <IndicadorItem>(indicadoresDiagnosticos.Enum().Select( i => new IndicadorItem { Indicador = i.Nombre, Valor = (int)i.Numero, ValorAuxiliar = i.Id })); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { IsBusyLoadingIndicadores = false; } }