dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41520
Parsing the json output from the API
Below is a patient tracked entity instance
In order to get a first name or a last name from this attribute list, we
would have to loop through all the attributes until we find an attribute
that has the displayName "firstName", as all the attribute seem to be in
random order for each patient. That is inefficient and clunky. Is there a
way to get the data in a format that could be read by javascript more
easily?
{
"lastUpdated":"2014-03-28 12:33:47.354",
"trackedEntity":"G0PlBqu2Boe",
"created":"2014-03-26 15:46:02.45",
"orgUnit":"DiszpKrYNg8",
"trackedEntityInstance":"JRm9etA1dG1",
"relationships":[
],
"attributes":[
{
"code":"MMD_PER_NAM",
"displayName":"First name",
"valueType":"TEXT",
"attribute":"w75KJ2mc4zz",
"value":"Kedija"
},
{
"displayName":"Gender",
"valueType":"TEXT",
"attribute":"cejWyOfXge6",
"value":"Female"
},
...
]
},
I tried something like the below, but that doesn't seem to work. What am I
missing?
https://play.dhis2.org/demo/api/trackedEntityInstances/PQfMcpmXeFE.json?fields=attributes[displayName]&filter=attributes[displayName]:eq:Gender
Follow ups