Skip to content

Commit

Permalink
Issue #1980 - changes per PR review
Browse files Browse the repository at this point in the history
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
  • Loading branch information
JohnTimm committed Mar 12, 2021
1 parent c832782 commit 4108a18
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 38 deletions.
1 change: 0 additions & 1 deletion docs/src/pages/guides/FHIRServerUsersGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,6 @@ This section contains reference information about each of the configuration prop
|`fhirServer/core/checkReferenceTypes`|true|
|`fhirServer/core/serverRegistryResourceProviderEnabled`|false|
|`fhirServer/core/graphTermServiceProvider/enabled`|false|
|`fhirServer/core/graphTermServiceProvider/configuration`|null|
|`fhirServer/core/conditionalDeleteMaxNumber`|10|
|`fhirServer/core/capabilityStatementCacheTimeout`|60|
|`fhirServer/core/extendedCodeableConceptValidation`|true|
Expand Down
30 changes: 30 additions & 0 deletions fhir-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,36 @@
<artifactId>commons-text</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-core</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-berkeleyje</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-cql</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-lucene</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-es</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-driver</artifactId>
<version>3.4.6</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
6 changes: 0 additions & 6 deletions fhir-term-graph/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,26 @@
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-core</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-berkeleyje</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-cql</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-lucene</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-es</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-driver</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2020
* (C) Copyright IBM Corp. 2020, 2021
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2020
* (C) Copyright IBM Corp. 2020, 2021
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -12,9 +12,20 @@
import com.ibm.fhir.term.graph.FHIRTermGraph;
import com.ibm.fhir.term.graph.impl.FHIRTermGraphImpl;

/*
* Factory class used to create FHIRTermGraph instances
*/
public final class FHIRTermGraphFactory {
private FHIRTermGraphFactory() { }

/**
* Create a {@link FHIRTermGraph} instance using the given configuration properties file
*
* @param propFileName
* the configuration properties file
* @return
* the {@link FHIRTermGraph} instance
*/
public static FHIRTermGraph open(String propFileName) {
try {
return open(new PropertiesConfiguration(propFileName));
Expand All @@ -23,6 +34,14 @@ public static FHIRTermGraph open(String propFileName) {
}
}

/**
* Create a {@link FHIRTermGraph} instance using the given configuration object
*
* @param configuration
* the configuration object
* @return
* the {@link FHIRTermGraph} instance
*/
public static FHIRTermGraph open(Configuration configuration) {
return new FHIRTermGraphImpl(configuration);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@
import com.ibm.fhir.term.graph.loader.impl.SnomedTermGraphLoader;
import com.ibm.fhir.term.graph.loader.impl.UMLSTermGraphLoader;

/*
* Factory class used to create FHIRTermGraphLoader instances
*/
public class FHIRTermGraphLoaderFactory {
/**
* Create {@link FHIRTermGraphLoader} instance using the provided type and options map
*
* @param type
* the type
* @param options
* the options map
* @return
* a {@link FHIRTermGraphLoader} instance
*/
public static FHIRTermGraphLoader create(Type type, Map<String, String> options) {
switch (type) {
case CODESYSTEM:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ public static void main(String[] args) throws Exception {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("CodeSystemTermGraphLoader", options);
} catch (Exception e) {
e.printStackTrace();
System.out.println("An error occurred: " + e.getMessage());
} finally {
if (loader != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ public static void main(String[] args) throws Exception {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("SnomedTermGraphLoader", options);
} catch (Exception e) {
e.printStackTrace();
System.out.println("An error occurred: " + e.getMessage());
} finally {
if (loader != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
Expand Down Expand Up @@ -58,9 +56,6 @@ public class UMLSTermGraphLoader extends AbstractTermGraphLoader {
// Map of code system name to preferred label, configured in properties file
private Properties codeSystemMap = new Properties();

// Set of code systems which are case sensitive, configured in properties file
private Set<String> caseSensitiveCodeSystems = new HashSet<>();

// Map of code system id to corresponding vertex
private Map<String, Vertex> codeSystemVertices = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -104,7 +99,6 @@ public UMLSTermGraphLoader(Map<String, String> options) {
public void load() {
try {
loadSourceAttributes();
loadCaseSensitiveCodeSystems();
loadConcepts();
loadRelations();
} catch (Exception e) {
Expand All @@ -121,12 +115,7 @@ public void load() {
private final Vertex createCodeSystemVertex(String sab) {
String version = sabToVersion.get(sab);
String url = (String) codeSystemMap.getOrDefault(sab, sab);

boolean caseSensitive = false;
if (caseSensitiveCodeSystems.contains(sab)) {
caseSensitive = true;
}
Vertex csv = g.addV("CodeSystem").property("url", url).property("version", version).property("caseSensitive", caseSensitive).next();
Vertex csv = g.addV("CodeSystem").property("url", url).property("version", version).next();
g.tx().commit();
return csv;

Expand Down Expand Up @@ -307,20 +296,6 @@ private void loadSourceAttributes() throws IOException {
}
}

/**
* Loads configuration of code systems noted to be case sensitive
*
* @throws IOException
*/
private void loadCaseSensitiveCodeSystems() throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("conf/umlsSourceCaseSensitivity.txt")))) {
String line = reader.readLine().trim();
if (!line.isEmpty()) {
caseSensitiveCodeSystems.add(reader.readLine());
}
}
}

/**
* Load UMLS data using properties provided in arguments
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public static void main(String[] args) throws Exception {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(String.format("FHIRTermGraphLoaderMain %s <loader-specific-options>", type.toString()), options);
} catch (Exception e) {
e.printStackTrace();
System.out.println("An error occurred: " + e.getMessage());
} finally {
if (loader != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
public class FHIRTermGraphUtil {
private FHIRTermGraphUtil() { }

/**
* Convert the given element value to an object value that is compatible with the graph schema
*
* @param value
* the element value
* @return
* an object value that is compatible with the graph schema
*/
public static Object toObject(Element value) {
if (value.is(FHIR_BOOLEAN)) {
return value.as(FHIR_BOOLEAN).getValue();
Expand All @@ -54,18 +62,40 @@ public static Object toObject(Element value) {
throw new IllegalArgumentException();
}

/**
* Normalize the string by making it case and accent insensitive
*
* @param value
* the string value to normalized
* @return
* the normalized string value
*/
public static String normalize(String value) {
if (value != null) {
return Normalizer.normalize(value, Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "").toLowerCase();
}
return null;
}

/**
* Sets the root logger level for the logback classic root logger
*
* @param level
* the level
*/
public static void setRootLoggerLevel(Level level) {
Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.setLevel(level);
}

/**
* Convert the {@link DateTime} value to a Long value that is compatible with the graph schema
*
* @param dateTime
* the dateTime value
* @return
* the Long equivalent value (milliseconds from the epoch)
*/
public static Long toLong(DateTime dateTime) {
TemporalAccessor value = dateTime.getValue();
if (value instanceof ZonedDateTime) {
Expand Down

0 comments on commit 4108a18

Please sign in to comment.