-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
general profile slice min fix rule, fixes #72
Replaced the old radiology-procedures slicing min fix rule with a general rule working for all effected profiles. Added a learning test, validating all example resources from de.gecco|1.0.5 with our validator. All resource except one validate without errors. For the Resource with error see hl7germany/forschungsnetz-covid19#139
- Loading branch information
Showing
5 changed files
with
183 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
...transfer/validation/structure_definition/GeccoRadiologyProceduresCodingSliceMinFixer.java
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
...smedizin/codex/processes/data_transfer/validation/structure_definition/SliceMinFixer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.validation.structure_definition; | ||
|
||
import java.util.Objects; | ||
|
||
import org.hl7.fhir.r4.model.StructureDefinition; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* HAPI snapshot generator adds bad min value to slices if min is not explicitly defined and slicing definition is not | ||
* part of the profile and path does not end with .value[x] | ||
*/ | ||
public class SliceMinFixer implements StructureDefinitionModifier | ||
{ | ||
private static final Logger logger = LoggerFactory.getLogger(SliceMinFixer.class); | ||
|
||
@Override | ||
public StructureDefinition modify(StructureDefinition sd) | ||
{ | ||
sd.getDifferential().getElement().stream() | ||
// slice with max but no min definition | ||
.filter(e -> e.hasSliceName() && !e.hasMin() && e.hasMax()) | ||
// no fix needed for rules with path ending in .value[x] | ||
.filter(e -> e.hasPath() && !e.getPath().endsWith(".value[x]")) | ||
// matching slicing definition not part of this profile (defined in base) | ||
.filter(e -> !sd.getDifferential().getElement().stream() | ||
.anyMatch(e1 -> Objects.equals(e.getPath(), e1.getPath()) && e1.hasSlicing())) | ||
.forEach(e -> | ||
{ | ||
logger.warn("Adding min=0 to rule with id {} in StructureDefinition {}|{}", e.getId(), sd.getUrl(), | ||
sd.getVersion(), sd.getBaseDefinition(), sd.getDifferential().getElement().stream() | ||
.anyMatch(e1 -> Objects.equals(e.getPath(), e1.getPath()) && e1.hasSlicing())); | ||
e.setMin(0); | ||
}); | ||
|
||
return sd; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters