private List <AnalysisRequestReportModel> GetReportDatasource(DataLibrary.Models.ReportModels.AnalysisRequestReportModel reportModel) { //map AnalysisRequestReport var report = new AnalysisRequestReportModel() { SampleSite = reportModel.SampleSite, CollectedDate = reportModel.CollectedDate, ReceivedDate = reportModel.ReceivedDate, EpisodeNumber = reportModel.EpisodeNumber, QcCalValidatedBy = reportModel.QcCalValidatedBy, ReportedAt = reportModel.ReportedAt, ReceivedBy = reportModel.ReceivedBy, AnalysedBy = reportModel.AnalysedBy, InstituteAssignedPatientId = reportModel.InstituteAssignedPatientId, SampleProcessedAt = reportModel.SampleProcessedAt }; //Map patient var patient = new Patient() { NidPp = reportModel.Patient.NidPp.Trim(), Fullname = reportModel.Patient.Fullname.Trim(), AgeSex = reportModel.Patient.AgeSex, Birthdate = reportModel.Patient.Birthdate, Address = reportModel.Patient.Address, Nationality = reportModel.Patient.Nationality }; //map Assays var assays = new BindingList <Assays>(); foreach (var assay in reportModel.Assays) { assays.Add(new Assays() { Cin = assay.Cin, Discipline = assay.Discipline, Assay = assay.Assay, Result = assay.Result, Unit = assay.Unit, DisplayNormalRange = assay.DisplayNormalRange, Comment = assay.Comment, SortOrder = assay.SortOrder, PrimaryHeader = assay.PrimaryHeader, SecondaryHeader = assay.SecondaryHeader }); } //add patient and assays to report report.Assays = assays; report.Patient = patient; report.PrintedDate = DateTime.Now.ToString("dd-MM-yyyy HH:mm"); //add report to a list of reports to make it compatible as datasource var reportDatasource = new List <AnalysisRequestReportModel>(); report.SetPdf417String(); reportDatasource.Add(report); return(reportDatasource); }
private void InitializeReport(string cin) { var report = new AnalysisRequestReportModel() { SampleSite = "Flu Clinic", CollectedDate = DateTime.Today, ReceivedDate = DateTime.Today }; var patient = new Patient() { NidPp = "A253455", Fullname = "Ahmed Bin Hambal", AgeSex = "23Y / MALE", Birthdate = DateTime.Today, Address = "The most complete address ever in the history of mankind!" }; var Assays = new BindingList <Assays>() { new Assays() { Cin = "BS1234567", Assay = "CRP", Result = "0.5" }, new Assays() { Cin = "BS1234567", Assay = "CK", Result = "9" }, new Assays() { Cin = "BS1234567", Assay = "CK-MB", Result = "50" } }; report.Patient = patient; report.Assays = Assays; var reports = new List <AnalysisRequestReportModel>(); reports.Add(report); var xreport = _reportExtensions.ReportTemplates[0].Execute(ReportTemplate.AnalysisReportDefault); xreport.DataSource = reports; ReportPrintTool tool = new ReportPrintTool(xreport); tool.ShowPreview(); }
/// <summary> /// Convert from AnalysisReportDatabaseModel to list of AnalysisRequestReportModel /// </summary> /// <param name="databaseModel">The AnalysisReportDatabaseModel returned by query</param> /// <returns>A list of AnalysisRequestReportModel</returns> private List <AnalysisRequestReportModel> MapFromDatabaseModelToReturnModel (AnalysisReportDatabaseModel databaseModel) { //Initialize a list inatance to return var output = new List <AnalysisRequestReportModel>(); //Initialize model to add to list. var reportModel = new AnalysisRequestReportModel() { //Initialize patient data Patient = new PatientModel() { Address = databaseModel.Patient.Address, Nationality = databaseModel.Patient.Nationality, AgeSex = databaseModel.Patient.AgeSex, Birthdate = databaseModel.Patient.Birthdate, Fullname = databaseModel.Patient.Fullname, NidPp = databaseModel.Patient.NidPp, }, EpisodeNumber = databaseModel.Patient.EpisodeNumber, QcCalValidatedBy = databaseModel.Patient.QcCalValidatedBy, ReportedAt = databaseModel.Patient.ReportedAt, ReceivedBy = databaseModel.Patient.ReceivedBy, AnalysedBy = databaseModel.Patient.AnalysedBy, InstituteAssignedPatientId = databaseModel.Patient.InstituteAssignedPatientId, SampleProcessedAt = databaseModel.Patient.SampleProcessedAt, //Initialize sample collected date, received date and sample site. CollectedDate = databaseModel.Patient.CollectedDate, ReceivedDate = databaseModel.Patient.ReceivedDate, SampleSite = databaseModel.Patient.SampleSite }; //Add assays to the model foreach (var assay in databaseModel.Results) { reportModel.Assays.Add(new AssaysModel { Assay = assay.Assay, Discipline = assay.Discipline, Cin = assay.Cin, Result = assay.Result, Unit = assay.Unit, DisplayNormalRange = assay.DisplayNormalRange, Comment = assay.Comment, SortOrder = assay.SortOrder, PrimaryHeader = assay.PrimaryHeader, SecondaryHeader = assay.SecondaryHeader }); } //add the model to the output list and return output.Add(reportModel); return(output); }