Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to remove the assumption of millisecond precision in reporting period start/end #724

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ private MeasureReport generateMeasureReport() {
MeasureReport measureReport;
String patientDataBundleId = ReportIdHelper.getPatientDataBundleId(reportContext.getMasterIdentifierValue(), patientId);
String measureId = this.measureContext.getMeasure().getIdElement().getIdPart();
String start = this.criteria.getPeriodStart().substring(0, this.criteria.getPeriodStart().indexOf("."));
String end = this.criteria.getPeriodEnd().substring(0, this.criteria.getPeriodEnd().indexOf("."));

Bundle patientBundle;
try (Stopwatch stopwatch = this.stopwatchManager.start(Constants.TASK_RETRIEVE_PATIENT_DATA, Constants.CATEGORY_REPORT)) {
Expand All @@ -60,7 +58,7 @@ private MeasureReport generateMeasureReport() {
Helper.dumpToFile(patientBundle, config.getDebugPath(), fileName);
}

logger.info("Executing $evaluate-measure for measure: {}, start: {}, end: {}, patient: {}, resources: {}", measureId, start, end, patientId, patientBundle.getEntry().size());
logger.info("Executing $evaluate-measure for measure: {}, start: {}, end: {}, patient: {}, resources: {}", measureId, criteria.getPeriodStart(), criteria.getPeriodEnd(), patientId, patientBundle.getEntry().size());

//noinspection unused
try (Stopwatch stopwatch = this.stopwatchManager.start(Constants.TASK_MEASURE, Constants.CATEGORY_EVALUATE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,17 @@ public List<GlobalReportResponse> getReports(
if (!startDate.isEmpty()) {
Date date = Helper.parseFhirDate(startDate);

reports = reports.stream().filter(x -> {
try {
return Helper.parseFhirDate(x.getPeriodStart()).after(date) || Helper.parseFhirDate(x.getPeriodStart()).equals(date);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList());
reports = reports.stream().filter(x ->
Helper.parseFhirDate(x.getPeriodStart()).after(date) || Helper.parseFhirDate(x.getPeriodStart()).equals(date)
).collect(Collectors.toList());
}

if (!endDate.isEmpty()) {
Date date = Helper.parseFhirDate(endDate);

reports = reports.stream().filter(x -> {
try {
return Helper.parseFhirDate(x.getPeriodEnd()).before(date) || Helper.parseFhirDate(x.getPeriodStart()).equals(date);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList());
reports = reports.stream().filter(x ->
Helper.parseFhirDate(x.getPeriodEnd()).before(date) || Helper.parseFhirDate(x.getPeriodStart()).equals(date)
).collect(Collectors.toList());
}

if (!tenantId.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ public LogSearchResponse getLogs(@RequestParam(required = false) String startDat
Date startDateObj;
Date endDateObj;

try {
startDateObj = Helper.parseFhirDate(startDate);
endDateObj = Helper.parseFhirDate(endDate);
} catch (ParseException ex) {
throw new IllegalArgumentException("Invalid date format, must be in the format yyyy-MM-dd'T'HH:mm:ss.SSSXXX or yyyy-MM-dd'T'HH:mm:ssXXX");
}
startDateObj = Helper.parseFhirDate(startDate);
endDateObj = Helper.parseFhirDate(endDate);

List<LogMessage> logMessages = this.sharedService.findLogMessages(startDateObj, endDateObj, severity, page, content);
LogSearchResponse res = new LogSearchResponse();
Expand Down
17 changes: 3 additions & 14 deletions core/src/main/java/com/lantanagroup/link/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.commons.text.StringEscapeUtils;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.CapabilityStatement;
import org.hl7.fhir.r4.model.DateTimeType;
import org.hl7.fhir.r4.model.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -66,20 +67,8 @@ public static String getFhirDate(Date date) {
return new SimpleDateFormat(SIMPLE_DATE_MILLIS_FORMAT).format(date);
}

public static Date parseFhirDate(String dateStr) throws ParseException {
if (StringUtils.isEmpty(dateStr)) {
return null;
}

SimpleDateFormat formatterMillis = new SimpleDateFormat(SIMPLE_DATE_MILLIS_FORMAT);
SimpleDateFormat formatterSec = new SimpleDateFormat(SIMPLE_DATE_SECONDS_FORMAT);
Date dateReturned;
try {
dateReturned = formatterMillis.parse(dateStr);
} catch (Exception ex) {
dateReturned = formatterSec.parse(dateStr);
}
return dateReturned;
public static Date parseFhirDate(String dateStr) {
return new DateTimeType(dateStr).getValue();
}

public static <T> List<T> concatenate(List<T> list1, List<T> list2) {
Expand Down