Skip to content

Commit 85f49e2

Browse files
Restore assignment, improve validation
1 parent 300b107 commit 85f49e2

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

hdrl/src/org/labkey/hdrl/query/InboundSpecimenUpdateService.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,30 +151,34 @@ public static void validate(Map<String, Object> row) throws ValidationException
151151
}
152152
}
153153
}
154-
if (row.get("BirthDate") != null)
154+
Object birthDateObj = row.get("BirthDate");
155+
if (birthDateObj != null)
155156
{
156-
Date birthDate;
157-
if (row.get("BirthDate") instanceof Date)
158-
row.get("BirthDate");
157+
Date birthDate = null;
158+
if (birthDateObj instanceof Date d)
159+
birthDate = d;
159160
else
160161
{
161162
try
162163
{
163164
birthDate = dateFormat.parse((String) row.get("BirthDate"));
164-
if (birthDate.after(today))
165-
{
166-
errors.add("Birth date cannot be in the future");
167-
}
168-
else if ((drawDate != null) && (drawDate.before(birthDate)))
169-
{
170-
errors.add("Draw date cannot be before birth date");
171-
}
172165
}
173166
catch (ParseException e)
174167
{
175168
errors.add("Invalid birth date format");
176169
}
177170
}
171+
if (birthDate != null)
172+
{
173+
if (birthDate.after(today))
174+
{
175+
errors.add("Birth date cannot be in the future");
176+
}
177+
else if ((drawDate != null) && (drawDate.before(birthDate)))
178+
{
179+
errors.add("Draw date cannot be before birth date");
180+
}
181+
}
178182
}
179183
if (row.get("SSN") == null || StringUtils.isEmpty(String.valueOf(row.get("SSN"))))
180184
missingFields.add("SSN");

0 commit comments

Comments
 (0)