1
0
mirror of https://github.com/pcvolkmer/onkostar-plugin-dnpm.git synced 2025-07-02 01:02:55 +00:00

Issue #7: Aktualisiere MTB + Datum in Reevaluation und gen. Beratung

This commit is contained in:
2023-03-14 11:05:31 +01:00
parent 53ee3f8645
commit c3e96d18fc
3 changed files with 222 additions and 58 deletions

166
pom.xml
View File

@ -1,64 +1,64 @@
<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>
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>
<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>
<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>
<spring-version>4.3.8.RELEASE</spring-version>
</properties>
<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>
<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>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.11.Final</version>
<scope>provided</scope>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.11.Final</version>
<scope>provided</scope>
</dependency>
<!-- zusätzliche Erweiterungen. -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
<scope>provided</scope>
</dependency>
<!-- zusätzliche Erweiterungen. -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
@ -77,6 +77,60 @@
<version>2.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- Test dependencies -->
<!-- Wird nur für Unit-tests benoetigt -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-base</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi</groupId>
<artifactId>hapi-structures-v26</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
</project>

View File

@ -89,17 +89,57 @@ public class TherapieplanAnalyzer implements IProcedureAnalyzer {
@Override
public void analyze(Procedure procedure, Disease disease) {
updateMtbInSections(procedure);
updateMtbInSubforms(procedure);
}
/**
* Verlinke MTB und Übernahme Datum aus Hauptformular in weiteren Bereichen
* "Humangenetische Beratung" und "Reevaluation", wenn erforderlich.
*
* @param procedure Die Prozedur mit Hauptformular
*/
private void updateMtbInSections(Procedure procedure) {
if (
null != onkostarApi.getGlobalSetting("mehrere_mtb_in_mtbepisode")
&& onkostarApi.getGlobalSetting("mehrere_mtb_in_mtbepisode").equals("true")
||
!procedure.getValue("humangenberatung").getString().equals("1")
&& !procedure.getValue("reevaluation").getString().equals("1")
) {
return;
}
var mtbReference = procedure.getValue("referstemtb").getInt();
var mtbDate = procedure.getValue("datum").getDate();
if (mtbReference != procedure.getValue("reftkhumangenber").getInt() && !mtbDate.equals(procedure.getValue("datumtkhumangenber").getDate())) {
procedure.setValue("reftkhumangenber", new Item("ref_tk_humangenber", mtbReference));
procedure.setValue("datumtkhumangenber", new Item("datum_tk_humangenber", mtbDate));
}
if (mtbReference != procedure.getValue("reftkreevaluation").getInt() && !mtbDate.equals(procedure.getValue("datumtkreevaluation").getDate())) {
procedure.setValue("reftkreevaluation", new Item("ref_tk_reevaluation", mtbReference));
procedure.setValue("datumtkreevaluation", new Item("datum_tk_reevaluation", mtbDate));
}
try {
onkostarApi.saveProcedure(procedure, false);
} catch (Exception e) {
logger.error("Formular 'DNPM Therapieplan' konnte nicht aktualisiert werden", e);
}
}
/**
* Verlinke MTB und Übernahme Datum aus Hauptformular in Unterformularen
*
* @param procedure Die Prozedur mit Hauptformular
*/
// TODO: 13.03.23 Onkostar führt nach Speicherung eines Unterformulars erneut eine Speicherung des Hauptformulars aus - ggf eigene Speicher-Methode ohne Verwendung der Onkostar-API implementieren.
private void updateMtbInSubforms(Procedure procedure) {
if (onkostarApi.getGlobalSetting("mehrere_mtb_in_mtbepisode").equals("true")) {
if (
null != onkostarApi.getGlobalSetting("mehrere_mtb_in_mtbepisode")
&& onkostarApi.getGlobalSetting("mehrere_mtb_in_mtbepisode").equals("true")
) {
return;
}

View File

@ -0,0 +1,70 @@
package DNPM.forms;
import DNPM.services.FormService;
import de.itc.onkostar.api.IOnkostarApi;
import de.itc.onkostar.api.Item;
import de.itc.onkostar.api.Procedure;
import de.itc.onkostar.api.constants.JaNeinUnbekannt;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Date;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
public class TherapieplanAnalyzerTest {
@Mock
private IOnkostarApi onkostarApi;
@Mock
private FormService formService;
private TherapieplanAnalyzer therapieplanAnalyzer;
@BeforeEach
void setUp() {
this.therapieplanAnalyzer = new TherapieplanAnalyzer(onkostarApi, formService);
}
@Test
void shouldNotUpdateSubformsOrSectionsIfMultipleMtbConfiguration() throws Exception {
doAnswer(invocationOnMock -> {
var settingName = invocationOnMock.getArgument(0, String.class);
if (settingName.equals("mehrere_mtb_in_mtbepisode")) {
return "true";
}
return null;
}).when(onkostarApi).getGlobalSetting(anyString());
this.therapieplanAnalyzer.analyze(new Procedure(onkostarApi), null);
verify(onkostarApi, never()).saveProcedure(any(Procedure.class), anyBoolean());
}
@Test
void shouldNotUpdateSectionsIfSectionsNotEnabled() throws Exception {
when(onkostarApi.getGlobalSetting(anyString())).thenReturn(null);
var testProcedure = new Procedure(onkostarApi);
testProcedure.setId(1000);
// Setzen MTB Referenz und Datum MTB
testProcedure.setValue("referstemtb", new Item("ref_tumorkonferenz", 1234));
testProcedure.setValue("datum", new Item("datum", new Date()));
// Keine humangenetische Beratung und keine Reevaluation empfohlen
testProcedure.setValue("humangenberatung", new Item("humangen_beratung", JaNeinUnbekannt.NEIN));
testProcedure.setValue("reevaluation", new Item("reevaluation", JaNeinUnbekannt.NEIN));
this.therapieplanAnalyzer.analyze(testProcedure, null);
verify(onkostarApi, never()).saveProcedure(any(Procedure.class), anyBoolean());
}
}