{
  "$schema": "https://schemas.rasd.dev/form/v1.json",
  "rasd": "1.0",
  "id": "pdm-gfd-2026",
  "version": "3",
  "requires": { "features": ["type:consent", "fn:pulldata"] },
  "meta": {
    "title": {
      "en": "Post-Distribution Monitoring – General Food Distribution",
      "ar": "رصد ما بعد التوزيع – التوزيع العام للغذاء"
    },
    "description": {
      "en": "Household interview conducted 4–6 weeks after a general food distribution: consent, household roster, ration received, food consumption score (7-day recall), satisfaction, complaints and feedback, GPS, ration-card photo and respondent signature.",
      "ar": "مقابلة أسرية تُجرى بعد 4–6 أسابيع من التوزيع العام للغذاء: الموافقة، قائمة أفراد الأسرة، الحصة المستلمة، درجة الاستهلاك الغذائي (تذكّر 7 أيام)، الرضا، الشكاوى والملاحظات، الموقع الجغرافي، صورة بطاقة التموين وتوقيع المستجيب."
    },
    "tags": ["pdm", "gfd", "food-security"],
    "author": "M&E Unit – Country Office Jordan",
    "createdAt": "2026-03-02T08:00:00Z",
    "updatedAt": "2026-08-15T10:00:00Z",
    "changelog": {
      "en": "v3: added FCS matrix, coping strategies and ration-card barcode; consent text 2026-06; retired old_note.",
      "ar": "الإصدار 3: إضافة مصفوفة درجة الاستهلاك الغذائي واستراتيجيات التكيّف ورمز بطاقة التموين؛ نص الموافقة 2026-06."
    },
    "ext": { "org.wfp.moda": { "programme": "GFD-JO-2026", "cycle": "2026-Q3", "activity": "GFD" } }
  },
  "settings": {
    "defaultLocale": "en",
    "locales": ["en", "ar"],
    "navigation": "paged",
    "showProgress": true,
    "allowDrafts": true,
    "autosaveMs": 2000,
    "instanceName": "concat(coalesce(pulldata('geo_dist', 'name', 'code', ${district}), '—'), ' · ', coalesce(${hh_id}, 'no id'))",
    "submissionIdPrefix": "PDM",
    "numbering": "latn",
    "calendar": "gregorian",
    "localeMeta": {
      "en": { "dir": "ltr" },
      "ar": { "dir": "rtl", "numbering": "native" }
    },
    "audit": {
      "enabled": true,
      "trackChanges": true,
      "changeReasons": "onEdit",
      "identifyUser": true,
      "location": { "enabled": true, "priority": "balanced", "minSeconds": 60, "minMeters": 50 }
    },
    "encryption": { "mode": "field", "publicKeyId": "wfp-jo-pdm-2026" },
    "theme": { "themeId": "rasd-field", "overrides": { "tokens": { "color": { "primary": "#0A6ED1" } } } },
    "ext": { "org.wfp.moda": { "autoSend": true } }
  },
  "choiceLists": {
    "yes_no": {
      "choices": [
        { "value": "yes", "label": { "en": "Yes", "ar": "نعم" } },
        { "value": "no", "label": { "en": "No", "ar": "لا" } }
      ]
    },
    "yes_no_dk": {
      "choices": [
        { "value": "yes", "label": { "en": "Yes", "ar": "نعم" } },
        { "value": "no", "label": { "en": "No", "ar": "لا" } },
        { "value": "dont_know", "label": { "en": "Don't know", "ar": "لا أعرف" } }
      ]
    },
    "sex": {
      "choices": [
        { "value": "female", "label": { "en": "Female", "ar": "أنثى" } },
        { "value": "male", "label": { "en": "Male", "ar": "ذكر" } }
      ]
    },
    "relation": {
      "choices": [
        { "value": "head", "label": { "en": "Head of household", "ar": "رب/ربة الأسرة" } },
        { "value": "spouse", "label": { "en": "Spouse", "ar": "الزوج/الزوجة" } },
        { "value": "child", "label": { "en": "Son / daughter", "ar": "ابن / ابنة" } },
        { "value": "parent", "label": { "en": "Parent", "ar": "أب / أم" } },
        { "value": "sibling", "label": { "en": "Sibling", "ar": "أخ / أخت" } },
        { "value": "other_relative", "label": { "en": "Other relative", "ar": "قريب آخر" } },
        { "value": "non_relative", "label": { "en": "Not related", "ar": "غير قريب" } }
      ]
    },
    "commodities": {
      "choices": [
        { "value": "wheat_flour", "label": { "en": "Wheat flour", "ar": "طحين القمح" }, "media": { "image": "assets/commodities/wheat_flour.png" } },
        { "value": "rice", "label": { "en": "Rice", "ar": "أرز" }, "media": { "image": "assets/commodities/rice.png" } },
        { "value": "pulses", "label": { "en": "Pulses (lentils, chickpeas, beans)", "ar": "بقوليات (عدس، حمص، فاصولياء)" } },
        { "value": "veg_oil", "label": { "en": "Vegetable oil", "ar": "زيت نباتي" } },
        { "value": "sugar", "label": { "en": "Sugar", "ar": "سكر" } },
        { "value": "salt", "label": { "en": "Iodised salt", "ar": "ملح ميودن" } },
        { "value": "none", "label": { "en": "None of these", "ar": "لا شيء مما سبق" } }
      ]
    },
    "dist_issues": {
      "choices": [
        { "value": "none", "label": { "en": "No problems", "ar": "لا توجد مشاكل" } },
        { "value": "waited_long", "label": { "en": "Waited more than 2 hours", "ar": "الانتظار أكثر من ساعتين" } },
        { "value": "quantity_less", "label": { "en": "Received less than entitled", "ar": "استلام أقل من الاستحقاق" } },
        { "value": "quality_poor", "label": { "en": "Poor quality / damaged items", "ar": "جودة رديئة / مواد تالفة" } },
        { "value": "distance_far", "label": { "en": "Distribution point too far", "ar": "نقطة التوزيع بعيدة جداً" } },
        { "value": "unsafe", "label": { "en": "Felt unsafe at or on the way to the site", "ar": "الشعور بعدم الأمان في الموقع أو في الطريق إليه" }, "ext": { "org.wfp.moda": { "protection": true } } },
        { "value": "asked_payment", "label": { "en": "Was asked for money or favours", "ar": "طُلب مني مال أو خدمات" }, "ext": { "org.wfp.moda": { "protection": true } } }
      ]
    },
    "cfm_channels": {
      "choices": [
        { "value": "hotline", "label": { "en": "Toll-free hotline", "ar": "الخط الساخن المجاني" } },
        { "value": "help_desk", "label": { "en": "Help desk at the distribution site", "ar": "مكتب المساعدة في موقع التوزيع" } },
        { "value": "complaint_box", "label": { "en": "Complaint / suggestion box", "ar": "صندوق الشكاوى والاقتراحات" } },
        { "value": "community_leader", "label": { "en": "Community leader / committee", "ar": "قائد المجتمع / اللجنة" } },
        { "value": "whatsapp", "label": { "en": "WhatsApp / SMS", "ar": "واتساب / رسائل نصية" } }
      ]
    },
    "complaint_status": {
      "choices": [
        { "value": "resolved", "label": { "en": "Resolved", "ar": "تم الحل" } },
        { "value": "pending", "label": { "en": "Still pending", "ar": "قيد المعالجة" } },
        { "value": "no_response", "label": { "en": "No response received", "ar": "لم يتم الرد" } }
      ]
    },
    "coping": {
      "choices": [
        { "value": "less_preferred", "label": { "en": "Relied on less preferred / less expensive food", "ar": "الاعتماد على طعام أقل تفضيلاً أو أرخص" } },
        { "value": "borrow_food", "label": { "en": "Borrowed food or relied on help from friends/relatives", "ar": "اقتراض الطعام أو الاعتماد على مساعدة الأقارب/الأصدقاء" } },
        { "value": "reduce_meals", "label": { "en": "Reduced number of meals per day", "ar": "تقليل عدد الوجبات في اليوم" } },
        { "value": "reduce_portion", "label": { "en": "Limited portion size at meals", "ar": "تقليل حجم الوجبات" } },
        { "value": "adults_restrict", "label": { "en": "Adults ate less so children could eat", "ar": "تناول البالغين كميات أقل ليأكل الأطفال" } },
        { "value": "none", "label": { "en": "None", "ar": "لا شيء" } }
      ]
    },
    "needs": {
      "choices": [
        { "value": "food", "label": { "en": "Food", "ar": "غذاء" } },
        { "value": "cash", "label": { "en": "Cash", "ar": "نقد" } },
        { "value": "health", "label": { "en": "Health care", "ar": "رعاية صحية" } },
        { "value": "shelter", "label": { "en": "Shelter / rent", "ar": "مأوى / إيجار" } },
        { "value": "education", "label": { "en": "Education", "ar": "تعليم" } }
      ]
    },
    "governorate": {
      "source": { "type": "dataset", "dataset": "geo_gov" },
      "valueKey": "code",
      "labelKey": "name"
    },
    "district": {
      "source": { "type": "dataset", "dataset": "geo_dist" },
      "valueKey": "code",
      "labelKey": "name",
      "filterKeys": ["gov_code"]
    },
    "dist_site": {
      "source": { "type": "dataset", "dataset": "dist_sites" },
      "valueKey": "code",
      "labelKey": "name",
      "filterKeys": ["dist_code"],
      "ext": { "org.wfp.moda": { "sourceSystem": "COMET" } }
    }
  },
  "datasets": [
    {
      "name": "geo_gov",
      "source": "server",
      "keyField": "code",
      "columns": [
        { "name": "code", "type": "string", "label": { "en": "P-code", "ar": "الرمز" } },
        { "name": "name", "type": "string", "label": { "en": "Governorate", "ar": "المحافظة" } }
      ]
    },
    {
      "name": "geo_dist",
      "source": "server",
      "keyField": "code",
      "columns": [
        { "name": "code", "type": "string" },
        { "name": "name", "type": "string" },
        { "name": "gov_code", "type": "string" }
      ]
    },
    {
      "name": "dist_sites",
      "source": "inline",
      "keyField": "code",
      "columns": [
        { "name": "code", "type": "string" },
        { "name": "name", "type": "string" },
        { "name": "dist_code", "type": "string" }
      ],
      "inline": [
        { "code": "ZAA-D3", "name": "Zaatari – District 3 FDP", "dist_code": "JO-MA-01" },
        { "code": "ZAA-D9", "name": "Zaatari – District 9 FDP", "dist_code": "JO-MA-01" },
        { "code": "MAF-C1", "name": "Mafraq City – Community Centre", "dist_code": "JO-MA-02" },
        { "code": "AZR-V6", "name": "Azraq – Village 6 FDP", "dist_code": "JO-ZA-03" }
      ],
      "ext": { "org.wfp.moda": { "sourceSystem": "COMET", "refreshedAt": "2026-08-01" } }
    }
  ],
  "pages": [
    {
      "id": "intro",
      "title": { "en": "Introduction & consent", "ar": "المقدمة والموافقة" },
      "elements": [
        {
          "type": "note",
          "name": "n_intro",
          "label": {
            "en": "**Read aloud:** My name is {enumerator}. We are visiting households that received food assistance to learn how the distribution went. The interview takes about 25 minutes. Your answers are confidential and will not affect your assistance.",
            "ar": "**اقرأ بصوت عالٍ:** اسمي {enumerator}. نزور الأسر التي استلمت مساعدات غذائية لمعرفة كيف جرى التوزيع. تستغرق المقابلة حوالي 25 دقيقة. إجاباتك سرية ولن تؤثر على مساعداتك."
          },
          "media": { "audio": { "ar": "assets/audio/intro_ar.mp3" } },
          "props": { "style": "info" }
        },
        { "type": "hidden", "name": "enumerator", "default": { "expr": "${meta.username}" } },
        { "type": "hidden", "name": "device_id", "default": { "expr": "${meta.deviceId}" } },
        { "type": "hidden", "name": "started_at", "default": { "expr": "${meta.startedAt}" } },
        { "type": "calculate", "name": "interview_uid", "calculate": "once(uuid())" },
        {
          "type": "date",
          "name": "interview_date",
          "label": { "en": "Interview date", "ar": "تاريخ المقابلة" },
          "default": { "expr": "today()" },
          "readonly": true,
          "constraint": ". <= today()",
          "constraintMessage": { "en": "The interview date cannot be in the future.", "ar": "لا يمكن أن يكون تاريخ المقابلة في المستقبل." }
        },
        {
          "type": "consent",
          "name": "consent",
          "label": { "en": "Informed consent", "ar": "الموافقة المستنيرة" },
          "hint": { "en": "Tap \"I agree\" only after the respondent has agreed verbally.", "ar": "اضغط \"أوافق\" فقط بعد موافقة المستجيب شفهياً." },
          "required": true,
          "requiredMessage": { "en": "The interview cannot continue without consent.", "ar": "لا يمكن متابعة المقابلة دون الموافقة." },
          "props": {
            "text": {
              "en": "Participation is voluntary. You may stop at any time or skip any question. We will record your household's location and a photo of your ration card to verify the distribution. Do you agree to take part?",
              "ar": "المشاركة طوعية. يمكنك التوقف في أي وقت أو تخطي أي سؤال. سنسجّل موقع أسرتك وصورة بطاقة التموين للتحقق من التوزيع. هل توافق على المشاركة؟"
            },
            "textVersion": "2026-06",
            "method": "tap",
            "allowWithdraw": true,
            "onWithdraw": "clearSensitive"
          },
          "ext": { "org.wfp.moda": { "dpia": "JO-PDM-2026-01" } }
        },
        {
          "type": "select_one",
          "name": "refusal_reason",
          "label": { "en": "Reason for refusal", "ar": "سبب الرفض" },
          "relevant": "${consent}.granted = false",
          "props": {
            "choices": [
              { "value": "no_time", "label": { "en": "No time", "ar": "لا وقت لديه" } },
              { "value": "not_interested", "label": { "en": "Not interested", "ar": "غير مهتم" } },
              { "value": "privacy", "label": { "en": "Privacy concerns", "ar": "مخاوف تتعلق بالخصوصية" } },
              { "value": "other", "label": { "en": "Other", "ar": "أخرى" } }
            ]
          },
          "appearance": { "variant": "radio" }
        }
      ]
    },
    {
      "id": "hh",
      "title": { "en": "Household identification", "ar": "تعريف الأسرة" },
      "relevant": "${consent}.granted = true",
      "elements": [
        {
          "type": "text",
          "name": "hh_id",
          "label": { "en": "Household ID", "ar": "رقم الأسرة" },
          "hint": { "en": "As printed on the ration card, e.g. JO-123456", "ar": "كما هو مطبوع على بطاقة التموين، مثال: JO-123456" },
          "required": true,
          "props": { "mask": "AA-######", "maxLength": 9 },
          "validators": [
            { "type": "regex", "pattern": "^[A-Z]{2}[0-9]{6}$", "message": { "en": "Format: two letters and six digits (JO-123456).", "ar": "الصيغة: حرفان وستة أرقام (JO-123456)." } }
          ],
          "bind": { "index": true }
        },
        {
          "type": "barcode",
          "name": "ration_card",
          "label": { "en": "Scan the ration card QR code", "ar": "امسح رمز QR على بطاقة التموين" },
          "props": { "formats": ["qr_code", "code_128"], "allowManual": true },
          "validators": [
            { "type": "regex", "pattern": "^[0-9]{10,14}$", "message": { "en": "Ration card numbers have 10–14 digits.", "ar": "أرقام بطاقات التموين تتكون من 10–14 رقماً." }, "severity": "warning" }
          ],
          "bind": { "index": true },
          "ext": { "org.wfp.moda": { "scopeField": "cardNumber" } }
        },
        {
          "type": "select_one",
          "name": "governorate",
          "label": { "en": "Governorate", "ar": "المحافظة" },
          "required": true,
          "props": { "list": "governorate" },
          "appearance": { "variant": "dropdown" }
        },
        {
          "type": "select_one",
          "name": "district",
          "label": { "en": "District", "ar": "اللواء" },
          "required": true,
          "props": { "list": "district", "choiceFilter": "gov_code = ${governorate}", "search": true },
          "appearance": { "variant": "dropdown" }
        },
        {
          "type": "select_one",
          "name": "dist_site",
          "label": { "en": "Distribution point", "ar": "نقطة التوزيع" },
          "required": true,
          "props": { "list": "dist_site", "choiceFilter": "dist_code = ${district}" },
          "appearance": { "variant": "radio" }
        },
        { "type": "calculate", "name": "district_name", "calculate": "pulldata('geo_dist', 'name', 'code', ${district})" },
        {
          "type": "group",
          "name": "hh_head",
          "label": { "en": "Head of household", "ar": "رب/ربة الأسرة" },
          "appearance": { "variant": "card" },
          "elements": [
            {
              "type": "text",
              "name": "head_name",
              "label": { "en": "Full name of the head of household", "ar": "الاسم الكامل لرب/ربة الأسرة" },
              "required": true,
              "props": { "maxLength": 120 },
              "bind": { "sensitive": true }
            },
            {
              "type": "select_one",
              "name": "head_sex",
              "label": { "en": "Sex of the head of household", "ar": "جنس رب/ربة الأسرة" },
              "required": true,
              "props": { "list": "sex" },
              "appearance": { "variant": "buttons" }
            },
            {
              "type": "text",
              "name": "head_phone",
              "label": { "en": "Contact phone number", "ar": "رقم الهاتف للتواصل" },
              "hint": { "en": "Optional – used only to follow up on complaints.", "ar": "اختياري – يُستخدم فقط لمتابعة الشكاوى." },
              "props": { "format": "phone", "mask": "##########", "maxLength": 10 },
              "validators": [
                { "type": "regex", "pattern": "^07[0-9]{8}$", "message": { "en": "Jordanian mobile numbers start with 07 and have 10 digits.", "ar": "أرقام الهواتف الأردنية تبدأ بـ 07 وتتكون من 10 أرقام." }, "severity": "warning" }
              ],
              "bind": { "sensitive": true, "saveIncomplete": false }
            },
            {
              "type": "select_one",
              "name": "respondent_is_head",
              "label": { "en": "Is the respondent the head of household?", "ar": "هل المستجيب هو رب/ربة الأسرة؟" },
              "required": true,
              "props": { "list": "yes_no" },
              "appearance": { "variant": "buttons" }
            }
          ],
          "ext": { "dev.rasd.builder": { "collapsed": false, "colour": "#0A6ED1" } }
        },
        {
          "type": "group",
          "name": "hh_comp",
          "label": { "en": "Household composition", "ar": "تكوين الأسرة" },
          "appearance": { "variant": "field-list", "columns": 2 },
          "elements": [
            {
              "type": "number",
              "name": "adults",
              "label": { "en": "Adults (18+)", "ar": "البالغون (18+)" },
              "required": true,
              "props": { "kind": "integer", "min": 0, "max": 30 },
              "validators": [
                { "type": "expr", "expr": ". >= 1", "message": { "en": "A household without adults is unusual – please double-check.", "ar": "أسرة بدون بالغين أمر غير معتاد – يرجى التحقق." }, "severity": "warning" }
              ]
            },
            {
              "type": "number",
              "name": "children",
              "label": { "en": "Children (under 18)", "ar": "الأطفال (دون 18)" },
              "required": true,
              "props": { "kind": "integer", "min": 0, "max": 30 }
            },
            { "type": "calculate", "name": "hh_size", "calculate": "coalesce(${adults}, 0) + coalesce(${children}, 0)" },
            {
              "type": "note",
              "name": "n_hh_size",
              "label": { "en": "Household size: **{hh_size}** – you will now list each member.", "ar": "حجم الأسرة: **{hh_size}** – ستقوم الآن بإدراج كل فرد." },
              "relevant": "${hh_size} > 0",
              "props": { "style": "success" }
            }
          ]
        },
        {
          "type": "repeat",
          "name": "hh_members",
          "label": { "en": "Household members", "ar": "أفراد الأسرة" },
          "hint": { "en": "One entry per member, starting with the head of household.", "ar": "إدخال واحد لكل فرد، بدءاً برب/ربة الأسرة." },
          "required": true,
          "relevant": "${hh_size} > 0",
          "props": {
            "min": 1,
            "max": 30,
            "count": "${hh_size}",
            "itemLabel": "concat('Member ', position(), if(notEmpty(${m_name}), concat(' – ', ${m_name}), ''))",
            "addLabel": { "en": "Add member", "ar": "إضافة فرد" },
            "removeLabel": { "en": "Remove member", "ar": "إزالة الفرد" },
            "confirmDelete": true
          },
          "elements": [
            {
              "type": "text",
              "name": "m_name",
              "label": { "en": "Name or initials", "ar": "الاسم أو الأحرف الأولى" },
              "required": true,
              "props": { "maxLength": 80 },
              "bind": { "sensitive": true }
            },
            {
              "type": "select_one",
              "name": "m_relation",
              "label": { "en": "Relationship to the head of household", "ar": "صلة القرابة برب/ربة الأسرة" },
              "required": true,
              "props": { "list": "relation" },
              "appearance": { "variant": "dropdown" }
            },
            {
              "type": "select_one",
              "name": "m_sex",
              "label": { "en": "Sex", "ar": "الجنس" },
              "required": true,
              "props": { "list": "sex" },
              "appearance": { "variant": "buttons" }
            },
            {
              "type": "number",
              "name": "m_age",
              "label": { "en": "Age (completed years)", "ar": "العمر (بالسنوات الكاملة)" },
              "required": true,
              "props": { "kind": "integer", "min": 0, "max": 120 },
              "constraint": "not(${m_relation} = 'head' and . < 15)",
              "constraintMessage": { "en": "A head of household must be at least 15 years old.", "ar": "يجب أن يكون عمر رب/ربة الأسرة 15 عاماً على الأقل." }
            },
            {
              "type": "select_one",
              "name": "m_disability",
              "label": { "en": "Does {m_name} have a lot of difficulty seeing, hearing, walking or remembering?", "ar": "هل يعاني {m_name} من صعوبة كبيرة في الرؤية أو السمع أو المشي أو التذكر؟" },
              "relevant": "${m_age} >= 5",
              "props": { "list": "yes_no_dk" },
              "appearance": { "variant": "buttons" }
            },
            {
              "type": "select_one",
              "name": "m_pregnant",
              "label": { "en": "Is she currently pregnant or breastfeeding?", "ar": "هل هي حامل أو مرضعة حالياً؟" },
              "relevant": "${m_sex} = 'female' and ${m_age} >= 12 and ${m_age} <= 49",
              "props": { "list": "yes_no_dk" },
              "appearance": { "variant": "buttons" }
            },
            { "type": "calculate", "name": "m_is_child", "calculate": "if(${m_age} < 18, 1, 0)" }
          ],
          "ext": { "org.wfp.moda": { "table": "hh_roster" } }
        }
      ]
    },
    {
      "id": "ration",
      "title": { "en": "Assistance received", "ar": "المساعدة المستلمة" },
      "relevant": "${consent}.granted = true",
      "elements": [
        {
          "type": "select_one",
          "name": "food_received",
          "label": { "en": "Did your household receive food from the last distribution?", "ar": "هل استلمت أسرتك الغذاء من التوزيع الأخير؟" },
          "media": { "audio": { "ar": "assets/audio/food_received_ar.mp3" } },
          "required": true,
          "props": { "list": "yes_no" },
          "appearance": { "variant": "buttons", "size": "lg" },
          "ext": { "org.wfp.moda": { "kpi": "PDM-01" } }
        },
        {
          "type": "text",
          "name": "no_food_reason",
          "label": { "en": "Why did the household not receive food?", "ar": "لماذا لم تستلم الأسرة الغذاء؟" },
          "relevant": "${food_received} = 'no'",
          "required": "${food_received} = 'no'",
          "props": { "multiline": true, "maxLength": 1000 }
        },
        {
          "type": "date",
          "name": "dist_date",
          "label": { "en": "Date of the distribution", "ar": "تاريخ التوزيع" },
          "relevant": "${food_received} = 'yes'",
          "required": "${food_received} = 'yes'",
          "constraint": ". <= today()",
          "constraintMessage": { "en": "The distribution date cannot be in the future.", "ar": "لا يمكن أن يكون تاريخ التوزيع في المستقبل." },
          "validators": [
            { "type": "expr", "expr": "dateDiff(., today(), 'days') <= 60", "message": { "en": "More than 60 days since distribution – PDM recall may be unreliable.", "ar": "مرّ أكثر من 60 يوماً على التوزيع – قد يكون التذكّر غير موثوق." }, "severity": "warning" }
          ],
          "props": { "calendar": "gregorian" },
          "appearance": { "variant": "no-calendar" }
        },
        {
          "type": "select_multiple",
          "name": "commodities",
          "label": { "en": "Which items did you receive?", "ar": "ما هي المواد التي استلمتها؟" },
          "relevant": "${food_received} = 'yes'",
          "required": "${food_received} = 'yes'",
          "props": { "list": "commodities", "exclusive": ["none"] },
          "appearance": { "variant": "chips", "columns": 2 }
        },
        {
          "type": "number",
          "name": "ration_kg",
          "label": { "en": "Total weight received", "ar": "إجمالي الوزن المستلم" },
          "relevant": "${food_received} = 'yes' and not(selected(${commodities}, 'none'))",
          "props": { "kind": "decimal", "min": 0, "max": 500, "step": 0.5, "unit": { "en": "kg", "ar": "كغ" } },
          "constraint": ". > 0",
          "constraintMessage": { "en": "Enter a weight greater than zero.", "ar": "أدخل وزناً أكبر من صفر." },
          "validators": [
            { "type": "range", "max": 120, "message": { "en": "More than 120 kg for one household is unusual – please double-check.", "ar": "أكثر من 120 كغ لأسرة واحدة أمر غير معتاد – يرجى التحقق." }, "severity": "warning" }
          ]
        },
        {
          "type": "select_one",
          "name": "ration_complete",
          "label": { "en": "Did you receive the full entitlement shown on your ration card?", "ar": "هل استلمت كامل الاستحقاق المبيّن على بطاقة التموين؟" },
          "relevant": "${food_received} = 'yes'",
          "required": "${food_received} = 'yes'",
          "props": { "list": "yes_no_dk" },
          "appearance": { "variant": "buttons" },
          "ext": { "org.wfp.moda": { "kpi": "PDM-02" } }
        },
        {
          "type": "text",
          "name": "ration_missing",
          "label": { "en": "What was missing or reduced?", "ar": "ما الذي كان ناقصاً أو مخفّضاً؟" },
          "relevant": "${ration_complete} = 'no'",
          "required": "${ration_complete} = 'no'",
          "props": { "multiline": true, "maxLength": 500 }
        },
        {
          "type": "select_multiple",
          "name": "dist_issues",
          "label": { "en": "Did you face any of the following problems during the distribution?", "ar": "هل واجهت أياً من المشاكل التالية أثناء التوزيع؟" },
          "relevant": "${food_received} = 'yes'",
          "props": { "list": "dist_issues", "exclusive": ["none"], "other": { "enabled": true, "label": { "en": "Other problem", "ar": "مشكلة أخرى" } } },
          "appearance": { "variant": "chips" },
          "ext": { "org.wfp.moda": { "kpi": "PDM-04" } }
        },
        {
          "type": "image",
          "name": "ration_card_photo",
          "label": { "en": "Photo of the ration card (front)", "ar": "صورة بطاقة التموين (الوجه الأمامي)" },
          "hint": { "en": "Make sure the card number is readable.", "ar": "تأكد من وضوح رقم البطاقة." },
          "relevant": "${food_received} = 'yes'",
          "required": "${food_received} = 'yes'",
          "props": { "source": "camera", "maxPixels": 1280, "quality": 0.7, "geotag": true },
          "bind": { "sensitive": true }
        },
        {
          "type": "select_multiple",
          "name": "coping",
          "label": { "en": "In the past 7 days, did your household do any of the following because there was not enough food?", "ar": "خلال الأيام السبعة الماضية، هل قامت أسرتك بأي مما يلي بسبب عدم كفاية الطعام؟" },
          "required": true,
          "props": { "list": "coping", "exclusive": ["none"], "maxSelected": 5 },
          "appearance": { "variant": "chips" },
          "ext": { "org.wfp.moda": { "kpi": "rCSI" } }
        }
      ]
    },
    {
      "id": "fcs",
      "title": { "en": "Food consumption (last 7 days)", "ar": "الاستهلاك الغذائي (آخر 7 أيام)" },
      "relevant": "${consent}.granted = true",
      "elements": [
        {
          "type": "note",
          "name": "n_fcs",
          "label": { "en": "Ask about food eaten **at home** by household members over the past 7 days. Enter the number of days (0–7) for each food group.", "ar": "اسأل عن الطعام الذي تناوله أفراد الأسرة **في المنزل** خلال الأيام السبعة الماضية. أدخل عدد الأيام (0–7) لكل مجموعة غذائية." },
          "guidance": { "en": "Count a food group only if it was eaten as a main ingredient, not as a condiment.", "ar": "احسب المجموعة الغذائية فقط إذا تم تناولها كمكوّن رئيسي وليس كتوابل." },
          "props": { "style": "info", "collapsible": false }
        },
        {
          "type": "matrix",
          "name": "fcs",
          "label": { "en": "Number of days each food group was eaten", "ar": "عدد الأيام التي تم فيها تناول كل مجموعة غذائية" },
          "required": true,
          "props": {
            "rows": [
              { "value": "cereals", "label": { "en": "Cereals, grains, roots and tubers", "ar": "الحبوب والجذور والدرنات" } },
              { "value": "pulses", "label": { "en": "Pulses, nuts and seeds", "ar": "البقوليات والمكسرات والبذور" } },
              { "value": "vegetables", "label": { "en": "Vegetables and leaves", "ar": "الخضروات والأوراق" } },
              { "value": "fruit", "label": { "en": "Fruits", "ar": "الفواكه" } },
              { "value": "meat", "label": { "en": "Meat, fish and eggs", "ar": "اللحوم والأسماك والبيض" } },
              { "value": "dairy", "label": { "en": "Milk and dairy products", "ar": "الحليب ومنتجات الألبان" } },
              { "value": "sugar", "label": { "en": "Sugar and sweets", "ar": "السكر والحلويات" } },
              { "value": "oil", "label": { "en": "Oil, fat and butter", "ar": "الزيوت والدهون والزبدة" } }
            ],
            "columns": { "type": "number", "kind": "integer", "min": 0, "max": 7 },
            "requiredRows": "all"
          },
          "ext": { "org.wfp.moda": { "kpi": "FCS", "indicatorCode": "FCS-01" } }
        },
        {
          "type": "calculate",
          "name": "fcs_score",
          "calculate": "coalesce(${fcs}.cereals, 0) * 2 + coalesce(${fcs}.pulses, 0) * 3 + coalesce(${fcs}.vegetables, 0) * 1 + coalesce(${fcs}.fruit, 0) * 1 + coalesce(${fcs}.meat, 0) * 4 + coalesce(${fcs}.dairy, 0) * 4 + coalesce(${fcs}.sugar, 0) * 0.5 + coalesce(${fcs}.oil, 0) * 0.5"
        },
        {
          "type": "calculate",
          "name": "fcs_group",
          "calculate": "if(${fcs_score} <= 21, 'poor', if(${fcs_score} <= 35, 'borderline', 'acceptable'))"
        },
        {
          "type": "note",
          "name": "n_fcs_result",
          "label": { "en": "Food Consumption Score: **{fcs_score}** ({fcs_group}).", "ar": "درجة الاستهلاك الغذائي: **{fcs_score}** ({fcs_group})." },
          "relevant": "notEmpty(${fcs})",
          "props": { "style": "info" }
        },
        {
          "type": "select_one",
          "name": "flag_followup",
          "label": { "en": "Flagged for nutrition follow-up", "ar": "مُعلَّم للمتابعة التغذوية" },
          "hint": { "en": "Set automatically when the FCS is poor.", "ar": "يُضبط تلقائياً عندما تكون درجة الاستهلاك الغذائي ضعيفة." },
          "readonly": true,
          "default": { "value": "no" },
          "props": { "list": "yes_no" },
          "appearance": { "variant": "buttons" }
        }
      ]
    },
    {
      "id": "feedback",
      "title": { "en": "Satisfaction, complaints and feedback", "ar": "الرضا والشكاوى والملاحظات" },
      "relevant": "${consent}.granted = true",
      "elements": [
        {
          "type": "rating",
          "name": "satisfaction",
          "label": { "en": "Overall, how satisfied are you with the distribution?", "ar": "بشكل عام، ما مدى رضاك عن التوزيع؟" },
          "required": true,
          "props": { "max": 5, "icon": "smiley", "labels": { "min": { "en": "Very unsatisfied", "ar": "غير راضٍ إطلاقاً" }, "max": { "en": "Very satisfied", "ar": "راضٍ جداً" } } },
          "validators": [
            { "type": "expr", "expr": "not(${food_received} = 'yes' and . <= 2)", "message": { "en": "Low satisfaction although food was received – please record the reason below.", "ar": "رضا منخفض رغم استلام الغذاء – يرجى تسجيل السبب أدناه." }, "severity": "warning" }
          ],
          "ext": { "org.wfp.moda": { "kpi": "PDM-07" } }
        },
        {
          "type": "text",
          "name": "satisfaction_reason",
          "label": { "en": "What is the main reason for your rating?", "ar": "ما السبب الرئيسي لتقييمك؟" },
          "relevant": "${satisfaction} <= 2",
          "required": "${satisfaction} <= 2",
          "props": { "multiline": true, "maxLength": 1000 }
        },
        {
          "type": "select_one",
          "name": "cfm_aware",
          "label": { "en": "Do you know how to make a complaint or give feedback about the assistance?", "ar": "هل تعرف كيف تقدّم شكوى أو ملاحظة حول المساعدة؟" },
          "required": true,
          "props": { "list": "yes_no" },
          "appearance": { "variant": "buttons" },
          "ext": { "org.wfp.moda": { "kpi": "AAP-01" } }
        },
        {
          "type": "select_multiple",
          "name": "cfm_channels",
          "label": { "en": "Which channels do you know?", "ar": "ما هي القنوات التي تعرفها؟" },
          "relevant": "${cfm_aware} = 'yes'",
          "required": "${cfm_aware} = 'yes'",
          "props": { "list": "cfm_channels", "other": { "enabled": true, "label": { "en": "Other channel", "ar": "قناة أخرى" }, "value": "other" }, "minSelected": 1 },
          "appearance": { "variant": "chips" }
        },
        {
          "type": "select_one",
          "name": "complaint_filed",
          "label": { "en": "Have you made a complaint in the past 3 months?", "ar": "هل قدّمت شكوى خلال الأشهر الثلاثة الماضية؟" },
          "relevant": "${cfm_aware} = 'yes'",
          "props": { "list": "yes_no" },
          "appearance": { "variant": "buttons" }
        },
        {
          "type": "select_one",
          "name": "complaint_status",
          "label": { "en": "What happened to your complaint?", "ar": "ماذا حدث لشكواك؟" },
          "relevant": "${complaint_filed} = 'yes'",
          "required": "${complaint_filed} = 'yes'",
          "props": { "list": "complaint_status" },
          "appearance": { "variant": "radio" }
        },
        {
          "type": "rank",
          "name": "priorities",
          "label": { "en": "Rank your household's most urgent needs (1 = most urgent)", "ar": "رتّب أكثر احتياجات أسرتك إلحاحاً (1 = الأكثر إلحاحاً)" },
          "props": { "list": "needs" }
        },
        {
          "type": "range",
          "name": "assistance_share",
          "label": { "en": "Roughly what share of the food your household ate last week came from the assistance?", "ar": "تقريباً ما نسبة الطعام الذي تناولته أسرتك الأسبوع الماضي من المساعدة؟" },
          "props": { "min": 0, "max": 100, "step": 5, "showValue": true },
          "appearance": { "size": "lg" }
        }
      ]
    },
    {
      "id": "wrapup",
      "title": { "en": "Location and sign-off", "ar": "الموقع والتوقيع" },
      "relevant": "${consent}.granted = true",
      "elements": [
        {
          "type": "geopoint",
          "name": "hh_location",
          "label": { "en": "Household location", "ar": "موقع الأسرة" },
          "hint": { "en": "Capture outdoors; wait until accuracy is 10 m or better.", "ar": "التقط الموقع في الخارج؛ انتظر حتى تصبح الدقة 10 م أو أفضل." },
          "required": true,
          "props": { "accuracyThreshold": 10, "warningThreshold": 50, "autoCapture": true, "allowManual": false, "map": false },
          "bind": { "sensitive": true }
        },
        {
          "type": "x:beneficiary-lookup",
          "name": "beneficiary",
          "label": { "en": "Link to beneficiary record (optional)", "ar": "ربط بسجل المستفيد (اختياري)" },
          "hint": { "en": "Search the offline SCOPE extract by ration card number.", "ar": "ابحث في نسخة SCOPE غير المتصلة برقم بطاقة التموين." },
          "props": { "registry": "scope", "searchBy": ["cardNumber", "hhId"], "prefill": { "cardNumber": "${ration_card}" }, "fields": ["id", "name", "familySize"] },
          "bind": { "sensitive": true },
          "ext": { "org.wfp.moda": { "kpi": "PDM-ID" } }
        },
        {
          "type": "text",
          "name": "enum_comments",
          "label": { "en": "Enumerator comments", "ar": "ملاحظات الباحث الميداني" },
          "props": { "multiline": true, "maxLength": 2000, "placeholder": { "en": "Anything unusual about this interview…", "ar": "أي شيء غير معتاد في هذه المقابلة…" } }
        },
        {
          "type": "checkbox",
          "name": "ack_complete",
          "label": { "en": "I confirm that the interview was conducted in full and the answers were recorded as given.", "ar": "أؤكد أن المقابلة أُجريت بالكامل وأن الإجابات سُجّلت كما وردت." },
          "required": true
        },
        {
          "type": "signature",
          "name": "respondent_signature",
          "label": { "en": "Respondent's signature or mark", "ar": "توقيع المستجيب أو علامته" },
          "hint": { "en": "Optional if the respondent prefers not to sign.", "ar": "اختياري إذا فضّل المستجيب عدم التوقيع." },
          "props": { "penColor": "#0B2A4A", "maxBytes": 262144 },
          "bind": { "sensitive": true }
        }
      ]
    }
  ],
  "logic": {
    "calculated": [
      { "name": "member_count", "calculate": "count(${hh_members})" },
      { "name": "children_count", "calculate": "sum(${hh_members[].m_is_child})", "includeInData": true },
      { "name": "has_protection_issue", "calculate": "selected(${dist_issues}, 'unsafe') or selected(${dist_issues}, 'asked_payment')" }
    ],
    "triggers": [
      {
        "id": "t-consent-no",
        "when": "${consent}.granted = false",
        "on": "pageLeave",
        "once": true,
        "actions": [
          { "type": "showMessage", "message": { "en": "Thank the respondent for their time.", "ar": "اشكر المستجيب على وقته." }, "severity": "info" },
          { "type": "complete", "message": { "en": "Interview ended – consent not given.", "ar": "انتهت المقابلة – لم تُمنح الموافقة." } }
        ],
        "ext": { "org.wfp.moda": { "outcome": "refused" } }
      },
      {
        "id": "t-no-food",
        "when": "${food_received} = 'no'",
        "actions": [
          { "type": "clearValue", "target": "dist_date" },
          { "type": "clearValue", "target": "commodities" },
          { "type": "clearValue", "target": "ration_kg" },
          { "type": "showMessage", "message": { "en": "Record why the household did not receive food, then continue.", "ar": "سجّل سبب عدم استلام الأسرة للغذاء ثم تابع." }, "severity": "warning" }
        ]
      },
      {
        "id": "t-fcs-poor",
        "when": "${fcs_group} = 'poor'",
        "on": "pageLeave",
        "once": true,
        "actions": [
          { "type": "setValue", "target": "flag_followup", "value": "yes" },
          { "type": "showMessage", "message": { "en": "Poor food consumption ({fcs_score}). The household is flagged for nutrition follow-up.", "ar": "استهلاك غذائي ضعيف ({fcs_score}). تم تعليم الأسرة للمتابعة التغذوية." }, "severity": "warning", "blocking": true }
        ]
      },
      {
        "id": "t-protection",
        "when": "${has_protection_issue}",
        "once": true,
        "actions": [
          { "type": "showMessage", "message": { "en": "Protection concern reported. Do not probe further; share the PSEA hotline card with the respondent.", "ar": "تم الإبلاغ عن مخاوف تتعلق بالحماية. لا تتعمّق في الأسئلة؛ سلّم المستجيب بطاقة الخط الساخن للحماية من الاستغلال والانتهاك الجنسيين." }, "severity": "error", "blocking": true },
          { "type": "custom", "id": "protection.referral", "payload": { "channel": "psea-focal-point", "priority": "high" } }
        ],
        "ext": { "org.wfp.moda": { "workflow": "protection-referral" } }
      }
    ]
  },
  "ext": {
    "org.wfp.moda": { "formUid": "aXb12", "project": "PDM-JO-2026" },
    "dev.rasd.builder": { "lastPage": "fcs", "paletteCollapsed": false }
  }
}
