Skip to content

Commit 861b627

Browse files
committed
Fix NumberFormatException
1 parent 217c345 commit 861b627

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

omod/src/main/java/org/openmrs/module/xforms/page/controller/PatientRegUrlHandler.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public String handleEditEncounterPage(HttpServletRequest request, HttpServletRes
8989
String encounterId = request.getParameter("encounterId");
9090
String patientId = request.getParameter("patientId");
9191
if (StringUtils.isNotBlank(encounterId) && StringUtils.isNotBlank(patientId)) {
92-
Encounter encounter = Context.getEncounterService().getEncounter(Integer.parseInt(encounterId));
92+
Encounter encounter = getEncounter(encounterId);
9393
if (encounter != null && encounter.getForm() != null) {
9494
Xform xform = Context.getService(XformsService.class).getXform(encounter.getForm());
9595
if (xform != null) {
@@ -106,6 +106,15 @@ public String handleEditEncounterPage(HttpServletRequest request, HttpServletRes
106106
return handlePath(path, request, response, model, httpSession);
107107
}
108108

109+
private Encounter getEncounter(String encounterId) {
110+
try {
111+
return Context.getEncounterService().getEncounter(Integer.parseInt(encounterId));
112+
}
113+
catch (NumberFormatException ex) {
114+
return Context.getEncounterService().getEncounterByUuid(encounterId);
115+
}
116+
}
117+
109118
/**
110119
* @param path should be of the form "provider/optional/subdirectories/pageName"
111120
* @param request

0 commit comments

Comments
 (0)