mirror of
https://github.com/pcvolkmer/onkostar-plugin-dnpm.git
synced 2025-07-02 01:02:55 +00:00
erste Version
This commit is contained in:
167
DNPMPlugins/pom.xml
Normal file
167
DNPMPlugins/pom.xml
Normal file
@ -0,0 +1,167 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>DNPMHelper</groupId>
|
||||
<artifactId>DNPMHelper</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<name>DNPMHelper</name>
|
||||
|
||||
<dependencies>
|
||||
<!-- This is the onkostar-api -->
|
||||
<dependency>
|
||||
<groupId>de.itc</groupId>
|
||||
<artifactId>onkostar-parent</artifactId>
|
||||
<version>2.11.1.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/onkostar-api-2.11.1.1.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- This is the core HAPI library -->
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi</groupId>
|
||||
<artifactId>hapi-base</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/hapi-base-2.2.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- This is the structure JAR for HL7 v2.1 -->
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi</groupId>
|
||||
<artifactId>hapi-structures-v23</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/hapi-structures-v23-2.2.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi</groupId>
|
||||
<artifactId>hapi-structures-v24</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/hapi-structures-v24-2.2.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi</groupId>
|
||||
<artifactId>hapi-structures-v25</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/hapi-structures-v25-2.2.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi</groupId>
|
||||
<artifactId>hapi-structures-v26</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/hapi-structures-v26-2.2.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>4.3.8.RELEASE</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/spring-beans-4.3.8.RELEASE.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- Hibernate -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>5.1.8.Final</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/hibernate-core-5.1.8.Final.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- zusätzliche Erweiterungen. -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.2.1.RELEASE</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
<version>3.2.1.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.14.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.14.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
<version>5.3.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-csv</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Hier wird definiert, wie Maven das Artifakt bauen soll. -->
|
||||
<!-- Das erste Plugin kopiert die Resourcen in das JAR -->
|
||||
<!-- Das zweite Plugin kompiliert die Klassen als Java 11 -->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<outputDirectory>C:\Onkostar-System\Onkostar\files\onkostar\plugins</outputDirectory>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<java.version>11</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<spring-version>4.3.8.RELEASE</spring-version>
|
||||
</properties>
|
||||
</project>
|
15
DNPMPlugins/src/main/java/ATCCodes/AgentCode.java
Normal file
15
DNPMPlugins/src/main/java/ATCCodes/AgentCode.java
Normal file
@ -0,0 +1,15 @@
|
||||
package ATCCodes;
|
||||
|
||||
/**
|
||||
* Common Agent Code definition
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public interface AgentCode extends Comparable<AgentCode> {
|
||||
String getCode();
|
||||
|
||||
String getName();
|
||||
|
||||
CodeSystem getSystem();
|
||||
}
|
51
DNPMPlugins/src/main/java/ATCCodes/AtcCode.java
Normal file
51
DNPMPlugins/src/main/java/ATCCodes/AtcCode.java
Normal file
@ -0,0 +1,51 @@
|
||||
package ATCCodes;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* ATC-Code as used in WHO XML file
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class AtcCode implements AgentCode {
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
public AtcCode(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CodeSystem getSystem() {
|
||||
return CodeSystem.ATC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final AgentCode agentCode) {
|
||||
return this.name.toLowerCase().compareTo(agentCode.getName().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AgentCode otherAgentCode = (AgentCode) o;
|
||||
return Objects.equals(code.toLowerCase(), otherAgentCode.getCode().toLowerCase())
|
||||
&& Objects.equals(name.toLowerCase(), otherAgentCode.getName().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code.toLowerCase(), name.toLowerCase());
|
||||
}
|
||||
}
|
110
DNPMPlugins/src/main/java/ATCCodes/AtcCodesPlugin.java
Normal file
110
DNPMPlugins/src/main/java/ATCCodes/AtcCodesPlugin.java
Normal file
@ -0,0 +1,110 @@
|
||||
package ATCCodes;
|
||||
|
||||
import de.itc.onkostar.api.Disease;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
import de.itc.onkostar.api.analysis.AnalyzerRequirement;
|
||||
import de.itc.onkostar.api.analysis.IProcedureAnalyzer;
|
||||
import de.itc.onkostar.api.analysis.OnkostarPluginType;
|
||||
import ATCCodes.services.AgentCodeService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Plugin implementation
|
||||
* Provides methods exposed to Onkostar
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@Component
|
||||
public class AtcCodesPlugin implements IProcedureAnalyzer {
|
||||
|
||||
private final List<AgentCodeService> agentCodeServices;
|
||||
|
||||
public AtcCodesPlugin(List<AgentCodeService> agentCodeServices) {
|
||||
this.agentCodeServices = agentCodeServices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnkostarPluginType getType() {
|
||||
return OnkostarPluginType.BACKEND_SERVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "0.4.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ATC-Codes und Substanzen";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "ATC-Codes und Substanzen";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSynchronous() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalyzerRequirement getRequirement() {
|
||||
return AnalyzerRequirement.PROCEDURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRelevantForDeletedProcedure() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRelevantForAnalyzer(final Procedure procedure, final Disease disease) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyze(final Procedure procedure, final Disease disease) {
|
||||
// Nothing to do - should never be called
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list with ATC codes and agents.
|
||||
* Usage in script:
|
||||
*
|
||||
* <pre>
|
||||
* executePluginMethod(
|
||||
* 'AtcCodesPlugin',
|
||||
* 'query',
|
||||
* { q: '', size: 10 },
|
||||
* function (result) {console.log(result);},
|
||||
* false
|
||||
* );
|
||||
* </pre>
|
||||
*
|
||||
* @param input The data Map
|
||||
* @return The result list filtered by input
|
||||
*/
|
||||
public List<AgentCode> query(final Map<String, Object> input) {
|
||||
String query = "";
|
||||
if (null != input.get("q")) {
|
||||
query = input.get("q").toString();
|
||||
}
|
||||
|
||||
int size = Integer.parseInt(input.get("size").toString());
|
||||
if (size == 0) {
|
||||
size = 10;
|
||||
}
|
||||
var result = new ArrayList<AgentCode>();
|
||||
for (var agentCodeService : this.agentCodeServices) {
|
||||
result.addAll(agentCodeService.findAgentCodes(query, size));
|
||||
}
|
||||
return result.stream().distinct().sorted().collect(Collectors.toList());
|
||||
}
|
||||
}
|
12
DNPMPlugins/src/main/java/ATCCodes/CodeSystem.java
Normal file
12
DNPMPlugins/src/main/java/ATCCodes/CodeSystem.java
Normal file
@ -0,0 +1,12 @@
|
||||
package ATCCodes;
|
||||
|
||||
/**
|
||||
* This enum provides usable coding systems
|
||||
*
|
||||
* @author Paul-Christion Volkmer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public enum CodeSystem {
|
||||
ATC,
|
||||
UNREGISTERED
|
||||
}
|
14
DNPMPlugins/src/main/java/ATCCodes/FileParsingException.java
Normal file
14
DNPMPlugins/src/main/java/ATCCodes/FileParsingException.java
Normal file
@ -0,0 +1,14 @@
|
||||
package ATCCodes;
|
||||
|
||||
/**
|
||||
* Exception to be thrown if any file parsing error occurs
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class FileParsingException extends RuntimeException {
|
||||
|
||||
public FileParsingException(final String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
51
DNPMPlugins/src/main/java/ATCCodes/UnregisteredCode.java
Normal file
51
DNPMPlugins/src/main/java/ATCCodes/UnregisteredCode.java
Normal file
@ -0,0 +1,51 @@
|
||||
package ATCCodes;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Unregistered code as used in Onkostar database
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class UnregisteredCode implements AgentCode {
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
public UnregisteredCode(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CodeSystem getSystem() {
|
||||
return CodeSystem.UNREGISTERED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final AgentCode agentCode) {
|
||||
return this.name.toLowerCase().compareTo(agentCode.getName().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AgentCode otherAgentCode = (AgentCode) o;
|
||||
return Objects.equals(code.toLowerCase(), otherAgentCode.getCode().toLowerCase())
|
||||
&& Objects.equals(name.toLowerCase(), otherAgentCode.getName().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code.toLowerCase(), name.toLowerCase());
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package ATCCodes.services;
|
||||
|
||||
import ATCCodes.AgentCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Common interface for agent code services
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
*/
|
||||
public interface AgentCodeService {
|
||||
|
||||
/**
|
||||
* Queries source for agents with name and code starting with query string.
|
||||
* If size is zero, all available results will be returned.
|
||||
*
|
||||
* @param query The query string
|
||||
* @param size Maximal amount of responses
|
||||
* @return A list with agent codes
|
||||
*/
|
||||
List<AgentCode> findAgentCodes(String query, int size);
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package ATCCodes.services;
|
||||
|
||||
import ATCCodes.AgentCode;
|
||||
import ATCCodes.AtcCode;
|
||||
import ATCCodes.FileParsingException;
|
||||
import org.apache.commons.csv.CSVFormat;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Service to query for agent codes based on WHO xml file
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@Service
|
||||
public class CsvAtcCodeService extends FileBasedAgentCodeService {
|
||||
|
||||
public CsvAtcCodeService(final ResourceLoader resourceLoader) {
|
||||
super(resourceLoader);
|
||||
}
|
||||
|
||||
protected List<AgentCode> parseFile(final ResourceLoader resourceLoader) {
|
||||
var result = new ArrayList<AgentCode>();
|
||||
var filename = getFilePath("atc.csv");
|
||||
try {
|
||||
var inputStream = resourceLoader.getResource(filename).getInputStream();
|
||||
var parser = CSVFormat.RFC4180
|
||||
.withHeader()
|
||||
.withSkipHeaderRecord()
|
||||
.parse(new InputStreamReader(inputStream));
|
||||
for (var row : parser) {
|
||||
if (!row.isMapped("CODE") || !row.isMapped("NAME")) {
|
||||
throw new FileParsingException("No CSV column 'CODE' or 'NAME' found");
|
||||
}
|
||||
result.add(new AtcCode(row.get("CODE"), row.get("NAME")));
|
||||
}
|
||||
logger.info("Found CSV file for ATC-Codes.");
|
||||
return result;
|
||||
} catch (IOException | FileParsingException e) {
|
||||
logger.warn("Error reading CSV file '{}' for ATC-Codes. Proceeding without data", filename);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package ATCCodes.services;
|
||||
|
||||
import ATCCodes.AgentCode;
|
||||
import org.apache.commons.lang.SystemUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Abstract {@link AgentCodeService} for use with files that will load information into memory
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public abstract class FileBasedAgentCodeService implements AgentCodeService {
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
protected final List<AgentCode> codeList = new ArrayList<>();
|
||||
|
||||
FileBasedAgentCodeService(final ResourceLoader resourceLoader) {
|
||||
this.codeList.addAll(parseFile(resourceLoader));
|
||||
}
|
||||
|
||||
static String getFilePath(final String filename) {
|
||||
String pluginPathPart = "onkostar/files/onkostar/plugins/onkostar-plugin-atccodes";
|
||||
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
return String.format("file:///c:/%s/%s", pluginPathPart, filename);
|
||||
} else if (SystemUtils.IS_OS_LINUX) {
|
||||
return String.format("file:///opt/%s/%s", pluginPathPart, filename);
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
protected abstract List<AgentCode> parseFile(final ResourceLoader resourceLoader);
|
||||
|
||||
/**
|
||||
* Queries source for agents code starting with or name containing query string.
|
||||
* If size is zero, all available results will be returned.
|
||||
*
|
||||
* @param query The query string
|
||||
* @param size Maximal amount of responses
|
||||
* @return A list with agent codes
|
||||
*/
|
||||
@Override
|
||||
public List<AgentCode> findAgentCodes(final String query, final int size) {
|
||||
var resultStream = this.codeList.stream().filter(agentCode ->
|
||||
agentCode.getCode().toLowerCase().startsWith(query.toLowerCase())
|
||||
|| agentCode.getName().toLowerCase().contains(query.toLowerCase())
|
||||
);
|
||||
|
||||
if (size > 0) {
|
||||
return resultStream.limit(size).collect(Collectors.toList());
|
||||
}
|
||||
return resultStream.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package ATCCodes.services;
|
||||
|
||||
import ATCCodes.AgentCode;
|
||||
import ATCCodes.UnregisteredCode;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of {@link AgentCodeService} that uses database to query for unregistered agents
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@Service
|
||||
public class OnkostarAgentCodeService implements AgentCodeService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
public OnkostarAgentCodeService(final DataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries source for agents code starting with or name containing query string.
|
||||
* If size is zero, all available results will be returned.
|
||||
*
|
||||
* @param query The query string
|
||||
* @param size Maximal amount of responses
|
||||
* @return A list with agent codes
|
||||
*/
|
||||
@Override
|
||||
public List<AgentCode> findAgentCodes(final String query, final int size) {
|
||||
var sql = "SELECT code, shortdesc\n" +
|
||||
" FROM property_catalogue\n" +
|
||||
" JOIN property_catalogue_version ON (property_catalogue_version.datacatalog_id = property_catalogue.id)\n" +
|
||||
" JOIN property_catalogue_version_entry p ON (p.property_version_id = property_catalogue_version.id)\n" +
|
||||
" WHERE name = 'OS.Substanzen'\n" +
|
||||
" AND (LOWER(code) LIKE ? OR LOWER(shortdesc) LIKE ? OR LOWER(synonyms) LIKE ?)";
|
||||
|
||||
if (size > 0) {
|
||||
sql = sql + " LIMIT " + size;
|
||||
}
|
||||
|
||||
return jdbcTemplate.query(
|
||||
sql,
|
||||
new Object[]{query + "%", "%" + query + "%", "%" + query + "%"},
|
||||
(resultSet, i) ->
|
||||
new UnregisteredCode(resultSet.getString("code"), resultSet.getString("shortdesc"))
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package ATCCodes.services;
|
||||
|
||||
import ATCCodes.AgentCode;
|
||||
import ATCCodes.AtcCode;
|
||||
import ATCCodes.FileParsingException;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Service to query for agent codes based on WHO xml file
|
||||
*
|
||||
* @author Paul-Christian Volkmer
|
||||
* @since 0.1.0
|
||||
*/
|
||||
@Service
|
||||
public class WhoAtcCodeService extends FileBasedAgentCodeService {
|
||||
|
||||
public WhoAtcCodeService(final ResourceLoader resourceLoader) {
|
||||
super(resourceLoader);
|
||||
}
|
||||
|
||||
protected List<AgentCode> parseFile(final ResourceLoader resourceLoader) {
|
||||
var result = new ArrayList<AgentCode>();
|
||||
var filename = getFilePath("atc.xml");
|
||||
try {
|
||||
var inputStream = resourceLoader.getResource(filename).getInputStream();
|
||||
var context = JAXBContext.newInstance(XmlResource.class);
|
||||
var xmlResource = (XmlResource) context.createUnmarshaller().unmarshal(inputStream);
|
||||
for (var row : xmlResource.data.rows) {
|
||||
if (null == row.code || null == row.name) {
|
||||
throw new FileParsingException("No XML attribute 'ATCCode' or 'Name' found");
|
||||
}
|
||||
result.add(new AtcCode(row.code, row.name));
|
||||
}
|
||||
logger.info("Found WHO XML file for ATC-Codes.");
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
logger.warn("Error reading WHO XML file '{}' for ATC-Codes. Proceeding without inserting data", filename);
|
||||
} catch (JAXBException | FileParsingException e) {
|
||||
logger.warn("Error parsing WHO XML file '{}' for ATC-Codes. Proceeding without inserting data", filename);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "xml")
|
||||
private static class XmlResource {
|
||||
@XmlElement(name = "data", namespace = "urn:schemas-microsoft-com:rowset")
|
||||
public XmlData data;
|
||||
}
|
||||
|
||||
private static class XmlData {
|
||||
@XmlElement(name = "row", namespace = "#RowsetSchema")
|
||||
public List<XmlRow> rows;
|
||||
}
|
||||
|
||||
private static class XmlRow {
|
||||
@XmlAttribute(name = "ATCCode")
|
||||
public String code;
|
||||
|
||||
@XmlAttribute(name = "Name")
|
||||
public String name;
|
||||
}
|
||||
}
|
151
DNPMPlugins/src/main/java/DNPM/ConsentManager.java
Normal file
151
DNPMPlugins/src/main/java/DNPM/ConsentManager.java
Normal file
@ -0,0 +1,151 @@
|
||||
package DNPM;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.transform.Transformers;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import de.itc.onkostar.api.Disease;
|
||||
import de.itc.onkostar.api.IOnkostarApi;
|
||||
import de.itc.onkostar.api.Item;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
import de.itc.onkostar.api.analysis.AnalyzerRequirement;
|
||||
import de.itc.onkostar.api.analysis.IProcedureAnalyzer;
|
||||
import de.itc.onkostar.api.analysis.OnkostarPluginType;
|
||||
|
||||
public class ConsentManager implements IProcedureAnalyzer {
|
||||
|
||||
@Autowired
|
||||
private IOnkostarApi onkostarApi;
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Aktualisiert Consent Daten in verknüpften Formularen";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Consent Manager";
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalyzerRequirement getRequirement() {
|
||||
return AnalyzerRequirement.PROCEDURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnkostarPluginType getType() {
|
||||
return OnkostarPluginType.ANALYZER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRelevantForAnalyzer(Procedure Prozedur, Disease Erkrankung) {
|
||||
return Prozedur.getFormName().equals(onkostarApi.getGlobalSetting("consentform"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRelevantForDeletedProcedure() {
|
||||
// TODO is relevant for deleted procedure = true
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSynchronous() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyze(Procedure Prozedur, Disease Erkrankung) {
|
||||
int value = 0;
|
||||
try {
|
||||
SessionFactory sessionFactory = onkostarApi.getSessionFactory();
|
||||
Session session = sessionFactory.getCurrentSession();
|
||||
// geänderte Werte checken
|
||||
String sql1 = "select id, max(timestamp) AS datum from aenderungsprotokoll where entity_id = '" + Prozedur.getId() + "'";
|
||||
SQLQuery query1 = session.createSQLQuery(sql1)
|
||||
.addScalar("id", StandardBasicTypes.INTEGER)
|
||||
.addScalar("datum", StandardBasicTypes.TIMESTAMP);
|
||||
System.out.println(query1.uniqueResult().toString());
|
||||
|
||||
try {
|
||||
String sql = "SELECT prozedur.id AS procedure_id, prozedur.data_form_id, data_catalogue.name AS data_catalogue, data_catalogue_entry.name AS data_catalogue_entry, data_form.description AS formname, prozedur.beginndatum AS datum " +
|
||||
"FROM prozedur " +
|
||||
"LEFT JOIN data_form_data_catalogue ON data_form_data_catalogue.data_form_id = prozedur.data_form_id " +
|
||||
"LEFT JOIN data_catalogue_entry ON data_catalogue_entry.data_catalogue_id = data_form_data_catalogue.data_catalogue_id " +
|
||||
"LEFT JOIN data_catalogue ON data_catalogue.id = data_catalogue_entry.data_catalogue_id " +
|
||||
"LEFT JOIN data_form ON data_form.id = prozedur.data_form_id " +
|
||||
"WHERE patient_id = " + Prozedur.getPatientId() + " " +
|
||||
"AND geloescht = 0 " +
|
||||
"AND data_catalogue_entry.type = 'formReference' " +
|
||||
"GROUP BY prozedur.id, prozedur.data_form_id, data_catalogue.name, data_catalogue_entry.name";
|
||||
|
||||
SQLQuery query = session.createSQLQuery(sql)
|
||||
.addScalar("procedure_id", StandardBasicTypes.INTEGER)
|
||||
.addScalar("data_form_id", StandardBasicTypes.INTEGER)
|
||||
.addScalar("data_catalogue", StandardBasicTypes.STRING)
|
||||
.addScalar("data_catalogue_entry", StandardBasicTypes.STRING)
|
||||
.addScalar("formname", StandardBasicTypes.STRING)
|
||||
.addScalar("datum", StandardBasicTypes.DATE);
|
||||
|
||||
query.setResultTransformer(Transformers.aliasToBean(VerweisVon.class));
|
||||
List<VerweisVon> result = query.list();
|
||||
try {
|
||||
for (VerweisVon var : result) {
|
||||
sql = var.getSQL();
|
||||
query = session.createSQLQuery(sql)
|
||||
.addScalar("value", StandardBasicTypes.INTEGER);
|
||||
if (query.uniqueResult() != null) {
|
||||
value = (Integer)query.uniqueResult();
|
||||
}
|
||||
if (value == Prozedur.getId()) {
|
||||
Procedure andereprozedur = onkostarApi.getProcedure(var.getProcedure_id());
|
||||
try {
|
||||
Map<String, Item> Felder = Prozedur.getAllValues();
|
||||
for (Map.Entry<String, Item> Feld: Felder.entrySet()) {
|
||||
if (Feld.getKey().length() > 6 && Feld.getKey().substring(0, 7).equals("Consent")) {
|
||||
if (Feld.getKey().equals("ConsentStatusEinwilligungDNPM")) {
|
||||
switch (Feld.getValue().getValue().toString()) {
|
||||
case "z":
|
||||
andereprozedur.setValue(Feld.getKey(), new Item(Feld.getKey(), "active"));
|
||||
break;
|
||||
case "a":
|
||||
andereprozedur.setValue(Feld.getKey(), new Item(Feld.getKey(), "rejected"));
|
||||
break;
|
||||
case "w":
|
||||
andereprozedur.setValue(Feld.getKey(), new Item(Feld.getKey(), "rejected"));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
andereprozedur.setValue(Feld.getKey(), Prozedur.getValue(Feld.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
onkostarApi.saveProcedure(andereprozedur);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
315
DNPMPlugins/src/main/java/DNPM/DNPMHelper.java
Normal file
315
DNPMPlugins/src/main/java/DNPM/DNPMHelper.java
Normal file
@ -0,0 +1,315 @@
|
||||
package DNPM;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.transform.Transformers;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import de.itc.onkostar.api.Disease;
|
||||
import de.itc.onkostar.api.IOnkostarApi;
|
||||
import de.itc.onkostar.api.Item;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
|
||||
import de.itc.onkostar.api.analysis.AnalyzerRequirement;
|
||||
import de.itc.onkostar.api.analysis.IProcedureAnalyzer;
|
||||
import de.itc.onkostar.api.analysis.OnkostarPluginType;
|
||||
|
||||
public class DNPMHelper implements IProcedureAnalyzer{
|
||||
|
||||
// Laden der API
|
||||
@Autowired
|
||||
private IOnkostarApi onkostarApi;
|
||||
|
||||
@Override
|
||||
public OnkostarPluginType getType() {
|
||||
// Typ des Plugins
|
||||
// Für das Interface IProcedureAnalyzer gültig sind ANALYZER und BACKEND_SERVICE
|
||||
return OnkostarPluginType.BACKEND_SERVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "UMR DNPM";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Methoden für DNPM-Formulare";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRelevantForDeletedProcedure() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSynchronous() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalyzerRequirement getRequirement() {
|
||||
return AnalyzerRequirement.PROCEDURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRelevantForAnalyzer(Procedure entry, Disease currentDisease) {
|
||||
// Plugin enthält nur Methoden für Formulare und soll nicht ausgeführt werden
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyze(Procedure entry, Disease currentDisease) {
|
||||
// wird nicht benötigt, da dass Plugin nicht ausgeführt wird
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getVerweise(final Map<String, Object> input) {
|
||||
int ProcedureId = (int) input.get("ProcedureId");
|
||||
int PatientId = (int) input.get("PatientId");
|
||||
int value = 0;
|
||||
List<Map<String, String>> VerbundeneFormulare = new ArrayList<Map<String, String>>();
|
||||
|
||||
try {
|
||||
SessionFactory sessionFactory = onkostarApi.getSessionFactory();
|
||||
Session session = sessionFactory.getCurrentSession();
|
||||
try {
|
||||
String sql = "SELECT prozedur.id AS procedure_id, prozedur.data_form_id, data_catalogue.name AS data_catalogue, data_catalogue_entry.name AS data_catalogue_entry, data_form.description AS formname, prozedur.beginndatum AS datum " +
|
||||
"FROM prozedur " +
|
||||
"LEFT JOIN data_form_data_catalogue ON data_form_data_catalogue.data_form_id = prozedur.data_form_id " +
|
||||
"LEFT JOIN data_catalogue_entry ON data_catalogue_entry.data_catalogue_id = data_form_data_catalogue.data_catalogue_id " +
|
||||
"LEFT JOIN data_catalogue ON data_catalogue.id = data_catalogue_entry.data_catalogue_id " +
|
||||
"LEFT JOIN data_form ON data_form.id = prozedur.data_form_id " +
|
||||
"WHERE patient_id = " + PatientId + " " +
|
||||
"AND geloescht = 0 " +
|
||||
"AND data_catalogue_entry.type = 'formReference' " +
|
||||
"GROUP BY prozedur.id, prozedur.data_form_id, data_catalogue.name, data_catalogue_entry.name";
|
||||
|
||||
SQLQuery query = session.createSQLQuery(sql)
|
||||
.addScalar("procedure_id", StandardBasicTypes.INTEGER)
|
||||
.addScalar("data_form_id", StandardBasicTypes.INTEGER)
|
||||
.addScalar("data_catalogue", StandardBasicTypes.STRING)
|
||||
.addScalar("data_catalogue_entry", StandardBasicTypes.STRING)
|
||||
.addScalar("formname", StandardBasicTypes.STRING)
|
||||
.addScalar("datum", StandardBasicTypes.DATE);
|
||||
|
||||
query.setResultTransformer(Transformers.aliasToBean(VerweisVon.class));
|
||||
List<VerweisVon> result = query.list();
|
||||
try {
|
||||
for (VerweisVon var : result) {
|
||||
sql = var.getSQL();
|
||||
query = session.createSQLQuery(sql)
|
||||
.addScalar("value", StandardBasicTypes.INTEGER);
|
||||
if (query.uniqueResult() != null) {
|
||||
value = (Integer)query.uniqueResult();
|
||||
}
|
||||
if (value == ProcedureId) {
|
||||
VerbundeneFormulare.add(Map.of("formular", var.getVerbundenesFormular()));
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return VerbundeneFormulare;
|
||||
}
|
||||
|
||||
public Object getSystemischeTherapienFromDiagnose(final Map<String, Object> input) {
|
||||
int DiagnoseId = (int) input.get("DiagnoseId");
|
||||
|
||||
String jsonStr = "";
|
||||
List<Object> Rueckgabewerte = new ArrayList<Object>();
|
||||
List<Procedure> Prozeduren = onkostarApi.getProceduresForDiseaseByForm(DiagnoseId, "OS.Systemische Therapie");
|
||||
// für jede Prozedur
|
||||
for (Procedure Prozedur : Prozeduren) {
|
||||
String Beginn = new String();
|
||||
String Ende = new String();
|
||||
String Wirkstoffe = new String();
|
||||
String Beendigung = new String();
|
||||
String Ergebnis = new String();
|
||||
|
||||
// SubstanzenCodesListe enthält die Liste der SubstanzenCodes
|
||||
List<Map<String, String>> SubstanzenCodesListe = new ArrayList<Map<String, String>>();
|
||||
|
||||
// alle Werte der Prozedur auslesen
|
||||
Map<String, Item> alleWerte = Prozedur.getAllValues();
|
||||
// Prozedurwerte enthält nur die interessanten Werte
|
||||
Map<String, Object> Prozedurwerte = new HashMap<>();
|
||||
// alle Werte durchgehen und die interessanten übernehmen
|
||||
for (Map.Entry<String, Item> WerteListe : alleWerte.entrySet()) {
|
||||
// Datum des Hauptformulars merken
|
||||
if (WerteListe.getKey().equals("Beendigung")) {
|
||||
Beendigung = WerteListe.getValue().getValue();
|
||||
}
|
||||
if (WerteListe.getKey().equals("Ergebnis")) {
|
||||
Ergebnis = WerteListe.getValue().getValue();
|
||||
}
|
||||
if (WerteListe.getKey().equals("Beginn")) {
|
||||
Beginn = WerteListe.getValue().getString();// + "," + WerteListe.getValue().getDateAccuracy();
|
||||
}
|
||||
if (WerteListe.getKey().equals("Ende")) {
|
||||
Ende = WerteListe.getValue().getString();// + "," + WerteListe.getValue().getDateAccuracy();
|
||||
}
|
||||
// im Subformular (SubstanzenList) Substanzen auslesen
|
||||
if (WerteListe.getKey().equals("SubstanzenList")) {
|
||||
int Index = -1;
|
||||
// SubstanzenCodesListe enthält die Liste der SubstanzenCodes eines Subformulars
|
||||
ArrayList<Map<String, Map<String, String>>> Subformular = new ArrayList<>();
|
||||
Subformular = WerteListe.getValue().getValue();
|
||||
// Werte aus Subformular verarbeiten
|
||||
for (Map<String, Map<String, String>> SubformularWerte: Subformular) {
|
||||
|
||||
// SubstanzenCodes enthält den Code und den Namen einer Substanz
|
||||
Map<String, String> SubstanzenCodes = new HashMap<String, String>();
|
||||
// Index des Codes (Substanz)
|
||||
Index = Arrays.asList((SubformularWerte.keySet().toArray())).indexOf("Substanz");
|
||||
if (SubformularWerte.values().toArray()[Index].toString().matches("[A-V]0[1-9][A-Z]{2}[0-9]{0,2}")) {
|
||||
SubstanzenCodes.put("system", "ATC");
|
||||
} else {
|
||||
SubstanzenCodes.put("system", "other");
|
||||
}
|
||||
|
||||
SubstanzenCodes.put("code", (String) SubformularWerte.values().toArray()[Index]);
|
||||
// Index der Substanz (Substanz_shortDescription)
|
||||
Index = Arrays.asList((SubformularWerte.keySet().toArray())).indexOf("Substanz_shortDescription");
|
||||
SubstanzenCodes.put("substance", (String) SubformularWerte.values().toArray()[Index]);
|
||||
SubstanzenCodesListe.add(SubstanzenCodes);
|
||||
Wirkstoffe = Wirkstoffe + (String) SubformularWerte.values().toArray()[Index] + ", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
ObjectMapper Obj = new ObjectMapper();
|
||||
try {
|
||||
jsonStr = Obj.writeValueAsString(SubstanzenCodesListe);
|
||||
} catch (JsonProcessingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Prozedurwerte.put("Beginn", Beginn);
|
||||
Prozedurwerte.put("Ende", Ende);
|
||||
Prozedurwerte.put("Beendigung", Beendigung);
|
||||
Prozedurwerte.put("Ergebnis", Ergebnis);
|
||||
Prozedurwerte.put("Wirkstoffe", Wirkstoffe.substring(0, Wirkstoffe.length()-2));
|
||||
Prozedurwerte.put("WirkstoffCodes", jsonStr);
|
||||
Rueckgabewerte.add(Prozedurwerte);
|
||||
}
|
||||
return Rueckgabewerte;
|
||||
}
|
||||
|
||||
public Object getProzedurenFromDiagnose(final Map<String, Object> input) {
|
||||
String dataForm = (String) input.get("dataForm");
|
||||
int DiagnoseId = (int) input.get("DiagnoseId");
|
||||
int PatientId = (int) input.get("PatientId");
|
||||
// Prozedur, Feldname, Wert
|
||||
|
||||
List<Object> Formulare = new ArrayList<Object>();
|
||||
String jsonStr = "";
|
||||
List<Procedure> Prozeduren = onkostarApi.getProceduresByPatientId(PatientId);
|
||||
for (Procedure Prozedur: Prozeduren ) {
|
||||
// Formular gehört zur aktuellen Diagnose und hat den angegebenen Namen
|
||||
if (Prozedur.getDiseaseIds().contains(DiagnoseId) && Prozedur.getFormName().contains(dataForm)) {
|
||||
// alle Werte auslesen
|
||||
Map<String, Item> Werte = Prozedur.getAllValues();
|
||||
Map<String, Object> Values = new HashMap<>();
|
||||
for (Map.Entry<String, Item> WerteListe: Werte.entrySet()) {
|
||||
Values.put(WerteListe.getKey(), WerteListe.getValue());
|
||||
// System.out.println(WerteListe.getKey() + ": " + WerteListe.getValue());
|
||||
}
|
||||
Map<String, Object> Formular = new HashMap<>();
|
||||
Formular.put("Formular", Prozedur.getFormName());
|
||||
Formular.put("Felder", Values);
|
||||
Formulare.add(Formular);
|
||||
}
|
||||
}
|
||||
ObjectMapper Obj = new ObjectMapper();
|
||||
try {
|
||||
jsonStr = Obj.writeValueAsString(Formulare);
|
||||
} catch (JsonProcessingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jsonStr;
|
||||
}
|
||||
|
||||
public Object getEmpfehlung(final Map<String, Object> input) {
|
||||
// Auslesen der Parameter aus 'input'
|
||||
int ProcedureID = (int) input.get("ProcedureID");
|
||||
|
||||
String sql;
|
||||
try {
|
||||
SessionFactory sessionFactory = onkostarApi.getSessionFactory();
|
||||
Session session = sessionFactory.getCurrentSession();
|
||||
try {
|
||||
sql = "SELECT * FROM prozedur "
|
||||
+ "LEFT JOIN dk_mtb_einzelempfehlung em ON em.id = prozedur.id "
|
||||
+ "WHERE prozedur.hauptprozedur_id = " + ProcedureID + " AND prozedur.geloescht = 0 AND prozedur.data_form_id = 489 "
|
||||
+ "ORDER BY beginndatum";
|
||||
|
||||
SQLQuery query = session.createSQLQuery(sql)
|
||||
.addScalar("id", StandardBasicTypes.STRING)
|
||||
.addScalar("genname", StandardBasicTypes.STRING)
|
||||
.addScalar("geneid", StandardBasicTypes.STRING)
|
||||
.addScalar("geneidlink", StandardBasicTypes.STRING)
|
||||
.addScalar("empfehlung", StandardBasicTypes.STRING)
|
||||
.addScalar("beginndatum", StandardBasicTypes.STRING);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String[]> rows = query.list();
|
||||
return rows;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object updateEmpfehlungPrio(final Map<String, Object> input) {
|
||||
// Auslesen der Parameter aus 'input'
|
||||
//int rid = (int) input.get("rid");
|
||||
Object rid = input.get("rid");
|
||||
Object strDate = input.get("bd");
|
||||
SQLQuery result = null;
|
||||
|
||||
//String strD = strDate.toString();
|
||||
//String CompareDate = strD.substring(1, 11);
|
||||
|
||||
//DateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
String sql;
|
||||
|
||||
try {
|
||||
sql = "UPDATE prozedur SET beginndatum = '"+ strDate +"' WHERE id = '"+ rid +"' ";
|
||||
result = onkostarApi.getSessionFactory().getCurrentSession().createSQLQuery(sql);
|
||||
result.executeUpdate();
|
||||
return true;
|
||||
|
||||
} catch (Exception e) {
|
||||
return "Achtung: Ein Fehler ist aufgetreten, Änderung konnte nicht gespeichert werden!";
|
||||
//return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
98
DNPMPlugins/src/main/java/DNPM/Merkmalskatalog.java
Normal file
98
DNPMPlugins/src/main/java/DNPM/Merkmalskatalog.java
Normal file
@ -0,0 +1,98 @@
|
||||
package DNPM;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import de.itc.onkostar.api.Disease;
|
||||
import de.itc.onkostar.api.IOnkostarApi;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
import de.itc.onkostar.api.analysis.AnalyzerRequirement;
|
||||
import de.itc.onkostar.api.analysis.IProcedureAnalyzer;
|
||||
import de.itc.onkostar.api.analysis.OnkostarPluginType;
|
||||
|
||||
public class Merkmalskatalog implements IProcedureAnalyzer{
|
||||
@Autowired
|
||||
private IOnkostarApi onkostarApi;
|
||||
|
||||
@Override
|
||||
public OnkostarPluginType getType() {
|
||||
return OnkostarPluginType.BACKEND_SERVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "UMR Merkmalskatalog";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Methoden für Merkmalskataloge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRelevantForDeletedProcedure() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSynchronous() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnalyzerRequirement getRequirement() {
|
||||
return AnalyzerRequirement.PROCEDURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRelevantForAnalyzer(Procedure procedure, Disease currentDisease) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyze(Procedure procedurea, Disease disease) {}
|
||||
|
||||
public Object getMerkmalskatalog(final Map<String, Object> input) {
|
||||
String Merkmalskatalog = (String) input.get("Merkmalskatalog");
|
||||
String Spalten = (String) input.get("Spalten");
|
||||
String[] SpaltenArray = Spalten.split("\\s*,\\s*");
|
||||
String sql;
|
||||
try {
|
||||
SessionFactory sessionFactory = onkostarApi.getSessionFactory();
|
||||
Session session = sessionFactory.getCurrentSession();
|
||||
try {
|
||||
sql = "SELECT p.id, p.code, p.shortdesc, p.description, p.note, p.synonyms "
|
||||
+ "FROM property_catalogue "
|
||||
+ "LEFT JOIN property_catalogue_version ON property_catalogue_version.datacatalog_id = property_catalogue.id "
|
||||
+ "LEFT JOIN property_catalogue_version_entry p ON p.property_version_id = property_catalogue_version.id "
|
||||
+ "WHERE name = '" + Merkmalskatalog + "' AND aktiv = 1 "
|
||||
+ "ORDER BY position ASC";
|
||||
|
||||
SQLQuery query = session.createSQLQuery(sql);
|
||||
|
||||
for (int i = 0; i < SpaltenArray.length; i++) {
|
||||
query.addScalar(SpaltenArray[i], StandardBasicTypes.STRING);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String[]> rows = query.list();
|
||||
return rows;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
54
DNPMPlugins/src/main/java/DNPM/VerweisVon.java
Normal file
54
DNPMPlugins/src/main/java/DNPM/VerweisVon.java
Normal file
@ -0,0 +1,54 @@
|
||||
package DNPM;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class VerweisVon {
|
||||
private int procedure_id;
|
||||
private int data_form_id;
|
||||
private String data_catalogue;
|
||||
private String data_catalogue_entry;
|
||||
private String formname;
|
||||
private Date datum;
|
||||
|
||||
public VerweisVon() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public int getProcedure_id() { return this.procedure_id; }
|
||||
public int getData_form_id() { return this.data_form_id; }
|
||||
public String getData_catalogue_name() { return this.data_catalogue; }
|
||||
public String getData_catalogue_entry_name() { return this.data_catalogue_entry; }
|
||||
public String getFormname() { return this.formname; }
|
||||
public Date getDate() { return this.datum; }
|
||||
public String getTable() {
|
||||
return "dk_" + this.data_catalogue.toLowerCase().replaceAll("[^a-zA-Z0-9]", "_");
|
||||
}
|
||||
public String getField() {
|
||||
return this.data_catalogue_entry.toLowerCase();
|
||||
}
|
||||
public String getSQL() {
|
||||
return "SELECT " + this.getField() + " AS value FROM " + this.getTable() + " WHERE id = " + this.getProcedure_id();
|
||||
}
|
||||
private String getDatumAsString() {
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy");
|
||||
String Datum = null;
|
||||
if (this.getDate() != null) {
|
||||
Datum = DATE_FORMAT.format(this.getDate());
|
||||
}
|
||||
return Datum;
|
||||
}
|
||||
public String getVerbundenesFormular() {
|
||||
String FName = "Formular " + this.getFormname();
|
||||
if (this.getDatumAsString() != null ) { FName += " vom " + this.getDatumAsString(); }
|
||||
return FName;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void setProcedure_id(int procedure_id) {this.procedure_id = procedure_id; }
|
||||
public void setData_form_id(int data_form_id) {this.data_form_id = data_form_id; }
|
||||
public void setData_catalogue_name(String data_catalogue_name) {this.data_catalogue = data_catalogue_name; }
|
||||
public void setData_catalogue_entry_name(String data_catalogue_entry) {this.data_catalogue_entry = data_catalogue_entry; }
|
||||
public void setDate(Date datum) { this.datum = datum; }
|
||||
public void setFormname(String formname) { this.formname = formname; }
|
||||
}
|
7
DNPMPlugins/src/main/java/DNPM/logger.java
Normal file
7
DNPMPlugins/src/main/java/DNPM/logger.java
Normal file
@ -0,0 +1,7 @@
|
||||
package DNPM;
|
||||
|
||||
public class logger {
|
||||
public static void error (String messagetext) {
|
||||
System.out.println(messagetext);
|
||||
}
|
||||
}
|
201
DNPMPlugins/src/main/resources/app/lib/umr/FormUtils.js
Normal file
201
DNPMPlugins/src/main/resources/app/lib/umr/FormUtils.js
Normal file
@ -0,0 +1,201 @@
|
||||
class FormUtils {
|
||||
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
|
||||
if (!this.context.genericEditForm) {
|
||||
console.error('Context does not contain "genericEditForm". Please use "new FormUtils(this)" or methods will return undefined values!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns field with given name from main form if it exists
|
||||
* @param fieldName
|
||||
* @returns {undefined|*}
|
||||
*/
|
||||
getMainformField(fieldName) {
|
||||
if (this.context.genericEditForm) {
|
||||
const query = '[originalName=' + fieldName + ']';
|
||||
const fields = this.context.genericEditForm
|
||||
.query(query)
|
||||
.filter(e => e.ownerCt.xtype === 'form' || e.ownerCt.xtype === 'panel' && e.ownerCt.title.length !== 0);
|
||||
|
||||
if (fields.length > 0) {
|
||||
return this.context.genericEditForm.down('#' + fields[0].id);
|
||||
}
|
||||
console.error('Field with name "' + fieldName + '" not found in main form!');
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns field with given field name found at given index within whole form.
|
||||
* @param fieldName
|
||||
* @param index
|
||||
* @returns {undefined|*}
|
||||
*/
|
||||
getFieldAtIndex(fieldName, index) {
|
||||
if (this.context.genericEditForm) {
|
||||
const query = '[originalName=' + fieldName + ']';
|
||||
const fields = this.context.genericEditForm.query(query);
|
||||
if (fields.length > index) {
|
||||
return this.context.genericEditForm.down('#' + fields[index].id);
|
||||
}
|
||||
console.error('Field with name "' + fieldName + '" and index "' + index + '" not found!');
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns field with given field name found in section with given name.
|
||||
* @param fieldName
|
||||
* @param sectionName
|
||||
* @returns {undefined|*}
|
||||
*/
|
||||
getFieldInSection(fieldName, sectionName) {
|
||||
if (this.genericEditForm) {
|
||||
const query = '[originalName=' + fieldName + ']';
|
||||
const fields = this.context.genericEditForm
|
||||
.query(query)
|
||||
.filter(e => e.ownerCt.xtype === 'panel' && e.ownerCt.ownerCt.originalName === sectionName);
|
||||
if (fields.length > 0) {
|
||||
return this.context.genericEditForm.down('#' + fields[0].id);
|
||||
}
|
||||
console.error('Field with name "' + fieldName + '" not found in section with name "' + sectionName + '"!');
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns value of field with given name from main form if it exists.
|
||||
* @param fieldName
|
||||
* @returns {undefined|*}
|
||||
*/
|
||||
getMainformFieldValue(fieldName) {
|
||||
let mainformField = this.getMainformField(fieldName);
|
||||
if (mainformField) {
|
||||
return mainformField.getValue();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates field with given name to given new value.
|
||||
* The field must reside in main form.
|
||||
* @param fieldName
|
||||
* @param newValue
|
||||
* @returns {undefined|*}
|
||||
*/
|
||||
setMainformFieldValue(fieldName, newValue) {
|
||||
let mainformField = this.getMainformField(fieldName);
|
||||
if (mainformField) {
|
||||
return mainformField.setValue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns value of field with given name in section with given name if it exists.
|
||||
* @param fieldName
|
||||
* @param sectionName
|
||||
* @returns {undefined|*}
|
||||
*/
|
||||
getFieldValueInSection(fieldName, sectionName) {
|
||||
let sectionField = this.getFieldInSection(fieldName, sectionName);
|
||||
if (sectionField) {
|
||||
return sectionField.getValue();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates field with given name in section with given name new value.
|
||||
* The field must reside in main form.
|
||||
* @param fieldName
|
||||
* @param sectionName
|
||||
* @param newValue
|
||||
* @returns {undefined|*}
|
||||
*/
|
||||
setFieldValueInSection(fieldName, sectionName, newValue) {
|
||||
let sectionField = this.getFieldInSection(fieldName, sectionName);
|
||||
if (sectionField) {
|
||||
return sectionField.setValue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns value of field with given field name found at given index within whole form.
|
||||
* @param fieldName
|
||||
* @param index
|
||||
* @returns {undefined|*}
|
||||
*/
|
||||
getFieldValueAtIndex(fieldName, index) {
|
||||
let field = this.getFieldAtIndex(fieldName, index);
|
||||
if (field) {
|
||||
return field.getValue();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates value of field with given field name found at given index within whole form.
|
||||
* @param fieldName
|
||||
* @param index
|
||||
* @param newValue
|
||||
* @returns {undefined|*}
|
||||
*/
|
||||
setFieldValueAtIndex(fieldName, index, newValue) {
|
||||
let field = this.getFieldAtIndex(fieldName, index);
|
||||
if (field) {
|
||||
field.setValue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all values for all fields with given name.
|
||||
* @param fieldName
|
||||
* @returns {*|*[]}
|
||||
*/
|
||||
getFieldValues(fieldName) {
|
||||
if (this.context.genericEditForm) {
|
||||
const query = '[originalName=' + fieldName + ']';
|
||||
const fields = this.context.genericEditForm.query(query);
|
||||
return fields.map(f => this.context.genericEditForm.down('#' + f.id).getValue());
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts blocks within given subform field name.
|
||||
* @param subformFieldName
|
||||
* @returns {undefined|*|number}
|
||||
*/
|
||||
subformBlockCount(subformFieldName) {
|
||||
if (this.context.genericEditForm) {
|
||||
const query = '[originalName=' + subformFieldName + ']';
|
||||
const elements = this.context.genericEditForm.query(query);
|
||||
|
||||
if (elements.length === 0) return 0;
|
||||
|
||||
return elements
|
||||
.map(e => e.numberOfBlocks)
|
||||
.reduce((sum, num) => sum + num);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns subform field names for given subform name.
|
||||
* @param subformName
|
||||
* @returns {undefined|*}
|
||||
*/
|
||||
getSubformFieldNames(subformName) {
|
||||
if (this.context.genericEditForm) {
|
||||
const query = '[formName=' + subformName + ']';
|
||||
|
||||
return Ext.ComponentQuery
|
||||
.query(query)
|
||||
.map(e => e.originalName);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
|
||||
|
||||
<bean id="DNPMHelper" class="DNPM.DNPMHelper" />
|
||||
<bean id="Merkmalskatalog" class="DNPM.Merkmalskatalog" />
|
||||
<bean id="ConsentManager" class="DNPM.ConsentManager" />
|
||||
|
||||
<context:component-scan base-package="ATCCodes"/>
|
||||
|
||||
<mvc:resources mapping="/app/lib/umr/**" location="classpath:/app/lib/umr/" />
|
||||
</beans>
|
@ -0,0 +1 @@
|
||||
onkostar-api=2.11.1.1
|
Reference in New Issue
Block a user