How to customise the Patient Registration page?

Thanks Darius, that indeed solved the controller issue. I was able to append a new section to Patient Registration using concepts behind the question/answers. That’s a great step forward. Thanks so much!

If possible you could help others by writing a step by step guide for the same.

1 Like

@mksd To answer your questions:

  1. Are you using the Address Hierarchy module? In order to use dropdowns to select addresses, you will have to set up a hierarchy using the module as described here: https://wiki.openmrs.org/display/docs/Address+Hierarchy+Module. Then, after you have the hierarchy set up, you will want to use the PersonAddressWithHierarchy widget providered by the registration app (provider=“registrationapp”, fragmentId=“field/personAddressWithHierarchy”).

You may have to set some of the configuration parameters on the person address with hierarchy widget as well–there’s no good documentation of them, but the code for the widget can be found here:

  1. Unfortunately, there is no easy way to add “edit” functionality to observations added to the registration encounter as part of the registration workflow. What we’ve done in these cases is created separate Html Form Entry forms for editng. This is not ideal, because you have to maintain the content of the form in two places–in the *_app.json and in a separate html form, but it is all we have for now. What we did was defined the registration encounter as an html form, and then added an instance of the coreapps “mostRecentEncounter” app to the registration dashboard and associated it with our registration encounter type.

openmrs-module-addresshierarchy

No I wasn’t using it, thanks for pointing that out. I tried to import the sample address hierarchy text file (copy/pasting the 4 liner provided in the wiki) and, although I just pasted it using the pipe as delimiter… well basically it ignored the pipe and created a address hierarchy level for every single character in the file (I guess I forgot to escape it at first, my bad).

When trying to re-upload while overriding it fails and logs:

Unable to import address hierarchy file org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [delete from address_hierarchy_entry where address_hierarchy_entry_id=?]; constraint [null] … ERROR - ManageAddressHierarchyController.processAddressHierarchyUploadForm(210) |2015-07-30 23:43:15,962| Unable to import address hierarchy file org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [delete from address_hierarchy_entry where address_hierarchy_entry_id=?]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at…

Hence my new questions :-/

  1. How do I delete this now to start over again?
  2. How do I change the address field to bring up something like ‘district’ as it is shown in the screenshots? Right now I only see the “usual”: Address, Address 2, City/Village… etc.

Edition

I guess I see the idea, I’ll come back to this after I have managed to fully figure out the above address challenge. But anyway the address will be editable right, it is only those fields where I used obs that will have to go the HFE way for editing?

@mogoodrich @darius

Ok I figured out, using Bahmni’s example how to import a CSV file correctly.

Here is how I changed my *_app.json file:

{
  "type": "personAddress",
  "label": "registrationapp.patient.address.question",
  "widget": {
      //"providerName": "uicommons",
      //"fragmentId": "field/personAddress"
      "providerName": "registrationapp",
      "fragmentId": "field/personAddressWithHierarchy"
  }
}

And here is the error log I get when trying to access the patient registration page after that: http://paste.ubuntu.com/11972180/

Clearly some controller fails to provide some name variable to the fragment, I’m not quite sure how to troubleshoot this right now, any help would be very welcome…

Have you set a “Mapped Address Field” for each level in the hierarchy as shown in the Bahmni example? It’s annoying to debug gsp because you can’t tell from the stack trace exactly where the problem is occurring, but it looks like the only places where a name field is being accessed in that page is addressfield.name.

For what it’s worth, I did see that in reference to map address fields in the Bahmni docs it says “From DB perspective this does not matter”… but, to be clear, it means that from a DB perspective it doesn’t matter which field you chose, but it does matters that you choose some field.

Yes you are right, I had figured that out as well, it was indeed coming from unset addressfield.name. But would you know how to delete an existing hierarchy?

@mogoodrich

Ok for now I could overwrite an existing hierarchy, which already helps. It would be good to be able to just delete it though.


I have a very important question left because this is a functional blocker: after setting up everything, I just couldn’t obtain a free field anymore (such as address1).

  • Either I map address1 in ‘Address Hierarchy Levels’ and it becomes constrained.
  • Or I don’t map it and it just doesn’t show up on the registration form.

