diff --git a/chpl/chpl-api/src/main/java/gov/healthit/chpl/web/controller/RealWorldTestingReportController.java b/chpl/chpl-api/src/main/java/gov/healthit/chpl/web/controller/RealWorldTestingReportController.java new file mode 100644 index 0000000000..e775eabaf2 --- /dev/null +++ b/chpl/chpl-api/src/main/java/gov/healthit/chpl/web/controller/RealWorldTestingReportController.java @@ -0,0 +1,41 @@ +package gov.healthit.chpl.web.controller; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import gov.healthit.chpl.report.ReportDataManager; +import gov.healthit.chpl.report.realworldtesting.RealWorldTestingSummaryReport; +import gov.healthit.chpl.util.SwaggerSecurityRequirement; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.extern.log4j.Log4j2; + +@Log4j2 +@Tag(name = "report-data/real-world-testing", description = "Allows retrieval of data used by Real World Testing report.") +@RestController +@RequestMapping("/report-data/real-world-testing") +public class RealWorldTestingReportController { + + private ReportDataManager reportDataManager; + + @Autowired + public RealWorldTestingReportController(ReportDataManager reportDataManager) { + this.reportDataManager = reportDataManager; + } + + @Operation(summary = "Retrieves the data used to generate the Standard Criteria Attribute Summary report.", + description = "Retrieves the data used to generate the Standard Criteria Attribute Summary report.", + security = { + @SecurityRequirement(name = SwaggerSecurityRequirement.API_KEY) + }) + @RequestMapping(value = "/plans", method = RequestMethod.GET, produces = "application/json; charset=utf-8") + public @ResponseBody List getRealWorldTestingPlanReports() { + return reportDataManager.getRealWorldTestingReportDataService().getRealWorldTestingPlanSummaryReports(); + } +} diff --git a/chpl/chpl-resources/src/main/resources/jobs.xml b/chpl/chpl-resources/src/main/resources/jobs.xml index d69f2b283b..3c1361f8db 100644 --- a/chpl/chpl-resources/src/main/resources/jobs.xml +++ b/chpl/chpl-resources/src/main/resources/jobs.xml @@ -925,7 +925,7 @@ realWorldTestingSummaryReportCreatorJob systemJobs - Update Task/Participant Friendly Ids Job + Populate RWT reporting tables gov.healthit.chpl.scheduler.job.RealWorldTestingSummaryReportCreatorJob true false diff --git a/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/ReportDataManager.java b/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/ReportDataManager.java index 40626336b3..7f01f990ae 100644 --- a/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/ReportDataManager.java +++ b/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/ReportDataManager.java @@ -24,6 +24,7 @@ import gov.healthit.chpl.report.product.ProductByAcb; import gov.healthit.chpl.report.product.ProductReportsService; import gov.healthit.chpl.report.product.UniqueProductCount; +import gov.healthit.chpl.report.realworldtesting.RealWorldTestingReportDataService; import gov.healthit.chpl.report.servicebaseurllistreport.ServiceBaseUrlListReportService; import gov.healthit.chpl.report.servicebaseurllistreport.UrlUptimeMonitorEx; import gov.healthit.chpl.report.surveillance.CapCounts; @@ -50,12 +51,22 @@ public class ReportDataManager { private StandardReportService standardReportService; private DirectReviewReportsService directReviewReportsService; private ReportMetadataDAO reportMetadataDAO; + private RealWorldTestingReportDataService realWorldTestingReportDataService; + @Autowired - public ReportDataManager(CriteriaMigrationReportService criteriaMigrationReportService, DeveloperReportsService developerReportsService, - SurveillanceReportsService surveillanceReportsService, ProductReportsService productReportsService, ListingReportsService listingReportsService, - TestToolReportService testToolReportService, DirectReviewReportsService directReviewReportsService, ReportMetadataDAO reportMetadataDAO, - ServiceBaseUrlListReportService serviceBaseUrlListReportService, StandardReportService standardReportService) { + public ReportDataManager(CriteriaMigrationReportService criteriaMigrationReportService, + DeveloperReportsService developerReportsService, + SurveillanceReportsService surveillanceReportsService, + ProductReportsService productReportsService, + ListingReportsService listingReportsService, + TestToolReportService testToolReportService, + DirectReviewReportsService directReviewReportsService, + ReportMetadataDAO reportMetadataDAO, + ServiceBaseUrlListReportService serviceBaseUrlListReportService, + StandardReportService standardReportService, + RealWorldTestingReportDataService realWorldTestingReportDataService) { + this.criteriaMigrationReportService = criteriaMigrationReportService; this.developerReportsService = developerReportsService; this.surveillanceReportsService = surveillanceReportsService; @@ -66,6 +77,7 @@ public ReportDataManager(CriteriaMigrationReportService criteriaMigrationReportS this.standardReportService = standardReportService; this.directReviewReportsService = directReviewReportsService; this.reportMetadataDAO = reportMetadataDAO; + this.realWorldTestingReportDataService = realWorldTestingReportDataService; } public List getReportMetadataByReportGroup(String reportGroup) { @@ -266,4 +278,9 @@ public List getStandardListingReports() { public DirectReviewCounts getDirectReviewCounts() { return directReviewReportsService.getDirectReviewCounts(); } + + @Synchronized("lock") + public RealWorldTestingReportDataService getRealWorldTestingReportDataService() { + return realWorldTestingReportDataService; + } } diff --git a/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/realworldtesting/RealWorldTestingPlanSummaryReportDao.java b/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/realworldtesting/RealWorldTestingPlanSummaryReportDao.java index 9a95c8df56..e8ab08f578 100644 --- a/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/realworldtesting/RealWorldTestingPlanSummaryReportDao.java +++ b/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/realworldtesting/RealWorldTestingPlanSummaryReportDao.java @@ -2,6 +2,7 @@ import java.time.LocalDate; import java.util.List; +import java.util.Optional; import org.springframework.stereotype.Component; @@ -34,6 +35,21 @@ public void save(RealWorldTestingSummaryReport realWorldTestingSummaryReport) th } } + public Optional getMaxRealWorldTestingYear() { + return Optional.ofNullable(entityManager.createQuery( + "select MAX(rwtpsr.realWorldTestingYear) " + + "from RealWorldTestingPlanSummaryReportEntity rwtpsr " + + "where (NOT deleted = true)", Long.class) + .getSingleResult()); + + } + + public List getRealWorldTestingReportsByTestingYear(Long realWorldTestingYear) { + return getEntitiesByRealWorldTestingYear(realWorldTestingYear).stream() + .map(entity -> entity.toDomain()) + .toList(); + } + private RealWorldTestingPlanSummaryReportEntity getEntity(Long id) throws EntityRetrievalException { Query query = entityManager.createQuery( "from RealWorldTestingPlanSummaryReportEntity where (NOT deleted = true) and id = :id", RealWorldTestingPlanSummaryReportEntity.class); @@ -70,4 +86,13 @@ private RealWorldTestingPlanSummaryReportEntity getEntityByCheckedDateAndAcb(Loc return null; } + private List getEntitiesByRealWorldTestingYear(Long testingYear){ + return entityManager.createQuery( + "from RealWorldTestingPlanSummaryReportEntity rwtps " + + "where (NOT deleted = true) " + + "and rwtps.realWorldTestingYear = :realWorldTestingYear", RealWorldTestingPlanSummaryReportEntity.class) + .setParameter("realWorldTestingYear", testingYear) + .getResultList(); + } + } diff --git a/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/realworldtesting/RealWorldTestingReportDataService.java b/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/realworldtesting/RealWorldTestingReportDataService.java new file mode 100644 index 0000000000..313c3c18ec --- /dev/null +++ b/chpl/chpl-service/src/main/java/gov/healthit/chpl/report/realworldtesting/RealWorldTestingReportDataService.java @@ -0,0 +1,33 @@ +package gov.healthit.chpl.report.realworldtesting; + +import java.util.List; +import java.util.Optional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import jakarta.transaction.Transactional; + +@Component +public class RealWorldTestingReportDataService { + private RealWorldTestingPlanSummaryReportDao realWorldTestingPlanSummaryReportDao; + private RealWorldTestingResultsSummaryReportDao realWorldTestingResultsSummaryReportDao; + + @Autowired + public RealWorldTestingReportDataService(RealWorldTestingPlanSummaryReportDao realWorldTestingPlanSummaryReportDao, + RealWorldTestingResultsSummaryReportDao realWorldTestingResultsSummaryReportDao) { + + this.realWorldTestingPlanSummaryReportDao = realWorldTestingPlanSummaryReportDao; + this.realWorldTestingResultsSummaryReportDao = realWorldTestingResultsSummaryReportDao; + } + + @Transactional + public List getRealWorldTestingPlanSummaryReports() { + Optional rwtYear = realWorldTestingPlanSummaryReportDao.getMaxRealWorldTestingYear(); + if (rwtYear.isPresent()) { + return realWorldTestingPlanSummaryReportDao.getRealWorldTestingReportsByTestingYear(rwtYear.get()); + } else { + return List.of(); + } + } +}