Commit 464ed23d authored by Julia Fischer's avatar Julia Fischer

Methode getDiagnosen() public gesetzt und Rückgabe auf List<AlphaID> gesetzt

parent 09910ceb
Pipeline #2881 skipped
package uebung7.fin.gui;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
......@@ -15,6 +14,7 @@ import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
......@@ -25,7 +25,6 @@ import javafx.stage.FileChooser;
import javafx.stage.Stage;
import uebung7.fin.medReader.DBSearch;
import uebung7.fin.medReader.MedReportSplitter;
import javafx.scene.control.ComboBox;
public class Uebung7GUI1 extends Application {
......@@ -115,7 +114,7 @@ public class Uebung7GUI1 extends Application {
DBSearch search = new DBSearch(reportSplit.getDiagnosen());
// Get Diags found from Backend
System.out.println("DBG: startGUI.java Diagnosen Return: " + search.getDiagnosisList());
System.out.println("DBG: startGUI.java Diagnosen Return: ");
// ToDO: GUI: Selection of Diag etc...
......
......@@ -5,19 +5,17 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import org.hibernate.CacheMode;
import org.hibernate.Session;
import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.hibernate.search.jpa.FullTextEntityManager;
import org.hibernate.search.query.dsl.QueryBuilder;
/**
* All database-related action goes in here, i.e. initalization & search on sqllite
*
* All database-related action goes in here, i.e. initalization & search on
* sqllite
*
* @author Julia
*
*/
......@@ -30,42 +28,36 @@ public class DBSearch {
*/
private static final float RATIO = 1.5f;
/**
* Constructor takes diagnoses seperated by /n
* Executes search for each Diagnosis
* @param diagnosen
* Constructor takes diagnoses seperated by /n Executes search for each
* Diagnosis
*
* @param diagnosen
*/
public DBSearch(ArrayList<String> diagnosen){
/** DBG create Index only
Instant start = Instant.now();
try {
doIndex();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Instant end = Instant.now();
System.out.println("\n >>>>>>> DBG: DBSearch.java Time to create Index: " + Duration.between(start, end));
**/
/** DBG: Perfrom search for each diag**/
for(String searchString: diagnosen){
public DBSearch(ArrayList<String> diagnosen) {
/**
* DBG create Index only Instant start = Instant.now(); try { doIndex();
* } catch (InterruptedException e1) { // TODO Auto-generated catch
* block e1.printStackTrace(); } Instant end = Instant.now();
*
* System.out.println(
* "\n >>>>>>> DBG: DBSearch.java Time to create Index: " +
* Duration.between(start, end));
**/
/** DBG: Perfrom search for each diag **/
for (String searchString : diagnosen) {
try {
searchDiag(searchString);
getDiagnose(searchString);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
/**
* Info: Die Suchergebnisse der Lucene-Textsuche sind soriert nach Score -
* der beste Treffer steht ganz oben.
......@@ -86,7 +78,6 @@ public class DBSearch {
return false;
}
/**
*
......@@ -99,7 +90,6 @@ public class DBSearch {
Session session = HibernateUtil.getSession();
FullTextSession fullTextSession = Search.getFullTextSession(session);
// Lucene Query erstellen - Suche in "text" (Diagnose-Namen) und
// "primary_key" (ICD10-Codes)
......@@ -192,8 +182,14 @@ public class DBSearch {
}
private void searchDiag(String searchStr) throws InterruptedException {
//String[] searchDiag
/**
*
* @param searchStr
* @return
* @throws InterruptedException
*/
public List<AlphaID> getDiagnose(String searchStr) throws InterruptedException {
// String[] searchDiag
// Indizierung
// doIndex();
......@@ -201,7 +197,7 @@ public class DBSearch {
String searchValue = searchStr;
// searchValue = "ozufgefcdfdfbnf"; // kein Ergebnis
// searchValue = "Dysthymia"; // nur ein Ergebnis
//searchValue = "Mückenstich"; // mehrere Ergebnisse - 1. eindeutig
// searchValue = "Mückenstich"; // mehrere Ergebnisse - 1. eindeutig
// searchValue = "Gemini"; // mehrere Ergebnisse -kein Ergebnis
// eindeutig
......@@ -215,66 +211,58 @@ public class DBSearch {
// searchValue = "Arterieller Hypertonus";
// searchValue = "Postpunktionelle Beschwerdesymptomatik";
// searchValue = "F40.1";
// DBG: Measure Query execution Time
Instant start = Instant.now();
// Suchen
List<AlphaID> searchResult = search(searchValue);
Instant end = Instant.now();
List<AlphaID> diagnosen = reduceResultIfUnique(searchResult);
// Suchergebnis analysieren hinsichtlich eindeutiger Ergebnisse
List<AlphaID> searchResult = search(searchValue);
Instant end = Instant.now();
// Suchergebnis analysieren hinsichtlich eindeutiger Ergebnisse
List<AlphaID> diagnosen = reduceResultIfUnique(searchResult);
// Ausgabe der Ergebnisse
System.out.println(
"\n >>>>>>> DBG: DBSearch.java Time: " + Duration.between(start, end)+" Es wurden " + diagnosen.size() + " Einträge gefunden für '" + searchValue + "' <<<<<<< \n");
System.out.println("\n >>>>>>> DBG: DBSearch.java Time: " + Duration.between(start, end) + " Es wurden "
+ diagnosen.size() + " Einträge gefunden für '" + searchValue + "' <<<<<<< \n");
for (AlphaID diagnose : diagnosen) {
System.out.println(diagnose.getAlpha_id() + " - " + diagnose.getPrimary_key() + " - " + diagnose.getText());
}
// System.exit(0);
return diagnosen;
}
// ToDo: Returns List? of all diagnoseses found to Frontent
public String getDiagnosisList(){
return "testReturn";
}
// // ToDo: Returns List? of all diagnoseses found to Frontent
// public String getDiagnosisList() {
//
// return "testReturn";
// }
/*
* Initializes hibernate Session (~1.4 seconds)‚
*/
public static void initDB(){
public static void initDB() {
Session session = HibernateUtil.getSession();
}
/**
* Indizierung
* Indizierung
*
* @throws InterruptedException
*/
private static void doIndex() throws InterruptedException {
Session session = HibernateUtil.getSession();
FullTextSession fullTextSession = Search.getFullTextSession(session);
fullTextSession
.createIndexer( AlphaID.class )
.batchSizeToLoadObjects( 25 )
.cacheMode( CacheMode.NORMAL )
.threadsToLoadObjects( 5 )
.threadsForSubsequentFetching( 20 )
.startAndWait();
fullTextSession.createIndexer(AlphaID.class).batchSizeToLoadObjects(25).cacheMode(CacheMode.NORMAL)
.threadsToLoadObjects(5).threadsForSubsequentFetching(20).startAndWait();
fullTextSession.disconnect();
fullTextSession.close();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment