Cht-core: Family creation form broken: cannot create children from repeat group

Created on 29 Aug 2017  Â·  20Comments  Â·  Source: medic/cht-core

Seen in 2.13.0-beta.10. To reproduce:

  1. Log in as a restricted user
  2. Click Add Family, then fill in the form (make sure you choose to register other family members now and enter information for at least 1 person to be sure you are using the repeat group).
  3. Click Submit.
  4. Notice that the family and its primary contact were created correctly but that the children/other family members were created with a blank parent field.

To avoid having to reconfigure forms for several projects, we should support this way of creating children at the same time a family is created.

Here is an xls form for reproducing the error:
clinic.xlsx

And here is the xml:

<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <h:head>
    <h:title>Add Family</h:title>
    <model>
      <instance>
        <data delimiter="#" id="family" prefix="J1!family!" version="2016-04-06">
          <inputs>
            <meta>
              <location>
                <lat/>
                <long/>
                <error/>
                <message/>
              </location>
            </meta>
            <user>
              <facility_id/>
            </user>
          </inputs>
          <clinic>
            <parent/>
            <name/>
            <geolocation/>
            <contact/>
          </clinic>
          <contact>
            <debug_note/>
            <parent>PARENT</parent>
            <name/>
            <notes/>
            <sex/>
            <date_of_birth_method/>
            <date_of_birth/>
            <phone/>
            <alternate_phone/>
            <pregnant_at_registration/>
          </contact>
          <ephemeral_phone>
            <phone1/>
            <phone2/>
          </ephemeral_phone>
          <ephemeral_phone_confirmation>
            <phone_note/>
          </ephemeral_phone_confirmation>
          <ephemeral_dob>
            <g_sex/>
            <contact_dob_method>approx</contact_dob_method>
            <dob_calendar/>
            <age/>
            <dob_raw/>
            <contact_dob_iso/>
          </ephemeral_dob>
          <ephemeral_pregnancy>
            <display_name/>
            <g_children_under_5/>
            <pregnant/>
            <pregnancy_note/>
          </ephemeral_pregnancy>
          <repeat-relevant>
            <child/>
          </repeat-relevant>
          <repeat>
            <child jr:template="">
              <delimiter/>
              <type>person</type>
              <parent>PARENT</parent>
              <name/>
              <notes/>
              <phone/>
              <alternate_phone/>
              <date_of_birth/>
              <dob_method>approx</dob_method>
              <dob_calendar/>
              <age_years/>
              <age_months>0</age_months>
              <ephemeral_months/>
              <ephemeral_years/>
              <dob_approx/>
              <dob_raw/>
              <dob_iso/>
              <person_age_years/>
              <person_age_months/>
              <dob_debug/>
              <sex/>
              <relationship_to_primary_caregiver/>
              <relationship_to_pc_other/>
              <delivered_in_facility/>
              <exclusively_breastfed/>
              <mother_attended_anc/>
              <slept_under_treated_net/>
            </child>
            <note/>
          </repeat>
          <meta>
            <instanceID/>
          </meta>
        </data>
      </instance>
      <bind nodeset="/data/inputs" relevant="false()"/>
      <bind nodeset="/data/inputs/user/facility_id" type="string"/>
      <bind nodeset="/data/contact/debug_note" readonly="true()" relevant="false()" type="string"/>
      <bind nodeset="/data/contact/parent" type="string"/>
      <bind nodeset="/data/contact/name" required="true()" type="string"/>
      <bind nodeset="/data/contact/notes" type="string"/>
      <bind calculate=" /data/ephemeral_dob/g_sex " nodeset="/data/contact/sex" type="string"/>
      <bind calculate=" /data/ephemeral_dob/contact_dob_method " nodeset="/data/contact/date_of_birth_method" type="string"/>
      <bind calculate=" /data/ephemeral_dob/contact_dob_iso " nodeset="/data/contact/date_of_birth" type="string"/>
      <bind calculate=" /data/ephemeral_phone/phone1 " nodeset="/data/contact/phone" type="string"/>
      <bind calculate=" /data/ephemeral_phone/phone2 " nodeset="/data/contact/alternate_phone" type="string"/>
      <bind calculate=" /data/ephemeral_pregnancy/pregnant " nodeset="/data/contact/pregnant_at_registration" type="string"/>
      <bind constraint="regex(.,'^\+254\s?(\d{3}\s?){3}|^07\d{2}\s?(\d{3}\s?){2}')" jr:constraintMsg="Please make sure the number is not already in use by another person and is in the format +254 7XX XXX XXX or 07XX XXX XXX." nodeset="/data/ephemeral_phone/phone1" type="tel"/>
      <bind constraint="regex(.,'^\+254\s?(\d{3}\s?){3}|^07\d{2}\s?(\d{3}\s?){2}')" jr:constraintMsg="Please make sure the number is not already in use by another person and is in the format +254 7XX XXX XXX or 07XX XXX XXX." nodeset="/data/ephemeral_phone/phone2" type="tel"/>
      <bind nodeset="/data/ephemeral_phone_confirmation" relevant=" /data/ephemeral_phone/phone1  != &quot;&quot; or  /data/ephemeral_phone/phone2  != &quot;&quot;"/>
      <bind nodeset="/data/ephemeral_phone_confirmation/phone_note" readonly="true()" type="string"/>
      <bind nodeset="/data/ephemeral_dob/g_sex" required="true()" type="select1"/>
      <bind nodeset="/data/ephemeral_dob/contact_dob_method" required="true()" type="select1"/>
      <bind constraint=".&lt;today()" jr:constraintMsg="Date must be before today" nodeset="/data/ephemeral_dob/dob_calendar" relevant="selected(../contact_dob_method,'calendar')" required="true()" type="date"/>
      <bind constraint=". &gt;= 0 and . &lt;= 130" jr:constraintMsg="Age must be between 0 and 130" nodeset="/data/ephemeral_dob/age" relevant="selected(../contact_dob_method,'approx')" required="true()" type="int"/>
      <bind calculate="if(selected( ../contact_dob_method,'calendar'), 
