Hi, If you are using /api/programs and sending one new program (POST), it should have a post create task that will _also_ create the program instance. As I said in the email, this will not work for /api/metadata, this is not fixed yet. Did you try this? this is not working?
Other than for importing bulk meta-data, do you have a usecase for creating multiple programs at the same time? is that common for you? I think I would prefer keeping the /api/type endpoints simple, and support collections etc in /api/metadata, we are looking into supporting these kinds of hooks there also, it should be there before the release next week. -- Morten On Thu, Jul 3, 2014 at 5:07 PM, Mansi Singhal <msing...@thoughtworks.com> wrote: > 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 <morte...@gmail.com> > 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 <morte...@gmail.com> >> 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 <msing...@thoughtworks.com >>> > 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 >
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp