Skip to content

Commit

Permalink
Merge branch 'develop' into feature/OP-1043-users-and-groups-soft-delete
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGT96 committed Nov 11, 2024
2 parents bf4af4b + f39d81e commit 98e9a16
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 94 deletions.
19 changes: 6 additions & 13 deletions src/main/java/org/isf/accounting/gui/BillDataLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,12 @@ public BillDataLoader(List<Bill> billPeriod, List<Bill> billFromPayments, Patien
}

public List<Bill> loadBills(String status, String username) throws OHServiceException {
List<Bill> tableArray = new ArrayList<>();

switch (status) {
case "O":
tableArray = getPendingBills(status, username);
break;
case "ALL":
tableArray = getAllBills(username);
break;
case "C":
tableArray = getClosedBills(status, username);
break;
}
List<Bill> tableArray = switch (status) {
case "O" -> getPendingBills(status, username);
case "ALL" -> getAllBills(username);
case "C" -> getClosedBills(status, username);
default -> new ArrayList<>();
};

tableArray.sort(Collections.reverseOrder());
return tableArray;
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/org/isf/admission/gui/AdmittedPatientBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1206,15 +1206,11 @@ else if (patientClassBox.getSelectedItem().equals(patientClassItems[1])) {
}

// sex patient type
Character sex = null;
switch (patientSexBox.getSelectedIndex()) {
case 1:
sex = 'M';
break;
case 2:
sex = 'F';
break;
}
Character sex = switch (patientSexBox.getSelectedIndex()) {
case 1 -> 'M';
case 2 -> 'F';
default -> null;
};

if (sex != null && !sex.equals(ap.getPatient().getSex())) {
continue;
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/org/isf/admission/gui/PatientFolderBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,19 +452,16 @@ public void mouseClicked(MouseEvent mouseEvent) {
}
}

if (selectedObject instanceof Admission) {
if (selectedObject instanceof Admission ad) {

Admission ad = (Admission) selectedObject;
startDate = ad.getAdmDate();
endDate = ad.getDisDate();

} else if (selectedObject instanceof Opd) {
} else if (selectedObject instanceof Opd opd) {

Opd opd = (Opd) selectedObject;
startDate = opd.getDate();

} else if (selectedObject instanceof PatientExamination) {
PatientExamination exam = (PatientExamination) selectedObject;
} else if (selectedObject instanceof PatientExamination exam) {
startDate = exam.getPex_date();
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/isf/opd/gui/OpdEditExtended.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,7 @@ private void setAttendance() {
return;
}
Object selectedObject = diseaseBox1.getSelectedItem();
if (selectedObject instanceof Disease) {
Disease disease = (Disease) selectedObject;
if (selectedObject instanceof Disease disease) {
if (lastOPDDisease1 != null && disease.getCode().equals(lastOPDDisease1.getCode())) {
rePatientButton.setSelected(true);
} else {
Expand Down
26 changes: 10 additions & 16 deletions src/main/java/org/isf/patient/gui/PatientInsert.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,11 @@ private JButton getJOkButton() {
String name = jFirstNameTextField.getText() + ' ' + jSecondNameTextField.getText();
try {
if (patientBrowserManager.isNamePresent(name)) {
switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION:
ok = true;
break;
case JOptionPane.NO_OPTION:
ok = false;
break;
}
ok = switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION -> true;
case JOptionPane.NO_OPTION -> false;
default -> ok;
};
}
} catch (OHServiceException ex) {
OHServiceExceptionUtil.showMessages(ex);
Expand Down Expand Up @@ -320,14 +317,11 @@ private JButton getJOkButton() {
if (!patient.getName().equals(name)) {
try {
if (patientBrowserManager.isNamePresent(name)) {
switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION:
ok = true;
break;
case JOptionPane.NO_OPTION:
ok = false;
break;
}
ok = switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION -> true;
case JOptionPane.NO_OPTION -> false;
default -> ok;
};
}
} catch (OHServiceException ex) {
OHServiceExceptionUtil.showMessages(ex);
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/org/isf/patient/gui/PatientInsertExtended.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,11 @@ private JButton getJOkButton() {
String name = firstName + ' ' + secondName;
try {
if (patientBrowserManager.isNamePresent(name)) {
switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION:
ok = true;
break;
case JOptionPane.NO_OPTION:
ok = false;
break;
}
ok = switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION -> true;
case JOptionPane.NO_OPTION -> false;
default -> ok;
};
}
} catch (OHServiceException ex) {
OHServiceExceptionUtil.showMessages(ex);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/isf/session/LoginEventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public class LoginEventListener implements LoginListener {

@Override
public void loginInserted(AWTEvent e) {
if (e.getSource() instanceof User) {
User myUser = (User) e.getSource();
if (e.getSource() instanceof User myUser) {
RestartUserSession.setUser(myUser);
RestartUserSession.getTimer().startTimer();
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/isf/therapy/gui/TherapyEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -1142,14 +1142,12 @@ public void mouseClicked(MouseEvent e) {
model = list.getModel();
for (int i = 0; i < model.getSize(); i++) {
Object iteratedItem = model.getElementAt(i);
if (iteratedItem instanceof Therapy) {
Therapy aTherapy = (Therapy) iteratedItem;
if (iteratedItem instanceof Therapy aTherapy) {
if (therapyID != 0 && aTherapy.getTherapyID() == therapyID) {
list.setSelectedIndex(i);
}
}
if (iteratedItem instanceof Visit) {
Visit aVisit = (Visit) iteratedItem;
if (iteratedItem instanceof Visit aVisit) {
if (visitID != 0 && aVisit.getVisitID() == visitID) {
list.setSelectedIndex(i);
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/isf/utils/jobjects/OhTableDrugsModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ public Object getValueAt(int rowIndex, int columnIndex) {
String value = "";
if (rowIndex >= 0 && rowIndex < this.filteredList.size()) {
T obj = this.filteredList.get(rowIndex);
if (obj instanceof MovementWard) {
MovementWard drugObj = (MovementWard) obj;
if (obj instanceof MovementWard drugObj) {
switch (columnIndex) {
case 0:
String dt;
Expand Down
24 changes: 8 additions & 16 deletions src/main/java/org/isf/utils/jobjects/OhTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public T filter(String searchQuery) throws OHException {

for (T t : this.dataList) {
Object object = t;
if (object instanceof Price) {
Price price = (Price) object;
if (object instanceof Price price) {
String strItem = price.getItem() + price.getDesc();
if (allowSearchByCode && searchQuery.equalsIgnoreCase(price.getItem())) {
T resPbj = (T) object;
Expand All @@ -83,8 +82,7 @@ public T filter(String searchQuery) throws OHException {
}
}

if (object instanceof MedicalWard) {
MedicalWard mdw = (MedicalWard) object;
if (object instanceof MedicalWard mdw) {
String strItem = mdw.getMedical().getProdCode() + mdw.getMedical().getDescription();

if (allowSearchByCode && searchQuery.equalsIgnoreCase(mdw.getMedical().getProdCode())) {
Expand All @@ -101,8 +99,7 @@ public T filter(String searchQuery) throws OHException {
}
}

if (object instanceof PricesOthers) {
PricesOthers priceO = (PricesOthers) object;
if (object instanceof PricesOthers priceO) {
String strItem = priceO.getCode() + priceO.getDescription();

if (allowSearchByCode && searchQuery.equalsIgnoreCase(priceO.getCode())) {
Expand All @@ -119,8 +116,7 @@ public T filter(String searchQuery) throws OHException {
}
}

if (object instanceof BillItems) {
BillItems priceO = (BillItems) object;
if (object instanceof BillItems priceO) {
String strItem = priceO.getItemDisplayCode() + priceO.getItemDescription();

if (allowSearchByCode && searchQuery.equalsIgnoreCase(priceO.getItemDisplayCode())) {
Expand Down Expand Up @@ -188,33 +184,29 @@ public Object getValueAt(int rowIndex, int columnIndex) {
String value = "";
if (rowIndex >= 0 && rowIndex < this.filteredList.size()) {
T obj = this.filteredList.get(rowIndex);
if (obj instanceof Price) {
Price priceObj = (Price) obj;
if (obj instanceof Price priceObj) {
if (columnIndex == 0) {
value = priceObj.getItem() != null ? priceObj.getItem() : String.valueOf(priceObj.getId());
} else {
value = priceObj.getDesc();
}
}
if (obj instanceof MedicalWard) {
MedicalWard mdwObj = (MedicalWard) obj;
if (obj instanceof MedicalWard mdwObj) {
if (columnIndex == 0) {
value = mdwObj.getMedical().getProdCode() != null ? mdwObj.getMedical().getProdCode() : String.valueOf(mdwObj.getMedical().getCode());
} else {
value = mdwObj.getMedical().getDescription();
}
}
if (obj instanceof PricesOthers) {
PricesOthers mdwObj = (PricesOthers) obj;
if (obj instanceof PricesOthers mdwObj) {
if (columnIndex == 0) {
value = mdwObj.getCode() != null ? mdwObj.getCode() : String.valueOf(mdwObj.getId());
} else {
value = mdwObj.getDescription();
}
}

if (obj instanceof BillItems) {
BillItems mdwObj = (BillItems) obj;
if (obj instanceof BillItems mdwObj) {
if (columnIndex == 0) {
value = mdwObj.getItemDisplayCode() != null ? mdwObj.getItemDisplayCode() : String.valueOf(mdwObj.getId());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public int filter(String searchQuery) {

for (T t : this.dataList) {
Object object = t;
if (object instanceof OperationRow) {
OperationRow price = (OperationRow) object;
if (object instanceof OperationRow price) {
String strItem = price.getOperation().getCode() + price.getOpResult();
strItem = strItem.toLowerCase();
searchQuery = searchQuery.toLowerCase();
Expand Down Expand Up @@ -126,8 +125,7 @@ public Object getValueAt(int rowIndex, int columnIndex) {
String value = "";
if (rowIndex >= 0 && rowIndex < this.filteredList.size()) {
T obj = this.filteredList.get(rowIndex);
if (obj instanceof OperationRow) {
OperationRow opdObj = (OperationRow) obj;
if (obj instanceof OperationRow opdObj) {
switch (columnIndex) {
case -1:
return opdObj;
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/org/isf/video/PhotoboothTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ public static void main(final String[] args) {
final PhotoboothPanelPresentationModel presentationModel = new PhotoboothPanelPresentationModel();
presentationModel.addBeanPropertyChangeListener(PhotoboothPanelModel.PROPERTY_IMAGE, propertyChangeEvent -> {
final Object newValue = propertyChangeEvent.getNewValue();
if (newValue instanceof BufferedImage) {
final BufferedImage bufferedImage = (BufferedImage) newValue;
LOGGER.info("New image is being set {}x{}", bufferedImage.getWidth(), bufferedImage.getHeight());
if (newValue instanceof BufferedImage bufferedImage) {
LOGGER.info("New image is being set {}x{}", bufferedImage.getWidth(), bufferedImage.getHeight());
}
});
presentationModel.addBeanPropertyChangeListener(PhotoboothPanelModel.PROPERTY_RESOLUTION, propertyChangeEvent -> {
Object newValue = propertyChangeEvent.getNewValue();
if (newValue instanceof Dimension) {
final Dimension newDimension = (Dimension) newValue;
LOGGER.info("New dimension is {}x{}", newDimension.getWidth(), newDimension.getHeight());
if (newValue instanceof Dimension newDimension) {
LOGGER.info("New dimension is {}x{}", newDimension.getWidth(), newDimension.getHeight());
}
});

Expand Down
10 changes: 4 additions & 6 deletions src/main/java/org/isf/video/gui/PhotoboothComponentImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ public Component getListCellRendererComponent(final JList list,
final boolean isSelected,
final boolean cellHasFocus) {
final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Dimension) {
final Dimension valueAsDimension = (Dimension) value;
setText(String.format("%d x %d", (int) valueAsDimension.getWidth(), (int) valueAsDimension.getHeight()));
if (value instanceof Dimension valueAsDimension) {
setText(String.format("%d x %d", (int) valueAsDimension.getWidth(), (int) valueAsDimension.getHeight()));
}
return component;
}
Expand All @@ -73,9 +72,8 @@ public Component getListCellRendererComponent(final JList list,
final boolean isSelected,
final boolean cellHasFocus) {
final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Webcam) {
final Webcam webcam = (Webcam) value;
setText(webcam.getName());
if (value instanceof Webcam webcam) {
setText(webcam.getName());
}
return component;
}
Expand Down

0 comments on commit 98e9a16

Please sign in to comment.