Skip to content

Commit

Permalink
feat: add endpoint /report-data/real-world-testing/plans
Browse files Browse the repository at this point in the history
OCD-4517
  • Loading branch information
tmy1313 committed Jan 4, 2025
1 parent 2358501 commit b3e81ba
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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<RealWorldTestingSummaryReport> getRealWorldTestingPlanReports() {
return reportDataManager.getRealWorldTestingReportDataService().getRealWorldTestingPlanSummaryReports();
}
}
2 changes: 1 addition & 1 deletion chpl/chpl-resources/src/main/resources/jobs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@
<job>
<name>realWorldTestingSummaryReportCreatorJob</name>
<group>systemJobs</group>
<description>Update Task/Participant Friendly Ids Job</description>
<description>Populate RWT reporting tables</description>
<job-class>gov.healthit.chpl.scheduler.job.RealWorldTestingSummaryReportCreatorJob</job-class>
<durability>true</durability>
<recover>false</recover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -66,6 +77,7 @@ public ReportDataManager(CriteriaMigrationReportService criteriaMigrationReportS
this.standardReportService = standardReportService;
this.directReviewReportsService = directReviewReportsService;
this.reportMetadataDAO = reportMetadataDAO;
this.realWorldTestingReportDataService = realWorldTestingReportDataService;
}

public List<ReportMetadata> getReportMetadataByReportGroup(String reportGroup) {
Expand Down Expand Up @@ -266,4 +278,9 @@ public List<StandardListingReport> getStandardListingReports() {
public DirectReviewCounts getDirectReviewCounts() {
return directReviewReportsService.getDirectReviewCounts();
}

@Synchronized("lock")
public RealWorldTestingReportDataService getRealWorldTestingReportDataService() {
return realWorldTestingReportDataService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;

import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -34,6 +35,21 @@ public void save(RealWorldTestingSummaryReport realWorldTestingSummaryReport) th
}
}

public Optional<Long> getMaxRealWorldTestingYear() {
return Optional.ofNullable(entityManager.createQuery(
"select MAX(rwtpsr.realWorldTestingYear) "
+ "from RealWorldTestingPlanSummaryReportEntity rwtpsr "
+ "where (NOT deleted = true)", Long.class)
.getSingleResult());

}

public List<RealWorldTestingSummaryReport> 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);
Expand Down Expand Up @@ -70,4 +86,13 @@ private RealWorldTestingPlanSummaryReportEntity getEntityByCheckedDateAndAcb(Loc
return null;
}

private List<RealWorldTestingPlanSummaryReportEntity> getEntitiesByRealWorldTestingYear(Long testingYear){
return entityManager.createQuery(
"from RealWorldTestingPlanSummaryReportEntity rwtps "
+ "where (NOT deleted = true) "
+ "and rwtps.realWorldTestingYear = :realWorldTestingYear", RealWorldTestingPlanSummaryReportEntity.class)
.setParameter("realWorldTestingYear", testingYear)
.getResultList();
}

}
Original file line number Diff line number Diff line change
@@ -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<RealWorldTestingSummaryReport> getRealWorldTestingPlanSummaryReports() {
Optional<Long> rwtYear = realWorldTestingPlanSummaryReportDao.getMaxRealWorldTestingYear();
if (rwtYear.isPresent()) {
return realWorldTestingPlanSummaryReportDao.getRealWorldTestingReportsByTestingYear(rwtYear.get());
} else {
return List.of();
}
}
}

0 comments on commit b3e81ba

Please sign in to comment.