../dob_calendar,
format-date-time( decimal-date-time( today() ) - (365.25 * ../age) , &quot;%Y-%m-%d&quot;) )" nodeset="/data/ephemeral_dob/dob_raw" type="string"/>
      <bind calculate="format-date-time(../dob_raw,&quot;%Y-%m-%d&quot;)" nodeset="/data/ephemeral_dob/contact_dob_iso" type="string"/>
      <bind calculate="../../contact/name" nodeset="/data/ephemeral_pregnancy/display_name" type="string"/>
      <bind constraint=". &gt;= 0" jr:constraintMsg="Number of children must be greater than 0" nodeset="/data/ephemeral_pregnancy/g_children_under_5" required="true()" type="int"/>
      <bind nodeset="/data/ephemeral_pregnancy/pregnant" relevant=" /data/ephemeral_dob/g_sex  = 'female' and  /data/ephemeral_dob/age  &gt;=14 and  /data/ephemeral_dob/age  &lt;=50" required="true()" type="select1"/>
      <bind nodeset="/data/ephemeral_pregnancy/pregnancy_note" readonly="true()" relevant=" /data/ephemeral_pregnancy/pregnant  = 'true'" type="string"/>
      <bind nodeset="/data/repeat-relevant/child" required="true()" type="select1"/>
      <bind nodeset="/data/repeat" relevant="/data/repeat-relevant/child = 'true'"/>
      <bind nodeset="/data/repeat/child/delimiter" readonly="true()" type="string"/>
      <bind nodeset="/data/repeat/child/type" type="string"/>
      <bind nodeset="/data/repeat/child/parent" type="string"/>
      <bind nodeset="/data/repeat/child/name" required="true()" type="string"/>
      <bind nodeset="/data/repeat/child/notes" type="string"/>
      <bind nodeset="/data/repeat/child/phone" type="string"/>
      <bind nodeset="/data/repeat/child/alternate_phone" type="string"/>
      <bind calculate="../dob_iso" nodeset="/data/repeat/child/date_of_birth" type="string"/>
      <bind nodeset="/data/repeat/child/dob_method" required="true()" type="select1"/>
      <bind constraint=".&lt;today()" jr:constraintMsg="Date must be before today" nodeset="/data/repeat/child/dob_calendar" relevant="selected(../dob_method,'calendar')" required="true()" type="date"/>
      <bind constraint=". &gt;= 0 and . &lt;=130" jr:constraintMsg="Age must be between 0 and 130" nodeset="/data/repeat/child/age_years" relevant="selected(../dob_method,'approx')" required="true()" type="int"/>
      <bind constraint=". &gt;= 0 and . &lt;= 11" jr:constraintMsg="Months must between 0 and 11" nodeset="/data/repeat/child/age_months" relevant="selected(../dob_method,'approx')" required="true()" type="int"/>
      <bind calculate="if(format-date-time(today(),&quot;%m&quot;) - ../age_months &lt; 0, format-date-time(today(),&quot;%m&quot;) - ../age_months + 12, format-date-time(today(),&quot;%m&quot;) - ../age_months)" nodeset="/data/repeat/child/ephemeral_months" type="string"/>
      <bind calculate="if(format-date-time(today(),&quot;%m&quot;) - ../age_months &lt; 0, format-date-time(today(),&quot;%Y&quot;) - ../age_years - 1, format-date-time(today(),&quot;%Y&quot;) -../age_years)" nodeset="/data/repeat/child/ephemeral_years" type="string"/>
      <bind calculate="date(concat(string(../ephemeral_years),'-',if(../ephemeral_months&lt;10, concat('0',string(../ephemeral_months)), ../ephemeral_months),'-',string(format-date-time(today(), &quot;%d&quot;))))" nodeset="/data/repeat/child/dob_approx" type="string"/>
      <bind calculate="if(not(selected( ../dob_method,'approx')), 
