Registration Search Error when apostrophe in name

Hello Bahmni Team–

Just a quick note that we’d discovered bug when searching for patients with apostrophes in their names.

In Sierra Leone we were looking to allow apostrophes in names (for example, “Troy O’Leary”) and so modified the Bahmni and OpenMRS regex to allow this. This seems to work fine, and we are able to create names with apostrophes.

However, searching for names with apostrophes in the registration apps results in an error.

Steps to reproduce

  1. Click on registration app
  2. Enter “Troy O’Leary” in the “Name” search box and hit “Search”

You’ll get a red error message “could not locate named parameter [limit]”.

Taking a quick look at the underlying server stack trace, I’m guessing this is due to the ’ not being properly escaped in the SQL error:

org.hibernate.QueryParameterException: could not locate named parameter [limit] at org.hibernate.engine.query.ParameterMetadata.getNamedParameterDescriptor(ParameterMetadata.java:101) at org.hibernate.engine.query.ParameterMetadata.getNamedParameterExpectedType(ParameterMetadata.java:107) at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:460) at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:430) at org.bahmni.module.bahmnicore.contract.patient.search.PatientSearchBuilder.buildSqlQuery(PatientSearchBuilder.java:156) at org.bahmni.module.bahmnicore.dao.impl.PatientDaoImpl.getPatients(PatientDaoImpl.java:44) at org.bahmni.module.bahmnicore.service.impl.BahmniPatientServiceImpl.search(BahmniPatientServiceImpl.java:52) at org.bahmni.module.bahmnicore.web.v1_0.controller.search.BahmniPatientSearchController.search(BahmniPatientSearchController.java:44) at sun.reflect.GeneratedMethodAccessor1004.invoke(Unknown Source)

Hi Mark,

Thanks for pointing this out…We have created a card for tracking this issue. https://bahmni.mingle.thoughtworks.com/projects/bahmni_emr/cards/1878

You are welcome!