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

Mapping für Formular "MR.MTB_Anmeldung" zu Therapieplan-Protokollauszug hinzugefügt

This commit is contained in:
2023-03-21 17:32:48 +01:00
parent 9534fec4ee
commit 28b834d922
10 changed files with 284 additions and 67 deletions

View File

@ -6,13 +6,13 @@ import de.itc.onkostar.api.Procedure;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.time.Instant;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.*;
import static org.assertj.core.api.Assertions.assertThat;
@ -28,7 +28,26 @@ public class DefaultMtbServiceTest {
@Mock IOnkostarApi onkostarApi
) {
this.onkostarApi = onkostarApi;
this.service = new DefaultMtbService();
this.service = new DefaultMtbService(onkostarApi);
}
private static Set<Map.Entry<String, Class<? extends ProcedureToProtocolMapper>>> expectedMappings() {
return Map.ofEntries(
Map.entry("OS.Tumorkonferenz", OsTumorkonferenzToProtocolMapper.class),
Map.entry("OS.Tumorkonferenz.VarianteUKW", OsTumorkonferenzVarianteUkwToProtocolMapper.class),
Map.entry("MR.MTB_Anmeldung", MrMtbAnmeldungToProtocolMapper.class)
).entrySet();
}
@ParameterizedTest
@MethodSource("expectedMappings")
void testShouldMapFormNameToMapper(Map.Entry<String, Class<?>> expectedMapping) {
var procedure = new Procedure(onkostarApi);
procedure.setFormName(expectedMapping.getKey());
var actual = service.procedureToProtocolMapper(procedure);
assertThat(actual).isExactlyInstanceOf(expectedMapping.getValue());
}
@Test

View File

@ -0,0 +1,87 @@
package DNPM.services.mtb;
import de.itc.onkostar.api.IOnkostarApi;
import de.itc.onkostar.api.Item;
import de.itc.onkostar.api.Procedure;
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.Set;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doAnswer;
@ExtendWith(MockitoExtension.class)
public class MrMtbAnmeldungToProtocolMapperTest {
private IOnkostarApi onkostarApi;
private MrMtbAnmeldungToProtocolMapper mapper;
@BeforeEach
void setup(
@Mock IOnkostarApi onkostarApi
) {
this.onkostarApi = onkostarApi;
this.mapper = new MrMtbAnmeldungToProtocolMapper(onkostarApi);
}
@Test
void testShouldMapCompletedForm() {
var anmeldung = new Procedure(onkostarApi);
anmeldung.setId(1);
anmeldung.setFormName("MR.MTB_Anmeldung");
anmeldung.setValue("Fragestellung", new Item("Fragestellung", "Frage?"));
anmeldung.setValue("Empfehlung", new Item("Empfehlung", 2));
var empfehlung = new Procedure(onkostarApi);
empfehlung.setId(2);
empfehlung.setFormName("MR.MTB_Empfehlung");
var einzelempfehlung1 = new Procedure(onkostarApi);
einzelempfehlung1.setId(10);
einzelempfehlung1.setFormName("MR.MTB_Einzelempfehlung");
einzelempfehlung1.setValue("Prioritaet", new Item("Empfehlungsprio", 1));
einzelempfehlung1.setValue("Empfehlung", new Item("Empfehlung", "Empfehlung1"));
var einzelempfehlung2 = new Procedure(onkostarApi);
einzelempfehlung2.setId(20);
einzelempfehlung2.setFormName("MR.MTB_Einzelempfehlung");
einzelempfehlung2.setValue("Prioritaet", new Item("Empfehlungsprio", 2));
einzelempfehlung2.setValue("Empfehlung", new Item("Empfehlung", "Empfehlung2"));
doAnswer(invocationOnMock -> {
var procedureId = invocationOnMock.getArgument(0, Integer.class);
if (2 == procedureId) {
return empfehlung;
} else if (10 == procedureId) {
return einzelempfehlung1;
} else if (20 == procedureId) {
return einzelempfehlung2;
}
return null;
}).when(onkostarApi).getProcedure(anyInt());
doAnswer(invocationOnMock -> {
var procedureId = invocationOnMock.getArgument(0, Integer.class);
if (2 == procedureId) {
return Set.of(einzelempfehlung1, einzelempfehlung2);
}
return null;
}).when(onkostarApi).getSubprocedures(anyInt());
var actual = this.mapper.apply(anmeldung);
assertThat(actual).isPresent();
assertThat(actual.get()).isEqualTo(
"Fragestellung:\nFrage?\n\n" +
"Empfehlung:\nEmpfehlung1\n\n" +
"Empfehlung:\nEmpfehlung2"
);
}
}

