bahmni registration search multiple local name parts

Hello, I’m trying to find if there is a way to search for patients by local name, specifying multiple parts of the local name.

The situation is that during registration, patients are given a transliterated english name from arabic, and then the arabic name is stored in the givenNameLocal, middleNameLocal and familyNameLocal patient attributes. In the bahmni registration app a custom search parameter has been specified as:

"customAttributes": {
    "label": "اسم العربي",
    "placeholder": "اسم العربي",
    "fields": ["givenNameLocal", "middleNameLocal", "grandfatherNameLocal", "familyNameLocal"]

This way the registration clerk can enter any one of given name, middle name or family name (or possibly grandfather name), and see the patients that match.

The problem is that many names in Arabic are very common. Searching by just one part of the arabic name is not specific enough to be very useful. If two names are specified in this search field with a space, no results are given. So we want to be able to enter in the search field " احمد محمد" and see all patients who have both احمد and محمد in their full arabic name.

I’ve taken a look in bahmni-core to see why this is the case, in I can see that it would probably be more complicated than what was done for the english name. We’d prefer not to be building and maintaining our own bahmni-core module though.

I could try coming up with a solution and writing a patch, but I thought I would ask here first. Is there another way to do this, and if not would such a feature be useful generally - to require a match of each word in a multi-word search entry against any of the patient attributes, but not necessarily match against the same attribute?

The right long-run solution is to refactor Bahmni such that the local name is stored in OpenMRS as a PersonName (rather than PersonAttributes). However this sounds like a significant amount of work, and might require introducing something new to OpenMRS, like a “Name Type”.

I do think that having multi-word searches work better against person attributes would be generally useful, but we’d want to ensure it doesn’t adversely affect performance in a notable way.

Actually, in recent Bahmni releases we’ve upgraded to use a version of the OpenMRS Platform that indexes patients in Lucene for faster/better patient searches. But we have not fully refactored Bahmni to take advantage of this. So maybe the most efficient solution is to see if PatientSearchBuilder can be refactored to use the Lucene API instead of the SQL generation in PatientAttributeQueryHelper.

Let’s use this thread to cover

  • BAH-273: Extend Lucene search use in registration screen (and every other place where applicable)