Commit 18022025
This commit is contained in:
@@ -4,9 +4,13 @@ import BASS.AudioPlayer;
|
||||
import BASS.PlaybackStatus;
|
||||
import Camera.*;
|
||||
import Config.CameraConfigEnum;
|
||||
import Config.SomeCodes;
|
||||
import Database.PhotoReviewClass;
|
||||
import Database.Sqlite;
|
||||
import ErhaAPI.ErhaAPI;
|
||||
import ErhaAPI.BarcodeResullt;
|
||||
import ErhaAPI.PhotoResult;
|
||||
import ErhaAPI.PatientRecord;
|
||||
import ErhaAPI.UploadResult;
|
||||
import FTP.FTPUpload;
|
||||
import FTP.FTPUploadEvent;
|
||||
import FTP.FtpMonitorData;
|
||||
@@ -33,6 +37,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import org.bytedeco.javacv.OpenCVFrameGrabber;
|
||||
import org.bytedeco.javacv.VideoInputFrameGrabber;
|
||||
import org.bytedeco.opencv.opencv_core.Rect;
|
||||
import org.bytedeco.opencv.opencv_core.Size;
|
||||
import org.tinylog.Logger;
|
||||
|
||||
@@ -44,13 +49,30 @@ public class CaptureView {
|
||||
private AnchorPane CaptureViewAnchor;
|
||||
|
||||
@FXML
|
||||
private AnchorPane cam1, cam2, cam3, cam4, cam5, controlpane;
|
||||
private AnchorPane cam1;
|
||||
@FXML
|
||||
private AnchorPane cam2;
|
||||
@FXML
|
||||
private AnchorPane cam3;
|
||||
@FXML
|
||||
private AnchorPane cam4;
|
||||
@FXML
|
||||
private AnchorPane cam5;
|
||||
@FXML
|
||||
private AnchorPane controlpane;
|
||||
|
||||
private Cameradetail image1, image2, image3, image4, image5;
|
||||
|
||||
|
||||
@FXML
|
||||
private TextArea directorypath, prefixfile;
|
||||
private TextArea directorypath;
|
||||
@FXML
|
||||
private TextArea barcodeData;
|
||||
@FXML
|
||||
private TextArea medicalRecordID;
|
||||
@FXML
|
||||
private TextArea PatientName;
|
||||
|
||||
@FXML
|
||||
private Button btnTakePhoto;
|
||||
@FXML
|
||||
@@ -80,6 +102,8 @@ public class CaptureView {
|
||||
private final AtomicBoolean[] have_right_eye = new AtomicBoolean[5];
|
||||
private final AtomicBoolean isTakingPhoto = new AtomicBoolean(false);
|
||||
|
||||
private final ErhaAPI erhaAPI = new ErhaAPI(false);
|
||||
|
||||
@FXML
|
||||
private void ChangeDirectory(){
|
||||
DirectoryChooser dc = new DirectoryChooser();
|
||||
@@ -95,11 +119,11 @@ public class CaptureView {
|
||||
if (image!=null){
|
||||
if (image.isCapturing()){
|
||||
image.setAutoFocus(false);
|
||||
Thread.sleep(2);
|
||||
image.setFocus(0.9);
|
||||
Thread.sleep(2);
|
||||
Thread.sleep(5);
|
||||
image.setFocus(0.7);
|
||||
Thread.sleep(5);
|
||||
image.setAutoFocus(true);
|
||||
Thread.sleep(2);
|
||||
Thread.sleep(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,16 +143,27 @@ public class CaptureView {
|
||||
private void TakePhotos(){
|
||||
boolean has_face = Arrays.stream(have_face).anyMatch(AtomicBoolean::get);
|
||||
if (has_face){
|
||||
if (audioPlayer.isPlaying()) audioPlayer.StopCurrentPlayback();
|
||||
audioPlayer.PlayFile(audio_countdown, ps);
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_countdown)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_countdown, ps);
|
||||
}
|
||||
|
||||
btnAutoFocus.fire();
|
||||
|
||||
try{
|
||||
AutoFocus();
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e){
|
||||
Logger.error("Error AutoFocus: "+e.getMessage());
|
||||
}
|
||||
|
||||
Size thumbsize = new Size(160,120);
|
||||
String directory = directorypath.getText();
|
||||
String prefix = RemoveSpaces(prefixfile.getText()) ;
|
||||
String prefix = RemoveSpaces(medicalRecordID.getText()) ;
|
||||
if (ValidDirectory(directory)){
|
||||
if (ValidPatientID(prefix)){
|
||||
if (ValidMedicalRecordId(prefix)){
|
||||
|
||||
PhotoReviewClass prc = new PhotoReviewClass();
|
||||
prc.setPrefix(prefix);
|
||||
@@ -137,75 +172,181 @@ public class CaptureView {
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(5);
|
||||
|
||||
// face detection Rect ROI to head detection Rect ROI
|
||||
// head is bigger than face, so we need to scale it
|
||||
final double face_to_head_scale = 1.2;
|
||||
Rect bestsize = new Rect(0,0,0,0);
|
||||
Rect reducedsize = new Rect(0,0,0,0);
|
||||
|
||||
if (image1!=null) {
|
||||
image1.RemapROI(face_to_head_scale);
|
||||
if (image1.getBestMatROI()!=null && image1.getBestMatROI().width()>bestsize.width()) {
|
||||
bestsize = image1.getBestMatROI();
|
||||
System.out.println("BestSize: "+bestsize.width()+"x"+bestsize.height());
|
||||
}
|
||||
|
||||
if (image1.getReducedMatROI()!=null && image1.getReducedMatROI().width()>reducedsize.width()) {
|
||||
reducedsize = image1.getReducedMatROI();
|
||||
System.out.println("ReducedSize: "+reducedsize.width()+"x"+reducedsize.height());
|
||||
}
|
||||
}
|
||||
if (image2!=null) {
|
||||
image2.RemapROI(face_to_head_scale);
|
||||
if (image2.getBestMatROI()!=null && image2.getBestMatROI().width()>bestsize.width()) {
|
||||
bestsize = image2.getBestMatROI();
|
||||
System.out.println("BestSize: "+bestsize.width()+"x"+bestsize.height());
|
||||
}
|
||||
if (image2.getReducedMatROI()!=null && image2.getReducedMatROI().width()>reducedsize.width()) {
|
||||
reducedsize = image2.getReducedMatROI();
|
||||
System.out.println("ReducedSize: "+reducedsize.width()+"x"+reducedsize.height());
|
||||
}
|
||||
}
|
||||
if (image3!=null) {
|
||||
image3.RemapROI(face_to_head_scale);
|
||||
if (image3.getBestMatROI()!=null && image3.getBestMatROI().width()>bestsize.width()) {
|
||||
bestsize = image3.getBestMatROI();
|
||||
System.out.println("BestSize: "+bestsize.width()+"x"+bestsize.height());
|
||||
}
|
||||
if (image3.getReducedMatROI()!=null && image3.getReducedMatROI().width()>reducedsize.width()) {
|
||||
reducedsize = image3.getReducedMatROI();
|
||||
System.out.println("ReducedSize: "+reducedsize.width()+"x"+reducedsize.height());
|
||||
}
|
||||
}
|
||||
if (image4!=null) {
|
||||
image4.RemapROI(face_to_head_scale);
|
||||
if (image4.getBestMatROI()!=null && image4.getBestMatROI().width()>bestsize.width()) {
|
||||
bestsize = image4.getBestMatROI();
|
||||
System.out.println("BestSize: "+bestsize.width()+"x"+bestsize.height());
|
||||
}
|
||||
if (image4.getReducedMatROI()!=null && image4.getReducedMatROI().width()>reducedsize.width()) {
|
||||
reducedsize = image4.getReducedMatROI();
|
||||
System.out.println("ReducedSize: "+reducedsize.width()+"x"+reducedsize.height());
|
||||
}
|
||||
}
|
||||
if (image5!=null) {
|
||||
image5.RemapROI(face_to_head_scale);
|
||||
if (image5.getBestMatROI()!=null && image5.getBestMatROI().width()>bestsize.width()) {
|
||||
bestsize = image5.getBestMatROI();
|
||||
System.out.println("BestSize: "+bestsize.width()+"x"+bestsize.height());
|
||||
}
|
||||
if (image5.getReducedMatROI()!=null && image5.getReducedMatROI().width()>reducedsize.width()) {
|
||||
reducedsize = image5.getReducedMatROI();
|
||||
System.out.println("ReducedSize: "+reducedsize.width()+"x"+reducedsize.height());
|
||||
}
|
||||
}
|
||||
|
||||
// find biggest BestROI and ReducedROI
|
||||
final Rect finalbestsize = bestsize;
|
||||
final Rect finalreducedsize = reducedsize;
|
||||
|
||||
|
||||
Callable<String> task1 = ()->{
|
||||
if (image1!=null) {
|
||||
image1.RemapROI();
|
||||
String p1 = image1.TakePhoto(directory,prefix, image1.getBestMatROI(), image1.getReducedMatROI());
|
||||
if (ValidFile(p1)) {
|
||||
Platform.runLater(()->image1.setCameraStatus("Photo: "+ SomeCodes.GetFileName(p1)));
|
||||
|
||||
prc.setFileLeft90(p1);
|
||||
String thumb1 = MakeThumbfile(p1, thumbsize);
|
||||
image1.RemapROI(face_to_head_scale);
|
||||
PhotoResult p1 = image1.TakePhoto(directory,prefix, finalbestsize, finalreducedsize);
|
||||
if (ValidFile(p1.getFullres())) {
|
||||
prc.setFileLeft90(p1.getFullres());
|
||||
String thumb1 = MakeThumbfile(p1.getFullres(), thumbsize);
|
||||
if (ValidFile(thumb1)) {
|
||||
prc.setThumbLeft90(thumb1);
|
||||
}
|
||||
} else System.out.println("Image1 ValidFile is false");
|
||||
if (ValidFile(p1.getCompressedfile())){
|
||||
prc.setCompressedLeft90(p1.getCompressedfile());
|
||||
}
|
||||
if (ValidFile(p1.getFullcrop())){
|
||||
prc.setCroppedLeft90(p1.getFullcrop());
|
||||
}
|
||||
if (ValidFile(p1.getCompressedcrop())){
|
||||
prc.setCompressedCropLeft90(p1.getCompressedcrop());
|
||||
}
|
||||
} else System.out.println("Image1 is null");
|
||||
return "Task 1 Done";
|
||||
};
|
||||
Callable<String> task2 = ()->{
|
||||
if (image2!=null) {
|
||||
image2.RemapROI();
|
||||
String p2 = image2.TakePhoto(directory,prefix, image2.getBestMatROI(), image2.getReducedMatROI());
|
||||
if (ValidFile(p2)) {
|
||||
Platform.runLater(()->image2.setCameraStatus("Photo: "+ SomeCodes.GetFileName(p2)));
|
||||
|
||||
prc.setFileLeft45(p2);
|
||||
String thumb2 = MakeThumbfile(p2, thumbsize);
|
||||
image2.RemapROI(face_to_head_scale);
|
||||
PhotoResult p2 = image2.TakePhoto(directory,prefix, finalbestsize, finalreducedsize);
|
||||
if (ValidFile(p2.getFullres())) {
|
||||
prc.setFileLeft45(p2.getFullres());
|
||||
String thumb2 = MakeThumbfile(p2.getFullres(), thumbsize);
|
||||
if (ValidFile(thumb2)) prc.setThumbLeft45(thumb2);
|
||||
} else System.out.println("Image2 ValidFile is false");
|
||||
if (ValidFile(p2.getCompressedfile())){
|
||||
prc.setCompressedLeft45(p2.getCompressedfile());
|
||||
}
|
||||
if (ValidFile(p2.getFullcrop())){
|
||||
prc.setCroppedLeft45(p2.getFullcrop());
|
||||
}
|
||||
if (ValidFile(p2.getCompressedcrop())){
|
||||
prc.setCompressedCropLeft45(p2.getCompressedcrop());
|
||||
}
|
||||
} else System.out.println("Image2 is null");
|
||||
return "Task 2 Done";
|
||||
};
|
||||
|
||||
Callable<String> task3 = ()->{
|
||||
if (image3!=null) {
|
||||
image3.RemapROI();
|
||||
String p3 = image3.TakePhoto(directory,prefix, image3.getBestMatROI(), image3.getReducedMatROI());
|
||||
if (ValidFile(p3)) {
|
||||
Platform.runLater(()->image3.setCameraStatus("Photo: "+ SomeCodes.GetFileName(p3)));
|
||||
prc.setFileCenter(p3);
|
||||
String thumb3 = MakeThumbfile(p3, thumbsize);
|
||||
image3.RemapROI(face_to_head_scale);
|
||||
PhotoResult p3 = image3.TakePhoto(directory,prefix, finalbestsize, finalreducedsize);
|
||||
if (ValidFile(p3.getFullres())) {
|
||||
prc.setFileCenter(p3.getFullres());
|
||||
String thumb3 = MakeThumbfile(p3.getFullres(), thumbsize);
|
||||
if (ValidFile(thumb3)) prc.setThumbCenter(thumb3);
|
||||
} else System.out.println("Image3 ValidFile is false");
|
||||
if (ValidFile(p3.getCompressedfile())){
|
||||
prc.setCompressedCenter(p3.getCompressedfile());
|
||||
}
|
||||
if (ValidFile(p3.getFullcrop())){
|
||||
prc.setCroppedCenter(p3.getFullcrop());
|
||||
}
|
||||
if (ValidFile(p3.getCompressedcrop())){
|
||||
prc.setCompressedCropCenter(p3.getCompressedcrop());
|
||||
}
|
||||
} else System.out.println("Image3 is null");
|
||||
return "Task 3 Done";
|
||||
};
|
||||
|
||||
Callable<String> task4 = ()->{
|
||||
if (image4!=null) {
|
||||
image4.RemapROI();
|
||||
String p4 = image4.TakePhoto(directory,prefix, image4.getBestMatROI(), image4.getReducedMatROI());
|
||||
if (ValidFile(p4)) {
|
||||
Platform.runLater(()->image4.setCameraStatus("Photo: "+ SomeCodes.GetFileName(p4)));
|
||||
prc.setFileRight45(p4);
|
||||
String thumb4 = MakeThumbfile(p4, thumbsize);
|
||||
image4.RemapROI(face_to_head_scale);
|
||||
PhotoResult p4 = image4.TakePhoto(directory,prefix, finalbestsize, finalreducedsize);
|
||||
if (ValidFile(p4.getFullres())) {
|
||||
prc.setFileRight45(p4.getFullres());
|
||||
String thumb4 = MakeThumbfile(p4.getFullres(), thumbsize);
|
||||
if (ValidFile(thumb4)) prc.setThumbRight45(thumb4);
|
||||
} else System.out.println("Image4 ValidFile is false");
|
||||
if (ValidFile(p4.getCompressedfile())){
|
||||
prc.setCompressedRight45(p4.getCompressedfile());
|
||||
}
|
||||
if (ValidFile(p4.getFullcrop())){
|
||||
prc.setCroppedRight45(p4.getFullcrop());
|
||||
}
|
||||
if (ValidFile(p4.getCompressedcrop())){
|
||||
prc.setCompressedCropRight45(p4.getCompressedcrop());
|
||||
}
|
||||
} else System.out.println("Image4 is null");
|
||||
return "Task 4 Done";
|
||||
};
|
||||
|
||||
Callable<String> task5 = ()->{
|
||||
if (image5!=null) {
|
||||
image5.RemapROI();
|
||||
String p5 = image5.TakePhoto(directory,prefix, image5.getBestMatROI(), image5.getReducedMatROI());
|
||||
if (ValidFile(p5)) {
|
||||
Platform.runLater(()->image5.setCameraStatus("Photo: "+ SomeCodes.GetFileName(p5)));
|
||||
prc.setFileRight90(p5);
|
||||
String thumb5 = MakeThumbfile(p5, thumbsize);
|
||||
image5.RemapROI(face_to_head_scale);
|
||||
PhotoResult p5 = image5.TakePhoto(directory,prefix, finalbestsize, finalreducedsize);
|
||||
if (ValidFile(p5.getFullres())) {
|
||||
prc.setFileRight90(p5.getFullres());
|
||||
String thumb5 = MakeThumbfile(p5.getFullres(), thumbsize);
|
||||
if (ValidFile(thumb5)) prc.setThumbRight90(thumb5);
|
||||
} else System.out.println("Image5 ValidFile is false");
|
||||
if (ValidFile(p5.getCompressedfile())){
|
||||
prc.setCompressedRight90(p5.getCompressedfile());
|
||||
}
|
||||
if (ValidFile(p5.getFullcrop())){
|
||||
prc.setCroppedRight90(p5.getFullcrop());
|
||||
}
|
||||
if (ValidFile(p5.getCompressedcrop())){
|
||||
prc.setCompressedCropRight90(p5.getCompressedcrop());
|
||||
}
|
||||
} else System.out.println("Image5 is null");
|
||||
return "Task 5 Done";
|
||||
};
|
||||
@@ -231,21 +372,81 @@ public class CaptureView {
|
||||
long duration = (System.nanoTime() - nanostart) / 1000000; // in milliseconds
|
||||
System.out.println("TakePhotos duration: "+duration+" ms");
|
||||
|
||||
|
||||
if (audioPlayer.isPlaying()) {
|
||||
if (!audio_pengambilan_berhasil.equals((audioPlayer.getCurrentFile()))){
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_pengambilan_berhasil)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_pengambilan_berhasil, ps);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_pengambilan_berhasil, ps);
|
||||
String[] files = prc.files();
|
||||
if (files!=null && files.length>0){
|
||||
|
||||
String[] files = prc.compressed();
|
||||
|
||||
if (files.length>0){
|
||||
InsertSQL(prc);
|
||||
|
||||
progressanchor.getChildren().clear();
|
||||
prefixfile.setText("");
|
||||
Task<Void> uploadtask = new Task<>() {
|
||||
@Override
|
||||
protected Void call() {
|
||||
int totalfiles = files.length;
|
||||
int counter = 0;
|
||||
for (String ff : files) {
|
||||
UploadResult ur = erhaAPI.Upload_File(prefix, ff);
|
||||
if (ur != null) {
|
||||
if (ur.message.startsWith("Record has been created")) {
|
||||
counter++;
|
||||
updateMessage("Upload success for " + ff);
|
||||
} else updateMessage("Upload failed for " + ff+", Message : "+ur.message);
|
||||
} else updateMessage("Upload failed for " + ff+" because UploadResult is null");
|
||||
|
||||
}
|
||||
if (counter == totalfiles) {
|
||||
super.succeeded();
|
||||
} else super.failed();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
uploadtask.messageProperty().addListener((obs, oldval, newval)-> {
|
||||
System.out.println("UploadTask message: "+newval);
|
||||
Logger.info(newval);
|
||||
});
|
||||
|
||||
|
||||
uploadtask.setOnSucceeded(e-> {
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_upload_berhasil)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_upload_berhasil, ps);
|
||||
audioPlayer.WaitUntilFinished();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
uploadtask.setOnFailed(e-> {
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_upload_gagal)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_upload_gagal, ps);
|
||||
audioPlayer.WaitUntilFinished();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
new Thread(uploadtask).start();
|
||||
|
||||
|
||||
progressanchor.getChildren().clear();
|
||||
barcodeData.setText("");
|
||||
medicalRecordID.setText("");
|
||||
PatientName.setText("");
|
||||
|
||||
//TODO ganti ke API upload
|
||||
|
||||
// new Thread(()-> {
|
||||
// try{
|
||||
@@ -294,19 +495,21 @@ public class CaptureView {
|
||||
}
|
||||
|
||||
} else {
|
||||
if (audioPlayer.isPlaying()) {
|
||||
if (!audio_posisikan_muka.equals((audioPlayer.getCurrentFile()))){
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_posisikan_muka)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_posisikan_muka, ps);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_posisikan_muka, ps);
|
||||
|
||||
}
|
||||
|
||||
isTakingPhoto.set(false);
|
||||
}
|
||||
|
||||
private void UpdateBtnTakePhoto(){
|
||||
boolean valid = ValidDirectory(directorypath.getText()) && ValidString(prefixfile.getText());
|
||||
boolean valid = ValidDirectory(directorypath.getText()) && ValidString(barcodeData.getText()) && ValidString(medicalRecordID.getText()) && ValidString(PatientName.getText());
|
||||
btnTakePhoto.setDisable(!valid);
|
||||
}
|
||||
|
||||
@@ -326,8 +529,9 @@ public class CaptureView {
|
||||
btnTakePhoto.setDisable(true);
|
||||
|
||||
directorypath.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
prefixfile.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
|
||||
barcodeData.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
medicalRecordID.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
PatientName.textProperty().addListener((obs, oldval, newval)-> UpdateBtnTakePhoto());
|
||||
cams = null;
|
||||
try{
|
||||
String[] xxx = VideoInputFrameGrabber.getDeviceDescriptions();
|
||||
@@ -600,27 +804,69 @@ public class CaptureView {
|
||||
reducewidth = ObsbotMeet2.Mode3.getWidth();
|
||||
reduceheight = ObsbotMeet2.Mode3.getHeight();
|
||||
}
|
||||
image.SetGrabber(grabber, livewidth,liveheight,photowidth,photoheight,reducewidth,reduceheight);
|
||||
image.SetGrabber(grabber, livewidth,liveheight,photowidth,photoheight,reducewidth,reduceheight, true);
|
||||
|
||||
boolean use_face_detector = true;
|
||||
boolean use_qr_detector = true;
|
||||
|
||||
LiveCamEvent lce = new LiveCamEvent() {
|
||||
@Override
|
||||
public void onDetectedQRCode(String qrCode) {
|
||||
qrCode = RemoveSpaces(qrCode);
|
||||
if (ValidPatientID(qrCode)){
|
||||
String prefix = prefixfile.getText();
|
||||
if (!qrCode.equals(prefix)){
|
||||
String finalQrCode = qrCode;
|
||||
System.out.println("PatientID detected: "+finalQrCode);
|
||||
Platform.runLater(()->prefixfile.setText(finalQrCode));
|
||||
if (audioPlayer.isPlaying()) {
|
||||
if (!audio_posisikan_muka.equals((audioPlayer.getCurrentFile()))){
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
public void onDetectedQRCode(String barCode) {
|
||||
barCode = RemoveSpaces(barCode);
|
||||
if (ValidBarCode(barCode)){
|
||||
String prefix = barcodeData.getText();
|
||||
if (!barCode.equals(prefix)){
|
||||
String finalbarCode = barCode;
|
||||
Platform.runLater(()-> barcodeData.setText(finalbarCode));
|
||||
Task<PatientRecord> checkpatientID = new Task<>() {
|
||||
@Override
|
||||
protected PatientRecord call() {
|
||||
BarcodeResullt br = erhaAPI.Validate_Barcode(finalbarCode);
|
||||
if (br!=null){
|
||||
if (br.message.startsWith("Records found")){
|
||||
if (br.data!=null && br.data.length>0){
|
||||
PatientRecord pr = br.data[0];
|
||||
if (!pr.medical_record_detail_id.isEmpty()){
|
||||
if (!pr.name.isEmpty()){
|
||||
super.succeeded();
|
||||
return pr;
|
||||
} else System.out.println("PatientRecord name is empty");
|
||||
} else System.out.println("PatientRecord medical_record_detail_id is empty");
|
||||
} else System.out.println("BarcodeResullt data is empty");
|
||||
} else System.out.println("BarcodeResullt message is not Records found");
|
||||
} else System.out.println("BarcodeResullt is null");
|
||||
super.failed();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
audioPlayer.PlayFile(audio_posisikan_muka, ps);
|
||||
};
|
||||
|
||||
checkpatientID.setOnSucceeded(event -> {
|
||||
PatientRecord pr = checkpatientID.getValue();
|
||||
if (pr!=null){
|
||||
int medrecid = toInt(pr.medical_record_detail_id);
|
||||
medicalRecordID.setText(medrecid+"");
|
||||
PatientName.setText(pr.name);
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_posisikan_muka)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_posisikan_muka, ps);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
checkpatientID.setOnFailed(event -> {
|
||||
medicalRecordID.setText("");
|
||||
PatientName.setText("");
|
||||
barcodeData.setText("");
|
||||
System.out.println("checkpatientID failed");
|
||||
});
|
||||
|
||||
new Thread(checkpatientID).start();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -687,23 +933,21 @@ public class CaptureView {
|
||||
if (isTakingPhoto.get()) return; // other camera is taking picture
|
||||
System.out.println("Blink detected at camera "+title+" delay= "+counter);
|
||||
isTakingPhoto.set(true);
|
||||
Platform.runLater(()->{
|
||||
|
||||
String prefix = prefixfile.getText();
|
||||
if (prefix.length()==10){
|
||||
System.out.println("Prefix valid, taking photo");
|
||||
btnTakePhoto.fire();
|
||||
} else {
|
||||
System.out.println("Prefix not valid, not taking photo");
|
||||
isTakingPhoto.set(false);
|
||||
if (audioPlayer.isPlaying()) {
|
||||
if (!audio_scan_barcode.equals((audioPlayer.getCurrentFile()))){
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
}
|
||||
String prefix = medicalRecordID.getText();
|
||||
if (!prefix.isEmpty()){
|
||||
System.out.println("Prefix valid, taking photo");
|
||||
btnTakePhoto.fire();
|
||||
} else {
|
||||
isTakingPhoto.set(false);
|
||||
if (audioPlayer!=null && audioPlayer.isInited()){
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_scan_barcode)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_scan_barcode, ps);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -916,7 +1160,10 @@ public class CaptureView {
|
||||
public void onUploadFinished(int total, int success, int failed, String[] files) {
|
||||
Logger.info("Upload Finished, Total: {}, Success: {}, Failed: {}", total, success, failed);
|
||||
Platform.runLater(()->{
|
||||
if (audioPlayer.isPlaying()) audioPlayer.StopCurrentPlayback();
|
||||
if (!audioPlayer.getCurrentFile().equals(audio_upload_berhasil)) {
|
||||
audioPlayer.StopCurrentPlayback();
|
||||
Wait(200);
|
||||
}
|
||||
audioPlayer.PlayFile(audio_upload_berhasil, ps);
|
||||
Alert Alert = new Alert(AlertType.INFORMATION);
|
||||
Alert.setTitle("Upload Finished");
|
||||
|
||||
Reference in New Issue
Block a user