From d8d288064761fd131a22ccfb2b0956fc8f3bb887 Mon Sep 17 00:00:00 2001 From: ra247362 Date: Fri, 29 Nov 2024 17:41:06 -0300 Subject: [PATCH] Small fix to ensure expected behavior for non existant patient code. --- src/main/java/org/isf/lab/gui/LabBrowser.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/isf/lab/gui/LabBrowser.java b/src/main/java/org/isf/lab/gui/LabBrowser.java index 37733c84d3..ff2db0de73 100644 --- a/src/main/java/org/isf/lab/gui/LabBrowser.java +++ b/src/main/java/org/isf/lab/gui/LabBrowser.java @@ -515,6 +515,7 @@ 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()) { @@ -522,12 +523,17 @@ public LabBrowsingModel(String exam, LocalDate dateFrom, LocalDate dateTo, Strin } 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; } } - pLabs = labManager.getLaboratory(exam, dateFrom.atStartOfDay(), dateTo.atStartOfDay(), pat); + if (exists) { + pLabs = labManager.getLaboratory(exam, dateFrom.atStartOfDay(), dateTo.atStartOfDay(), pat); + } else { + pLabs = new ArrayList<>(); + } } catch (OHServiceException e) { pLabs = new ArrayList<>(); OHServiceExceptionUtil.showMessages(e);