-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from medizininformatik-initiative/update-mapp…
…ing-tree Update Mapping Tree
- Loading branch information
Showing
24 changed files
with
741 additions
and
552 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
17 changes: 17 additions & 0 deletions
17
src/main/java/de/numcodex/sq2cql/model/MappingTreeBase.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,17 @@ | ||
package de.numcodex.sq2cql.model; | ||
|
||
|
||
import de.numcodex.sq2cql.model.structured_query.ContextualTermCode; | ||
|
||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
public record MappingTreeBase(List<MappingTreeModuleRoot> moduleRoots) { | ||
|
||
public Stream<ContextualTermCode> expand(ContextualTermCode termCode) { | ||
var key = termCode.termCode().code(); | ||
|
||
return moduleRoots.stream().flatMap(moduleRoot -> | ||
moduleRoot.isModuleMatching(termCode) ? moduleRoot.expand(key) : Stream.empty()); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/de/numcodex/sq2cql/model/MappingTreeModuleEntry.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,16 @@ | ||
package de.numcodex.sq2cql.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.List; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record MappingTreeModuleEntry(String key, List<String> children) { | ||
@JsonCreator | ||
static MappingTreeModuleEntry fromJson(@JsonProperty("key") String key, | ||
@JsonProperty("children") List<String> children) { | ||
return new MappingTreeModuleEntry(key, children); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/de/numcodex/sq2cql/model/MappingTreeModuleRoot.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,40 @@ | ||
package de.numcodex.sq2cql.model; | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import de.numcodex.sq2cql.model.common.TermCode; | ||
import de.numcodex.sq2cql.model.structured_query.ContextualTermCode; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import static java.util.function.Function.identity; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record MappingTreeModuleRoot(TermCode context, String system, Map<String, MappingTreeModuleEntry> entries) { | ||
@JsonCreator | ||
static MappingTreeModuleRoot fromJson(@JsonProperty("context") TermCode context, | ||
@JsonProperty("system") String system, | ||
@JsonProperty("entries") List<MappingTreeModuleEntry> entries) { | ||
return new MappingTreeModuleRoot( | ||
context, | ||
system, | ||
entries.stream().collect(Collectors.toMap(MappingTreeModuleEntry::key, identity()))); | ||
} | ||
|
||
public Stream<ContextualTermCode> expand(String key) { | ||
var newTermCode = new ContextualTermCode(context, new TermCode(system, key, "")); | ||
|
||
return Stream.concat(Stream.of(newTermCode), entries.get(key).children().stream().flatMap(this::expand)); | ||
} | ||
|
||
boolean isModuleMatching(ContextualTermCode contextualTermCode) { | ||
return context.equals(contextualTermCode.context()) && | ||
system.equals(contextualTermCode.termCode().system()) && | ||
entries.containsKey(contextualTermCode.termCode().code()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.