private void RefreshComponent() { if (_context == null) { _reports = new List <CommonReportListItem>(); _selectedReport = null; OnReportSelectionChanged(); NotifyAllPropertiesChanged(); return; } LoadReports(); }
private void LoadReports() { Async.CancelPending(this); if (_context == null) { return; } Async.Request( this, (IBrowsePatientDataService service) => { var request = new GetDataRequest { ListReportsRequest = new ListReportsRequest(null, _context.OrderRef), ListPatientProfilesRequest = new ListPatientProfilesRequest(_context.PatientRef), GetOrderDetailRequest = new GetOrderDetailRequest(_context.OrderRef, false, true, false, false, false, false) }; return(service.GetData(request)); }, response => { var procedure = CollectionUtils.FirstElement(response.GetOrderDetailResponse.Order.Procedures); if (procedure != null) { var facilityCode = procedure.PerformingFacility.InformationAuthority.Code; var matchingProfile = CollectionUtils.SelectFirst( response.ListPatientProfilesResponse.Profiles, summary => summary.Mrn.AssigningAuthority.Code == facilityCode); _patientProfileRef = matchingProfile != null ? matchingProfile.PatientProfileRef : null; } var reports = new List <CommonReportListItem>(); CollectionUtils.ForEach(response.ListReportsResponse.Reports, delegate(ReportListItem item) { var existingItem = CollectionUtils.SelectFirst(reports, crli => Equals(crli.ReportRef, item.ReportRef)); if (existingItem != null) { existingItem.AddReportListItem(item); } else { reports.Add(new CommonReportListItem(item.ProcedureRef, item.ReportRef, item)); } }); _reports = reports; _selectedReport = CollectionUtils.FirstElement(_reports); OnReportSelectionChanged(); NotifyAllPropertiesChanged(); }, exception => { _reports = new List <CommonReportListItem>(); _selectedReport = null; ExceptionHandler.Report(exception, this.Host.DesktopWindow); OnReportSelectionChanged(); NotifyAllPropertiesChanged(); }); }