Skip to content

Commit

Permalink
Merge pull request #85 in TELIMA/karnak from feat/update_from_dev to …
Browse files Browse the repository at this point in the history
…release

* commit '877ebcd993ca69d062dcfed17114c8f6069b7d54':
  feat: Destination DeIdentification
  • Loading branch information
jdcshug committed Sep 8, 2021
2 parents 7f2b1c3 + 877ebcd commit 3de3e95
Show file tree
Hide file tree
Showing 7 changed files with 493 additions and 386 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package org.karnak.frontend.forwardnode.edit;

import static org.karnak.backend.enums.PseudonymType.EXTID_IN_TAG;
import static org.karnak.backend.enums.PseudonymType.MAINZELLISTE_PID;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
Expand All @@ -36,9 +35,10 @@
import org.karnak.frontend.forwardnode.edit.component.EditAETitleDescription;
import org.karnak.frontend.forwardnode.edit.component.TabSourcesDestination;
import org.karnak.frontend.forwardnode.edit.destination.DestinationView;
import org.karnak.frontend.forwardnode.edit.destination.component.DeIdentificationComponent;
import org.karnak.frontend.forwardnode.edit.destination.component.FilterBySOPClassesForm;
import org.karnak.frontend.forwardnode.edit.destination.component.LayoutDesidentification;
import org.karnak.frontend.forwardnode.edit.destination.component.NewUpdateDestination;
import org.karnak.frontend.forwardnode.edit.destination.component.NotificationComponent;
import org.karnak.frontend.forwardnode.edit.source.SourceView;
import org.karnak.frontend.forwardnode.edit.source.component.NewUpdateSourceNode;
import org.karnak.frontend.util.UIS;
Expand Down Expand Up @@ -110,8 +110,8 @@ private void addBinders() {
newUpdateDestination.getFormDICOM().getFilterBySOPClassesForm());
addBindersFilterBySOPClassesForm(
newUpdateDestination.getFormSTOW().getFilterBySOPClassesForm());
addBinderExtidInDicomTag(newUpdateDestination.getFormSTOW().getLayoutDesidentification());
addBinderExtidInDicomTag(newUpdateDestination.getFormDICOM().getLayoutDesidentification());
addBinderExtidInDicomTag(newUpdateDestination.getFormSTOW().getDeIdentificationComponent());
addBinderExtidInDicomTag(newUpdateDestination.getFormDICOM().getDeIdentificationComponent());
}

