Skip to content

Commit

Permalink
Merge branch 'develop' into feature/MAT-7300-signature-level
Browse files Browse the repository at this point in the history
  • Loading branch information
chubert-sb authored Jul 19, 2024
2 parents 2f1635b + a289e48 commit 2660986
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
<dependency>
<groupId>gov.cms.madie</groupId>
<artifactId>madie-java-models</artifactId>
<version>0.6.30-SNAPSHOT</version>
<version>0.6.42-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>jackson-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,20 @@ public void enterCodesystemDefinition(cqlParser.CodesystemDefinitionContext ctx)
CQLCodeSystem codeSystem = new CQLCodeSystem();
codeSystem.setId(csDef.getId());
codeSystem.setOID(csDef.getId());
codeSystem.setCodeSystemVersion(getParsedVersion(csDef.getVersion()));
codeSystem.setCodeSystemName(csDef.getName());

codeSystemMap.putIfAbsent(identifier, codeSystem);
}
}

private String getParsedVersion(String version) {
if (version != null && version.startsWith("urn:hl7:version:")) {
return version.substring("urn:hl7:version:".length());
}
return version;
}

@Override
public void enterQualifiedFunction(QualifiedFunctionContext ctx) {
if (ctx.identifierOrFunctionIdentifier() != null
Expand Down Expand Up @@ -556,18 +564,29 @@ private Element resolve(String identifier, CompiledLibrary library) {
currentContext, def.getPath() + "-" + def.getVersion() + "|" + def.getLocalIdentifier());
libraryAccessor = def;
try {
parseChildLibraries(def);
libraries.add(
CQLIncludeLibrary.builder()
.cqlLibraryName(def.getPath())
.aliasName(def.getLocalIdentifier())
.version(def.getVersion())
// TODO: should be taken from librarySetId
.id(def.getTrackerId().toString())
.setId(def.getTrackerId().toString())
.build());
var parsedLibrary =
libraries.stream()
.filter(
l ->
l.getCqlLibraryName().equalsIgnoreCase(def.getPath())
&& l.getVersion().equalsIgnoreCase(def.getVersion()))
.findFirst();
if (parsedLibrary.isEmpty()) {
parseChildLibraries(def);
libraries.add(
CQLIncludeLibrary.builder()
.cqlLibraryName(def.getPath())
.aliasName(def.getLocalIdentifier())
.version(def.getVersion())
// TODO: should be taken from librarySetId
.id(def.getTrackerId().toString())
.setId(def.getTrackerId().toString())
.build());
}
} catch (IOException e) {
e.printStackTrace();
log.error(
"IOException while parsing child library [{}] " + e.getMessage(),
def.getPath() + "-" + def.getVersion());
}
} else if (element instanceof CodeDef codeDef) {
codes.add(formattedIdentifier);
Expand All @@ -578,6 +597,8 @@ private Element resolve(String identifier, CompiledLibrary library) {
.codeName(codeDef.getDisplay())
.codeSystemName(codeDef.getCodeSystem().getName())
.codeSystemOID(cqlCodeSystem == null ? null : cqlCodeSystem.getOID())
.codeSystemVersion(
cqlCodeSystem == null ? null : cqlCodeSystem.getCodeSystemVersion())
.codeIdentifier(formattedIdentifier)
.build();
declaredCodes.add(declaredCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import java.util.Queue;
import java.util.Set;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CQLGraph {

private final Map<String, Set<String>> graph = new HashMap<>();
Expand Down Expand Up @@ -49,20 +52,32 @@ public boolean isPath(String source, String destination) {

while (!queue.isEmpty()) {
String currentNode = queue.remove();
List<String> adjacentVertices = new ArrayList<>(this.graph.get(currentNode));

for (String adjacentNode : adjacentVertices) {
// we've found the destination node that we were looking for, so return true.
if (adjacentNode.equals(destination)) {
return true;
}

// if it's not the destination node and the node hasn't been visited yet, add it to the
// queue to be visited.
if (!visited.contains(adjacentNode)) {
visited.add(adjacentNode);
queue.add(adjacentNode);
if (this.graph.get(currentNode) != null) {
List<String> adjacentVertices = new ArrayList<>(this.graph.get(currentNode));

for (String adjacentNode : adjacentVertices) {
// we've found the destination node that we were looking for, so return true.
if (adjacentNode.equals(destination)) {
return true;
}

// if it's not the destination node and the node hasn't been visited yet, add it to the
// queue to be visited.
if (!visited.contains(adjacentNode)) {
visited.add(adjacentNode);
queue.add(adjacentNode);
}
}
} else {
log.error(
"source = "
+ source
+ " destination = "
+ destination
+ " this.graph.get currentNode: "
+ currentNode
+ " is null");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
server:
port: 8083
servlet:
context-path: /api/fhir
context-path: /api/qdm

spring:
profiles:
Expand Down

0 comments on commit 2660986

Please sign in to comment.