get patient uuid with fieldgen

Hi there!

does anybody have an idea how I could get the UUID instead of the patient ID using the openmrs:fieldGen of type Patient?

When looking at:

I dont see how, my only thought is to create my own custom patientField.tag where I replace ui.item.object.patientId with ui.item.object.uuid

The reason why I need this is that I am now using REST to populate my datatables in the legacyui and need the patients UUID as a param.

I am trying to create a custom patientUuidField.tag which uses value ui.item.object.uuid

How do I use this field tag then?

I tried setting the url in

 <openmrs:fieldGen type="org.openmrs.Patient"
            formFieldName="patientQuery" url="patientUuid.field" />

but that didnt work out. Not sure if this is because I am in a module, so I need a prefix to the url for it to find my custom field (it currently lives under omod/src/main/webapp/tags/patientUuidField.tag) or do I also need to write a FieldGenHandler?

Thanks a lot for any hints :slight_smile:

Here is an example of the things you need to do:

  1. You create the tag file as here: https://github.com/openmrs/openmrs-module-reporting/blob/master/omod/src/main/webapp/tags/cronDisplay.tag

  2. Include it in your jsp with as prefix as here: https://github.com/openmrs/openmrs-module-reporting/blob/master/omod/src/main/webapp/include.jsp#L9

  3. Then access it as here: https://github.com/openmrs/openmrs-module-reporting/blob/master/omod/src/main/webapp/portlets/reportRequests.jsp#L81

NOTE: field gens are different from your tag. :slight_smile:

1 Like

spot on! just what I needed :wink: thank you soo much!

can you tell me what the difference is between a “normal” tag and a field gen?

For the field gen,

  1. Instead of the jsp, you would create a Java file as here: https://github.com/openmrs/openmrs-module-reporting/blob/master/omod/src/main/java/org/openmrs/module/reporting/web/taglib/DisplayLabelTag.java

  2. Configure it in the tag library descriptor file as here: https://github.com/openmrs/openmrs-module-reporting/blob/master/omod/src/main/webapp/resources/reporting.tld#L161

  3. Include it in your jsp with a prefix as here: https://github.com/openmrs/openmrs-module-reporting/blob/master/omod/src/main/webapp/include.jsp#L8

  4. Then access it as here: https://github.com/openmrs/openmrs-module-reporting/blob/master/omod/src/main/webapp/cohorts/cohortDefinitionEditor.jsp#L17

As for the difference between the two, you can start with this: http://stackoverflow.com/questions/228607/jsp-custom-tag-library-vs-jsp2-tag-files

thanks for the extensive explanation and your help!!