Skip to content

Commit

Permalink
Merge branch 'OCD-4800' into qa
Browse files Browse the repository at this point in the history
  • Loading branch information
kekey1 committed Mar 4, 2025
2 parents 8c7e5ad + a859820 commit 3793c19
Show file tree
Hide file tree
Showing 18 changed files with 906 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import java.util.List;
import java.util.stream.Collectors;

import jakarta.persistence.Query;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
Expand All @@ -21,6 +19,7 @@
import gov.healthit.chpl.surveillance.report.entity.SurveillanceOutcomeEntity;
import gov.healthit.chpl.surveillance.report.entity.SurveillanceProcessTypeEntity;
import gov.healthit.chpl.util.ChplProductNumberUtil;
import jakarta.persistence.Query;
import lombok.extern.log4j.Log4j2;

@Repository("quarterlyReportSurveillanceMapDao")
Expand Down Expand Up @@ -167,6 +166,7 @@ public Long create(Long quarterlyReportId, PrivilegedSurveillance toCreate)
entity.setDirectionDeveloperResolution(toCreate.getDirectionDeveloperResolution());
entity.setCompletedCapVerification(toCreate.getCompletedCapVerification());
entity.setSurveillanceProcessTypeOther(toCreate.getSurveillanceProcessTypeOther());
entity.setSurveillanceFindings(toCreate.getSurveillanceFindings());
entity.setDeleted(false);
create(entity);

