/// <summary> /// Gets the customization model. /// </summary> /// <param name="key">The key.</param> /// <param name="reportName">Name of the report.</param> /// <param name="patientKey">The patient key.</param> /// <returns> /// A <see cref="IReportModel"/>. /// </returns> public IReportModel GetCustomizationModel(Guid key, string reportName, Guid?patientKey = null) { AssessmentScoreOverTimeParameters parameters = null; if (key != Guid.Empty) { var reportTemplate = _reportTemplateRepository.GetByKey(key); if (reportTemplate != null) { parameters = reportTemplate.Parameters as AssessmentScoreOverTimeParameters; } if (parameters == null) { var reporthistory = _recentReportRepository.GetByKey(key); if (reporthistory != null) { parameters = reporthistory.Parameters as AssessmentScoreOverTimeParameters; } } } else { parameters = new AssessmentScoreOverTimeParameters { ReportName = reportName }; } if (parameters != null && patientKey.HasValue) { parameters.PatientName = _patientRepository.GetByKey(patientKey.Value).Name; } return(parameters); }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="response">The response.</param> protected override void Handle(SaveReportTemplateRequest request, SaveReportTemplateResponse response) { var reportTemplateDto = request.ReportTemplate; if (reportTemplateDto.Key == Guid.Empty) { var reportTemplateFactory = new ReportTemplateFactory(); var paramertersType = reportTemplateDto.Parameters.GetType(); var destinationType = Mapper.GetAllTypeMaps().First(typeMap => typeMap.SourceType == paramertersType).DestinationType; var parameters = Mapper.Map(reportTemplateDto.Parameters, paramertersType, destinationType) as BaseReportParameters; if (parameters == null) { return; } parameters.ReportName = reportTemplateDto.Name; var reportTemplate = reportTemplateFactory.Create( reportTemplateDto.SystemAccountKey, reportTemplateDto.Name, reportTemplateDto.ReportType, parameters, _lookupProvider.Find <ReportState> (reportTemplateDto.ReportState.Code)); if (reportTemplate != null) { var dto = Mapper.Map <ReportTemplate, ReportTemplateDto> (reportTemplate); response.ReportTemplate = dto; } } else { //update var reportTemplate = _reportTemplateRepository.GetByKey(reportTemplateDto.Key); if (reportTemplate != null) { reportTemplate.ChangeName(reportTemplateDto.Name); reportTemplate.ChangeReportType(reportTemplateDto.ReportType); reportTemplate.ChangeParameters(reportTemplateDto.Parameters); reportTemplate.ChangeReportState(_lookupProvider.Find <ReportState> (reportTemplateDto.ReportState.Code)); var dto = Mapper.Map <ReportTemplate, ReportTemplateDto> (reportTemplate); response.ReportTemplate = dto; } } }
/// <summary> /// Gets the customization model. /// </summary> /// <param name="key">The key.</param> /// <param name="reportName">Name of the report.</param> /// <param name="patientKey">The patient key.</param> /// <returns> /// A <see cref="IReportModel" />. /// </returns> public IReportModel GetCustomizationModel(Guid key, string reportName, Guid?patientKey = null) { if (key != Guid.Empty) { var reportTemplate = _reportTemplateRepository.GetByKey(key); if (reportTemplate != null) { return(reportTemplate.Parameters as NotCompletedAssessmentParameters); } var reporthistory = _recentReportRepository.GetByKey(key); if (reporthistory != null) { return(reporthistory.Parameters as NotCompletedAssessmentParameters); } } return(new NotCompletedAssessmentParameters { ReportName = reportName }); }
/// <summary> /// Gets the customization model. /// </summary> /// <param name="key">The key.</param> /// <param name="reportName">Name of the report.</param> /// <param name="patientKey">The patient key.</param> /// <returns> /// A <see cref="IReportModel" />. /// </returns> public IReportModel GetCustomizationModel(Guid key, string reportName, Guid?patientKey = null) { if (key != Guid.Empty) { var reportTemplate = _reportTemplateRepository.GetByKey(key); if (reportTemplate != null) { return(reportTemplate.Parameters as PatientsWithSpecificResponseParameters); } var reporthistory = _recentReportRepository.GetByKey(key); if (reporthistory != null) { return(reporthistory.Parameters as PatientsWithSpecificResponseParameters); } } return(new PatientsWithSpecificResponseParameters { ReportName = reportName }); }