/** Add events on components */
Expand All @@ -121,9 +121,9 @@ private void addEvents() {
addEventButtonSaveNewUpdateDestination();
addEventButtonDeleteNewUpdateDestination();
addEventCheckboxLayoutDesidentification(
newUpdateDestination.getFormDICOM().getLayoutDesidentification());
newUpdateDestination.getFormDICOM().getDeIdentificationComponent());
addEventCheckboxLayoutDesidentification(
newUpdateDestination.getFormSTOW().getLayoutDesidentification());
newUpdateDestination.getFormSTOW().getDeIdentificationComponent());
setEventChangeTabValue();
setEventBinderForwardNode();
setEventDestination();
Expand All @@ -139,7 +139,7 @@ private void initComponents() {
// FormDicom
newUpdateDestination
.getFormDICOM()
.getLayoutDesidentification()
.getDeIdentificationComponent()
.getProjectDropDown()
.setItems(projectService.getAllProjects());
newUpdateDestination
Expand All @@ -151,7 +151,7 @@ private void initComponents() {
// FormStow
newUpdateDestination
.getFormSTOW()
.getLayoutDesidentification()
.getDeIdentificationComponent()
.getProjectDropDown()
.setItems(projectService.getAllProjects());
newUpdateDestination
Expand Down Expand Up @@ -360,59 +360,79 @@ private void addEventButtonDeleteNewUpdateSourceNode() {
}

private void addEventButtonSaveNewUpdateDestination() {
addEventButtonSaveNewUpdateDestinationDICOM();
addEventButtonSaveNewUpdateDestinationSTOW();
}

private void addEventButtonSaveNewUpdateDestinationSTOW() {
newUpdateDestination
.getButtonDestinationDICOMSaveDeleteCancel()
.getButtonDestinationSTOWSaveDeleteCancel()
.getSave()
.addClickListener(
event -> {
if (newUpdateDestination.getCurrentDestinationEntity().getDestinationType()
== DestinationType.dicom
DestinationEntity currentDestinationEntity =
newUpdateDestination.getCurrentDestinationEntity();

if (currentDestinationEntity.getDestinationType() == DestinationType.stow
&& newUpdateDestination
.getBinderFormDICOM()
.writeBeanIfValid(newUpdateDestination.getCurrentDestinationEntity())) {

// Update notification default values if empty
newUpdateDestination
.getFormDICOM()
.getNotificationComponent()
.updateDefaultValuesNotification(
newUpdateDestination.getCurrentDestinationEntity());

NodeEventType nodeEventType =
newUpdateDestination.getCurrentDestinationEntity().getId() == null
? NodeEventType.ADD
: NodeEventType.UPDATE;
saveCurrentDestination(nodeEventType);
.getBinderFormSTOW()
.writeBeanIfValid(currentDestinationEntity)) {
// Reset / set defaults and save destination
resetDefaultValuesAndSaveDestination(
currentDestinationEntity,
newUpdateDestination.getFormSTOW().getNotificationComponent(),
newUpdateDestination.getFormSTOW().getDeIdentificationComponent());
}
});
}

private void addEventButtonSaveNewUpdateDestinationDICOM() {
newUpdateDestination
.getButtonDestinationSTOWSaveDeleteCancel()
.getButtonDestinationDICOMSaveDeleteCancel()
.getSave()
.addClickListener(
event -> {
if (newUpdateDestination.getCurrentDestinationEntity().getDestinationType()
== DestinationType.stow
DestinationEntity currentDestinationEntity =
newUpdateDestination.getCurrentDestinationEntity();

if (currentDestinationEntity.getDestinationType() == DestinationType.dicom
&& newUpdateDestination
.getBinderFormSTOW()
.writeBeanIfValid(newUpdateDestination.getCurrentDestinationEntity())) {

// Update notification default values if empty
newUpdateDestination
.getFormSTOW()
.getNotificationComponent()
.updateDefaultValuesNotification(
newUpdateDestination.getCurrentDestinationEntity());

NodeEventType nodeEventType =
newUpdateDestination.getCurrentDestinationEntity().getId() == null
? NodeEventType.ADD
: NodeEventType.UPDATE;
saveCurrentDestination(nodeEventType);
.getBinderFormDICOM()
.writeBeanIfValid(currentDestinationEntity)) {
// Reset / set defaults and save destination
resetDefaultValuesAndSaveDestination(
currentDestinationEntity,
newUpdateDestination.getFormDICOM().getNotificationComponent(),
newUpdateDestination.getFormDICOM().getDeIdentificationComponent());
}
});
}

/**
* Reset / set defaults and save destination
*
* @param destinationEntity Destination
* @param notificationComponent Notification component
* @param deIdentificationComponent DeIdentification component
*/
private void resetDefaultValuesAndSaveDestination(
DestinationEntity destinationEntity,
NotificationComponent notificationComponent,
DeIdentificationComponent deIdentificationComponent) {

// Update notification default values if empty
notificationComponent.updateDefaultValuesNotification(destinationEntity);

// Clean fields of destination which are not saved because not selected by user
deIdentificationComponent.cleanUnSavedData(destinationEntity);

NodeEventType nodeEventType =
destinationEntity.getId() == null ? NodeEventType.ADD : NodeEventType.UPDATE;

// Save
saveCurrentDestination(nodeEventType);
}

private void saveCurrentDestination(NodeEventType nodeEventType) {
destinationView
.getDestinationLogic()
Expand Down Expand Up @@ -460,38 +480,22 @@ private void removeCurrentDestination() {
}

private void addEventCheckboxLayoutDesidentification(
LayoutDesidentification layoutDesidentification) {
layoutDesidentification
.getCheckboxDesidentification()
DeIdentificationComponent deIdentificationComponent) {
deIdentificationComponent
.getDeIdentificationCheckbox()
.addValueChangeListener(
event -> {
if (event.getValue() != null) {
if (event.getValue()) {
if (projectService.getAllProjects().size() > 0) {
layoutDesidentification
.getDiv()
.add(
layoutDesidentification.getLabelDisclaimer(),
layoutDesidentification.getProjectDropDown(),
layoutDesidentification.getDesidentificationName(),
layoutDesidentification.getDivExtID(),
layoutDesidentification.getIssuerOfPatientIDByDefault());
layoutDesidentification.setTextOnSelectionProject(
layoutDesidentification.getProjectDropDown().getValue());
deIdentificationComponent.getDeIdentificationDiv().setVisible(true);
deIdentificationComponent.setTextOnSelectionProject(
deIdentificationComponent.getProjectDropDown().getValue());
} else {
layoutDesidentification.getWarningNoProjectsDefined().open();
deIdentificationComponent.getWarningNoProjectsDefined().open();
}
} else {
layoutDesidentification
.getDiv()
.remove(
layoutDesidentification.getLabelDisclaimer(),
layoutDesidentification.getProjectDropDown(),
layoutDesidentification.getDesidentificationName(),
layoutDesidentification.getIssuerOfPatientIDByDefault());
layoutDesidentification.getExtidListBox().setValue(MAINZELLISTE_PID.getValue());
layoutDesidentification.getExtidPresentInDicomTagView().clear();
layoutDesidentification.getDiv().remove(layoutDesidentification.getDivExtID());
deIdentificationComponent.getDeIdentificationDiv().setVisible(false);
}
}
});
Expand Down Expand Up @@ -525,16 +529,16 @@ private void addBindersFilterBySOPClassesForm(FilterBySOPClassesForm filterBySOP
.bind(DestinationEntity::isFilterBySOPClasses, DestinationEntity::setFilterBySOPClasses);
}

public void addBinderExtidInDicomTag(LayoutDesidentification layoutDesidentification) {
layoutDesidentification
public void addBinderExtidInDicomTag(DeIdentificationComponent deIdentificationComponent) {
deIdentificationComponent
.getDestinationBinder()
.forField(layoutDesidentification.getExtidPresentInDicomTagView().getTag())
.forField(deIdentificationComponent.getPseudonymInDicomTagComponent().getTag())
.withConverter(String::valueOf, value -> (value == null) ? "" : value, "Must be a tag")
.withValidator(
tag -> {
if (!layoutDesidentification.getCheckboxDesidentification().getValue()
|| !layoutDesidentification
.getExtidListBox()
if (!deIdentificationComponent.getDeIdentificationCheckbox().getValue()
|| !deIdentificationComponent
.getPseudonymTypeSelect()
.getValue()
.equals(EXTID_IN_TAG.getValue())) {
return true;
Expand All @@ -550,24 +554,27 @@ public void addBinderExtidInDicomTag(LayoutDesidentification layoutDesidentifica
"Choose a valid tag\n")
.bind(DestinationEntity::getTag, DestinationEntity::setTag);

layoutDesidentification
deIdentificationComponent
.getDestinationBinder()
.forField(layoutDesidentification.getExtidPresentInDicomTagView().getDelimiter())
.forField(deIdentificationComponent.getPseudonymInDicomTagComponent().getDelimiter())
.withConverter(
String::valueOf, value -> (value == null) ? "" : value, "Must be a delimiter")
.withValidator(
delimiter -> {
if (!layoutDesidentification.getCheckboxDesidentification().getValue()
|| !layoutDesidentification
.getExtidListBox()
if (!deIdentificationComponent.getDeIdentificationCheckbox().getValue()
|| !deIdentificationComponent
.getPseudonymTypeSelect()
.getValue()
.equals(EXTID_IN_TAG.getValue())) {
return true;
}
if (layoutDesidentification.getExtidPresentInDicomTagView().getPosition().getValue()
if (deIdentificationComponent
.getPseudonymInDicomTagComponent()
.getPosition()
.getValue()
!= null
&& layoutDesidentification
.getExtidPresentInDicomTagView()
&& deIdentificationComponent
.getPseudonymInDicomTagComponent()
.getPosition()
.getValue()
> 0) {
Expand All @@ -578,23 +585,26 @@ public void addBinderExtidInDicomTag(LayoutDesidentification layoutDesidentifica
"A delimiter must be defined, when a position is present")
.bind(DestinationEntity::getDelimiter, DestinationEntity::setDelimiter);

layoutDesidentification
deIdentificationComponent
.getDestinationBinder()
.forField(layoutDesidentification.getExtidPresentInDicomTagView().getPosition())
.forField(deIdentificationComponent.getPseudonymInDicomTagComponent().getPosition())
.withConverter(new DoubleToIntegerConverter())
.withValidator(
position -> {
if (!layoutDesidentification.getCheckboxDesidentification().getValue()
|| !layoutDesidentification
.getExtidListBox()
if (!deIdentificationComponent.getDeIdentificationCheckbox().getValue()
|| !deIdentificationComponent
.getPseudonymTypeSelect()
.getValue()
.equals(EXTID_IN_TAG.getValue())) {
return true;
}
if (layoutDesidentification.getExtidPresentInDicomTagView().getDelimiter().getValue()
if (deIdentificationComponent
.getPseudonymInDicomTagComponent()
.getDelimiter()
.getValue()
!= null
&& !layoutDesidentification
.getExtidPresentInDicomTagView()
&& !deIdentificationComponent
.getPseudonymInDicomTagComponent()
.getDelimiter()
.getValue()
.equals("")) {
Expand All @@ -605,9 +615,9 @@ public void addBinderExtidInDicomTag(LayoutDesidentification layoutDesidentifica
"A position must be defined, when a delimiter is present")
.bind(DestinationEntity::getPosition, DestinationEntity::setPosition);

layoutDesidentification
deIdentificationComponent
.getDestinationBinder()
.forField(layoutDesidentification.getExtidPresentInDicomTagView().getSavePseudonym())
.forField(deIdentificationComponent.getPseudonymInDicomTagComponent().getSavePseudonym())
.bind(DestinationEntity::getSavePseudonym, DestinationEntity::setSavePseudonym);
}
}
Loading

0 comments on commit 3de3e95

Please sign in to comment.