|
- package de.uniluebeck.mi.projmi6;
-
- import ca.uhn.hl7v2.model.v251.message.ADT_A01;
- import ca.uhn.hl7v2.model.v251.message.BAR_P05;
- import de.uniluebeck.mi.projmi6.controller.MainController;
- import de.uniluebeck.mi.projmi6.db.DBHandler;
- import de.uniluebeck.mi.projmi6.hapi.HL7Receiver;
- import de.uniluebeck.mi.projmi6.hapi.HL7Server;
- import javafx.application.Application;
- import javafx.beans.property.ReadOnlyStringProperty;
- import javafx.collections.FXCollections;
- import javafx.concurrent.Task;
- import javafx.fxml.FXMLLoader;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.scene.image.Image;
- import javafx.scene.image.ImageView;
- import javafx.scene.layout.Background;
- import javafx.scene.layout.BackgroundFill;
- import javafx.scene.layout.CornerRadii;
- import javafx.scene.layout.VBox;
- import javafx.scene.paint.Paint;
- import javafx.scene.text.Font;
- import javafx.scene.text.Text;
- import javafx.stage.Stage;
- import javafx.stage.StageStyle;
-
-
- public class Main extends Application {
-
- public static String OPS_IP = "127.0.0.1";
- public static int OPS_PORT = 1112;
-
-
- private HL7Server server;
-
- /**
- * Cuz building the GUI from FXML is a bit costly,
- * it's done from its own thread.
- */
- private Task<Parent> loadMainWindowTask = new Task<Parent>() {
-
-
- @Override
- protected Parent call() throws Exception {
-
- MainController mainController = new MainController();
- updateMessage("Lade OPS-Codes...");
- mainController.getStammdaten().setOpsCodes(FXCollections.observableArrayList(
- DBHandler.getAllOpsCodes()
- ));
-
- updateMessage("Lade ICD-10-Codes...");
- mainController.getStammdaten().setIcd10Codes(FXCollections.observableArrayList(
- DBHandler.getAllIcd10Codes()
- ));
-
- updateMessage("Lade Krankenkassen...");
- mainController.getStammdaten().setKassen(FXCollections.observableArrayList(
- DBHandler.getAllKassen()
- ));
-
- updateMessage("Lade Mitarbeiter...");
- mainController.getStammdaten().setMitarbeiter(FXCollections.observableArrayList(
- DBHandler.getAllMitarbeiter()
- ));
-
- updateMessage("Lade Stationen...");
- mainController.getStammdaten().setStationen(FXCollections.observableArrayList(
- DBHandler.getAllStationen())
- );
-
- updateMessage("Lade GUI...");
- FXMLLoader fxmlLoader = new FXMLLoader();
- fxmlLoader.setLocation(getClass().getClassLoader().getResource("main.fxml"));
- fxmlLoader.setControllerFactory(mainController.getControllerFactory());
-
- Parent root = fxmlLoader.load();
-
- server = new HL7Server();
- server.registerApplication("ADT", "A01", new HL7Receiver<>(ADT_A01.class, mainController)); // ADT_A01 parsen
- server.registerApplication("BAR", "P05", new HL7Receiver<>(BAR_P05.class, mainController)); // BAR_P05 parsen
- server.start();
-
- return root;
- }
- };
- /**
- * The applications logo (an owl).
- */
- private Image icon = new Image("icon.png", true);
-
- /**
- * Applications entry point.
- *
- * @param args Commandline parameters
- */
- public static void main(String[] args) {
- launch(args);
- }
-
- @Override
- public void stop() throws Exception {
- if (server != null) {
- server.stop();
- server.shutdown();
- }
- super.stop();
- }
-
- @Override
- public void start(Stage primaryStage) {
- // TODO: Jojo kann das weg?
- // System.out.println(getClass().getClassLoader().getResource("").toExternalForm());
-
- primaryStage.getIcons().add(icon);
-
- Stage loadingMessage = createLoadWindow(loadMainWindowTask.messageProperty());
-
- loadMainWindowTask.setOnFailed(event -> {
- loadMainWindowTask.getException().printStackTrace();
- loadingMessage.close();
- });
- loadMainWindowTask.setOnSucceeded(event -> {
- Parent root = loadMainWindowTask.getValue();
-
- loadingMessage.close();
-
- primaryStage.setTitle("KIS Gruppe 06");
- primaryStage.setScene(new Scene(root, 1200, 800));
- primaryStage.show();
- });
-
- Thread thread = new Thread(loadMainWindowTask);
- thread.setDaemon(true);
- thread.start();
-
-
- }
-
- /**
- * Creates a small, undecorated stage for
- * showing a splash-screen to the user.
- *
- * @return the splash screen
- */
- public Stage createLoadWindow(ReadOnlyStringProperty progressMessage) {
- Text kis = new Text("KIS");
- kis.setFont(Font.font(50));
-
- Text gruppe6 = new Text("Gruppe 06");
- gruppe6.setFont(Font.font(20));
-
- Text progress = new Text();
- progress.textProperty().bind(progressMessage);
-
- VBox root = new VBox(gruppe6, new ImageView(icon), kis, progress);
- root.setSpacing(20);
- root.setAlignment(Pos.CENTER);
- Scene scene = new Scene(root, 400, 500);
-
- Stage stage = new Stage(StageStyle.UNDECORATED);
- stage.getIcons().add(icon);
- root.setBackground(new Background(new BackgroundFill(Paint.valueOf("#0093D1"), CornerRadii.EMPTY, Insets.EMPTY)));
- stage.setScene(scene);
- stage.show();
-
- return stage;
- }
- }
|