View File

@ -1,47 +0,0 @@
package DNPM.services.mtb;
import de.itc.onkostar.api.IOnkostarApi;
import de.itc.onkostar.api.Procedure;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Map;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class)
public class MtbServiceTest {
private IOnkostarApi onkostarApi;
@BeforeEach
void setup(
@Mock IOnkostarApi onkostarApi
) {
this.onkostarApi = onkostarApi;
}
private static Set<Map.Entry<String, Class<? extends ProcedureToProtocolMapper>>> expectedMappings() {
return Map.ofEntries(
Map.entry("OS.Tumorkonferenz", OsTumorkonferenzToProtocolMapper.class),
Map.entry("OS.Tumorkonferenz.VarianteUKW", OsTumorkonferenzVarianteUkwToProtocolMapper.class)
).entrySet();
}
@ParameterizedTest
@MethodSource("expectedMappings")
void testShouldMapFormNameToMapper(Map.Entry<String, Class<?>> expectedMapping) {
var procedure = new Procedure(onkostarApi);
procedure.setFormName(expectedMapping.getKey());
var actual = MtbService.procedureToProtocolMapper(procedure);
assertThat(actual).isExactlyInstanceOf(expectedMapping.getValue());
}
}

View File

@ -0,0 +1,46 @@
package DNPM.services.mtb;
import de.itc.onkostar.api.IOnkostarApi;
import de.itc.onkostar.api.Item;
import de.itc.onkostar.api.Procedure;
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.time.Instant;
import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class)
public class OsTumorkonferenzToProtocolMapperTest {
private IOnkostarApi onkostarApi;
private OsTumorkonferenzToProtocolMapper mapper;
@BeforeEach
void setup(
@Mock IOnkostarApi onkostarApi
) {
this.onkostarApi = onkostarApi;
this.mapper = new OsTumorkonferenzToProtocolMapper();
}
@Test
void testShouldReturnMtbProtocolForDefaultImplementation() {
var procedure = new Procedure(onkostarApi);
procedure.setFormName("OS.Tumorkonferenz");
procedure.setStartDate(Date.from(Instant.parse("2023-01-01T00:00:00Z")));
procedure.setValue("Fragestellung", new Item("Fragestellung", "Test ok?"));
procedure.setValue("Empfehlung", new Item("Empfehlung", "Rerun Test if not ok!"));
var actual = mapper.apply(procedure);
assertThat(actual).isPresent();
assertThat(actual.get()).isEqualTo("Fragestellung:\nTest ok?\n\nEmpfehlung:\nRerun Test if not ok!");
}
}

View File

@ -0,0 +1,46 @@
package DNPM.services.mtb;
import de.itc.onkostar.api.IOnkostarApi;
import de.itc.onkostar.api.Item;
import de.itc.onkostar.api.Procedure;
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.time.Instant;
import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class)
public class OsTumorkonferenzVarianteUkwToProtocolMapperTest {
private IOnkostarApi onkostarApi;
private OsTumorkonferenzVarianteUkwToProtocolMapper mapper;
@BeforeEach
void setup(
@Mock IOnkostarApi onkostarApi
) {
this.onkostarApi = onkostarApi;
this.mapper = new OsTumorkonferenzVarianteUkwToProtocolMapper();
}
@Test
void testShouldReturnMtbProtocolForDefaultImplementation() {
var procedure = new Procedure(onkostarApi);
procedure.setFormName("OS.Tumorkonferenz.VarianteUKW");
procedure.setStartDate(Date.from(Instant.parse("2023-01-01T00:00:00Z")));
procedure.setValue("Fragestellung", new Item("Fragestellung", "Test ok?"));
procedure.setValue("Empfehlung", new Item("Empfehlung", "Rerun Test if not ok!"));
var actual = mapper.apply(procedure);
assertThat(actual).isPresent();
assertThat(actual.get()).isEqualTo("Fragestellung:\nTest ok?\n\nEmpfehlung:\nRerun Test if not ok!");
}
}