How can I then combine a few constrained fileds (country, province, district) with one free field (address)?

Thanks for all your help so far!

Kind of hacky, but I think if you upload a blank csv file, it may just blow away the existing hierarchy, The other hacky alternative would be just to clear out all the rows in the address_hierarchy_entry and address_hierarchy_level table.

I believe for your other issue you need to add a list of the fields that allow manual entry like so:

widget : {
  "providerName": "uicommons",
   ...
  "config": {
     "manualFields": [
          "addressfield-name-of-field-that-allows-manual-entry"
      ]

   }
}

For now I have this:

"legend": "Person.address",
"fields": [
    {
        "type": "personAddress",
        "label": "registrationapp.patient.address.question",
        "widget": {
            "providerName": "registrationapp",
            "fragmentId": "field/personAddressWithHierarchy"
        }
    }
]

Should it become that?

"legend": "Person.address",
"fields": [
    {
        "type": "personAddress",
        "label": "registrationapp.patient.address.question",
        "widget": {
            "providerName": "registrationapp",
            "fragmentId": "field/personAddressWithHierarchy",
            "config": {
              "manualFields": [
                "Foobar"
              ]
            }
        }
    }
]

This doesn’t produce any result. I am sorry if this is obvious, I’m just really unsure about this config logic in the widget. But from the widget class that you pointed out above in the thread, it seems that it should be at the same level as fragmentId or providerName, which is why I put it there. I’m not sure if you really meant uicommons in your snippet, in which case I may need more info here I’m afraid.

Another issue is that the address template in Admin > Manage Address Template is reset to the default one each time I restart Jetty. Have you ever noticed anything like that?

Thanks for your responsivness.

EDIT Being a bit stuck, I tried to debug PersonAddressWithHierarchyWidget.java but this was never reached. When exactly is this Config object instanciated/read?

Sorry, I’ve been swamped with a lot of stuff, so haven’t had much of a chance to look into this, but, yes, the example you listed is more or less what I suggested. I must be missing something somewhere.

It’s been hard to point you to an example, because we have some java code that dynamically created the json structures that we use, so I was trying to quickly look through that to figure out the format. You can take a closer look here… hopefully it will help some!

1 Like

Whats the use of sections under config in the app.json file @darius

Cannot find the documentation for it

Say you want to change the address format when using hierarchy module , do you pass these parameters here?

@judy, the <sections> part adds additional “sections” which have “questions” and “fields” in them (see the wiki page about Simple Form UI for a description of section/question/field).

I don’t think configuring the registration page is properly documented anywhere, but it’s definitely possible to figure it out by looking at examples, as @mksd did earlier in this thread (and maybe he can share his examples).

In the Ebola module you can see examples of capturing person attributes, obs, and a custom widget:

PIH has done the most recent customizations (including adding some features that didn’t exist when I was doing the Ebola module configuration), but their code may be harder to read since it is written as Java rather than JSON.

2 Likes

I ran into the same error when trying to overwrite the address hierarchy. I used the following SQL to clean out the database…

SET foreign_key_checks = 0; 
TRUNCATE address_hierarchy_entry;
TRUNCATE address_hierarchy_level;
SET foreign_key_checks = 1;

A post was split to a new topic: Personalizing patient registration fields

@arbaughj @mksd @mogoodrich a headsup @wyclif has worked on https://issues.openmrs.org/browse/RA-951 so need some testing when you get some time, will look at it over the weekend too

Is this issue fixed? Can i add a new field (like Father Name) to patient registration form? which is just a text field.

@hpardess, yes, here is a configuration example for such a person attribute:

2 Likes

Hi, I am installed AdressHierarchy loaded in module manage its showing Addresss Hierarchy Error occured starting

how to resolve this.

I am downloaded Bahmni in ubuntu . and chnanging registration folder app.json file

“customAttributes”: { “label”: “Sub Center”, “placeholder”: "Sub Center ", “fields”: [“givenNameLocal”, “middleNameLocal”, “family_name”] }

but its not reflecting to Browser ,also clear cache of browser than also not reflect using vagrant
use bahmni