CommCare MOTECH data integration

HI Ashish,

I'm responding to your email on the commcare-developers google group.
Please use this list for future API-related questions so that all of the
developers can see them. Quick responses inline:

Hi Cory,
As discussed earlier, we are analyzing following two API from CommCareHQ
in order to pull FLW/group information.

https://confluence.dimagi.com/display/commcarepublic/List+Users
List Groups - CommCare Public - CommCare Public

We have few queries regarding above APIs.

  1. Do Ids for FLWs and Groups change everytime the information is updated
    on CommCareHQ? or it remains same for a particular FLW or group?

The id will be the same for all time.

  1. How to determine primary group (data sharing group) for an FLW?

This would have to be done in two parts. First you would query the single
user API to get the users group ids, then you would query the single group
API for each of the groups to determine which one has case_sharing = true.

  1. Group API does not have information on the type of group. How to get
    that information?

Not sure what you mean by "type"? The "case_sharing" and "reporting" fields
tell you whether it is a case sharing and/or reporting group.

  1. Does "List Users" API return web users also or it only returns FLWs?

Currently only FLWs. Would you need API access to web users?

thanks,
Cory

··· On Thu, May 9, 2013 at 7:59 AM, Ashish Kumar Mishra < ashishkm@thoughtworks.com> wrote:

Please clarify.

Regards,
Ashish

On Tue, Apr 23, 2013 at 11:55 PM, Cory Zue czue@dimagi.com wrote:

Hey Ashish,

Inline again.

  1. How to sync FLW data from CommCare?

Best bet is to use the user api:
https://wiki.commcarehq.org/display/commcarepublic/List+Users

* We have looked at this API. We have also looked at the
other API provided by CommCare
https://india.commcarehq.org/a/care-bihar/api/v0.2/user/using which we can fetch individual user details. These are pull based
APIs. *But is there any other way by which MOTECH can be notified if
user details are changed/added (PUSH based)?

This is not something that exists today but is something that could be
developed to support this use case.

It would be great if something could be developed on the
CommCareHQ to push details about any updates/creation/deletion on
group/user, just like case updates. Can you please let us know if you would
be considering this feature. If yes, what could be timelines.

Not sure on timelines at the moment. We are about to add an API for
groups, so a polling implementation on your side should also be able to
accomplish this. If you are on a specific timeline you should likely go
that route.

  1. What are the different versions of forms. How much difference in

the versions can we expect in the future.

The forms change any time we roll out a new version of the
application (I think there have only been about 3 so far). You can continue
to expect changes in the future and should plan on using the "version"
attribute of the form to detect changes.

*Can any version (0.1, 0.2 and 0.3) APIs be used for
care-bihar domain? Or are versions domain specific? What is
the difference between version attribute on the forms and version in the
data API endpoints? *Can you please explain it bit more?

The versions are form specific and the forms are domain specific. The
best thing to do is to use the app version tag from the meta block which
should be a guaranteed unique version of that form. This looks something
like:

cc:appVersionv2.0.0dev
(7d4efc-95aede-unvers-2.1.0-Nokia/S40-native-input) #23 b:2012-May-25
r:2012-May-26</cc:appVersion>

I assume you're asking because you might need logic that says "get this
property from here if this version, otherwise from here if this other
version" which you could maintain a mapping of using that property.

We would look at the app version tag.
Also for case data API like https://
www.commcarehq.org/a/[domain]/api/v0.3/case/[case_id]/http://www.commcarehq.org/a/[domain]/api/v0.3/case/[case_id]/,
can we use "0.3", "0.2" "0.1" interchangeably? Or is this specific to
domains?

