1
0
mirror of https://github.com/pcvolkmer/mv64e-onkostar-data.git synced 2025-09-12 23:42:52 +00:00

feat: add catalogue for Immunhisto and PCR

This commit is contained in:
2025-08-22 16:49:01 +02:00
parent 09843349d9
commit 202fab9b50
5 changed files with 318 additions and 0 deletions

View File

@@ -97,6 +97,10 @@ public class DataCatalogueFactory {
return MolekulargenuntersuchungCatalogue.create(jdbcTemplate);
} else if (c == MolekulargenMsiCatalogue.class) {
return MolekulargenMsiCatalogue.create(jdbcTemplate);
} else if (c == MolekularImmunhistoCatalogue.class) {
return MolekularImmunhistoCatalogue.create(jdbcTemplate);
} else if (c == MolekularPcrCatalogue.class) {
return MolekularPcrCatalogue.create(jdbcTemplate);
} else if (c == RebiopsieCatalogue.class) {
return RebiopsieCatalogue.create(jdbcTemplate);
} else if (c == ReevaluationCatalogue.class) {

View File

@@ -0,0 +1,46 @@
/*
* This file is part of mv64e-onkostar-data
*
* Copyright (C) 2025 Paul-Christian Volkmer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package dev.pcvolkmer.onco.datamapper.datacatalogues;
import org.springframework.jdbc.core.JdbcTemplate;
/**
* Load raw result sets from database table 'dk_molekularimmunhisto'
*
* @author Paul-Christian Volkmer
* @since 0.1
*/
public class MolekularImmunhistoCatalogue extends AbstractSubformDataCatalogue {
private MolekularImmunhistoCatalogue(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}
@Override
protected String getTableName() {
return "dk_molekularimmunhisto";
}
public static MolekularImmunhistoCatalogue create(JdbcTemplate jdbcTemplate) {
return new MolekularImmunhistoCatalogue(jdbcTemplate);
}
}

View File

@@ -0,0 +1,46 @@
/*
* This file is part of mv64e-onkostar-data
*
* Copyright (C) 2025 Paul-Christian Volkmer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package dev.pcvolkmer.onco.datamapper.datacatalogues;
import org.springframework.jdbc.core.JdbcTemplate;
/**
* Load raw result sets from database table 'dk_molekularpcr'
*
* @author Paul-Christian Volkmer
* @since 0.1
*/
public class MolekularPcrCatalogue extends AbstractSubformDataCatalogue {
private MolekularPcrCatalogue(JdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}
@Override
protected String getTableName() {
return "dk_molekularpcr";
}
public static MolekularPcrCatalogue create(JdbcTemplate jdbcTemplate) {
return new MolekularPcrCatalogue(jdbcTemplate);
}
}

View File

@@ -0,0 +1,111 @@
/*
* This file is part of mv64e-onkostar-data
*
* Copyright (C) 2025 Paul-Christian Volkmer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package dev.pcvolkmer.onco.datamapper.datacatalogues;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
class MolekularImmunhistochemieCatalogueTest {
JdbcTemplate jdbcTemplate;
MolekularImmunhistoCatalogue catalogue;
@BeforeEach
void setUp(@Mock JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
this.catalogue = MolekularImmunhistoCatalogue.create(jdbcTemplate);
}
@Test
void shouldUseCorrectQuery(@Mock Map<String, Object> resultSet) {
doAnswer(invocationOnMock -> List.of(resultSet))
.when(jdbcTemplate)
.queryForList(anyString(), anyInt());
this.catalogue.getById(1);
var captor = ArgumentCaptor.forClass(String.class);
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
assertThat(captor.getValue())
.isEqualTo("SELECT patient.patienten_id, dk_molekularimmunhisto.*, prozedur.patient_id, prozedur.hauptprozedur_id FROM dk_molekularimmunhisto JOIN prozedur ON (prozedur.id = dk_molekularimmunhisto.id) JOIN patient ON (patient.id = prozedur.patient_id) WHERE geloescht = 0 AND prozedur.id = ?");
}
@Test
void shouldUseCorrectMerkmalQuery(@Mock Map<String, Object> resultSet) {
when(resultSet.get(anyString()))
.thenReturn(Map.of("feldname", "name", "feldwert", "wert"));
doAnswer(invocationOnMock -> List.of(resultSet))
.when(jdbcTemplate)
.queryForList(anyString(), anyInt());
this.catalogue.getMerkmaleById(1);
var captor = ArgumentCaptor.forClass(String.class);
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
assertThat(captor.getValue())
.isEqualTo("SELECT feldname, feldwert FROM dk_molekularimmunhisto_merkmale WHERE eintrag_id = ?");
}
@Test
void shouldUseMerkmalList() {
doAnswer(invocationOnMock -> {
var sql = invocationOnMock.getArgument(0, String.class);
ArrayList<Map<String, Object>> result = new ArrayList<>();
if (sql.startsWith("SELECT feldname")) {
result.add(Map.of("feldname", "name", "feldwert", "wert1"));
result.add(Map.of("feldname", "name", "feldwert", "wert2"));
} else {
var map = new HashMap<String, Object>();
map.put("id", 1);
map.put("name", "x");
result.add(map);
}
return result;
})
.when(jdbcTemplate)
.queryForList(anyString(), anyInt());
var result = this.catalogue.getById(1);
assertThat(result.getInteger("id")).isEqualTo(1);
assertThat(result.getMerkmalList("name")).isEqualTo(List.of("wert1", "wert2"));
}
}

View File

@@ -0,0 +1,111 @@
/*
* This file is part of mv64e-onkostar-data
*
* Copyright (C) 2025 Paul-Christian Volkmer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package dev.pcvolkmer.onco.datamapper.datacatalogues;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
class MolekularPcrCatalogueTest {
JdbcTemplate jdbcTemplate;
MolekularPcrCatalogue catalogue;
@BeforeEach
void setUp(@Mock JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
this.catalogue = MolekularPcrCatalogue.create(jdbcTemplate);
}
@Test
void shouldUseCorrectQuery(@Mock Map<String, Object> resultSet) {
doAnswer(invocationOnMock -> List.of(resultSet))
.when(jdbcTemplate)
.queryForList(anyString(), anyInt());
this.catalogue.getById(1);
var captor = ArgumentCaptor.forClass(String.class);
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
assertThat(captor.getValue())
.isEqualTo("SELECT patient.patienten_id, dk_molekularpcr.*, prozedur.patient_id, prozedur.hauptprozedur_id FROM dk_molekularpcr JOIN prozedur ON (prozedur.id = dk_molekularpcr.id) JOIN patient ON (patient.id = prozedur.patient_id) WHERE geloescht = 0 AND prozedur.id = ?");
}
@Test
void shouldUseCorrectMerkmalQuery(@Mock Map<String, Object> resultSet) {
when(resultSet.get(anyString()))
.thenReturn(Map.of("feldname", "name", "feldwert", "wert"));
doAnswer(invocationOnMock -> List.of(resultSet))
.when(jdbcTemplate)
.queryForList(anyString(), anyInt());
this.catalogue.getMerkmaleById(1);
var captor = ArgumentCaptor.forClass(String.class);
verify(this.jdbcTemplate).queryForList(captor.capture(), anyInt());
assertThat(captor.getValue())
.isEqualTo("SELECT feldname, feldwert FROM dk_molekularpcr_merkmale WHERE eintrag_id = ?");
}
@Test
void shouldUseMerkmalList() {
doAnswer(invocationOnMock -> {
var sql = invocationOnMock.getArgument(0, String.class);
ArrayList<Map<String, Object>> result = new ArrayList<>();
if (sql.startsWith("SELECT feldname")) {
result.add(Map.of("feldname", "name", "feldwert", "wert1"));
result.add(Map.of("feldname", "name", "feldwert", "wert2"));
} else {
var map = new HashMap<String, Object>();
map.put("id", 1);
map.put("name", "x");
result.add(map);
}
return result;
})
.when(jdbcTemplate)
.queryForList(anyString(), anyInt());
var result = this.catalogue.getById(1);
assertThat(result.getInteger("id")).isEqualTo(1);
assertThat(result.getMerkmalList("name")).isEqualTo(List.of("wert1", "wert2"));
}
}