Skip to content

Commit

Permalink
Refactor one of the LabBrowsingModel to streamline overall logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
ra247362 committed Dec 26, 2024
1 parent 491280e commit aeae08e
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions src/main/java/org/isf/lab/gui/LabBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -515,29 +515,24 @@ class LabBrowsingModel extends DefaultTableModel {
private static final long serialVersionUID = 1L;

public LabBrowsingModel(String exam, LocalDate dateFrom, LocalDate dateTo, String patid) {
boolean exists = true;
try {
Patient pat;
if (patid.isEmpty()) {
pat = null;
} else {
try {
pat = patManager.getPatientById(Integer.parseInt(patid));
exists = pat == null ? false : true;
} catch (NumberFormatException e) {
MessageDialog.error(null, "angal.lab.insertvalidpatientid.msg");
pat = null;
}
}
if (exists) {
pLabs = labManager.getLaboratory(exam, dateFrom.atStartOfDay(), dateTo.atStartOfDay(), pat);
if (!patid.isEmpty()) {
Patient pat = patManager.getPatientById(Integer.parseInt(patid));
if (pat == null) {
pLabs = new ArrayList<>();;
} else {
pLabs = labManager.getLaboratory(exam, dateFrom.atStartOfDay(), dateTo.atStartOfDay(), pat);
}
} else {
pLabs = new ArrayList<>();
pLabs = labManager.getLaboratory(exam, dateFrom.atStartOfDay(), dateTo.atStartOfDay(), null);
}
} catch (OHServiceException e) {
pLabs = new ArrayList<>();
OHServiceExceptionUtil.showMessages(e);
}
} catch (NumberFormatException e) {
pLabs = new ArrayList<>();
MessageDialog.error(null, "angal.lab.insertvalidpatientid.msg");
}
}

public LabBrowsingModel(String patid) {
Expand Down Expand Up @@ -644,4 +639,4 @@ public void laboratoryInserted() {
}
}

}
}

0 comments on commit aeae08e

Please sign in to comment.