Latest obs for concept list widget returns incorrect values for boolean obs

Hello,

Using OpenMRS version 2.3.2 with the refapp 2.11.0, we encounter problem with a boolean concept. In our medical history form, we ask if women are pregnant using the following HTML code:

HTM form
                <li>
                   <div class='form-label'>
                      Are you currently pregnant?
                   </div>
                   <div class='form-answer'>
                      <obs conceptId="1434" style="yes_no"/>
                   </div>
                </li>

Then on the patient dashboard, the results are displayed using the latestobsforconceptlist widget as follow:

App definition
{
  "id": "TDC.medicalhistory",
  "description": "coreapps.latestObsForConceptList.app.description",
  "order": 1,
  "config": {
    "widget": "latestobsforconceptlist",
    "icon": " icon-plus-sign-alt",
    "label": "Medical history",
    "nLatestObs":  "10",
    "obsGroupLabels": "shortName",
    "conceptNameType": "shortName",
    "concepts": "162141AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,1628AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,162165AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,162163AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,1434AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"detailsUrl": "htmlformentryui/htmlform/enterHtmlFormWithStandardUi.page?patientId={{patient.uuid}}&formUuid=7da3f6f6-df89-4790-bd01-2bafcf693a14&returnUrl=/coreapps/clinicianfacing/patient.page?patientId={{patient.uuid}}"
  },
  "extensions": [
    {
      "id": "org.openmrs.module.coreapps.mostRecentVitals.clinicianDashboardFirstColumn",
      "appId": "TDC.medicalhistory",
      "extensionPointId": "patientDashboard.secondColumnFragments",
      "extensionParams": {
        "provider": "coreapps",
        "fragment": "dashboardwidgets/dashboardWidget"
      }
    }
  ]
}

The problem is that instead of displaying the boolean values, the widget displays the concept with either the concept ID 1 or 2:

Screenshot from 2021-09-06 12-09-56 Screenshot from 2021-09-06 12-08-47

Here is the API request send by the widget:

API request

https://trinity.elwaministries.org/openmrs/ws/rest/v1/latestobs?concept=162141AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%2C1628AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%2C162165AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%2C162163AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%2C1434AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&nLatestObs=10&patient=3244e730-39b5-4517-9982-7a54ad97c5ee&v=custom%3A(obsDatetime%2Cconcept%3A(uuid%2Cdisplay%2Cdatatype%3A(uuid)%2Cnames%3A(name%2Clocale%2ClocalePreferred%2Cvoided%2CconceptNameType))%2Cvalue%3A(uuid%2Cdisplay%2Cnames%3A(name%2Clocale%2ClocalePreferred%2Cvoided%2CconceptNameType))%2CgroupMembers%3A(value%2Cconcept%3A(display%2Cnames%3A(name%2Clocale%2ClocalePreferred%2Cvoided%2CconceptNameType))))`

and the reponse:

Response
{
	"results": [
		{
			"obsDatetime": "2021-09-01T09:17:05.000+0000",
			"concept": {
				"uuid": "1628AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
				"display": "Past medical history added",
				"datatype": {
					"uuid": "8d4a48b6-c2cc-11de-8d13-0010c6dffd0f"
				},
				"names": [
					{
						"name": "ISTWA MEDIKAL an plis",
						"locale": "ht",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					},
					{
						"name": "Problems",
						"locale": "en",
						"localePreferred": false,
						"voided": false,
						"conceptNameType": "SHORT"
					},
					{
						"name": "Past medical history added",
						"locale": "en",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					},
					{
						"name": "Historique médicale ajoutée",
						"locale": "fr",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					}
				]
			},
			"value": {
				"uuid": "163608AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
				"display": "No significant past medical history",
				"names": [
					{
						"name": "Aucun antécédent médical significatif",
						"locale": "fr",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					},
					{
						"name": "None",
						"locale": "en",
						"localePreferred": false,
						"voided": false,
						"conceptNameType": "SHORT"
					},
					{
						"name": "No significant past medical history",
						"locale": "en",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					},
					{
						"name": "Pa gen istwa medikal enpòtan",
						"locale": "ht",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					}
				]
			},
			"groupMembers": null
		},
		{
			"obsDatetime": "2021-09-01T00:00:00.000+0000",
			"concept": {
				"uuid": "1434AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
				"display": "Currently pregnant",
				"datatype": {
					"uuid": "8d4a5cca-c2cc-11de-8d13-0010c6dffd0f"
				},
				"names": [
					{
						"name": "Currently pregnant",
						"locale": "en",
						"localePreferred": false,
						"voided": false,
						"conceptNameType": "SHORT"
					},
					{
						"name": "Ujauzito wa sasa",
						"locale": "sw",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					},
					{
						"name": "Fanm ensent",
						"locale": "ht",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					},
					{
						"name": "Currently pregnant",
						"locale": "en",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					},
					{
						"name": "Femme enceinte",
						"locale": "fr",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					}
				]
			},
			"value": {
				"uuid": "1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
				"display": "Anemia due to blood loss",
				"names": [
					{
						"name": "Anemia, blood loss",
						"locale": "en",
						"localePreferred": false,
						"voided": false,
						"conceptNameType": null
					},
					{
						"name": "Anemia por pérdida de sangre",
						"locale": "es",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					},
					{
						"name": "Anémie secondaire à une hémorragie",
						"locale": "fr",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					},
					{
						"name": "خون کی کمی، خون بہنے کی وجہ سے",
						"locale": "ur",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					},
					{
						"name": "Anemia due to blood loss",
						"locale": "en",
						"localePreferred": true,
						"voided": false,
						"conceptNameType": "FULLY_SPECIFIED"
					}
				]
			},
			"groupMembers": null
		}
	]
}```

Are we doing something incorrect or is it a bug in the widget code?

Thank you for your help!

1 Like

cc @dimitar

Can you also share a screenshot of what this concept looks like in the dictionary? Something along these lines: WHO Medical Certification of Cause of Death - #17 by akanter

Yes, here is it:

Screenshot from 2021-09-09 15-13-38

Thanks for helping!

This looks like a bug.

OK thanks for the confirmation.

I have created a bug report here :[RA-1956] latestobsforconceptlist widget returns incorrect values for boolean obs - OpenMRS Issues