# Obs Graph Widget in RefApp 2.x

**URL:** <https://talk.openmrs.org/t/obs-graph-widget-in-refapp-2-x/39583>\
**Category:** Ask OpenMRS\
**Tags:** refapp, install\
**Created:** [May 8, 2023, 6:54pm UTC](https://talk.openmrs.org/t/obs-graph-widget-in-refapp-2-x/39583 "2023-05-08T18:54:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nischith](https://talk.openmrs.org/user_avatar/talk.openmrs.org/nischith/32/13088_2.png) [@nischith](https://talk.openmrs.org/u/nischith)\
**Post date:** [May 8, 2023, 6:54pm UTC](https://talk.openmrs.org/t/obs-graph-widget-in-refapp-2-x/39583/1 "2023-05-08T18:54:22Z")

</div>

The attempt has been to plot a BMI graph using the [Obs Graph widget](https://wiki.openmrs.org/display/docs/Patient+Summary+Widget+Documentation#PatientSummaryWidgetDocumentation-conceptgraphObsGraph)

The Widget config is almost exactly the same as the example in the above doc and visible [here](http://textsharing.com/4919/)

As of now, all that I get is a [warning in the server logs](http://textsharing.com/4918/) and no graph gets displayed.

The config has a _key_ called “function” where an actual function called **bmi** gets used, should this function be defined somewhere? or is the possible solution something else?

Thank you!

---

<div class="post-metadata">

**Author:** ![ibacher](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ibacher/32/19751_2.png) [@ibacher](https://talk.openmrs.org/u/ibacher)\
**Post date:** [May 8, 2023, 8:05pm UTC](https://talk.openmrs.org/t/obs-graph-widget-in-refapp-2-x/39583/2 "2023-05-08T20:05:49Z")

</div>

> [@nischith](#):
>
> should this function be defined somewhere?

It is, but in a slightly convoluted way (specifically, it’s defined [here](https://github.com/openmrs/openmrs-module-coreapps/blob/92e582416c13759029b36dc00eab1bc02b4e0b18/omod/src/main/web/dashboardwidgets/obsgraph/obsgraph.controller.js#L58)).

The problem seems to be accessing some data via the REST interface… Is there anything earlier in the server logs? Alternatively, in your browser network tab do you see a failed request for either the `/concept` or `/obs` endpoints?

---

<div class="post-metadata">

**Author:** ![nischith](https://talk.openmrs.org/user_avatar/talk.openmrs.org/nischith/32/13088_2.png) [@nischith](https://talk.openmrs.org/u/nischith)\
**Post date:** [May 8, 2023, 8:31pm UTC](https://talk.openmrs.org/t/obs-graph-widget-in-refapp-2-x/39583/3 "2023-05-08T20:31:26Z")

</div>

Thanks for the reply @ibacher. I can now see a request Error (type _500_) for the below end-point:

```auto
/concept/'5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'?v=custom:(uuid,display,name:(display),datatype:(uuid,display))
```

---

<div class="post-metadata">

**Author:** ![nischith](https://talk.openmrs.org/user_avatar/talk.openmrs.org/nischith/32/13088_2.png) [@nischith](https://talk.openmrs.org/u/nischith)\
**Post date:** [May 8, 2023, 8:37pm UTC](https://talk.openmrs.org/t/obs-graph-widget-in-refapp-2-x/39583/4 "2023-05-08T20:37:29Z")

</div>

There is a similar request error involving the other concept ‘5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA’ as well.

_PS:_ Both these concepts exist in the Dictionary and if I remove the line with the “function” key from the config (which is Ln. 14 [here](http://textsharing.com/4920/)), the widget works perfectly fine.

---

<div class="post-metadata">

**Author:** ![ibacher](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ibacher/32/19751_2.png) [@ibacher](https://talk.openmrs.org/u/ibacher)\
**Post date:** [May 9, 2023, 12:20pm UTC](https://talk.openmrs.org/t/obs-graph-widget-in-refapp-2-x/39583/5 "2023-05-09T12:20:54Z")

</div>

> [@nischith](#):
>
> `'5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'`

So the problem with the request is definitely the single-quotes that get added there. It must be returning some kind of error that isn’t properly converted.

> [@nischith](#):
>
> Both these concepts exist in the Dictionary and if I remove the line with the “function” key from the config (which is Ln. 14 [here](http://textsharing.com/4920/)), the widget works perfectly fine.

Presumably, though, you don’t see a graph of the BMI right? If you don’t need it, I suppose we can stop there…

However, another option. The “function” entry in both the example config and the config used in coreapps has this:

```auto
"function": "(bmi,\"5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\", \"5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\");" 

```

Could we try instead using this:

```auto
"function": "(bmi,5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, 5090AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA);" 

```

Basically, my guess is that since the value of `function` is already a string, we don’t need the additional quotes there.

---

<div class="post-metadata">

**Author:** ![nischith](https://talk.openmrs.org/user_avatar/talk.openmrs.org/nischith/32/13088_2.png) [@nischith](https://talk.openmrs.org/u/nischith)\
**Post date:** [May 9, 2023, 2:52pm UTC](https://talk.openmrs.org/t/obs-graph-widget-in-refapp-2-x/39583/6 "2023-05-09T14:52:08Z")

</div>

Yes! that is working…the additional quotes seem to be unnecessary after all (and in fact are the trouble makers).

With the additional quotes removed and the Widget config changed to [this](http://textsharing.com/4928/), a nice multi-variable graph is produced showing Weight, Height & BMI:

![image](https://talk.openmrs.org/uploads/default/original/3X/9/7/971f216c1c5d7073c70b54960834a3fd9f44aa35.png)

However, if you observe the value of the BMI…it is 10x times more than the expected. But, that is a different issue altogether…and we will have to look through the function being used for this calculation and other pieces of codes.

I’m going to mark _this_ thread as SOLVED!

Thanks a lot @ibacher !

---

<div class="post-metadata">

**Author:** ![ibacher](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ibacher/32/19751_2.png) [@ibacher](https://talk.openmrs.org/u/ibacher)\
**Post date:** [May 9, 2023, 3:07pm UTC](https://talk.openmrs.org/t/obs-graph-widget-in-refapp-2-x/39583/7 "2023-05-09T15:07:17Z")

</div>

> [@nischith](#):
>
> it is 10x times more than the expected

That’s a weird one… 70 kg and 174 cm should give a BMI of 23.1 too.
