1
0
mirror of https://github.com/pcvolkmer/onkostar-plugin-dnpm.git synced 2025-07-03 09:42:54 +00:00

Zusätzliche Prüfung auf Formularname vor Consentübernahme hinzugefügt

Diese zusätzliche Prüfung ermöglicht die Erkennung, ob der aktuell ausgewählte
ConsentManagerService die entsprechende Prozedur bearbeiten und Consent-Daten
in das Formular "DNPM-Klinik/Anamnese" übernehmen kann.

Die Standardimplementierung prüft dabei nur, ob die Prozedur nicht `null` ist.
This commit is contained in:
2023-04-04 16:04:54 +02:00
parent c4d9abdf0c
commit 541d2e3a03
5 changed files with 42 additions and 2 deletions

View File

@ -69,7 +69,12 @@ public class ConsentManager implements IProcedureAnalyzer {
@Override
public void analyze(Procedure prozedur, Disease erkrankung) {
consentManagerServiceFactory.currentUsableInstance().applyConsent(prozedur);
var consentManagerService = consentManagerServiceFactory.currentUsableInstance();
if (! consentManagerService.canApply(prozedur)) {
logger.error("Fehler im ConsentManagement: Kann Prozedur mit Formularnamen '{}' nicht anwenden", prozedur.getFormName());
return;
}
consentManagerService.applyConsent(prozedur);
}
}

View File

@ -15,4 +15,13 @@ public interface ConsentManagerService {
*/
void applyConsent(Procedure procedure);
/**
* Optionale Prüfung, ob die angegebene Prozedur angewendet werden kann.
* @param procedure Anzuwendende Prozedur
* @return Gibt <code>true</code> zurück, wenn die Prozedur angewendet werden kann.
*/
default boolean canApply(Procedure procedure) {
return null != procedure;
}
}

View File

@ -22,7 +22,7 @@ import java.util.Map;
*/
public class MrConsentManagerService implements ConsentManagerService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final IOnkostarApi onkostarApi;
@ -30,6 +30,11 @@ public class MrConsentManagerService implements ConsentManagerService {
this.onkostarApi = onkostarApi;
}
@Override
public boolean canApply(Procedure procedure) {
return null != procedure && procedure.getFormName().equals("MR.Consent");
}
/**
* Wende Consent an, wenn dieses Consent-Formular gespeichert wird
*

View File

@ -23,6 +23,11 @@ public class UkwConsentManagerService implements ConsentManagerService {
this.onkostarApi = onkostarApi;
}
@Override
public boolean canApply(Procedure procedure) {
return null != procedure && procedure.getFormName().equals("Excel-Formular");
}
/**
* Wende Consent an, wenn dieses Consent-Formular gespeichert wird
*

View File

@ -35,6 +35,8 @@ class ConsentManagerTest {
void shouldRunServiceMethodsOnAnalyzeCalled() {
var consentManagerServiceMock = mock(MrConsentManagerService.class);
when(consentManagerServiceMock.canApply(any(Procedure.class))).thenReturn(true);
when(this.consentManagerServiceFactory.currentUsableInstance())
.thenReturn(consentManagerServiceMock);
@ -43,4 +45,18 @@ class ConsentManagerTest {
verify(consentManagerServiceMock, times(1)).applyConsent(any(Procedure.class));
}
@Test
void shouldNotRunServiceMethodsIfProcedureCannotBeAppliesForForm() {
var consentManagerServiceMock = mock(MrConsentManagerService.class);
when(consentManagerServiceMock.canApply(any(Procedure.class))).thenReturn(false);
when(this.consentManagerServiceFactory.currentUsableInstance())
.thenReturn(consentManagerServiceMock);
this.consentManager.analyze(new Procedure(onkostarApi), null);
verify(consentManagerServiceMock, times(0)).applyConsent(any(Procedure.class));
}
}