Skip to content

Commit

Permalink
issue #3147 Build fails in 2022 due to test data violating current ye…
Browse files Browse the repository at this point in the history
…ar constraint

Signed-off-by: Robin Arnold <robin.arnold@ibm.com>
  • Loading branch information
punktilious committed Jan 1, 2022
1 parent d8adefd commit d3c0d9f
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2021
* (C) Copyright IBM Corp. 2021, 2022
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -22,8 +22,10 @@

import com.ibm.fhir.model.format.Format;
import com.ibm.fhir.model.parser.FHIRParser;
import com.ibm.fhir.model.resource.Bundle;
import com.ibm.fhir.model.resource.OperationOutcome.Issue;
import com.ibm.fhir.model.resource.Resource;
import com.ibm.fhir.model.type.Instant;
import com.ibm.fhir.model.type.code.IssueSeverity;
import com.ibm.fhir.path.FHIRPathNode;
import com.ibm.fhir.path.evaluator.FHIRPathEvaluator.EvaluationContext;
Expand Down Expand Up @@ -70,6 +72,18 @@ public boolean isValid(Path path) {
try (InputStream in = new FileInputStream(path.toFile())) {
System.out.println("Path: " + path);
Resource resource = FHIRParser.parser(Format.JSON).parse(in);

// Before we can validate, we need to update resources with a
// timestamp so we don't violate:
// spl-X.1.1.2: The effective time year is equal to the current year
if (resource.is(Bundle.class)) {
Bundle bundle = resource.as(Bundle.class);
if (bundle.getTimestamp() != null && bundle.getTimestamp().getValue() != null) {
resource = bundle.toBuilder()
.timestamp(Instant.now())
.build();
}
}
List<Issue> issues = FHIRValidator.validator().validate(resource);
for (Issue issue : issues) {
if (IssueSeverity.ERROR.equals(issue.getSeverity())) {
Expand Down

0 comments on commit d3c0d9f

Please sign in to comment.