← Back to team overview

dhis2-devs team mailing list archive

Re: API - Assign DataElements to ProgramStage

 

Hi Morten,

Yes it is:
/api/programStages/<Program Stage ID>/programStageDataElements/<Data
Element ID to add>

Thanks,

Lorill

On Thu, May 21, 2015 at 9:51 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
wrote:

> Hi
>
> The ID you are using, is it data element ID?
>
> --
> Morten
>
> On Tue, May 19, 2015 at 11:22 PM, Lorill Crees <lcrees@xxxxxxxxxx> wrote:
>
>> We have also tried a POST to this to add each one individually:
>>
>> /api/programStages/<ID>/programStageDataElements/<ID to add>
>>
>> but get this error:
>>
>> "Collection programStageDataElements does not have an item with ID: xxx"
>>
>> From the example below it would be:
>>
>> /api/programStages/Ge9BWs3Bin2/programStageDataElements/auYAWubqi2C
>>
>> Any thoughts on how we can achieve this?
>>
>> Thanks,
>>
>> Lorill
>>
>> On Tue, May 12, 2015 at 6:56 PM, Alan Hill <ahill@xxxxxxxxxx> wrote:
>>
>>> Is there any way to assign DataElements to ProgramStages through the API
>>> as per the UI?
>>>
>>> I've tried PUTing to /api/programStage/<ID> with
>>> programStageDataElements set to a list of dataElement ids but without joy
>>> e.g.
>>>
>>> {
>>>     "id": "Ge9BWs3Bin2",
>>>     "created": "2015-05-12T21:54:21.303+0000",
>>>     "name": "NAME",
>>>     "href": "http://localhost:8000/api/programStages/Ge9BWs3Bin2";,
>>>     "lastUpdated": "2015-05-12T22:45:36.117+0000",
>>>     "dataEntryType": "default",
>>>     "reportDateDescription": "Survey Date",
>>>     "blockEntryForm": false,
>>>     "displayGenerateEventBox": true,
>>>     "description": "Births Data",
>>>     "externalAccess": false,
>>>     "openAfterEnrollment": false,
>>>     "captureCoordinates": false,
>>>     "defaultTemplateMessage": "Dear {person-name}, please come to your
>>> appointment on {program-stage-name} at {due-date}",
>>>     "remindCompleted": false,
>>>     "validCompleteOnly": false,
>>>     "generatedByEnrollmentDate": false,
>>>     "preGenerateUID": false,
>>>     "autoGenerateEvent": true,
>>>     "allowGenerateNextVisit": false,
>>>     "repeatable": true,
>>>     "minDaysFromStart": 0,
>>>     "displayName": "DISPLAY NAME",
>>>     "access": {
>>>         "update": true,
>>>         "externalize": false,
>>>         "write": true,
>>>         "delete": true,
>>>         "read": true,
>>>         "manage": false
>>>     },
>>>     "program": {
>>>         "id": "RrU8oA7Ja0R",
>>>         "name": "PROGRAM NAME",
>>>         "created": "2015-05-12T21:54:20.954+0000",
>>>         "lastUpdated": "2015-05-12T21:54:21.077+0000",
>>>         "href": "http://localhost:8000/api/programs/RrU8oA7Ja0R";
>>>     },
>>>     "trackedEntityInstanceReminders": [],
>>>     "programStageDataElements": [
>>>         {
>>>             "id": "auYAWubqi2C",
>>>             "created": "2015-05-12T22:52:52.865+0000",
>>>             "lastUpdated": "2015-05-12T22:52:52.866+0000",
>>>             "href": "
>>> http://localhost:8000/api/programStageDataElements/auYAWubqi2C";
>>>         },
>>>         {
>>>             "id": "ouarmjjDK30",
>>>             "created": "2015-05-12T22:52:52.871+0000",
>>>             "lastUpdated": "2015-05-12T22:52:52.871+0000",
>>>             "href": "
>>> http://localhost:8000/api/programStageDataElements/ouarmjjDK30";
>>>         },
>>>         {
>>>             "id": "HuAKbEkv8R9",
>>>             "created": "2015-05-12T22:52:52.875+0000",
>>>             "lastUpdated": "2015-05-12T22:52:52.875+0000",
>>>             "href": "
>>> http://localhost:8000/api/programStageDataElements/HuAKbEkv8R9";
>>>         }
>>>     ],
>>>     "attributeValues": [],
>>>     "userGroupAccesses": [],
>>>     "programStageSections": []
>>> }
>>>
>>> Tells me it's been updated but nothing changes.
>>>
>>> Any suggestions greatly appreciated.
>>>
>>> Thanks
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-devs
>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>

Follow ups

References