../dob_calendar,
../dob_approx )" nodeset="/data/repeat/child/dob_raw" type="string"/>
      <bind calculate="format-date-time(../dob_raw,&quot;%Y-%m-%d&quot;)" nodeset="/data/repeat/child/dob_iso" type="string"/>
      <bind calculate="if(selected(../dob_method,'calendar'),floor( difference-in-months( ../dob_iso, today() ) div 12 ),../age_years)" nodeset="/data/repeat/child/person_age_years" type="string"/>
      <bind calculate="if(selected(../dob_method,'calendar'),difference-in-months( ../dob_iso, today() ),../age_months)" nodeset="/data/repeat/child/person_age_months" type="string"/>
      <bind nodeset="/data/repeat/child/dob_debug" readonly="true()" relevant="false()" type="string"/>
      <bind nodeset="/data/repeat/child/sex" required="true()" type="select1"/>
      <bind nodeset="/data/repeat/child/relationship_to_primary_caregiver" required="true()" type="select1"/>
      <bind nodeset="/data/repeat/child/relationship_to_pc_other" relevant="../relationship_to_primary_caregiver = 'other'" required="true()" type="string"/>
      <bind nodeset="/data/repeat/child/delivered_in_facility" relevant="(../person_age_years &lt; 1) and (../person_age_months &lt; 6) and (../dob_iso != '')" required="true()" type="select1"/>
      <bind nodeset="/data/repeat/child/exclusively_breastfed" relevant="(../person_age_years &lt; 1) and (../person_age_months &lt; 6) and (../dob_iso != '')" required="true()" type="select1"/>
      <bind nodeset="/data/repeat/child/mother_attended_anc" relevant="(../person_age_years &lt; 1) and (../person_age_months &lt; 11) and (../dob_iso != '')" required="true()" type="select1"/>
      <bind nodeset="/data/repeat/child/slept_under_treated_net" required="true()" type="select1"/>
      <bind nodeset="/data/repeat/note" readonly="true()" type="string"/>
      <bind calculate="/data/inputs/user/facility_id" nodeset="/data/clinic/parent" type="string"/>
      <bind calculate="concat(../../contact/name, ' Family')" nodeset="/data/clinic/name" type="string"/>
      <bind calculate="concat(../../inputs/meta/location/lat, concat(' ', ../../inputs/meta/location/long))" nodeset="/data/clinic/geolocation" type="string"/>
      <bind calculate="&quot;NEW&quot;" nodeset="/data/clinic/contact" type="string"/>
      <bind calculate="concat('uuid:', uuid())" nodeset="/data/meta/instanceID" readonly="true()" type="string"/>
    </model>
  </h:head>
  <h:body class="pages">
    <group ref="/data/inputs">
      <group ref="/data/inputs/user">
        <input ref="/data/inputs/user/facility_id">
          <label>Facility ID for the parent user</label>
        </input>
      </group>
    </group>
    <group appearance="field-list" ref="/data/contact">
      <label>Primary Caregiver</label>
      <input ref="/data/contact/debug_note">
        <label>Debug: <output value=" /data/inputs/user/facility_id "/></label></input>
      <input appearance="hidden" ref="/data/contact/parent">
        <label>Parent</label>
        <hint>mandatory</hint>
      </input>
      <input ref="/data/contact/name">
        <label>Names</label>
      </input>
      <input ref="/data/contact/notes">
        <label>Notes (optional)</label>
      </input>
    </group>
    <group appearance="field-list" ref="/data/ephemeral_phone">
      <label>Primary Caregiver</label>
      <input appearance="numbers" ref="/data/ephemeral_phone/phone1">
        <label>Primary Mobile Number</label>
        <hint>Use one of the following formats: +254 7XX XXX XXX or 07XX XXX XXX</hint>
      </input>
      <input appearance="numbers" ref="/data/ephemeral_phone/phone2">
        <label>Secondary Mobile Number</label>
        <hint>Use one of the following formats: +254 7XX XXX XXX or 07XX XXX XXX</hint>
      </input>
    </group>
    <group appearance="field-list" ref="/data/ephemeral_phone_confirmation">
      <label>Primary Caregiver</label>
      <input ref="/data/ephemeral_phone_confirmation/phone_note">
        <label>**Please verify that the phone numbers are accurate**

