Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash for search patient using special character #4842

Merged
merged 3 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Bump AGP to v8.3.1
- Bump desugar JDK library to v2.0.4

### Fixes

- Fix app crash on searching overdue patient with special characters

## 2024-01-08-8979

### Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,16 @@ class AppointmentRepository @Inject constructor(
)
}

private fun transformSearchInputsIntoQuery(searchInputs: List<String>) = searchInputs
.joinToString(separator = " OR ") { "*$it*" }
private fun transformSearchInputsIntoQuery(searchInputs: List<String>): String {
msasikanth marked this conversation as resolved.
Show resolved Hide resolved
return searchInputs.joinToString(separator = " OR ") {
sanitizeSearchQuery(it)
}
}

private fun sanitizeSearchQuery(query: String): String {
val escapedQuery = query.replace(Regex.fromLiteral("\""), "\"\"")
return "\"*$escapedQuery*\""
}

fun lastCreatedAppointmentForPatient(patientUuid: UUID): Optional<Appointment> {
return appointmentDao.lastCreatedAppointmentForPatient(patientUuid).toOptional()
Expand Down
Loading