Skip to content

Commit

Permalink
Merge pull request I-TECH-UW#1243 from CalebSLane/develop
Browse files Browse the repository at this point in the history
Add Method to analysis and attach to WHONet report
  • Loading branch information
CalebSLane authored Aug 19, 2024
2 parents 95b9bbe + 7b25dcc commit 1b268b6
Show file tree
Hide file tree
Showing 23 changed files with 360 additions and 809 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<maven.java.release>11</maven.java.release>
<major.version>3</major.version>
<minor.version>0</minor.version>
<state.version>2</state.version>
<state.version>3</state.version>
<!-- 0 = alpha, 1 = beta, 2 = rc, 3 = deployable -->
<fix.version>1</fix.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,6 @@ List<Analysis> getStudyAnalysisForSiteBetweenResultDates(String referringSiteId,
int getCountOfAnalysisCompletedOnByStatusId(Date completedDate, List<Integer> statusIds);

int getCountOfAnalysisStartedOnByStatusId(Date startedDate, List<Integer> statusIds);

String getMethodId(Analysis analysis);
}
Original file line number Diff line number Diff line change
Expand Up @@ -772,4 +772,9 @@ public int getCountOfAnalysisStartedOnByStatusId(Date startedDate, List<Integer>
public List<Analysis> getAnalysesResultEnteredOnExcludedByStatusId(Date completedDate, Set<Integer> statusIds) {
return baseObjectDAO.getAnalysesResultEnteredOnExcludedByStatusId(completedDate, statusIds);
}

@Override
public String getMethodId(Analysis analysis) {
return analysis == null ? "" : analysis.getMethod() == null ? "" : analysis.getMethod().getId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.openelisglobal.common.valueholder.BaseObject;
import org.openelisglobal.common.valueholder.ValueHolder;
import org.openelisglobal.common.valueholder.ValueHolderInterface;
import org.openelisglobal.method.valueholder.Method;
import org.openelisglobal.note.service.NoteObject;
import org.openelisglobal.note.service.NoteServiceImpl.BoundTo;
import org.openelisglobal.panel.valueholder.Panel;
Expand Down Expand Up @@ -81,6 +82,7 @@ public class Analysis extends BaseObject<String> implements NoteObject {
private String sampleTypeName;
private List<Analysis> children;
private boolean correctedSincePatientReport;
private ValueHolderInterface method;

public Analysis() {
super();
Expand All @@ -90,6 +92,7 @@ public Analysis() {
parentAnalysis = new ValueHolder();
parentResult = new ValueHolder();
panel = new ValueHolder();
method = new ValueHolder();
}

@Override
Expand Down Expand Up @@ -497,4 +500,12 @@ public UUID getFhirUuid() {
public void setFhirUuid(UUID fhirUuid) {
this.fhirUuid = fhirUuid;
}

public Method getMethod() {
return (Method) method.getValue();
}

public void setMethod(Method method) {
this.method.setValue(method);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,12 @@ public Localization getLocalization() {
public void setLocalization(Localization localization) {
this.localization.setValue(localization);
}

public String getLocalizedValue() {
if (getLocalization() == null) {
return methodName;
} else {
return getLocalization().getLocalizedValue();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ public static IReportParameterSetter getParameterSetter(String report) {
return new TBOrderReport();
} else if (report.equals("Trends")) {
return new ExportTrendsByDate();
} else if (report.equals("WHONETReport")) {
return new WHONETReport();
} else if (report.equals("ExportWHONETReportByDate")) {
return new WHONETExportRoutineByDate();
} else if (report.equals("covidResultsReport")) {
Expand Down Expand Up @@ -279,8 +277,6 @@ public static IReportCreator getReportCreator(String report) {
return new MauritiusProtocolSheet();
} else if (report.equals("ExportWHONETReportByDate")) {
return new WHONETExportRoutineByDate();
} else if (report.equals("WHONETReport")) {
return new WHONETReport();
} else if (report.equals("covidResultsReport")) {
return new CovidResultsReport();
} else if (report.equals("statisticsReport")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
import net.sf.jasperreports.engine.JRField;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;

/**
* @author pahill ([email protected])
* @since Mar 17, 2011
*/
public abstract class WHONETCSVRoutineExportReport extends Report implements JRDataSource {

/**
Expand Down Expand Up @@ -74,4 +70,4 @@ public Object getFieldValue(JRField arg0) throws JRException {
public boolean next() throws JRException {
throw new UnsupportedOperationException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.List;
import javax.xml.ws.Response;
import net.sf.jasperreports.engine.JRException;
import org.openelisglobal.reports.action.implementation.reportBeans.WHONETRoutineColumnBuilder;
import org.openelisglobal.reports.action.implementation.reportBeans.WHONETCSVRoutineColumnBuilder;

public abstract class WHONETCSVRoutineSampleExportReport extends WHONETCSVRoutineExportReport {

Expand All @@ -30,7 +30,7 @@ public abstract class WHONETCSVRoutineSampleExportReport extends WHONETCSVRoutin
protected List<Object> reportItems;
protected int iReportItem = -1;

protected WHONETRoutineColumnBuilder WHONETcsvRoutineColumnBuilder;
protected WHONETCSVRoutineColumnBuilder WHONETcsvRoutineColumnBuilder;
protected DateRange dateRange;

@Override
Expand Down Expand Up @@ -77,4 +77,4 @@ protected void writeResultsToBuffer(ByteArrayOutputStream buffer)
buffer.write(WHONETcsvRoutineColumnBuilder.nextLine().getBytes("windows-1252"));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,16 @@
*/
package org.openelisglobal.reports.action.implementation;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.SQLException;
import java.text.ParseException;
import org.apache.commons.validator.GenericValidator;
import org.jfree.util.Log;
import org.openelisglobal.common.util.StringUtil;
import org.openelisglobal.internationalization.MessageUtil;
import org.openelisglobal.project.service.ProjectService;
import org.openelisglobal.reports.action.implementation.reportBeans.WHONETRoutineColumnBuilder;
import org.openelisglobal.reports.action.implementation.reportBeans.WHONETCSVRoutineColumnBuilder;
import org.openelisglobal.reports.form.ReportForm;
import org.openelisglobal.spring.util.SpringContext;

/**
* @author Paul A. Hill ([email protected])
* @since Jan 26, 2011
*/
public class WHONETExportRoutineByDate extends WHONETCSVRoutineSampleExportReport
implements IReportParameterSetter, IReportCreator {
public class WHONETExportRoutineByDate extends WHONETCSVRoutineSampleExportReport implements IReportParameterSetter {
protected final ProjectService projectService = SpringContext.getBean(ProjectService.class);
// private String projectStr;
// private Project project;

@Override
protected String reportFileName() {
Expand All @@ -48,8 +35,6 @@ public void setRequestParameters(ReportForm form) {
form.setReportName(getReportNameForParameterPage());
form.setUseLowerDateRange(Boolean.TRUE);
form.setUseUpperDateRange(Boolean.TRUE);
// form.setUseProjectCode(Boolean.TRUE);
// form.setProjectCodeList(getProjectList());
} catch (RuntimeException e) {
Log.error("Error in ExportRoutineByDate.setRequestParemeters: ", e);
}
Expand All @@ -59,11 +44,6 @@ protected String getReportNameForParameterPage() {
return MessageUtil.getMessage("reports.label.project.export") + " "
+ MessageUtil.getContextualMessage("sample.collectionDate");
}
/*
* protected void createReportParameters() { super.createReportParameters();
* reportParameters.put("studyName", (project == null) ? null :
* project.getLocalizedName()); }
*/

@Override
public void initializeReport(ReportForm form) {
Expand All @@ -72,7 +52,6 @@ public void initializeReport(ReportForm form) {

lowDateStr = form.getLowerDateRange();
highDateStr = form.getUpperDateRange();
// projectStr = form.getProjectCode();
dateRange = new DateRange(lowDateStr, highDateStr);

createReportParameters();
Expand All @@ -91,23 +70,6 @@ private boolean validateSubmitParameters() {
return dateRange.validateHighLowDate("report.error.message.date.received.missing");
}

// -------------------------------

/**
* @return true, if location is not blank or "0" is is found in the DB; false
* otherwise
*/
// --------------------------
/*
* private boolean validateProject() { if (isBlankOrNull(projectStr) ||
* "0".equals(Integer.getInteger(projectStr))) {
* add1LineErrorMessage("report.error.message.project.missing"); return false; }
* ProjectService Service = new ProjectServiceImpl(); project =
* Service.getProjectById(projectStr); if (project == null) {
* add1LineErrorMessage("report.error.message.project.missing"); return false; }
* return true; }
*/
// -------------------------
/** creating the list for generation to the report */
private void createReportItems() {
try {
Expand All @@ -119,75 +81,8 @@ private void createReportItems() {
}
}

@Override
protected void writeResultsToBuffer(ByteArrayOutputStream buffer)
throws IOException, UnsupportedEncodingException, SQLException, ParseException {

String currentAccessionNumber = null;
String[] splitBase = null;
while (WHONETcsvRoutineColumnBuilder.next()) {
String line = WHONETcsvRoutineColumnBuilder.nextLine();
String[] splitLine = StringUtil.separateCSVWithMixedEmbededQuotes(line);

if (splitLine[0].equals(currentAccessionNumber)) {
merge(splitBase, splitLine);
} else {
if (currentAccessionNumber != null) {
writeConsolidatedBaseToBuffer(buffer, splitBase);
}
splitBase = splitLine;
currentAccessionNumber = splitBase[0];
}
}

writeConsolidatedBaseToBuffer(buffer, splitBase);
}

private void merge(String[] base, String[] line) {
for (int i = 0; i < base.length; ++i) {
if (GenericValidator.isBlankOrNull(base[i])) {
base[i] = line[i];
}
}
}

protected void writeConsolidatedBaseToBuffer(ByteArrayOutputStream buffer, String[] splitBase)
throws IOException, UnsupportedEncodingException {

if (splitBase != null) {
StringBuffer consolidatedLine = new StringBuffer();
for (String value : splitBase) {
consolidatedLine.append(value);
consolidatedLine.append(",");
}

consolidatedLine.deleteCharAt(consolidatedLine.lastIndexOf(","));
buffer.write(consolidatedLine.toString().getBytes("windows-1252"));
}
}

private WHONETRoutineColumnBuilder getColumnBuilder() {
return new WHONETRoutineColumnBuilder(dateRange);
private WHONETCSVRoutineColumnBuilder getColumnBuilder() {
return new WHONETCSVRoutineColumnBuilder(dateRange);
}

/**
* @return a list of the correct projects for display
*/
/*
* protected List<Project> getProjectList() { List<Project> projects = new
* ArrayList<Project>(); Project project = new Project();
* project.setProjectName("Antiretroviral Study");
* projects.add(projectService.getProjectByName(project, false, false));
* project.setProjectName("Antiretroviral Followup Study");
* projects.add(projectService.getProjectByName(project, false, false));
* project.setProjectName("Routine HIV Testing");
* projects.add(projectService.getProjectByName(project, false, false));
* project.setProjectName("Early Infant Diagnosis for HIV Study");
* projects.add(projectService.getProjectByName(project, false, false));
* project.setProjectName("Viral Load Results");
* projects.add(projectService.getProjectByName(project, false, false));
* project.setProjectName("Indeterminate Results");
* projects.add(projectService.getProjectByName(project, false, false)); return
* projects; }
*/
}
}

This file was deleted.

Loading

0 comments on commit 1b268b6

Please sign in to comment.