Expand Down Expand Up @@ -218,6 +218,7 @@ public void update(PrivilegedSurveillance existing, PrivilegedSurveillance toUpd
entity.setDirectionDeveloperResolution(toUpdate.getDirectionDeveloperResolution());
entity.setCompletedCapVerification(toUpdate.getCompletedCapVerification());
entity.setSurveillanceProcessTypeOther(toUpdate.getSurveillanceProcessTypeOther());
entity.setSurveillanceFindings(toUpdate.getSurveillanceFindings());
update(entity);
updateSurveillanceProcessTypes(entity,
existing.getSurveillanceProcessTypes(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,15 @@ public Long create(QuarterlyReport toCreate) throws EntityCreationException {
QuarterlyReportEntity toCreateEntity = QuarterlyReportEntity.builder()
.certificationBodyId(toCreate.getAcb().getId())
.year(toCreate.getYear())
.activitiesOutcomesSummary(toCreate.getSurveillanceActivitiesAndOutcomes())
.appropriateUseOfMark(toCreate.getAppropriateUseOfMark())
.developerComplaintsLogReview(toCreate.getDeveloperComplaintsLogReview())
.disclosureRequirementsSummary(toCreate.getDisclosureRequirementsSummary())
.icsSurveillanceSummary(toCreate.getIcsSurveillanceSummary())
.prioritizedElementSummary(toCreate.getPrioritizedElementSummary())
.postCertificationPerformanceOfCertifiedCapabilities(toCreate.getPostCertificationPerformanceOfCertifiedCapabilities())
.quarterId(quarterDao.getByName(toCreate.getQuarter()).getId())
.activitiesOutcomesSummary(toCreate.getSurveillanceActivitiesAndOutcomes())
.reactiveSurveillanceSummary(toCreate.getReactiveSurveillanceSummary())
.disclosureRequirementsSummary(toCreate.getDisclosureRequirementsSummary())
.build();

super.create(toCreateEntity);
Expand All @@ -228,9 +232,13 @@ public Long create(QuarterlyReport toCreate) throws EntityCreationException {
public void update(QuarterlyReport toUpdate) throws EntityRetrievalException {
QuarterlyReportEntity toUpdateEntity = getEntityById(toUpdate.getId());
toUpdateEntity.setActivitiesOutcomesSummary(toUpdate.getSurveillanceActivitiesAndOutcomes());
toUpdateEntity.setAppropriateUseOfMark(toUpdate.getAppropriateUseOfMark());
toUpdateEntity.setDeveloperComplaintsLogReview(toUpdate.getDeveloperComplaintsLogReview());
toUpdateEntity.setDisclosureRequirementsSummary(toUpdate.getDisclosureRequirementsSummary());
toUpdateEntity.setIcsSurveillanceSummary(toUpdate.getIcsSurveillanceSummary());
toUpdateEntity.setPrioritizedElementSummary(toUpdate.getPrioritizedElementSummary());
toUpdateEntity.setPostCertificationPerformanceOfCertifiedCapabilities(toUpdate.getPostCertificationPerformanceOfCertifiedCapabilities());
toUpdateEntity.setReactiveSurveillanceSummary(toUpdate.getReactiveSurveillanceSummary());
toUpdateEntity.setDisclosureRequirementsSummary(toUpdate.getDisclosureRequirementsSummary());

super.update(toUpdateEntity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ private void reviewQuarterlyReportToCreate(QuarterlyReport toCreate)
}

Quarter quarter = null;
if(StringUtils.isEmpty(toCreate.getQuarter())) {
if (StringUtils.isEmpty(toCreate.getQuarter())) {
throw new InvalidArgumentsException("report.quarterlySurveillance.missingQuarter");
} else {
quarter = quarterDao.getByName(toCreate.getQuarter());
Expand All @@ -447,9 +447,13 @@ private void reviewQuarterlyReportToCreate(QuarterlyReport toCreate)
private void copyPreviousReportDataIntoNextReport(QuarterlyReport nextReport) {
QuarterlyReport prevReport = getPreviousReport(nextReport);
if (prevReport != null) {
//copy the four data fields
//copy the data fields
nextReport.setSurveillanceActivitiesAndOutcomes(prevReport.getSurveillanceActivitiesAndOutcomes());
nextReport.setIcsSurveillanceSummary(prevReport.getIcsSurveillanceSummary());
nextReport.setPrioritizedElementSummary(prevReport.getPrioritizedElementSummary());
nextReport.setAppropriateUseOfMark(prevReport.getAppropriateUseOfMark());
nextReport.setDeveloperComplaintsLogReview(prevReport.getDeveloperComplaintsLogReview());
nextReport.setPostCertificationPerformanceOfCertifiedCapabilities(prevReport.getPostCertificationPerformanceOfCertifiedCapabilities());
nextReport.setReactiveSurveillanceSummary(prevReport.getReactiveSurveillanceSummary());
nextReport.setDisclosureRequirementsSummary(prevReport.getDisclosureRequirementsSummary());
try {
Expand Down Expand Up @@ -487,6 +491,7 @@ private void copyPreviousReportDataIntoNextReport(QuarterlyReport nextReport) {
nextReportSurv.setSurveillanceOutcome(prevReportSurv.getSurveillanceOutcome());
nextReportSurv.setSurveillanceOutcomeOther(prevReportSurv.getSurveillanceOutcomeOther());
nextReportSurv.setSurveillanceProcessTypes(prevReportSurv.getSurveillanceProcessTypes());
nextReportSurv.setSurveillanceFindings(prevReportSurv.getSurveillanceFindings());
try {
quarterlySurvMapDao.create(nextReport.getId(), nextReportSurv);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -55,51 +56,48 @@
public abstract class ActivitiesAndOutcomesWorksheetBuilder {
private static final int LAST_DATA_COLUMN = 37;

private static final int COL_CHPL_ID = 1;
private static final int COL_SURV_ID = 2;
private static final int COL_SURV_ACTIVITY_TRACKER = 3;
private static final int COL_RELATED_COMPLAINT_ACB_ID = 4;
private static final int COL_RELATED_COMPLAINT_ONC_ID = 5;
private static final int COL_Q1 = 6;
private static final int COL_Q2 = 7;
private static final int COL_Q3 = 8;
private static final int COL_Q4 = 9;
private static final int COL_DEVELOPER_NAME = 10;
private static final int COL_PRODUCT_NAME = 11;
private static final int COL_PRODUCT_VERSION = 12;
private static final int COL_K1_REVIEWED = 13;
private static final int COL_SURV_TYPE = 14;
private static final int COL_SURV_RANDOMIZED_SITES_USED = 15;
private static final int COL_SURV_BEGIN = 16;
private static final int COL_SURV_END = 17;
private static final int COL_SURV_OUTCOME = 18;
private static final int COL_SURV_OUTCOME_OTHER = 19;
private static final int COL_NC_SURVEILLED_REQ_TYPE = 20;
private static final int COL_NC_SURVEILLED_REQ = 21;
private static final int COL_NC_TYPE = 22;
private static final int COL_NC_CLOSE_DATE = 23;
private static final int COL_NC_CAP_APPROVAL_DATE = 24;
private static final int COL_NC_CAP_MUST_COMPLETE_DATE = 25;
private static final int COL_NC_CAP_WAS_COMPLETE_DATE = 26;
private static final int COL_NC_FINDINGS = 27;
private static final int COL_CERT_STATUS_RESULTANT = 28;
private static final int COL_SUSPENDED = 29;
private static final int COL_SURV_PROCESS_TYPE = 30;
private static final int COL_SURV_PROCESS_TYPE_OTHER = 31;
private static final int COL_SURV_GROUNDS = 32;
private static final int COL_NONCONFORMITY_CAUSES = 33;
private static final int COL_NONCONFORMITY_NATURES = 34;
private static final int COL_SURV_STEPS = 35;
private static final int COL_ENGAGEMENT_STEPS = 36;
private static final int COL_ADDITIONAL_COSTS = 37;
private static final int COL_LIMITATIONS_EVAL = 38;
private static final int COL_NONDISCLOSURE_EVAL = 39;
private static final int COL_DEV_RESOLUTION = 40;
private static final int COL_COMPLETED_CAP = 41;
private static final int[] HIDDEN_COLS =
{COL_SURV_ACTIVITY_TRACKER, COL_Q1, COL_Q2, COL_Q3, COL_Q4, COL_NONCONFORMITY_NATURES,
COL_SURV_STEPS, COL_ENGAGEMENT_STEPS, COL_ADDITIONAL_COSTS, COL_LIMITATIONS_EVAL,
COL_NONDISCLOSURE_EVAL, COL_DEV_RESOLUTION};
protected static final int COL_CHPL_ID = 1;
protected static final int COL_SURV_ID = 2;
protected static final int COL_SURV_ACTIVITY_TRACKER = 3;
protected static final int COL_RELATED_COMPLAINT_ACB_ID = 4;
protected static final int COL_RELATED_COMPLAINT_ONC_ID = 5;
protected static final int COL_Q1 = 6;
protected static final int COL_Q2 = 7;
protected static final int COL_Q3 = 8;
protected static final int COL_Q4 = 9;
protected static final int COL_DEVELOPER_NAME = 10;
protected static final int COL_PRODUCT_NAME = 11;
protected static final int COL_PRODUCT_VERSION = 12;
protected static final int COL_K1_REVIEWED = 13;
protected static final int COL_SURV_TYPE = 14;
protected static final int COL_SURV_RANDOMIZED_SITES_USED = 15;
protected static final int COL_SURV_BEGIN = 16;
protected static final int COL_SURV_END = 17;
protected static final int COL_SURV_OUTCOME = 18;
protected static final int COL_SURV_OUTCOME_OTHER = 19;
protected static final int COL_NC_SURVEILLED_REQ_TYPE = 20;
protected static final int COL_NC_SURVEILLED_REQ = 21;
protected static final int COL_NC_TYPE = 22;
protected static final int COL_NC_CLOSE_DATE = 23;
protected static final int COL_NC_CAP_APPROVAL_DATE = 24;
protected static final int COL_NC_CAP_MUST_COMPLETE_DATE = 25;
protected static final int COL_NC_CAP_WAS_COMPLETE_DATE = 26;
protected static final int COL_NC_FINDINGS = 27;
protected static final int COL_CERT_STATUS_RESULTANT = 28;
protected static final int COL_SUSPENDED = 29;
protected static final int COL_SURV_PROCESS_TYPE = 30;
protected static final int COL_SURV_PROCESS_TYPE_OTHER = 31;
protected static final int COL_SURV_GROUNDS = 32;
protected static final int COL_SURV_FINDINGS = 33;
protected static final int COL_NONCONFORMITY_CAUSES = 34;
protected static final int COL_NONCONFORMITY_NATURES = 35;
protected static final int COL_SURV_STEPS = 36;
protected static final int COL_ENGAGEMENT_STEPS = 37;
protected static final int COL_ADDITIONAL_COSTS = 38;
protected static final int COL_LIMITATIONS_EVAL = 39;
protected static final int COL_NONDISCLOSURE_EVAL = 40;
protected static final int COL_DEV_RESOLUTION = 41;
protected static final int COL_COMPLETED_CAP = 42;

private SurveillanceReportManager reportManager;
private CertifiedProductDetailsManager detailsManager;
Expand All @@ -122,10 +120,16 @@ public ActivitiesAndOutcomesWorksheetBuilder(SurveillanceReportManager reportMan
}

protected abstract String getGroundsForInitiatingSurveillanceDescription();
protected abstract String getSurveillanceFindingsDescription();
protected abstract String getStepsToSurveilDescription();
protected abstract String getAdditionalCostsEvaluationDescription();
protected abstract String getLimitationsEvaluationDescription();
protected abstract String getNonDisclosureEvaluationDescription();
protected List<Integer> getHiddenColumnsIndices() {
return Stream.of(COL_SURV_ACTIVITY_TRACKER, COL_Q1, COL_Q2, COL_Q3, COL_Q4,
COL_NONCONFORMITY_NATURES, COL_SURV_STEPS, COL_ENGAGEMENT_STEPS, COL_ADDITIONAL_COSTS,
COL_LIMITATIONS_EVAL, COL_NONDISCLOSURE_EVAL, COL_DEV_RESOLUTION).toList();
}

public int getLastDataColumn() {
return LAST_DATA_COLUMN;
Expand Down Expand Up @@ -188,6 +192,7 @@ public Sheet buildWorksheet(SurveillanceReportWorkbookWrapper workbook, List<Qua
sheet.setColumnWidth(COL_SURV_PROCESS_TYPE, workbook.getColumnWidth(30.67));
sheet.setColumnWidth(COL_SURV_PROCESS_TYPE_OTHER, workbook.getColumnWidth(30.67));
sheet.setColumnWidth(COL_SURV_GROUNDS, longTextColWidth);
sheet.setColumnWidth(COL_SURV_FINDINGS, longTextColWidth);
sheet.setColumnWidth(COL_NONCONFORMITY_CAUSES, longTextColWidth);
sheet.setColumnWidth(COL_NONCONFORMITY_NATURES, longTextColWidth);
sheet.setColumnWidth(COL_SURV_STEPS, longTextColWidth);
Expand Down Expand Up @@ -271,9 +276,7 @@ public Sheet buildWorksheet(SurveillanceReportWorkbookWrapper workbook, List<Qua
sheet.addValidationData(validation);

//hide some rows the ACBs are not expected to fill out (columns D-I)
for (int i = 0; i < HIDDEN_COLS.length; i++) {
sheet.setColumnHidden(HIDDEN_COLS[i], true);
}
getHiddenColumnsIndices().forEach(index -> sheet.setColumnHidden(index, true));

//apply the borders after the sheet has been created
pt.drawBorders(new CellRangeAddress(1, getLastDataRow(), 1, LAST_DATA_COLUMN - 1),
Expand Down Expand Up @@ -324,6 +327,10 @@ private int addHeadingRow(SurveillanceReportWorkbookWrapper workbook, Sheet shee
String cellSubtitle = getGroundsForInitiatingSurveillanceDescription();
addRichTextHeadingCell(workbook, row, COL_SURV_GROUNDS, cellTitle, cellSubtitle);

cellTitle = "Surveillance Findings";
cellSubtitle = getSurveillanceFindingsDescription();
addRichTextHeadingCell(workbook, row, COL_SURV_FINDINGS, cellTitle, cellSubtitle);

cellTitle = "Potential Causes of Non-Conformities or Suspected Non-Conformities";
cellSubtitle = "What were the substantial factors that, in the ONC-ACB’s assessment, "
+ "caused or contributed to the suspected non-conformity or non-conformities "
Expand Down Expand Up @@ -589,6 +596,8 @@ private void addSurveillanceData(SurveillanceReportWorkbookWrapper workbook,
generateSurveillanceProcessTypeOtherValue(quarterlyReports, privilegedSurvQuarterlyData));
addDataCell(workbook, row, COL_SURV_GROUNDS,
generateGroundsForInitiatingValue(quarterlyReports, privilegedSurvQuarterlyData));
addDataCell(workbook, row, COL_SURV_FINDINGS,
generateSurveillanceFindingsValue(quarterlyReports, privilegedSurvQuarterlyData));
addDataCell(workbook, row, COL_NONCONFORMITY_CAUSES,
generateNonconformityCausesValue(quarterlyReports, privilegedSurvQuarterlyData));
addDataCell(workbook, row, COL_NONCONFORMITY_NATURES,
Expand Down Expand Up @@ -867,6 +876,42 @@ private String generateGroundsForInitiatingValue(List<QuarterlyReport> quarterly
return result;
}

private String generateSurveillanceFindingsValue(List<QuarterlyReport> quarterlyReports,
List<PrivilegedSurveillance> privilegedSurvData) {
String result = "";
if (quarterlyReports.size() == 1) {
//find the privileged surv data for the single report
QuarterlyReport report = quarterlyReports.get(0);
for (PrivilegedSurveillance currSurv : privilegedSurvData) {
if (currSurv.getQuarterlyReport().getId().longValue() == report.getId().longValue()
&& currSurv.getSurveillanceFindings() != null) {
result = currSurv.getSurveillanceFindings();
}
}
} else {
//there are multiple reports... combine the values for this field in a nice way for the user
//key is surveillance findings str and value is applicable quarter name(s) like 'Q1, Q2'
Map<String, ArrayList<String>> valueMap = new LinkedHashMap<String, ArrayList<String>>();
for (QuarterlyReport currReport : quarterlyReports) {
for (PrivilegedSurveillance currSurv : privilegedSurvData) {
if (currSurv.getQuarterlyReport().getId().longValue() == currReport.getId().longValue()
&& currSurv.getSurveillanceFindings() != null) {
String survFindingsVal = currSurv.getSurveillanceFindings();
if (valueMap.get(survFindingsVal) != null) {
valueMap.get(survFindingsVal).add(currReport.getQuarter());
} else {
ArrayList<String> quarterNameList = new ArrayList<String>();
quarterNameList.add(currReport.getQuarter());
valueMap.put(survFindingsVal, quarterNameList);
}
}
}
}
result = MultiQuarterWorksheetBuilderUtil.buildStringFromMap(valueMap);
}
return result;
}

private String generateNonconformityCausesValue(List<QuarterlyReport> quarterlyReports,
List<PrivilegedSurveillance> privilegedSurvData) {
String result = "";
Expand Down
Loading

0 comments on commit 3793c19

Please sign in to comment.