Hello Cory and all -- Thanks very much for your very useful info about the commcare API process earlier in this thread. I now have a "second level" of questions to make sure I am oriented correctly about the API, so that when I work with the coding side of our team, I'm sure we are headed in the right direction.
** As a reminder, we have a fully working commcare project that involves a few separate apps and two different levels of referrals. To over-simplify, our outreach workers fill out form A1 when they interview people on the street. When we determine that person needs a referral to HIV testing, it creates a referral by creating a new child case of type "referral." Then, over in the HIV testing clinic, the clinicians pick up their commcare phone and go to form C1 which allows them to open up that "referral" case and fill out a form describing the results of the HIV test visit. And if the results of that test were HIV positive, then the app is designed to create a further referral to ART care, by creating a new child case, of type "art-client," which will later on be picked up over in the ART clinic in form D1.
** That is all working fine. But now our goal is to make it so that over in that middle clinic -- the HIV testing clinic described above that would normally use our smartphone app to load up cases on form C1 and sometimes create child cases -- we can use the CommCare API to actually build that full "C1 form" process into a PHP-based web app that is currently operating in those clinics. Therefore, the web app would replace that smartphone in that one clinic's role in the chain that I describe above.
(1) My first question is just confirming my understanding. Earlier, I had been hoping that the info that the web app would have to submit through the API would be somewhat minimal, and that much of the complex plumbing stuff would be taken care of on the configurations already existing on the CommCare servers. But now I am understanding that when the person using their PHP web app goes to do the C1 form, and they select which 'referral' case they want to open and fill out the form for, the web app will actually have to do a lot of loading up of values from that existing case... and then, after the web app contributes the few new pieces of info collected by the web app (like the results of the HIV test etc.), if a child case/referral is indeed required to be made, then their web app will also have to generate all the right code to fully create the new ongoing case ("art-client") and then submit that.
--> Other than confirming that I understand that correctly, my only question here is probably obvious to all -- can you remind me which API is used to load the values from the existing case into variables in the web app, so that they can later be submitted correctly in the XML?
(2) My second question is simply trying to orient myself in the XML that the C1 form created. Since the web app will have to output this XML faithfully, I wanted to make sure I understood the general overview, so that I and the coding team will be headed in the right direction with the same understanding.
... So I filled out one of our C1 forms completely, giving responses in which the patient tested HIV positive and therefore a child case is indeed created. I am now attaching the XML that resulted from that C1 form submission -- I have highlighted with a little color. Here are some embarrassingly high-level questions to make sure I'm oriented OK. And if I appear to be misunderstanding things, please point that out too:
** The first section, in green -- this seems simply submitting exactly the fields that were completed when the C1 form was filled out. This seems straightforward.
** The second section, whose tags start n0, in blue, seems to be only those the fields that I had configured to save their values to the PARENT case rather than the case itself. That I also basically understand.
** The third section, whose tags start n1, in yellow, seems to be all the info that is needed for the CHILD case that is being created because the person tested HIV positive. That also seems clear.
** But the fourth section, whose tags start n2, in grey, is confusing to me. It seems that it is simply submitting a few fields that were already submitted up in the first section (the "simply the values from this form" one.) For example, it is submitting the "hct-services-provided" field again, exactly as it did up above. Can you tell what this grey "n2" section is for?
** The last section, n3, just seems like various metadata about versions and deviceIDs.
(3) A few odd questions:
-- When we go to analyze our app's data, we have very attentive to make sure we can do analysis that is able to recall the exact links between a given A1 form submission, its resulting exact C1 form submission, and its resulting D1 form submission. Looking at the data, I have found that the workable key value to connect all of those is the A1 form's info.caseid, the C1 form's parents.parent.case.@case_id, and the D1 form's parents.parent.parent.case.@case_id. Is there any chance that when we implement this API to allow a web app to take the place of the mobile app's C1 form, that that chain of key values could be spoiled? That method of linking the three forms will still work, right?
-- it's a little bit daunting to see all of those identifier values placed into the headers of those sections in the XML. for example, things like case_id, user_id, instanceID, owner_id, deviceID, etc. But I'm guessing that all those IDs are nicely obtained through the API calls that we will use to locate and load up the case. It can't hurt for me to ask, are any of those values not actually fully required? It is good for me to ask in case it saves us a bit of effort :)
Giant thanks for your help, and tolerance of my unbelievably verbose approach :)
Eric