Now that we can configure the contact-summary, we're able to display a lot of really useful information in a patient's profile related to the care that has been provided to them in the past. We'd like to extend this feature so that the information that is being calculated in the contact-summary.js file can be made available as input to forms (or we could add a new object to contact-summary that contains data available to forms). This would close the loop on a few items and enable us to better track care over time in analytics:
This is needed for outbreak surveillance (cc @samkanga) so that we can look and see if a patient was sick recently or delivered recently and use that as context within a form. It will also be useful for the examples cited above (cc @derickl).
@sglangevin this would also be useful for a nutrition use case - will will need to track certain aspects/conditions of a mother and/or their child.
@derickl not sure of your specific use case with nutrition, but as long as that info is entered into a form about the child, then this will work!
Should be supported via https://opendatakit.github.io/xforms-spec/#secondary-instances---external
More info at https://github.com/enketo/enketo-core#usage-as-a-library (data.external); enketo-express implementation at https://github.com/kobotoolbox/enketo-express/blob/master/public/js/src/module/connection.js#L358
@derickl when you have a moment it would be great to go over the current implementation of this and see if it's suitable for you
@alxndrsn does tomorrow work? I've slacked you just in case
@alxndrsn @garethbowen does this issue still need more work? Not sure if either of you have connected with @derickl about this on Slack.
@sglangevin I'm working on it currently and hoping to get it back to Alex for review this week.
@alxndrsn I can't assign you as reviewer because you submitted the initial PR but can you review my changes and merge if you're happy?
How to AT:
Configure your contact summary script to output something useful in the context, eg:
return {
context: {
age: 15
}
}
Configure a form with a secondary instance with the ID 'contact-summary'. This prompts our code to bind the contact summary context in. Bind that to a primary instance field, and then display the primary instance field somewhere in the form. Below is a minimal example - you'll need to flesh this out with all the usual fields.
<h:html>
<h:head>
<model>
<instance>
<visit>
<age/>
</visit>
</instance>
<instance id="contact-summary"/>
<bind calculate="instance('contact-summary')/context/age" nodeset="/visit/age" type="string"/>
</model>
</h:head>
<h:body>
<input ref="/visit/age" />
</h:body>
</h:html>
Now you should see the input populated with "15".
Is this testable on any instance @sglangevin ?
It's testable on any instance, you just have to create the right type of form to do the testing. I can take this one for AT.
Trying to AT this and am struggling to find a way to create my XLS Form such that it creates the correct XML. The only way I know of to generate a secondary instance from an xlsform is to do something similar to cascading selects. However, that seems to create a secondary instance for every choices list that I have.
@garethbowen do you have any pointers on how I can achieve the correct XML when I'm creating the forms in XLSform? I've tried a bunch of different things without any success.
No idea sorry. @alxndrsn Thoughts?
I tried this yesterday afternoon and hit a brick wall (thought I was going crazy :))
@abbyad may know. If not, I will check with the enketo/odk docs because secondary instances are used by other projects. It may need an update to our pyxform if it's not currently working as documented.
@abbyad is out until next Friday, so if there is any way to move forward on this before he is back, that would be better.
@alxndrsn I did a bunch of googling and couldn't find any useful sections of the enketo/odk docs yesterday, but I'll give it another shot today to see if I can figure it out. I can also test a form with XML that I create manually, just to be sure that the feature is working as expected while we continue figuring out the XLSform part.
Update: I've tested and this is working with the syntax that Gareth provided. I've also managed to get close to the right syntax in XLSform to make this work. However, I am creating the second instance the same way it would be done for cascading selects and I am pretty sure I'm running into the same bug as #3624. I've done a bunch of research and I can't find any other documentation on how to create a second (internal) instance in an XLSForm.
The XML below will work if you remove the following section:
Section to remove:
<select1 appearance="hidden" ref="/pregnancy_visit/inputs/contact-summary">
<label>Contact Summary</label>
<itemset nodeset="instance('contact-summary')/root/item[/context/age]">
<value ref="name"/>
<label ref="jr:itext(itextId)"/>
</itemset>
</select1>
Whole XML file:
<?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>Pregnancy Visit</h:title>
<model>
<itext>
<translation lang="default">
<text id="static_instance-select_danger_signs-8">
<value>Diarrhea that doesn't go away</value>
</text>
<text id="static_instance-select_danger_signs-0">
<value>Pain, pressure or cramping in abdomen</value>
</text>
<text id="static_instance-select_danger_signs-1">
<value>Bleeding or fluid leaking from vagina or vaginal discharge with bad odour</value>
</text>
<text id="static_instance-select_danger_signs-2">
<value>Severe nausea or vomiting</value>
</text>
<text id="static_instance-select_danger_signs-3">
<value>Fever of 38 degrees or higher</value>
</text>
<text id="static_instance-select_preg_essn_kit_sold-0">
<value>Pregnancy Essentials Kit Sold</value>
</text>
<text id="static_instance-select_danger_signs-5">
<value>Sudden weight gain or severe swelling of feet, ankles, face, or hands</value>
</text>
<text id="static_instance-select_danger_signs-6">
<value>Less movement and kicking from the baby</value>
</text>
<text id="static_instance-select_danger_signs-7">
<value>Blood in the urine or painful, burning urination</value>
</text>
<text id="static_instance-select_mama_kit_sold-0">
<value>Mama Kit Sold</value>
</text>
<text id="static_instance-not_pregnant_reason-1">
<value>Woman miscarried</value>
</text>
<text id="static_instance-not_pregnant_reason-0">
<value>Woman delivered</value>
</text>
<text id="static_instance-select_danger_signs-4">
<value>Severe headache or new, blurry vision problems</value>
</text>
<text id="static_instance-select_albendazole_sold-2">
<value>No sale</value>
</text>
<text id="static_instance-select_albendazole_sold-0">
<value>Albendazole sold</value>
</text>
<text id="static_instance-select_albendazole_sold-1">
<value>Pregnancy essentials kit sold</value>
</text>
<text id="static_instance-select_fansidar_sold-0">
<value>Fansidar sold</value>
</text>
<text id="static_instance-select_fansidar_sold-1">
<value>Pregnancy essentials kit sold</value>
</text>
<text id="static_instance-select_fansidar_sold-2">
<value>No sale</value>
</text>
<text id="static_instance-not_pregnant_reason-2">
<value>Woman died</value>
</text>
<text id="static_instance-contact-summary-0">
<value>Age</value>
</text>
<text id="static_instance-select_iron_follate_sold-0">
<value>Iron folate sold</value>
</text>
<text id="static_instance-select_iron_follate_sold-1">
<value>Pregnancy essentials kit sold</value>
</text>
<text id="static_instance-select_iron_follate_sold-2">
<value>No sale</value>
</text>
<text id="static_instance-select_follow_up_method-1">
<value>By Phone</value>
</text>
<text id="static_instance-select_follow_up_method-0">
<value>In Person</value>
</text>
<text id="static_instance-select_delivery_plan_discussed-0">
<value>Delivery Plan Discussed</value>
</text>
<text id="static_instance-select_yes_no-1">
<value>No</value>
</text>
<text id="static_instance-select_yes_no-0">
<value>Yes</value>
</text>
</translation>
</itext>
<instance>
<pregnancy_visit delimiter="#" id="pregnancy_visit" prefix="J1!pregnancy_visit!" version="2016-04-06">
<inputs>
<meta>
<location>
<lat/>
<long/>
<error/>
<message/>
</location>
</meta>
<source>user</source>
<source_id/>
<t_lmp_date/>
<contact-summary/>
<age/>
<contact>
<_id/>
<name/>
<date_of_birth>0</date_of_birth>
<sex/>
<phone/>
<parent>
<contact>
<phone/>
</contact>
</parent>
</contact>
</inputs>
<patient_age_in_years/>
<patient_contact_phone/>
<patient_id/>
<patient_name/>
<lmp_date/>
<follow_up_method/>
<delivery_plan_discussed/>
<danger_signs/>
<referral_follow_up_needed/>
<days_since_lmp/>
<weeks_since_lmp/>
<edd/>
<edd_8601/>
<new_lmp/>
<discontinue_follow_up/>
<edd_updated/>
<p_note/>
<group_followup_options>
<g_follow_up_method/>
<call_button/>
</group_followup_options>
<update_pregnancy>
<continue_follow_up/>
<why_not_pregnant/>
<submit_delivery_report/>
<change_edd/>
<new_edd/>
</update_pregnancy>
<group_danger_signs>
<g_danger_signs/>
</group_danger_signs>
<group_review>
<submit/>
<r_summary/>
<r_pregnancy_details/>
<r_delivery_date/>
<r_referral/>
<r_referral_note/>
<r_danger_sign1/>
<r_danger_sign2/>
<r_danger_sign3/>
<r_danger_sign4/>
<r_danger_sign5/>
<r_danger_sign6/>
<r_danger_sign7/>
<r_danger_sign8/>
<r_danger_sign9/>
<r_reminders/>
<r_reminder_trim1/>
<r_reminder_trim2/>
<r_reminder_trim3/>
<r_followup_instructions/>
<r_followup/>
<r_followup_note/>
<r_no_more_follow_ups/>
</group_review>
<group_delivery_plan>
<no_delivery_plan_discussed/>
<delivery_plan/>
<g_delivery_plan_discussed/>
</group_delivery_plan>
<group_healthy_newborn_practices>
<healthy_newborn_practices/>
<submit/>
</group_healthy_newborn_practices>
<meta>
<instanceID/>
</meta>
</pregnancy_visit>
</instance>
<instance id="select_preg_essn_kit_sold">
<root>
<item>
<itextId>static_instance-select_preg_essn_kit_sold-0</itextId>
<name>preg_essn_kit_sold</name>
</item>
</root>
</instance>
<instance id="not_pregnant_reason">
<root>
<item>
<itextId>static_instance-not_pregnant_reason-0</itextId>
<name>delivery</name>
</item>
<item>
<itextId>static_instance-not_pregnant_reason-1</itextId>
<name>miscarriage</name>
</item>
<item>
<itextId>static_instance-not_pregnant_reason-2</itextId>
<name>maternal_death</name>
</item>
</root>
</instance>
<instance id="select_mama_kit_sold">
<root>
<item>
<itextId>static_instance-select_mama_kit_sold-0</itextId>
<name>mama_kit_sold</name>
</item>
</root>
</instance>
<instance id="select_danger_signs">
<root>
<item>
<itextId>static_instance-select_danger_signs-0</itextId>
<name>d1</name>
</item>
<item>
<itextId>static_instance-select_danger_signs-1</itextId>
<name>d2</name>
</item>
<item>
<itextId>static_instance-select_danger_signs-2</itextId>
<name>d3</name>
</item>
<item>
<itextId>static_instance-select_danger_signs-3</itextId>
<name>d4</name>
</item>
<item>
<itextId>static_instance-select_danger_signs-4</itextId>
<name>d5</name>
</item>
<item>
<itextId>static_instance-select_danger_signs-5</itextId>
<name>d6</name>
</item>
<item>
<itextId>static_instance-select_danger_signs-6</itextId>
<name>d7</name>
</item>
<item>
<itextId>static_instance-select_danger_signs-7</itextId>
<name>d8</name>
</item>
<item>
<itextId>static_instance-select_danger_signs-8</itextId>
<name>d9</name>
</item>
</root>
</instance>
<instance id="contact-summary">
<root>
<item>
<itextId>static_instance-contact-summary-0</itextId>
<name>age</name>
</item>
</root>
</instance>
<instance id="select_iron_follate_sold">
<root>
<item>
<itextId>static_instance-select_iron_follate_sold-0</itextId>
<name>iron_follate_sold</name>
</item>
<item>
<itextId>static_instance-select_iron_follate_sold-1</itextId>
<name>pregnancy_essentials_kit</name>
</item>
<item>
<itextId>static_instance-select_iron_follate_sold-2</itextId>
<name>no_sale</name>
</item>
</root>
</instance>
<instance id="select_delivery_plan_discussed">
<root>
<item>
<itextId>static_instance-select_delivery_plan_discussed-0</itextId>
<name>delivery_plan_discussed</name>
</item>
</root>
</instance>
<instance id="select_follow_up_method">
<root>
<item>
<itextId>static_instance-select_follow_up_method-0</itextId>
<name>in_person</name>
</item>
<item>
<itextId>static_instance-select_follow_up_method-1</itextId>
<name>phone</name>
</item>
</root>
</instance>
<instance id="select_albendazole_sold">
<root>
<item>
<itextId>static_instance-select_albendazole_sold-0</itextId>
<name>albendazole_sold</name>
</item>
<item>
<itextId>static_instance-select_albendazole_sold-1</itextId>
<name>pregnancy_essentials_kit</name>
</item>
<item>
<itextId>static_instance-select_albendazole_sold-2</itextId>
<name>no_sale</name>
</item>
</root>
</instance>
<instance id="select_fansidar_sold">
<root>
<item>
<itextId>static_instance-select_fansidar_sold-0</itextId>
<name>fansidar_sold</name>
</item>
<item>
<itextId>static_instance-select_fansidar_sold-1</itextId>
<name>pregnancy_essentials_kit</name>
</item>
<item>
<itextId>static_instance-select_fansidar_sold-2</itextId>
<name>no_sale</name>
</item>
</root>
</instance>
<instance id="select_yes_no">
<root>
<item>
<itextId>static_instance-select_yes_no-0</itextId>
<name>yes</name>
</item>
<item>
<itextId>static_instance-select_yes_no-1</itextId>
<name>no</name>
</item>
</root>
</instance>
<bind nodeset="/pregnancy_visit/inputs" relevant="./source = 'user'"/>
<bind nodeset="/pregnancy_visit/inputs/source" type="string"/>
<bind nodeset="/pregnancy_visit/inputs/source_id" type="string"/>
<bind nodeset="/pregnancy_visit/inputs/t_lmp_date" type="string"/>
<bind nodeset="/pregnancy_visit/inputs/contact-summary" type="select1"/>
<bind calculate="instance('contact-summary')/context/age" nodeset="/pregnancy_visit/inputs/age" type="string"/>
<bind constraint=" /pregnancy_visit/inputs/contact/sex != 'male' and /pregnancy_visit/patient_age_in_years > 9.9 and /pregnancy_visit/patient_age_in_years < 65.1" jr:constraintMsg="Patient must female and between 10 and 65 years old" nodeset="/pregnancy_visit/inputs/contact/_id" type="db:person"/>
<bind nodeset="/pregnancy_visit/inputs/contact/name" type="string"/>
<bind nodeset="/pregnancy_visit/inputs/contact/date_of_birth" type="string"/>
<bind nodeset="/pregnancy_visit/inputs/contact/sex" type="string"/>
<bind nodeset="/pregnancy_visit/inputs/contact/phone" type="string"/>
<bind nodeset="/pregnancy_visit/inputs/contact/parent/contact/phone" type="string"/>
<bind calculate="floor( difference-in-months( /pregnancy_visit/inputs/contact/date_of_birth , today() ) div 12 )" nodeset="/pregnancy_visit/patient_age_in_years" type="string"/>
<bind calculate="coalesce(/pregnancy_visit/inputs/contact/phone,/pregnancy_visit/inputs/contact/parent/contact/phone)" nodeset="/pregnancy_visit/patient_contact_phone" type="string"/>
<bind calculate="../inputs/contact/_id" nodeset="/pregnancy_visit/patient_id" required="true()" type="string"/>
<bind calculate="../inputs/contact/name" nodeset="/pregnancy_visit/patient_name" type="string"/>
<bind calculate="if( /pregnancy_visit/update_pregnancy/change_edd = 'yes', /pregnancy_visit/new_lmp , /pregnancy_visit/inputs/t_lmp_date )" nodeset="/pregnancy_visit/lmp_date" type="string"/>
<bind calculate=" /pregnancy_visit/group_followup_options/g_follow_up_method " nodeset="/pregnancy_visit/follow_up_method" type="string"/>
<bind calculate=" /pregnancy_visit/group_delivery_plan/g_delivery_plan_discussed " nodeset="/pregnancy_visit/delivery_plan_discussed" type="string"/>
<bind calculate=" /pregnancy_visit/group_danger_signs/g_danger_signs " nodeset="/pregnancy_visit/danger_signs" type="string"/>
<bind calculate="if (count-selected( /pregnancy_visit/danger_signs ) > 0, 'true', 'false')" nodeset="/pregnancy_visit/referral_follow_up_needed" type="string"/>
<bind calculate="round(decimal-date-time(today()) - decimal-date-time( /pregnancy_visit/lmp_date ), 2)" nodeset="/pregnancy_visit/days_since_lmp" type="string"/>
<bind calculate="round( /pregnancy_visit/days_since_lmp div 7, 2)" nodeset="/pregnancy_visit/weeks_since_lmp" type="string"/>
<bind calculate="coalesce(format-date-time(date-time(decimal-date-time( /pregnancy_visit/update_pregnancy/new_edd )),"%b %e, %Y"),format-date-time(date-time(decimal-date-time( /pregnancy_visit/inputs/t_lmp_date )+280),"%b %e, %Y"))" nodeset="/pregnancy_visit/edd" type="string"/>
<bind calculate="format-date-time(date-time(decimal-date-time( /pregnancy_visit/update_pregnancy/new_edd )),"%Y-%m-%dT00:00:00.000Z")" nodeset="/pregnancy_visit/edd_8601" type="string"/>
<bind calculate="format-date-time(date-time(decimal-date-time( /pregnancy_visit/update_pregnancy/new_edd )-280),"%b %e, %Y")" nodeset="/pregnancy_visit/new_lmp" type="string"/>
<bind calculate="if( /pregnancy_visit/update_pregnancy/continue_follow_up = 'no','true','false')" nodeset="/pregnancy_visit/discontinue_follow_up" type="string"/>
<bind calculate="if( /pregnancy_visit/update_pregnancy/change_edd = 'yes','true','false')" nodeset="/pregnancy_visit/edd_updated" type="string"/>
<bind nodeset="/pregnancy_visit/p_note" readonly="true()" relevant="false()" type="string"/>
<bind nodeset="/pregnancy_visit/group_followup_options/g_follow_up_method" required="true()" type="select1"/>
<bind nodeset="/pregnancy_visit/group_followup_options/call_button" readonly="true()" relevant=" /pregnancy_visit/follow_up_method ='phone' and /pregnancy_visit/patient_contact_phone != ''" type="string"/>
<bind nodeset="/pregnancy_visit/update_pregnancy/continue_follow_up" required="true()" type="select1"/>
<bind nodeset="/pregnancy_visit/update_pregnancy/why_not_pregnant" relevant=" /pregnancy_visit/update_pregnancy/continue_follow_up = 'no'" required="true()" type="select1"/>
<bind nodeset="/pregnancy_visit/update_pregnancy/submit_delivery_report" readonly="true()" relevant=" /pregnancy_visit/update_pregnancy/why_not_pregnant = 'delivery'" type="string"/>
<bind nodeset="/pregnancy_visit/update_pregnancy/change_edd" relevant=" /pregnancy_visit/update_pregnancy/continue_follow_up = 'yes'" required="true()" type="select1"/>
<bind constraint=".>today() and ((decimal-date-time(.)-294) <= decimal-date-time(today()))" nodeset="/pregnancy_visit/update_pregnancy/new_edd" relevant=" /pregnancy_visit/update_pregnancy/change_edd = 'yes'" required="true()" type="date"/>
<bind nodeset="/pregnancy_visit/group_danger_signs" relevant=" /pregnancy_visit/update_pregnancy/continue_follow_up = 'yes'"/>
<bind nodeset="/pregnancy_visit/group_danger_signs/g_danger_signs" type="select"/>
<bind nodeset="/pregnancy_visit/group_review/submit" readonly="true()" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_summary" readonly="true()" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_pregnancy_details" readonly="true()" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_delivery_date" readonly="true()" relevant=" /pregnancy_visit/edd != '' and /pregnancy_visit/update_pregnancy/continue_follow_up = 'yes'" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_referral" readonly="true()" relevant=" /pregnancy_visit/group_danger_signs/g_danger_signs != ''" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_referral_note" readonly="true()" relevant=" /pregnancy_visit/group_danger_signs/g_danger_signs != ''" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_danger_sign1" readonly="true()" relevant="selected( /pregnancy_visit/group_danger_signs/g_danger_signs , 'd1')" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_danger_sign2" readonly="true()" relevant="selected( /pregnancy_visit/group_danger_signs/g_danger_signs , 'd2')" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_danger_sign3" readonly="true()" relevant="selected( /pregnancy_visit/group_danger_signs/g_danger_signs , 'd3')" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_danger_sign4" readonly="true()" relevant="selected( /pregnancy_visit/group_danger_signs/g_danger_signs , 'd4')" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_danger_sign5" readonly="true()" relevant="selected( /pregnancy_visit/group_danger_signs/g_danger_signs , 'd5')" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_danger_sign6" readonly="true()" relevant="selected( /pregnancy_visit/group_danger_signs/g_danger_signs , 'd6')" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_danger_sign7" readonly="true()" relevant="selected( /pregnancy_visit/group_danger_signs/g_danger_signs , 'd7')" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_danger_sign8" readonly="true()" relevant="selected( /pregnancy_visit/group_danger_signs/g_danger_signs , 'd8')" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_danger_sign9" readonly="true()" relevant="selected( /pregnancy_visit/group_danger_signs/g_danger_signs , 'd9')" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_reminders" readonly="true()" relevant=" /pregnancy_visit/weeks_since_lmp > 0 and /pregnancy_visit/update_pregnancy/continue_follow_up = 'yes'" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_reminder_trim1" readonly="true()" relevant=" /pregnancy_visit/weeks_since_lmp <= 12 and /pregnancy_visit/weeks_since_lmp > 0 and /pregnancy_visit/update_pregnancy/continue_follow_up = 'yes'" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_reminder_trim2" readonly="true()" relevant=" /pregnancy_visit/weeks_since_lmp <= 27 and /pregnancy_visit/weeks_since_lmp > 12 and /pregnancy_visit/update_pregnancy/continue_follow_up = 'yes'" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_reminder_trim3" readonly="true()" relevant=" /pregnancy_visit/weeks_since_lmp > 27 and /pregnancy_visit/update_pregnancy/continue_follow_up = 'yes'" type="string"/>
<bind calculate="if ( /pregnancy_visit/group_danger_signs/g_danger_signs != '',
'Follow up in 1 day to ensure that patient goes to a health facility',
'Tasks will appear when follow up is needed'
)" nodeset="/pregnancy_visit/group_review/r_followup_instructions" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_followup" readonly="true()" relevant=" /pregnancy_visit/group_review/r_followup_instructions != ''" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_followup_note" readonly="true()" relevant=" /pregnancy_visit/group_review/r_followup_instructions != '' and /pregnancy_visit/update_pregnancy/continue_follow_up = 'yes'" type="string"/>
<bind nodeset="/pregnancy_visit/group_review/r_no_more_follow_ups" readonly="true()" relevant=" /pregnancy_visit/update_pregnancy/continue_follow_up = 'no'" type="string"/>
<bind nodeset="/pregnancy_visit/group_delivery_plan" relevant=" /pregnancy_visit/weeks_since_lmp >= 32 and /pregnancy_visit/weeks_since_lmp < 38 and /pregnancy_visit/update_pregnancy/continue_follow_up = 'yes'"/>
<bind nodeset="/pregnancy_visit/group_delivery_plan/no_delivery_plan_discussed" readonly="true()" relevant=" /pregnancy_visit/weeks_since_lmp >= 36 and /pregnancy_visit/weeks_since_lmp < 38" type="string"/>
<bind nodeset="/pregnancy_visit/group_delivery_plan/delivery_plan" readonly="true()" relevant=" /pregnancy_visit/weeks_since_lmp >= 32 and /pregnancy_visit/weeks_since_lmp < 38" type="string"/>
<bind nodeset="/pregnancy_visit/group_delivery_plan/g_delivery_plan_discussed" relevant=" /pregnancy_visit/weeks_since_lmp >= 32 and /pregnancy_visit/weeks_since_lmp < 38" type="select"/>
<bind nodeset="/pregnancy_visit/group_healthy_newborn_practices" relevant=" /pregnancy_visit/weeks_since_lmp >= 32 and /pregnancy_visit/weeks_since_lmp < 38 and /pregnancy_visit/update_pregnancy/continue_follow_up = 'yes'"/>
<bind nodeset="/pregnancy_visit/group_healthy_newborn_practices/healthy_newborn_practices" readonly="true()" relevant=" /pregnancy_visit/weeks_since_lmp >= 32 and /pregnancy_visit/weeks_since_lmp < 38" type="string"/>
<bind nodeset="/pregnancy_visit/group_healthy_newborn_practices/submit" readonly="true()" type="string"/>
<bind calculate="concat('uuid:', uuid())" nodeset="/pregnancy_visit/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
<h:body class="pages">
<group appearance="field-list" ref="/pregnancy_visit/inputs">
<label>Patient</label>
<input appearance="hidden" ref="/pregnancy_visit/inputs/source">
<label>Source</label>
</input>
<input appearance="hidden" ref="/pregnancy_visit/inputs/source_id">
<label>Source ID</label>
</input>
<input appearance="hidden" ref="/pregnancy_visit/inputs/t_lmp_date">
<label>LMP Date</label>
</input>
<select1 appearance="hidden" ref="/pregnancy_visit/inputs/contact-summary">
<label>Contact Summary</label>
<itemset nodeset="instance('contact-summary')/root/item[/context/age]">
<value ref="name"/>
<label ref="jr:itext(itextId)"/>
</itemset>
</select1>
<input appearance="hidden" ref="/pregnancy_visit/inputs/age">
<label>Age</label>
</input>
<group ref="/pregnancy_visit/inputs/contact">
<input appearance="db-object" ref="/pregnancy_visit/inputs/contact/_id">
<label>What is the patient's name?</label>
<hint>Select a person from list</hint>
</input>
<input appearance="hidden" ref="/pregnancy_visit/inputs/contact/name">
<label>Name</label>
</input>
<input appearance="hidden" ref="/pregnancy_visit/inputs/contact/date_of_birth">
<label>Date of Birth</label>
</input>
<input appearance="hidden" ref="/pregnancy_visit/inputs/contact/sex">
<label>Sex</label>
</input>
<input appearance="hidden" ref="/pregnancy_visit/inputs/contact/phone">
<label>Person Phone</label>
</input>
<group ref="/pregnancy_visit/inputs/contact/parent">
<group ref="/pregnancy_visit/inputs/contact/parent/contact">
<input appearance="hidden" ref="/pregnancy_visit/inputs/contact/parent/contact/phone">
<label>Parent Phone</label>
</input>
</group>
</group>
</group>
</group>
<input ref="/pregnancy_visit/p_note">
<label>ID: <output value=" /pregnancy_visit/patient_id "/>
Name: <output value=" /pregnancy_visit/patient_name "/>
Date of birth: <output value=" /pregnancy_visit/inputs/contact/date_of_birth "/>
LMP: <output value=" /pregnancy_visit/inputs/t_lmp_date "/>
- in days: <output value=" /pregnancy_visit/days_since_lmp "/>
- in weeks: <output value=" /pregnancy_visit/weeks_since_lmp "/></label></input>
<group appearance="field-list" ref="/pregnancy_visit/group_followup_options">
<label>Follow up options</label>
<select1 ref="/pregnancy_visit/group_followup_options/g_follow_up_method">
<label>How are you following up?</label>
<item>
<label>In Person</label>
<value>in_person</value>
</item>
<item>
<label>By Phone</label>
<value>phone</value>
</item>
</select1>
<input ref="/pregnancy_visit/group_followup_options/call_button">
<label><b>Call:</b> <output value=" /pregnancy_visit/patient_contact_phone "/></label></input>
</group>
<group appearance="field-list" ref="/pregnancy_visit/update_pregnancy">
<label>Pregnancy Information</label>
<select1 ref="/pregnancy_visit/update_pregnancy/continue_follow_up">
<label>Is the woman still pregnant?</label>
<item>
<label>Yes</label>
<value>yes</value>
</item>
<item>
<label>No</label>
<value>no</value>
</item>
</select1>
<select1 ref="/pregnancy_visit/update_pregnancy/why_not_pregnant">
<label>Why did the pregnancy end?</label>
<item>
<label>Woman delivered</label>
<value>delivery</value>
</item>
<item>
<label>Woman miscarried</label>
<value>miscarriage</value>
</item>
<item>
<label>Woman died</label>
<value>maternal_death</value>
</item>
</select1>
<input ref="/pregnancy_visit/update_pregnancy/submit_delivery_report">
<label>After completing this form, please do a Newborn Visit to record the delivery details for the mother.</label>
</input>
<select1 ref="/pregnancy_visit/update_pregnancy/change_edd">
<label>Would you like to update the EDD?</label>
<item>
<label>Yes</label>
<value>yes</value>
</item>
<item>
<label>No</label>
<value>no</value>
</item>
</select1>
<input ref="/pregnancy_visit/update_pregnancy/new_edd">
<label>Select the mother's EDD</label>
</input>
</group>
<group appearance="field-list" ref="/pregnancy_visit/group_danger_signs">
<label>Danger Signs</label>
<select ref="/pregnancy_visit/group_danger_signs/g_danger_signs">
<label>Does the mother have any of the following danger signs?</label>
<hint>Select all that apply</hint>
<item>
<label>Pain, pressure or cramping in abdomen</label>
<value>d1</value>
</item>
<item>
<label>Bleeding or fluid leaking from vagina or vaginal discharge with bad odour</label>
<value>d2</value>
</item>
<item>
<label>Severe nausea or vomiting</label>
<value>d3</value>
</item>
<item>
<label>Fever of 38 degrees or higher</label>
<value>d4</value>
</item>
<item>
<label>Severe headache or new, blurry vision problems</label>
<value>d5</value>
</item>
<item>
<label>Sudden weight gain or severe swelling of feet, ankles, face, or hands</label>
<value>d6</value>
</item>
<item>
<label>Less movement and kicking from the baby</label>
<value>d7</value>
</item>
<item>
<label>Blood in the urine or painful, burning urination</label>
<value>d8</value>
</item>
<item>
<label>Diarrhea that doesn't go away</label>
<value>d9</value>
</item>
</select>
</group>
<group appearance="field-list summary" ref="/pregnancy_visit/group_review">
<input ref="/pregnancy_visit/group_review/submit">
<label><h4 style="text-align:center;">Be sure you Submit to complete this action.</h4></label>
</input>
<input appearance="h1 yellow" ref="/pregnancy_visit/group_review/r_summary">
<label>Pregnancy Details<i class="fa fa-user"></i></label>
</input>
<input ref="/pregnancy_visit/group_review/r_pregnancy_details">
<label><h4 style="text-align:center;"><output value=" /pregnancy_visit/patient_name "/></h4></label>
</input>
<input ref="/pregnancy_visit/group_review/r_delivery_date">
<label><h5 style="text-align:center;">Estimated delivery date: <output value=" /pregnancy_visit/edd "/></h5></label>
</input>
<input appearance="h1 red" ref="/pregnancy_visit/group_review/r_referral">
<label>Refer to a health facility<i class="fa fa-warning"></i></label>
</input>
<input ref="/pregnancy_visit/group_review/r_referral_note">
<label><b>Refer to the health facility for danger signs.</b></label>
</input>
<input appearance="li" ref="/pregnancy_visit/group_review/r_danger_sign1">
<label>Pain or cramping in abdomen</label>
</input>
<input appearance="li" ref="/pregnancy_visit/group_review/r_danger_sign2">
<label>Bleeding or fluid leaking from vagina or vaginal discharge with bad odour</label>
</input>
<input appearance="li" ref="/pregnancy_visit/group_review/r_danger_sign3">
<label>Severe nausea or vomiting</label>
</input>
<input appearance="li" ref="/pregnancy_visit/group_review/r_danger_sign4">
<label>Fever of 38 degrees or higher</label>
</input>
<input appearance="li" ref="/pregnancy_visit/group_review/r_danger_sign5">
<label>Severe headache or new, blurry vision problems</label>
</input>
<input appearance="li" ref="/pregnancy_visit/group_review/r_danger_sign6">
<label>Sudden weight gain or severe swelling of feet, ankles, face, or hands</label>
</input>
<input appearance="li" ref="/pregnancy_visit/group_review/r_danger_sign7">
<label>Less movement and kicking from the baby</label>
</input>
<input appearance="li" ref="/pregnancy_visit/group_review/r_danger_sign8">
<label>Blood in the urine or painful, burning urination</label>
</input>
<input appearance="li" ref="/pregnancy_visit/group_review/r_danger_sign9">
<label>Diarrhea that doesn't go away</label>
</input>
<input appearance="h1 blue" ref="/pregnancy_visit/group_review/r_reminders">
<label>Healthy Pregnancy Tips<i class="fa fa-heart"></i></label>
</input>
<input ref="/pregnancy_visit/group_review/r_reminder_trim1">
<label>**Living Goods strongly recommends that you deliver your child at a health center**
Remind mother of the **6 STEPS TO A HEALTHY PREGNANCY:**
<ol style="margin-left:1em; list-style: decimal inside;"><li>Attend regular ANC visits</li><li>Sleep under a treated net **every** night</li><li><output value=" /pregnancy_visit/patient_name "/> is in her **first trimester**. Remind her to take supplements:<ul style="margin-left:1em; list-style: disc inside;"><li>_Take Iron Folate daily_</li></ul></li>Eat well: Eat more often than usual and eat a variety of foods to give you strength and to help your baby grow<li>Deliver your child at a health center</li></ol></label>
</input>
<input ref="/pregnancy_visit/group_review/r_reminder_trim2">
<label>**Living Goods strongly recommends that you deliver your child at a health center**
Remind mother of the **6 STEPS TO A HEALTHY PREGNANCY:**
<ol style="margin-left:1em; list-style: decimal inside;"><li>Attend regular ANC visits</li><li>Sleep under a treated net **every** night</li><li><output value=" /pregnancy_visit/patient_name "/> is in her second trimester. Remind her to take supplements:<ul style="margin-left:1em; list-style: disc inside;"><li>_Take Iron Folate daily_</li><li>_Take Deworming/Albendazole once_</li><li>_Take Malaria Prophylaxis/Fansidar every month_</li></ul></li><li>Eat well: Eat more often than usual and eat a variety of foods to give you strength and to help your baby grow</li><li>Deliver your child at a health center</li><li>Breastfeed the baby **immediately** after birth</ol></label>
</input>
<input ref="/pregnancy_visit/group_review/r_reminder_trim3">
<label>**Living Goods strongly recommends that you deliver your child at a health center**
Remind mother of the **6 STEPS TO A HEALTHY PREGNANCY:**
<ol style="margin-left:1em; list-style: decimal inside;"><li>Attend regular ANC visits</li><li>Sleep under a treated net **every** night</li><li><output value=" /pregnancy_visit/patient_name "/> is in her third trimester. Remind her to take supplements:<ul style="margin-left:1em; list-style: disc inside;"><li>_Take Iron Folate daily_</li><li>_Take Deworming/Albendazole once_</li><li>_Take Malaria Prophylaxis/Fansidar every month_</li></ul></li><li>Eat well: Eat more often than usual and eat a variety of foods to give you strength and to help your baby grow</li><li>Deliver your child at a health center</li><li>Breastfeed the baby **immediately** after birth. Do NOT give baby anything else.</ol></label>
</input>
<input appearance="h1 green" ref="/pregnancy_visit/group_review/r_followup">
<label>Follow Up<i class="fa fa-flag"></i></label>
</input>
<input ref="/pregnancy_visit/group_review/r_followup_note">
<label><output value=" /pregnancy_visit/group_review/r_followup_instructions "/></label>
</input>
<input ref="/pregnancy_visit/group_review/r_no_more_follow_ups">
<label>No more follow-ups will appear for this woman.</label>
</input>
</group>
<group appearance="field-list" ref="/pregnancy_visit/group_delivery_plan">
<label>Discuss Delivery Plan</label>
<input ref="/pregnancy_visit/group_delivery_plan/no_delivery_plan_discussed">
<label><em style="font-style:italics">If delivery plan not discussed at previous visit</em></label>
</input>
<input ref="/pregnancy_visit/group_delivery_plan/delivery_plan">
<label>**Discussion Talking Points:**
<ul style="margin-left:1em;list-style:disc inside"><li>Where do you plan to deliver?</li><li>How do you plan to get there?</li><li>Who will go with you? etc.</li><ul></label>
</input>
<select ref="/pregnancy_visit/group_delivery_plan/g_delivery_plan_discussed">
<label>Have you discussed delivery plan?</label>
<item>
<label>Delivery Plan Discussed</label>
<value>delivery_plan_discussed</value>
</item>
</select>
</group>
<group appearance="field-list" ref="/pregnancy_visit/group_healthy_newborn_practices">
<label>Healthy Newborn Care Practices</label>
<input ref="/pregnancy_visit/group_healthy_newborn_practices/healthy_newborn_practices">
<label>**Remind mother of the best care for a newborn:**
<ol style="margin-left:1em; list-style: decimal inside;"><li>Keep the baby warm</li><li>Protect the cord</li><li>Breastfeed</li><li>Wash your hands before touching the baby</li><li>Do not bathe the baby for 24 hours</li></ol></label>
</input>
<input ref="/pregnancy_visit/group_healthy_newborn_practices/submit">
<label>**Be sure you Submit to complete this action.**</label>
</input>
</group>
</h:body>
</h:html>
So, we can safely mark this as 'ready' and leave the XLSForm issue to be dealt with by #3624. Right @sglangevin ?
No - this is not yet working so we can't move it to Ready.
For this to be used in 2.13 we need to find a reasonable way to use this in our workflow, using XLSForm and medic-conf.
Some options:
1) Manually remove the offending XML
1) Modify the convert script to remove the offending XML
1) Create an external instance with the fields declared
1) Automatically pull in the context values from contact-summary into forms
Option 4 would be ideal, and it turns out is also the easiest because it is mostly done! We need to add the secondary instance <instance id="contact-summary"/> to every form, and you can then use XPath to access _all_ values returned in result.context. This works* without declaring in the instance which fields are needed, so it is a very flexible solution and easier to manage when building forms.
For example, a form field with instance('contact-summary')/context/lineage[2]/name as a _calculation_ will get lineage[1].name from a contact-summary with the following:
...
context.lineage = lineage;
var result = {
fields: fields,
cards: cards,
context: context
};
return result;
Summary: we need to add <instance id="contact-summary"/> to every form via medic-config to mainstream this feature.
_* You can pass a large object to the form, which can then read any value, but doing so does noticeably slow the loading of the form. Because of this it is preferable to remove from the context any fields that are not being used. It is a good idea to future proofing by maintaining the same structure so that fields can be adding without needing to modify existing form calculations._
Adding the secondary instance to every form has been introduced in medic-configurer 1.5.1. Make sure you are using the latest version of medic-configurer if you are expecting this feature to work!
Still waiting on #3812 as we need to be able to access parent.contact for each place in lineage for forms that use any parent.contact.* fields.
This works well now, and easy to configure with the latest medic-configurer. Moving to Ready.