That is the API version. You should preferably use the latest version
(which is currently v0.4, though we haven't updated the docs). You should
definitely not use 0.1 or 0.2 as we will be deprecating, and eventually
removing them.

  1. How to existing production data to sync with MOTECH.

Isn't this already happening? If you need to re-access all the data,
the best bet is the case APIs.
List Cases (version 3+) - CommCare Public - CommCare Public

Currently we are not keeping all the case data. We are
just keeping the data which is needed for generating vaccination schedules.
For reporting work, we would also need the forms/cases which are already
present in CommCare. As per my understanding, data APIs provided by
CommCare can only be used for fetching forms/cases based on IDs. Is there
any API which can provide list of all the cases or forms present in
CommCare. The other option i can think is using the export functionality
and parsing excels and processing them. Please suggest.

Yes, the list cases and list forms APIs can do this.

List Cases (version 3+) - CommCare Public - CommCare Public
Form Data - CommCare Public - CommCare Public

Will go through these APIs and come back if we need more info
on that.

Ok.

Cory

Cory

Regards,
Ashish

On Tue, Apr 9, 2013 at 7:03 PM, Cory Zue czue@dimagi.com wrote:

Hi Ashish,

Please send over a few times after 8:00am EDT / 5:30pm IST that
work for you in the next few weeks and I'll choose something that works.

If you can provide any additional context over email before we talk
that would be useful as well.

Cory

On Tue, Apr 9, 2013 at 4:14 AM, Ashish Kumar Mishra < ashishkm@thoughtworks.com> wrote:

Hi Cory,

We are in the process of analyzing CommCare data and integration
APIs for data integration between CommCare and MOTECH.

We have few queries regarding integration APIs and form data for
which we need your help.

Please let us know your availability for a meeting.

Regards,
Ashish

Not sure what you mean by "type"? The "case_sharing" and "reporting"
fields tell you whether it is a case sharing and/or reporting group.

Yes, by type i meant "case_sharing" or "reporting".

  1. Does "List Users" API return web users also or it only returns FLWs?

Currently only FLWs. Would you need API access to web users?

No, we dont need API access to web users. Just wanted to confirm.

Thanks.

Regards,
Ashish

··· On Thursday, May 9, 2013 5:52:48 PM UTC+5:30, Cory Zue wrote: > > HI Ashish, > > I'm responding to your email on the commcare-developers google group. > Please use this list for future API-related questions so that all of the > developers can see them. Quick responses inline: > > On Thu, May 9, 2013 at 7:59 AM, Ashish Kumar Mishra < ashi...@thoughtworks.com > wrote: > >> Hi Cory, >> As discussed earlier, we are analyzing following two API from CommCareHQ >> in order to pull FLW/group information. >> >> https://confluence.dimagi.com/display/commcarepublic/List+Users >> https://confluence.dimagi.com/display/commcarepublic/List+Groups >> >> We have few queries regarding above APIs. >> >> 1. Do Ids for FLWs and Groups change everytime the information is updated >> on CommCareHQ? or it remains same for a particular FLW or group? >> > > The id will be the same for all time. > > >> 2. How to determine primary group (data sharing group) for an FLW? >> > > This would have to be done in two parts. First you would query the single > user API to get the users group ids, then you would query the single group > API for each of the groups to determine which one has case_sharing = true. > > >> 3. Group API does not have information on the type of group. How to get >> that information? >> > > Not sure what you mean by "type"? The "case_sharing" and "reporting" > fields tell you whether it is a case sharing and/or reporting group. > > 4. Does "List Users" API return web users also or it only returns FLWs? >> > > Currently only FLWs. Would you need API access to web users? > > thanks, > Cory > > > >> >> Please clarify. >> >> Regards, >> Ashish >> >> >> >> >> >> On Tue, Apr 23, 2013 at 11:55 PM, Cory Zue <cz...@dimagi.com wrote: >> >>> Hey Ashish, >>> >>> Inline again. >>> >>> >>> 1. How to sync FLW data from CommCare? >>>>>>>> >>>>>>> >>>>>>> Best bet is to use the user api: >>>>>>> https://wiki.commcarehq.org/display/commcarepublic/List+Users >>>>>>> >>>>>> * We have looked at this API. We have also looked at the >>>>>> other API provided by CommCare >>>>>> https://india.commcarehq.org/a/care-bihar/api/v0.2/user/using which we can fetch individual user details. These are pull based >>>>>> APIs. **But is there any other way by which MOTECH can be notified >>>>>> if user details are changed/added (PUSH based)?* >>>>>> >>>>> >>>>> This is not something that exists today but is something that could be >>>>> developed to support this use case. >>>>> >>>> It would be great if something could be developed on the >>>> CommCareHQ to push details about any updates/creation/deletion on >>>> group/user, just like case updates. Can you please let us know if you would >>>> be considering this feature. If yes, what could be timelines. >>>> >>> >>> Not sure on timelines at the moment. We are about to add an API for >>> groups, so a polling implementation on your side should also be able to >>> accomplish this. If you are on a specific timeline you should likely go >>> that route. >>> >>> >>>> >>>> >>>>> 3. What are the different versions of forms. How much difference in >>>>>>>> the versions can we expect in the future. >>>>>>>> >>>>>>> >>>>>>> The forms change any time we roll out a new version of the >>>>>>> application (I think there have only been about 3 so far). You can continue >>>>>>> to expect changes in the future and should plan on using the "version" >>>>>>> attribute of the form to detect changes. >>>>>>> >>>>>>> *Can any version (0.1, 0.2 and 0.3) APIs be used for >>>>>> care-bihar domain? Or are versions domain specific? What is >>>>>> the difference between version attribute on the forms and version in the >>>>>> data API endpoints? **Can you please explain it bit more?* >>>>>> >>>>> >>>>> The versions are form specific and the forms are domain specific. The >>>>> best thing to do is to use the app version tag from the meta block which >>>>> should be a guaranteed unique version of that form. This looks something >>>>> like: >>>>> >>>>> v2.0.0dev >>>>> (7d4efc-95aede-unvers-2.1.0-Nokia/S40-native-input) #23 b:2012-May-25 >>>>> r:2012-May-26 >>>>> >>>>> I assume you're asking because you might need logic that says "get >>>>> this property from here if this version, otherwise from here if this other >>>>> version" which you could maintain a mapping of using that property. >>>>> >>>> We would look at the app version tag. >>>> Also for case data API like https:// >>>> www.commcarehq.org/a/[domain]/api/v0.3/case/[case_id]/, >>>> can we use "0.3", "0.2" "0.1" interchangeably? Or is this specific to >>>> domains? >>>> >>> >>> That is the API version. You should preferably use the latest version >>> (which is currently v0.4, though we haven't updated the docs). You should >>> definitely not use 0.1 or 0.2 as we will be deprecating, and eventually >>> removing them. >>> >>> >>> >>>>>>>> 4. How to existing production data to sync with MOTECH. >>>>>>>> >>>>>>> >>>>>>> Isn't this already happening? If you need to re-access all the data, >>>>>>> the best bet is the case APIs. >>>>>>> https://wiki.commcarehq.org/pages/viewpage.action?pageId=12224287 >>>>>>> >>>>>> * Currently we are not keeping all the case data. We are >>>>>> just keeping the data which is needed for generating vaccination schedules. >>>>>> For reporting work, we would also need the forms/cases which are already >>>>>> present in CommCare. As per my understanding, data APIs provided by >>>>>> CommCare can only be used for fetching forms/cases based on IDs. Is there >>>>>> any API which can provide list of all the cases or forms present in >>>>>> CommCare. The other option i can think is using the export functionality >>>>>> and parsing excels and processing them. Please suggest.* >>>>>> >>>>> >>>>> Yes, the list cases and list forms APIs can do this. >>>>> >>>>> https://wiki.commcarehq.org/pages/viewpage.action?pageId=12224287 >>>>> https://wiki.commcarehq.org/display/commcarepublic/Form+Data >>>>> >>>> >>>> Will go through these APIs and come back if we need more info >>>> on that. >>>> >>> >>> Ok. >>> >>> Cory >>> >>>> >>>>> >>>>> Cory >>>>> >>>>>> >>>>>>> >>>>>>> >>>>>>>> >>>>>>>> Regards, >>>>>>>> Ashish >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Tue, Apr 9, 2013 at 7:03 PM, Cory Zue <cz...@dimagi.com wrote: >>>>>>>> >>>>>>>>> Hi Ashish, >>>>>>>>> >>>>>>>>> Please send over a few times after 8:00am EDT / 5:30pm IST that >>>>>>>>> work for you in the next few weeks and I'll choose something that works. >>>>>>>>> >>>>>>>>> If you can provide any additional context over email before we >>>>>>>>> talk that would be useful as well. >>>>>>>>> >>>>>>>>> Cory >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Tue, Apr 9, 2013 at 4:14 AM, Ashish Kumar Mishra < ashi...@thoughtworks.com > wrote: >>>>>>>>> >>>>>>>>>> Hi Cory, >>>>>>>>>> >>>>>>>>>> We are in the process of analyzing CommCare data and integration >>>>>>>>>> APIs for data integration between CommCare and MOTECH. >>>>>>>>>> >>>>>>>>>> We have few queries regarding integration APIs and form data for >>>>>>>>>> which we need your help. >>>>>>>>>> >>>>>>>>>> Please let us know your availability for a meeting. >>>>>>>>>> >>>>>>>>>> Regards, >>>>>>>>>> Ashish >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> >