How set a field to dropdown in Registration App Configuration

i followed this documentation and i can add some fields in patient registration , but i want add a field with dropdown and i don’t know

https://wiki.openmrs.org/display/docs/Registration+App+Configuration#RegistrationAppConfiguration-SetupMasterPatientIndexconfiguration

1 Like

Hi @ibatista, unfortunately there is a bug in the Reference App registration module that prevents the use of coded person attributes. See https://issues.openmrs.org/browse/RA-982 and vote for it.

:frowning:where is dislike buttom ? :’(

i voted, i hope that this can be solved

Write your custom field containing as many dropdown elements you want and later add it to refapp_registrationapp_app.json under any section as field.

For example, I added Country, State, City dropdowns for address like: { "legend": "Person.address", "header": "registrationapp.patient.address.question", "fields": [ { "type": "personAddress", "label": "registrationapp.patient.address.label", "widget": { "providerName": "registrationapp", "fragmentId": "field/personAddress" } ] }

Here, personAddress is the custom field containing the three dropdown elements.

1 Like

Hi @ibatista,

We could achieve this by including a <select> tag providing the values for the dropdown, see below. But beware that this would save an obs and not a person attribute, should it matter.

1) The fragment bringing in the <select>

<p>
  <label>
    ${config.label}
  </label>
  <select name="${config.formFieldName}" size="6">
    <option value ="LFHC:901">Lao</option>
    <option value ="LFHC:902">Hmong</option>
    <option value ="LFHC:905">Khmuic</option>
    <option value ="LFHC:906">Other Lao</option>
    <option value ="LFHC:911">Foreigner</option>
  </select>
  <span class="field-error"></span>
</p>

2) Its use in the app config:

"type": "obs",
"formFieldName": "obs.LFHC:912",
"label": "${project.parent.artifactId}.app.registerPatient.ethnicity",
"widget": {
  "providerName": "lfhcforms",
  "fragmentId": "field/ethnicity"
}

3) The UI result:

As you can see we used obs to do this, the registration field is of type "obs" and each of the possible answers is coded. This is the JSON configured version of a similar piece of work that we had been pointed to by @mogoodrich (thanks again) back in the days. The PIH team had done this too, but entirely in Java, see for example getCivilStatusQuestion() in their PatientRegistrationApp.java.

2 Likes

Where you write this fragment?

i don´t know if i understand, but did you say that i have create a concept (in your case is obs.LFHC:912) and the answer coded will be show?

When you see this in the app’s config:

"fragmentId": "field/ethnicity"

It means that the path of the fragment is:

omod/src/main/webapp/fragments/field/ethnicity.gsp

When you see this in the app’s config:

"type": "obs",
"formFieldName": "obs.LFHC:912",

It says that the form field saves an obs answering the question coded by concept LFHC:912. What is actually shown in the dropdown to choose from is up to the fragment, please refer to my previous message to see its content. And, in particular, for each option to choose from, look at the value attribute. Example:

<option value ="LFHC:901">Lao</option>

In practice, this means that when the user chooses (and saves) the value ‘Lao’ from the dropdown, the following obs is recoded:

  • Question: LFHC:912 (= “Ethnic group?”)
  • Answer: LFHC:901 (= “Lao”)
2 Likes

Thanks for you response, how make report with this?

I am not sure what you mean exactly by ‘report’ but perhaps this thread could help you: ‘Extend ‘Edit Patient Information’ page’. Please read through and let me know if that is what you are after.

Sorry,

I mean if i want make a report (Could be by Queries) for example in your case is: the number of patient that have the Lao Ethnicity.

Ah! thanks for the extend patient information page, is very usefull

This should be the subject of another thread about obtaining metrics out of obs recorded through the EMR. It is not specific to this thread at all anymore (and is rather a question about using the reporting module). I just want to stress that we are just recording obs here, as you would do with any other encounter form. Reporting goes ‘as usual’.

Hi, where u have this label ? i dont know how config on my OpenMRS

Hi @ibatista,

You should indeed not have this label anywhere since it is a custom label that we have brought in through our custom module. You can just replace it by anything that you deem relevant.

I get this error, is for the field “label”?

@ibatista, can you share the code you’re working on?

The specific error is that you’ve put a “label” field inside a Question, but that’s not a legal field. Maybe you want “header” or “legend”?

The legal fields are here: https://github.com/openmrs/openmrs-module-registrationapp/blob/master/api/src/main/java/org/openmrs/module/registrationapp/model/Question.java

Here the code of APP http://pastebin.com/gsFZ4xHL

And this is the fragment

<!-- <p class="required"> -->
<p>
    <label>
        ${config.label}
        <!-- <span>(${ ui.message("emr.formValidation.messages.requiredField.label") })</span> -->
    </label>
    <select name="${config.formFieldName}" size="6">
        <option value ="CIEL:1056">Separado/a</option>
        <option value ="CIEL:1057">Nunca se ha casado</option>
        <option value ="CIEL:1058">Divorciado/a</option>
        <option value ="CIEL:1059">Viudo/a</option>
        <option value ="CIEL:1060">Union Libre</option>
        <option value ="CIEL:5555">Casado/a</option>
        <option value ="CIEL:135704">Vive Solo/a</option>
        <option value ="CIEL:5622">Otro</option>
    </select>
    <span class="field-error"></span>
</p>

the problem is on “EstadoCivil”

Skimming your code I cannot find where the problem is coming from. Are you sure what you pasted in pastebin is the same as what you’re running that led to that stack trace? The error message says that you have a “section” that has “questions” in it, and one of the questions has a “label” property (but I con’t find this in the pastebin.)

Also, "providerName": "uicommons" should probably point to a different module (i.e. I assume that you added this fragment in your own module, not that you’re forking uicommons).

The example I did one for something similar to what you’re trying is here:

Hi, im very sure that the pastebin is the same code that i running, and i created in uicommons module the fragment called [EstadoCivil]