/// <summary> /// Retrieve report data for a case /// </summary> /// <param name="item">Case item</param> /// <returns>Report data for the case in question</returns> public Report GetReport(CaseListItem item) { Log.Debug("Retrieving report data..."); // Always return a valid object for binding Report rep = new Report(); if (item == null) { Log.Error("Missing parameter: caselistitem."); return rep; } // first we need to get the report template based on the type indicate in the accession number AccessionNumber accNum = new AccessionNumber(item.AccessionNumber); VixReportTemplateObject templateObj = GetReportTemplate(item.SiteCode, accNum.Type); // in case there is an error in the tranmission if (templateObj.TemplateXML == string.Empty) { Log.Error("Failed to get template."); return rep; } // retrieve a list of fields to grab data from the template rep.ReportTemplate = templateObj.GetReportTemplate(); //List<string> fields = rep.GetFieldList(); List<string> fields = rep.GetAllFieldList(); string URI = String.Format("pathology/case/template/{0}", item.CaseURN); IRestResponse response; try { PathologyCaseTemplateInputFieldsType fieldList = new PathologyCaseTemplateInputFieldsType(fields); string xml = ResponseParser.SerializeToXml<PathologyCaseTemplateInputFieldsType>(fieldList); response = ExecutePost(URI, VixServiceTypes.Pathology, xml); ValidateRestResponse(response); PathologyCaseTemplateType rawRep = ResponseParser.ParseGetReport(response.Content); rep.LoadReportData(rawRep); } catch (MagResponseParsingFailureException rpf) { Log.Error("Failed to parse report fields.", rpf); } catch (MagVixFailureException vfe) { Log.Error("Unexpected response.", vfe); } catch (Exception ex) { Log.Error("Could not complete request to retrieve report data.", ex); } return rep; }