Skip to content

Commit

Permalink
feat(visit): add bind tab disable to visit save or patient selection
Browse files Browse the repository at this point in the history
Refs: #6
  • Loading branch information
szwrk committed Apr 25, 2024
1 parent 8c172ca commit 0be3a1e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public class QuickVisitController
private UserDialog finalDialog;
@FXML private Label statusLabel;
@FXML private Button finishButton;


@FXML
void onActionConfirmRegistrationVisitInfo(ActionEvent event) {
logger.debug("[CONTROLLER] Clicked on confirm visit details...");
Expand Down Expand Up @@ -151,7 +153,6 @@ private void handleSuccessfulVisitConfirmation(VisitDtoResponse visitDto) {
finalDialog.close();
}
Tooltip.install(confirmButton, new Tooltip("Wait! The visit has been already saved. Please navigate to the 'End of Visit' tab for finalization."));
nestedVisitVM().updateVisitStatus();
confirmButton
.setOnAction(
event -> UserAlert.simpleWarn( "Wait!", " The visit has been already saved. Please navigate to the 'End of Visit' tab for finalization." )
Expand All @@ -164,6 +165,7 @@ private void handleSuccessfulVisitConfirmation(VisitDtoResponse visitDto) {
dialog.showAndWait();
}


private void validateIsPatientExist() {
logger.trace("[CONTROLLER] Enter validate patient exist...");
if (currentPatient() == null) {
Expand Down Expand Up @@ -203,31 +205,22 @@ public void postInitialize() {
informExaminationAboutSelectedPatient();
requestFocusOnViewStart();
fireConfirmButtonWhenPressKeyCombination();
bindExaminationTabDisableToSelectedPatient();
bindSummaryTabDisableToSelectedPatient();
bindNotesTabDisableToSelectedPatient();

bindTabsDisableToCriteria();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}

private void bindNotesTabDisableToSelectedPatient() {
private void bindTabsDisableToCriteria() {
notesTab
.disableProperty()
.bind(nestedPatientVm().isPatientNull());
}

private void bindSummaryTabDisableToSelectedPatient() {
.bind(nestedPatientVm().isPatientNull().or( nestedVisitVM().getIsVisitNotSaved() ));
summaryTab
.disableProperty()
.bind(nestedPatientVm().isPatientNull());
}

private void bindExaminationTabDisableToSelectedPatient() {
.disableProperty()
.bind(nestedPatientVm().isPatientNull().or( nestedVisitVM().getIsVisitNotSaved() ));
examinationsTab
.disableProperty()
.bind(nestedPatientVm().isPatientNull());
.disableProperty()
.bind(nestedPatientVm().isPatientNull().or( nestedVisitVM().getIsVisitNotSaved() ));
}

private void fireConfirmButtonWhenPressKeyCombination() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public BooleanBinding isPatientNull(){
return selectedPatientProperty().isNull();
}


private void chooseFirstPatientIfOnlyOneResult() {
selectedPatientProperty().set(patients.get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ private void selectMinuteOnComboBox(int actualMinute) {
realizationMinutesChoiceBox.getSelectionModel().select(position);
});
}

private void bindStatus() {
statusLabel.textProperty().bind(visitViewModel.getStatusProperty());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class VisitViewModel {
private final ResourceBundle bundle = null;
private ConnectorVisit service = null;
private ConnectorSimpleDictionaries dictService = null;

private final BooleanProperty isVisitNotSaved = new SimpleBooleanProperty(true);
public VisitViewModel(
ConnectorVisit service, ConnectorSimpleDictionaries dictService, ConnectorUser connectorUser) {
this.service = service;
Expand Down Expand Up @@ -176,6 +178,8 @@ public Optional<VisitDtoResponse> confirmVisit() throws VisitVmValidationExcepti
temp = service.save( dtoCreate );
Long newVisitId = temp.get( ).visitId( );
visitIdProperty.set( newVisitId );
updateVisitStatus("SAVED");
isVisitNotSaved.set( false );
} catch (RuntimeException e){
logger.error( e.getMessage(),e );
}
Expand All @@ -188,7 +192,9 @@ public void selectPatient(PatientVM selectedPatient) {
this.selectedPatient.set( selectedPatient );
}

public void updateVisitStatus() {
public void updateVisitStatus(String status) {
if (status.equals( "SAVED" )) {
statusProperty.set( "SAVED" );
}
}
}

0 comments on commit 0be3a1e

Please sign in to comment.