**Primary Number:** <output value=" /data/ephemeral_phone/phone1 "/>
**Secondary Number:** <output value=" /data/ephemeral_phone/phone2 "/></label></input>
    </group>
    <group appearance="field-list" ref="/data/ephemeral_dob">
      <label>Primary Caregiver</label>
      <select1 appearance="horizontal" ref="/data/ephemeral_dob/g_sex">
        <label>Gender</label>
        <item>
          <label>Female</label>
          <value>female</value>
        </item>
        <item>
          <label>Male</label>
          <value>male</value>
        </item>
      </select1>
      <select1 appearance="horizontal hidden" ref="/data/ephemeral_dob/contact_dob_method">
        <label>Method to select date of birth</label>
        <item>
          <label>With calendar (preferred)</label>
          <value>calendar</value>
        </item>
        <item>
          <label>With current age</label>
          <value>approx</value>
        </item>
      </select1>
      <input ref="/data/ephemeral_dob/dob_calendar">
        <label>Date of Birth</label>
      </input>
      <input ref="/data/ephemeral_dob/age">
        <label>Age</label>
      </input>
    </group>
    <group appearance="field-list" ref="/data/ephemeral_pregnancy">
      <label>Primary Caregiver</label>
      <input ref="/data/ephemeral_pregnancy/g_children_under_5">
        <label>How many children under 5 are in the family of <output value=" /data/ephemeral_pregnancy/display_name "/>?</label>
      </input>
      <select1 appearance="horizontal" ref="/data/ephemeral_pregnancy/pregnant">
        <label>Is <output value=" /data/ephemeral_pregnancy/display_name "/> currently pregnant?</label>
        <item>
          <label>Yes</label>
          <value>true</value>
        </item>
        <item>
          <label>No</label>
          <value>false</value>
        </item>
      </select1>
      <input ref="/data/ephemeral_pregnancy/pregnancy_note">
        <label>**Make sure to register this pregnancy so you are qualified for your incentive.**</label>
      </input>
    </group>
    <group appearance="field-list" ref="/data/repeat-relevant">
      <label>Other Household Members</label>
      <select1 appearance="horizontal" ref="/data/repeat-relevant/child">
        <label>Do you want to register other household members now?</label>
        <hint>Make sure to register all children under 5 now. You can register other family members at a later time.</hint>
        <item>
          <label>Yes</label>
          <value>true</value>
        </item>
        <item>
          <label>No</label>
          <value>false</value>
        </item>
      </select1>
    </group>
    <group appearance="field-list" ref="/data/repeat">
      <label>Other Household Members</label>
      <group ref="/data/repeat/child">
        <label></label>
        <repeat appearance="field-list" nodeset="/data/repeat/child">
          <input ref="/data/repeat/child/delimiter">
            <label>&lt;hr style=&quot;margin:0 auto;&quot;&gt;</label>
          </input>
          <input appearance="hidden" ref="/data/repeat/child/type">
            <label>Person Type</label>
            <hint>mandatory</hint>
          </input>
          <input appearance="hidden" ref="/data/repeat/child/parent">
            <label>Parent</label>
            <hint>mandatory</hint>
          </input>
          <input ref="/data/repeat/child/name">
            <label>Names</label>
          </input>
          <input appearance="hidden" ref="/data/repeat/child/notes">
            <label>Notes (optional)</label>
          </input>
          <input appearance="hidden" ref="/data/repeat/child/phone">
            <label>Phone Number</label>
          </input>
          <input appearance="hidden" ref="/data/repeat/child/alternate_phone">
            <label>Alternate Phone Number</label>
          </input>
          <select1 appearance="horizontal" ref="/data/repeat/child/dob_method">
            <label>Method to select date of birth</label>
            <item>
              <label>With calendar (preferred)</label>
              <value>calendar</value>
            </item>
            <item>
              <label>With current age</label>
              <value>approx</value>
            </item>
          </select1>
          <input ref="/data/repeat/child/dob_calendar">
            <label>Date of Birth</label>
          </input>
          <input ref="/data/repeat/child/age_years">
            <label>Age</label>
            <hint>Age in years</hint>
          </input>
          <input ref="/data/repeat/child/age_months">
            <hint>And how many months?</hint>
          </input>
          <input ref="/data/repeat/child/dob_debug">
            <label>Months: <output value=" /data/repeat/child/ephemeral_months "/>
