Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP-1341 Enable Medical Type for Soft Deletion #2092

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/isf/medicals/gui/MedicalBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ private JComboBox getComboBoxMedicalType() {
pbox.addItem(STR_ALL);
List<MedicalType> type;
try {
type = medicalTypeManager.getMedicalType();
type = medicalTypeManager.getAllActiveMedicalType();
for (MedicalType elem : type) {
pbox.addItem(elem);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/isf/medicals/gui/MedicalEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ private JComboBox<MedicalType> getTypeComboBox() {
if (typeComboBox == null) {
typeComboBox = new JComboBox<>();
try {
List<MedicalType> types = medicalTypeManager.getMedicalType();
List<MedicalType> types = medicalTypeManager.getAllActiveMedicalType();
for (MedicalType elem : types) {
typeComboBox.addItem(elem);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ private JComboBox getMedicalTypeBox() {
medicalTypeBox.addItem(TEXT_ALL);

try {
medical = medicalTypeBrowserManager.getMedicalType();
medical = medicalTypeBrowserManager.getAllActiveMedicalType();

for (MedicalType aMedicalType : medical) {
medicalTypeBox.addItem(aMedicalType);
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/org/isf/medtype/gui/MedicalTypeBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ public class MedicalTypeBrowser extends ModalJFrame implements MedicalTypeListen
private List<MedicalType> pMedicalType;
private String[] pColumns = {
MessageBundle.getMessage("angal.common.code.txt").toUpperCase(),
MessageBundle.getMessage("angal.common.description.txt").toUpperCase()
MessageBundle.getMessage("angal.common.description.txt").toUpperCase(),
MessageBundle.getMessage("angal.common.deleted.label").toUpperCase()
};
private int[] pColumnWidth = {80, 200};
private final int[] pColumnWidth = { 20, 200, 20 };
private JPanel jContainPanel;
private JPanel jButtonPanel;
private JButton jNewButton;
Expand Down Expand Up @@ -198,6 +199,7 @@ private JTable getJTable() {
jTable = new JTable(model);
jTable.getColumnModel().getColumn(0).setMinWidth(pColumnWidth[0]);
jTable.getColumnModel().getColumn(1).setMinWidth(pColumnWidth[1]);
jTable.getColumnModel().getColumn(2).setMinWidth(pColumnWidth[2]);
}
return jTable;
}
Expand Down Expand Up @@ -243,6 +245,8 @@ public Object getValueAt(int r, int c) {
return medType.getCode();
} else if (c == 1) {
return medType.getDescription();
} else if (c == 2) {
return medType.getDeleted() == 'Y';
}
return null;
}
Expand All @@ -251,6 +255,11 @@ public Object getValueAt(int r, int c) {
public boolean isCellEditable(int arg0, int arg1) {
return false;
}

@Override
public Class getColumnClass(int column) {
return (column == 2) ? Boolean.class : String.class;
}
}

@Override
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/org/isf/medtype/gui/MedicalTypeBrowserEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.EventListener;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
Expand Down Expand Up @@ -95,8 +96,10 @@ private void fireMedicalUpdated() {
private JButton cancelButton;
private JButton okButton;
private JTextField descriptionTextField;
private JCheckBox deletedCheckbox;
private VoLimitedTextField codeTextField;
private String lastdescription;
private char isLastDeleted;
private MedicalType medicalType;
private boolean insert;
private JPanel jDataPanel;
Expand All @@ -110,6 +113,7 @@ public MedicalTypeBrowserEdit(JFrame owner, MedicalType old, boolean inserting)
insert = inserting;
medicalType = old; //medical type will be used for every operation
lastdescription = medicalType.getDescription();
isLastDeleted = medicalType.getDeleted();
initialize();
}

Expand All @@ -124,6 +128,7 @@ private void initialize() {
this.setTitle(MessageBundle.getMessage("angal.medtype.editmedicaltype.title"));
}
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.getDeletedField();
this.pack();
this.setLocationRelativeTo(null);
}
Expand Down Expand Up @@ -197,7 +202,8 @@ private JButton getOkButton() {

medicalType.setDescription(descriptionTextField.getText());
medicalType.setCode(codeTextField.getText());

medicalType.setDeleted(deletedCheckbox.isSelected() ? 'Y' : 'N');

if (insert) { // inserting
try {
MedicalType insertedMedicalType = medicalTypeBrowserManager.newMedicalType(medicalType);
Expand All @@ -211,7 +217,7 @@ private JButton getOkButton() {
OHServiceExceptionUtil.showMessages(e1);
}
} else { // updating
if (descriptionTextField.getText().equals(lastdescription)) {
if (descriptionTextField.getText().equals(lastdescription) && medicalType.getDeleted() == isLastDeleted) {
dispose();
} else {
try {
Expand Down Expand Up @@ -263,6 +269,14 @@ private JTextField getCodeTextField() {
}
return codeTextField;
}

private JCheckBox getDeletedField() {
if (deletedCheckbox == null) {
deletedCheckbox = new JCheckBox(MessageBundle.getMessage("angal.common.deleted.label"));
deletedCheckbox.setSelected(medicalType.getDeleted() == 'Y');
}
return deletedCheckbox;
}

/**
* This method initializes jDataPanel
Expand All @@ -276,7 +290,9 @@ private JPanel getJDataPanel() {
jDataPanel.add(getCodeTextField());
jDataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.description.txt") + ':'));
jDataPanel.add(getDescriptionTextField());
SpringUtilities.makeCompactGrid(jDataPanel, 2, 2, 5, 5, 5, 5);
jDataPanel.add(new JLabel(MessageBundle.getMessage("angal.common.deleted.label") + ':'));
jDataPanel.add(getDeletedField());
SpringUtilities.makeCompactGrid(jDataPanel, 3, 2, 5, 5, 5, 5);
}
return jDataPanel;
}
Expand Down