Observation value data type

Hi, “value” field in observation json coming from server is sometime a string value, some time double and some time its an object. When its a string or double, its not a problem but when its an object, Jackson is throwing exception. What should be the data type for value. String: visit note Double: vitals value Object: Observation Group Member:

"value": {
                        "uuid": "159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                        "display": "Primary",
                        "name": {
                            "display": "Primary",
                            "uuid": "107493BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
                            "name": "Primary",
                            "locale": "en",
                            "localePreferred": true,
                            "conceptNameType": "FULLY_SPECIFIED",
                            "links": [
                                {
                                    "rel": "self",
                                    "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/name/107493BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
                                },
                                {
                                    "rel": "full",
                                    "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/name/107493BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB?v=full"
                                }
                            ],
                            "resourceVersion": "1.9"
                        },
                        "datatype": {
                            "uuid": "8d4a4c94-c2cc-11de-8d13-0010c6dffd0f",
                            "display": "N/A",
                            "links": [
                                {
                                    "rel": "self",
                                    "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/conceptdatatype/8d4a4c94-c2cc-11de-8d13-0010c6dffd0f"
                                }
                            ]
                        },
                        "conceptClass": {
                            "uuid": "8d492774-c2cc-11de-8d13-0010c6dffd0f",
                            "display": "Misc",
                            "links": [
                                {
                                    "rel": "self",
                                    "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/conceptclass/8d492774-c2cc-11de-8d13-0010c6dffd0f"
                                }
                            ]
                        },
                        "set": false,
                        "version": "",
                        "retired": false,
                        "names": [
                            {
                                "uuid": "107494BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
                                "display": "Principal",
                                "links": [
                                    {
                                        "rel": "self",
                                        "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/name/107494BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
                                    }
                                ]
                            },
                            {
                                "uuid": "127621BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
                                "display": "Đầu",
                                "links": [
                                    {
                                        "rel": "self",
                                        "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/name/127621BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
                                    }
                                ]
                            },
                            {
                                "uuid": "134530BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
                                "display": "Primordial",
                                "links": [
                                    {
                                        "rel": "self",
                                        "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/name/134530BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
                                    }
                                ]
                            },
                            {
                                "uuid": "107493BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
                                "display": "Primary",
                                "links": [
                                    {
                                        "rel": "self",
                                        "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/name/107493BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
                                    }
                                ]
                            },
                            {
                                "uuid": "134531BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
                                "display": "Prensipal",
                                "links": [
                                    {
                                        "rel": "self",
                                        "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/name/134531BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
                                    }
                                ]
                            }
                        ],
                        "descriptions": [
                            {
                                "uuid": "16472FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
                                "display": "Primary, principal or first (as in qualifier for diagnosis)",
                                "links": [
                                    {
                                        "rel": "self",
                                        "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/description/16472FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
                                    }
                                ]
                            }
                        ],
                        "mappings": [
                            {
                                "uuid": "137043ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
                                "display": "SNOMED CT: 63161005",
                                "links": [
                                    {
                                        "rel": "self",
                                        "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/mapping/137043ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
                                    }
                                ]
                            },
                            {
                                "uuid": "217084ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
                                "display": "CIEL: 159943",
                                "links": [
                                    {
                                        "rel": "self",
                                        "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/mapping/217084ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
                                    }
                                ]
                            },
                            {
                                "uuid": "236982ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
                                "display": "org.openmrs.module.emrapi: Primary",
                                "links": [
                                    {
                                        "rel": "self",
                                        "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/mapping/236982ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
                                    }
                                ]
                            }
                        ],
                        "answers": [],
                        "setMembers": [],
                        "attributes": [],
                        "links": [
                            {
                                "rel": "self",
                                "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
                            },
                            {
                                "rel": "full",
                                "uri": "http://localhost:8080/openmrshttp://localhost:8080/openmrs/ws/rest/v1/concept/159943AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA?v=full"
                            }
                        ],
                        "resourceVersion": "2.0"
                    }

Value can be any type depending on the datatype of the question concept

1 Like

Hi @wyclif, Since “value” could be any data type, what is best way to deserialize it.

It depends, if you doing it from another Java application written against the OpenMRS java API you just need to call Obs.setValueAsString(String) otherwise you need to check the datatype of the question concept to determine the type to deserialize it to.

1 Like