Skip to content

Instantly share code, notes, and snippets.

field('gps_lat', (state) => {
// define this once, it's constant...
const coords = state.data.form.gps_coordinates;
// write your contional
if (coords) {
return coords.split(" ")[0];
}
// the 'else' is unnecessary, return '' if there are no coords
return '';
});
encounter(
fields(
field("resourceType", "Encounter"),
field("status", "finished"),
field("type", function(state) {
return [{
"coding": [{
"system": "momconnect:type",
"code": "8"
}]
// the data we get from a facebook inbound message...
{
"sender":{
"id":"<PSID>"
},
"recipient":{
"id":"<PAGE_ID>"
},
"timestamp":1458692752478,
"message":{
//line 301...
beta.each(
merge(dataPath("staff_repeat[*]"), fields(
field("parentId", dataValue("instanceID"))
)),
create("ECD_Audit_Repeats__c",fields(
field("Position_of_Staff_Member__c",dataValue("staff_position")),
relationship("Annual_Tracking__r", "ID__c", dataValue("parentId")),
field("Name_of_Staff_Member__c", dataValue('staff_name')),
field("Classes_Taught__c",function(state) {
// try this...
beta.each(
merge(dataPath("staff_repeat[*]"), fields(
field("parentId", dataValue("instanceID"))
)),
create("ECD_Audit_Repeats__c",fields(
field("Position_of_Staff_Member__c",dataValue("staff_position")),
relationship("Annual_Tracking__r", "ID__c", dataValue("parentId")),
field("Name_of_Staff_Member__c", dataValue('staff_name')),
field("Classes_Taught__c",function(state) {
top - 14:25:48 up 15:41, 1 user, load average: 0.48, 0.37, 0.34
Tasks: 293 total, 2 running, 291 sleeping, 0 stopped, 0 zombie
%Cpu(s): 3.4 us, 1.2 sy, 0.0 ni, 95.3 id, 0.0 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem: 16433848 total, 16196616 used, 237232 free, 184028 buffers
KiB Swap: 0 total, 0 used, 0 free. 1486552 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
10434 cchq 20 0 3203404 653968 11464 S 0.0 4.0 1:18.16 java
1526 kafka 20 0 5159680 419096 10496 S 3.3 2.6 73:15.78 java
12259 cchq 20 0 967000 363240 4796 S 0.0 2.2 0:51.35 gunicorn: worke
event({
"program": "GaOaL76FraA",
"orgUnit": dataValue("properties.userLocationOrgUnitID"),
"eventDate": dataValue("date_closed".substring(0, 10)),
"status": "COMPLETED",
"storedBy": "AF-commcare-interface",
"dataValues": function(state) {
const converter = function(string){
switch(string){
case "1": return "true";
field("What_activity_are_you_currently_doing__c", function(state){
if (state.data.activity) {
return dataValue("activity")(state).toString().replace("_"," ")
} else {
return "something else. null, nada, zip, zilch!"
}
})
{
"rdfs:member": [
{
"spi:stagingbin": false,
"spi:stagedcurbal": 0,
"spi:siteid": "RPP",
"spi:reconciled": true,
"spi:physcntdate": "2015-10-03T05:05:32-04:00",
"spi:physcnt": 1,
"spi:orgid": "RAVEN",
{
"id": "5eb14f7a-dc13-4ab8-8b4c-fd51b7080539",
"form": {
"case": {
"@xmlns": "http://commcarehq.org/case/transaction/v2",
"create": {
"owner_id": "950a4ccb5cc16eb0b8eff3f417015119",
"case_name": "",
"case_type": "case"
},