← Back to team overview

dhis2-devs team mailing list archive

Re: Facing issues creating programs using /metadata api

 

Hello Morten,

We had a look into /api/programs api. It seems it is just creating
'ProgramInstance' and not a 'Program' .

Does this mean that We need to create a program using '/api/metadata' api
and then create the associated programInstance object using '/api/programs'
api?

We tried creating Program using '/api/metadata' api. It created
successfully.
We tried creating programInstance using '/api/programs' api. It failed.

*Input: *

{
        "kind": "SINGLE_EVENT_WITHOUT_REGISTRATION",
        "name": "Program1",
        "userRoles": [{
            "id": "someId",
            "name": "someRole"
        }],
        "dateOfIncidentDescription": "Incident Date",
        "version": 1,
        "organisationUnits": [{
            "id": "orgUnit1",
            "name": "MSF"
        }],
        "singleEvent": true,
        "type": 3,
        "id": "prg1",
        "description": "Program 1"
    }

*Error:*

500 Not-null property references a transient value - transient instance
must be saved before current operation:
org.hisp.dhis.program.ProgramInstance.program ->
org.hisp.dhis.program.Program

*Also, we just noticed , '/api/programs' api takes single program whereas
'api/metadata' api can take a json containing multiple programs. Can the
same be done for new api(/api/programs) ?*


On Thu, Jul 3, 2014 at 1:35 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
wrote:

> Hi guys
>
> Could you please try again with rev 15953, it should create the
> programinstance now when you use the /api/programs endpoint. If you have
> time to try it out, please do.
>
> We are looking into doing a more proper fix for this that will also work
> on /api/metadata, but for now, please use /api/programs.
>
> --
> Morten
>
>
> On Tue, Jul 1, 2014 at 4:45 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
> wrote:
>
>> Hi
>>
>> Yes, this should be considered a bug. It's a bit weird, but when you
>> create a new non-registration program, it actually enrolls a "hidden"
>> tracked entity instance to that program, so just creating a new program
>> meta-data is not enough to start doing data-entry. For registration
>> program, it should be ok, you just enroll a tracked entity instance into it.
>>
>> I will try and fix it before release, it will need a bit of special
>> handlng for non-registration programs.
>>
>> --
>> Morten
>>
>>
>> On Tue, Jul 1, 2014 at 3:10 PM, Mansi Singhal <msinghal@xxxxxxxxxxxxxxxx>
>> wrote:
>>
>>> Hello,
>>>
>>> We created  "Program" using "/metadata" api.
>>>
>>> Problem we faced:  On "Event Capture Screen", when we try to create new
>>> event, we get error : *"No active event exists for single event no
>>> registration program"*
>>>
>>> When we tried looking into issue, it seems that When we create a program
>>> from dhis screen(without using api), another object called
>>> "programInstance" is created for a program.
>>>
>>> But that never happens when we use "/metadata" api to create program.
>>>
>>> We tried looking into "/programs" api to create a program so that it
>>> takes care of creating "programInstance" object for the program. But it
>>> seems there is no such api.
>>>
>>> Just want to confirm 'if you are planning to write that api' or 'do you
>>> want us to write the same'.
>>> --
>>> Thanks,
>>> Mansi Singhal
>>>
>>
>>
>


-- 
Thanks,,
Mansi Singhal

Follow ups

References