Year: <output value=" /data/repeat/child/ephemeral_years "/>
DOB ISO: <output value=" /data/repeat/child/dob_iso "/></label></input>
          <select1 appearance="horizontal" ref="/data/repeat/child/sex">
            <label>Gender</label>
            <item>
              <label>Female</label>
              <value>female</value>
            </item>
            <item>
              <label>Male</label>
              <value>male</value>
            </item>
          </select1>
          <select1 ref="/data/repeat/child/relationship_to_primary_caregiver">
            <label>What is the relationship to the primary caregiver?</label>
            <item>
              <label>Spouse</label>
              <value>spouse</value>
            </item>
            <item>
              <label>Child</label>
              <value>child</value>
            </item>
            <item>
              <label>Grandchild</label>
              <value>grandchild</value>
            </item>
            <item>
              <label>Brother</label>
              <value>brother</value>
            </item>
            <item>
              <label>Sister</label>
              <value>sister</value>
            </item>
            <item>
              <label>Other</label>
              <value>other</value>
            </item>
          </select1>
          <input ref="/data/repeat/child/relationship_to_pc_other">
            <label>Specify other:</label>
          </input>
          <select1 ref="/data/repeat/child/delivered_in_facility">
            <label>Was the child delivered in a health facility?</label>
            <item>
              <label>Yes</label>
              <value>true</value>
            </item>
            <item>
              <label>No</label>
              <value>false</value>
            </item>
          </select1>
          <select1 ref="/data/repeat/child/exclusively_breastfed">
            <label>Is the child exclusively breastfeeding?</label>
            <item>
              <label>Yes</label>
              <value>true</value>
            </item>
            <item>
              <label>No</label>
              <value>false</value>
            </item>
          </select1>
          <select1 ref="/data/repeat/child/mother_attended_anc">
            <label>Did the mother attend 4 or more ANC visits?</label>
            <item>
              <label>Yes</label>
              <value>true</value>
            </item>
            <item>
              <label>No</label>
              <value>false</value>
            </item>
          </select1>
          <select1 ref="/data/repeat/child/slept_under_treated_net">
            <label>Did the person sleep under an insecticide treated net last night?</label>
            <item>
              <label>Yes</label>
              <value>true</value>
            </item>
            <item>
              <label>No</label>
              <value>false</value>
            </item>
          </select1>
        </repeat>
      </group>
      <input ref="/data/repeat/note">
        <label>&lt;span style=&quot;color:#888;font-size:11px;&quot;&gt;**Add another person by pressing the + button.** 
