Skip to content

Commit

Permalink
Merge pull request #722 from lantanagroup/LNK-1833
Browse files Browse the repository at this point in the history
LNK-1833: Move reporting plan configuration into ApiConfig
  • Loading branch information
arianamihailescu committed Mar 14, 2024
2 parents 256ff48 + 1845269 commit 78a8f6d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.lantanagroup.link.*;
import com.lantanagroup.link.api.ReportGenerator;
import com.lantanagroup.link.auth.LinkCredentials;
import com.lantanagroup.link.config.api.ApiConfig;
import com.lantanagroup.link.db.SharedService;
import com.lantanagroup.link.db.TenantService;
import com.lantanagroup.link.db.model.*;
Expand Down Expand Up @@ -82,6 +83,10 @@ public class ReportController extends BaseController {
@Autowired
private ValidationService validationService;

@Autowired
private ApiConfig apiConfig;


@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields(DISALLOWED_FIELDS);
Expand Down Expand Up @@ -275,15 +280,15 @@ public Report generateReport(
}

private void checkReportingPlan(TenantService tenantService, String periodStart, List<String> measureIds) throws ParseException, URISyntaxException, IOException {
if (tenantService.getConfig().getReportingPlan() == null) {
if (apiConfig.getReportingPlan() == null) {
return;
}

if (!tenantService.getConfig().getReportingPlan().isEnabled()) {
if (!apiConfig.getReportingPlan().isEnabled()) {
return;
}

if (StringUtils.isEmpty(tenantService.getConfig().getReportingPlan().getUrl())) {
if (StringUtils.isEmpty(apiConfig.getReportingPlan().getUrl())) {
logger.error("Reporting plan for tenant {} is not configured with a URL", tenantService.getConfig().getId());
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand All @@ -293,13 +298,13 @@ private void checkReportingPlan(TenantService tenantService, String periodStart,
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR);
}

ReportingPlanService reportingPlanService = new ReportingPlanService(tenantService.getConfig().getReportingPlan(), tenantService.getConfig().getCdcOrgId());
ReportingPlanService reportingPlanService = new ReportingPlanService(apiConfig.getReportingPlan(), tenantService.getConfig().getCdcOrgId());

Date date = Helper.parseFhirDate(periodStart);
int year = date.getYear() + 1900;
int month = date.getMonth() + 1;
for (String bundleId : measureIds) {
String planName = tenantService.getConfig().getReportingPlan().getPlanNames().get(bundleId);
String planName = apiConfig.getReportingPlan().getPlanNames().get(bundleId);
if (!reportingPlanService.isReporting(planName, year, month)) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Measure not in MRP for specified year and month");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,12 @@ public class ApiConfig {
*/
private String validationPackagesPath = "classpath:/packages/**";


/**
* Configuration for how to query the MRP (reporting plan) interface at CDC/NHSN to determine if a facility/tenant
* is signed up to report during the calculated reporting period.
*/
private ReportingPlan reportingPlan;


}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.lantanagroup.link.db.model.tenant;
package com.lantanagroup.link.config.api;

import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ public class Tenant {
*/
private FhirQuery fhirQuery;

/**
* Configuration for how to query the MRP (reporting plan) interface at CDC/NHSN to determine if a facility/tenant
* is signed up to report during the calculated reporting period.
*/
private ReportingPlan reportingPlan;

/**
* ISO 8601 formatted duration in which to keep data for each tenant. Defaulted to 3 months.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.lantanagroup.link.Helper;
import com.lantanagroup.link.db.model.tenant.ReportingPlan;
import com.lantanagroup.link.config.api.ReportingPlan;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.http.HttpHeaders;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -31,7 +27,6 @@

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;

public class ReportingPlanService {
Expand Down

0 comments on commit 78a8f6d

Please sign in to comment.