Remove this child by pressing the - button&lt;/span&gt;</label>
      </input>
    </group>
    <group ref="/data/clinic">
      <label>Add Household</label>
    </group>
  </h:body>
</h:html>
Configuration 1 - High Bug

All 20 comments

@alxndrsn Could you please have a look at this one when you get a chance?

This currently creates children whose parent is the contact of the clinic. This appears to be by design, but would be simple to change...

The children's parent should be the clinic itself as opposed to the contact of the clinic. Can we make that change? Or are you saying that it's something we need to change in the form itself?

Can we make that change? Or are you saying that it's something we need to change in the form itself?

Yes, I've just pushed code to make this change, and I'm waiting to see if it breaks unrelated tests. It seems like it was written like this quite deliberately, but I can't see an obvious reason for the behaviour in current master.

Please backport this one to 2.13.x.

@alxndrsn please backport this to 2.13.x so it can be included for testing in the next beta release. Re-assigning to you.

@alxndrsn I've backported this on your behalf so I can get another beta out.

Thanks!

I tested this in master and it is working. However, testing on 2.13.x is blocked on #3891.

Working well on 2.13.0-beta.15. Moving to ready.

I was doing some testing for something else and discovered that I may have spoken too soon on this one. Looks like there is still an issue with creating the children from the repeat group. While the immediate parent is set correctly, it's not including the rest of hierarchy. Each child should have _ids for the immediate parent (family), next level up (chp area) and the top level (branch) but right now they are only getting the _id of the family.

This is what a newly registered child looks like when I use the form with the repeat group: https://beta.dev.medicmobile.org/_couch/_utils/document.html?medic/a1d165b3-469c-477a-996b-a5c29867a52c

And here is what a correct record should look like: https://beta.dev.medicmobile.org/_couch/_utils/document.html?medic/bdc3c3c0-3c9a-4715-b1e0-c9808248f5bf

(I have no idea why Github is claiming there is a new commit (381449a), it's from 19 days ago and that particular hash doesn't exist in git AFAICT, at least not locally)

@sglangevin I don't think those two beta links are correct. They point to identically size hierarchies:

image

image

I think I may have edited the first one after posting this in an effort to make sure I didn't have weird, orphaned records. Sorry about that! Originally the parent field had only the first _id in it, no nested parent fields.

@sglangevin so I think I've fixed it

Family:

{
  "_id": "5bfc4a75-b8db-4aaf-aa78-06756e57448b",
  "_rev": "1-c145f9bd389052552334f9c6b68a6a65",
  "parent": {
    "_id": "5d25264c-5064-456a-a30b-9dab2670e4da",
    "parent": {
      "_id": "9f180245-1977-4252-8ca3-19d501ed878a"
    }
  },
  "name": "JKKKJKJJJ Family",
  "geolocation": "",
  "contact": {
    "_id": "5d4a6934-cbe4-41d9-af5e-26655e455286"
  },
  "type": "clinic",
  "reported_date": 1505848672847
}

Head of household:

{
  "_id": "5d4a6934-cbe4-41d9-af5e-26655e455286",
  "_rev": "1-f582c22b1ad4ae7271bfa38ca0300cf2",
  "debug_note": "",
  "name": "JKKKJKJJJ",
  "notes": "",
  "sex": "male",
  "date_of_birth_method": "approx",
  "date_of_birth": "1996-09-19",
  "phone": "",
  "alternate_phone": "",
  "pregnant_at_registration": "",
  "reported_date": 1505848697824,
  "type": "person",
  "parent": {
    "_id": "5bfc4a75-b8db-4aaf-aa78-06756e57448b",
    "parent": {
      "_id": "5d25264c-5064-456a-a30b-9dab2670e4da",
      "parent": {
        "_id": "9f180245-1977-4252-8ca3-19d501ed878a"
      }
    }
  }
}

Sprog:

{
  "_id": "2b6c0395-4a07-4fc3-a0a8-e885ca174357",
  "_rev": "1-add3dcb0cf9518217cff032f577cd5a9",
  "delimiter": "",
  "type": "person",
  "parent": {
    "_id": "5bfc4a75-b8db-4aaf-aa78-06756e57448b",
    "parent": {
      "_id": "5d25264c-5064-456a-a30b-9dab2670e4da",
      "parent": {
        "_id": "9f180245-1977-4252-8ca3-19d501ed878a"
      }
    }
  },
  "name": "opopopopop",
  "notes": "",
  "phone": "",
  "alternate_phone": "",
  "date_of_birth": "2013-09-19",
  "dob_method": "approx",
  "dob_calendar": "",
  "age_years": "4",
  "age_months": "0",
  "ephemeral_months": "9",
  "ephemeral_years": "2013",
  "dob_approx": "2013-09-19",
  "dob_raw": "2013-09-19",
  "dob_iso": "2013-09-19",
  "person_age_years": "4",
  "person_age_months": "0",
  "dob_debug": "",
  "sex": "male",
  "relationship_to_primary_caregiver": "child",
  "relationship_to_pc_other": "",
  "delivered_in_facility": "",
  "exclusively_breastfed": "",
  "mother_attended_anc": "",
  "slept_under_treated_net": "true",
  "reported_date": 1505848798041
}

@SCdF that looks correct to me!

@garethbowen please take a look at the above PR to make sure my heart is in the right place. I'll add tests tomorrow (I know, I know, TDD. Come at me bro 👊 )

FWIW I really don't like how I'm fixing this. It's not clear to me how I'd make it better.. it doesn't help that the attachment code is "generic", so there are implicit hard-to-document ties between a form configuration being correct and this code actually working (ie you need to make sure you're attaching the parent on the doc, because otherwise your children will be malformed).

I know we've talked before about making this less… hacky, and about reworking this functionality so that you don't have these odd child documents, and instead some kind of linkage between first class forms (if you tick that you want to add children that triggers an entire new enketo session after this one etc). I think this kind of thing is fuel for the fire here.

Merged into 2.13.x and backported into master. 2.13.0-beta.17 has been released.

Looks good in v2.13.0-beta.17. Moving to ready!

Was this page helpful?
0 / 5 - 0 ratings