Creating Surveys for CareSuite
Survey building is a foundational requirement for operationalizing both the Contact and Care applications. Caresuite works with Kobotoolbox as a plug-in form builder to allow users
Caresuite Survey Building Guide
This guide provides comprehensive best practices and anti-patterns for building surveys in Caresuite
Survey Types in Caresuite
Caresuite supports four main types of surveys:
1. Intake Survey
Purpose: Data collection for case creation in a project
Scope: Project-level (each project has one intake survey)
Usage: Used when creating or updating cases
Storage: Survey responses are stored on the Case entity
Key Features: Required for all projects, used for case creation
2. Demographic Survey
Purpose: Profile-level demographic information collection
Scope: Organization-level (each organization has one demographic survey)
Usage: Used to collect and update profile demographics
Storage: Survey responses are stored on the Profile entity (
profile.survey)Key Features: Used for global profile search and demographic data collection
3. Follow-Up Survey
Purpose: Post-referral follow-up data collection
Scope: Project-level (optional, each project can have one follow-up survey)
Usage: Completed by case managers post service delivery
Storage: Survey responses stored as follow-up survey responses per referral
4. Additional Surveys
Purpose: Custom supplemental data collection
Scope: Project-level (multiple additional surveys per project are allowed)
Usage: Custom surveys for specific data collection needs
Storage: Survey responses stored in
additionalSurveyResponsetableKey Features: Supports single and multiple responses per case per survey
Survey Format Requirements
File Format
File Type: XML (
.xmlextension)MIME Type:
text/xmlMaximum File Size: 10 MB (
MAX_SURVEY_FILESIZE = 10 * 1024 * 1024)Format Standard: XForms/ODK (Open Data Kit) format
Compatibility: Must be compatible with Kobo Toolbox format
XML Structure Requirements
Surveys must follow the XForms/ODK XML structure:
Required Namespaces
http://www.w3.org/2002/xformshttp://www.w3.org/2001/xml-eventshttp://www.w3.org/1999/xhtmlhttp://openrosa.org/javarosahttp://www.opendatakit.org/xformshttp://openrosa.org/xformshttp://www.w3.org/2001/XMLSchema
Supported Data Types
For a more detailed breakdown of stat types see Supported Data Types
✅ Fully Supported Types
1. string (Text)
XML Type:
type="string"Usage: Text input fields, names, descriptions, notes
Query Operators: Equals, Not equals, Begins with, Ends with, Contains, Doesn't contain, Is empty, Is not empty, In, Not in
Example:
2. int (Integer)
XML Type:
type="int"Usage: Whole numbers (age, counts, scores)
Query Operators: Equals, Not equals, Greater than, Less than
Example:
3. date (Date)
XML Type:
type="date"Usage: Date fields (no time component)
Query Operators: Equals to, After, Before, Between
Format: ISO date format (YYYY-MM-DD)
Example:
4. select1 (Single Select)
XML Type:
type="string"with<select1>inputUsage: Single-choice dropdown/radio buttons
Query Operators: Equals, Not equals, Is empty, Is not empty
Example:
5. select (Multi-Select)
XML Type:
type="string"with<select>inputUsage: Multiple-choice checkboxes/lists
Storage: Values stored as space-separated string (e.g., "value1 value2 value3")
Query Operators: Equals, Not equals, Is empty, Is not empty
Example:
❌ Not Supported Types
The following data types are NOT supported and should be avoided:
time - Time-only fields (use
stringor separate date field)dateTime - Date and time combined (use
datetype and store time separately if needed)decimal - Decimal numbers (may work as
int, but not explicitly supported)boolean - Boolean values (use
select1with "yes"/"no" options instead)geopoint - Geographic coordinates (store as separate lat/lng
stringorintfields)geotrace - Geographic paths
geoshape - Geographic shapes/polygons
binary - File uploads (not supported in surveys)
barcode - Barcode scanning
intent - External application intents
Best Practices
1. Field Naming
✅ DO:
Use descriptive, lowercase field names with underscores:
caller_age,first_time_caller,hear_about_211Use consistent naming conventions throughout the survey
Keep field names concise but meaningful
Use snake_case for multi-word field names
❌ DON'T:
Use spaces in field names
Use special characters (except underscores)
Use camelCase (use snake_case instead)
Use extremely long field names
Example:
2. Field Organization with Groups
✅ DO:
Organize related fields using
<group>elementsUse descriptive group names:
group_AARP_careprovider,group_kick_itNest groups when necessary to create logical hierarchies
Example:
3. Use itext for All Text Content
✅ DO:
Always use
<itext>translations for labels, hints, and option labelsReference text using
jr:itext()functionKeep actual text content in the itext section, not inline
Example:
4. Conditional Logic (Relevant Attributes)
✅ DO:
Use
relevantattributes for conditional field displayUse clear, readable XPath expressions
Test all conditional logic paths
Example:
5. Required Fields
✅ DO:
Use
requiredattributes with clear XPath conditionsConsider using conditional required logic when appropriate
Allow fields to be optional when data may not be available
Example:
6. Validation and Constraints
✅ DO:
Use regex constraints for format validation (phone numbers, emails, etc.)
Provide clear constraint messages using
jr:constraintMsgValidate data at the field level when possible
Example:
7. Calculated Fields
✅ DO:
Use
calculateattributes for computed valuesMark calculated fields as
readonly="true()"Include constraints that prevent manual modification if needed
Example:
8. Pre-loaded Values
✅ DO:
Use
jr:preloadfor auto-populated values (timestamps, instance IDs)Use appropriate preload parameters
Example:
9. Date Handling
✅ DO:
Use
date()function for default date valuesSet default dates using
<setvalue>events when appropriateUse date constraints for validation
Example:
10. Incomplete Data Handling
✅ DO:
Include options for handling incomplete data collection
Provide standard options: "Did Not Ask", "Declined to Answer", "Call Terminated Early", "Crisis Call - Did not ask"
Make fields conditionally required based on completion status
Example:
Common Anti-Patterns and Things to Avoid
1. ❌ Using Unsupported Data Types
Problem: Using data types that are not supported (dateTime, time, binary, etc.) will cause issues with data storage, querying, and display.
Solution:
Use
dateinstead ofdateTime(store time separately if needed)Use
stringfor boolean values with select1 optionsUse
stringor separateintfields for geographic coordinates
2. ❌ Inconsistent Field Naming
Problem: Inconsistent naming (mixing camelCase, snake_case, spaces) makes surveys harder to maintain and query.
Solution:
Always use snake_case for field names
Establish and follow a naming convention document
Use descriptive names that indicate the field's purpose
3. ❌ Inline Text Instead of itext
Problem: Hardcoding text directly in field definitions makes translations difficult and maintenance harder.
Solution:
Always use
<itext>translationsReference text using
jr:itext()Keep all user-facing text in the itext section
4. ❌ Missing or Incorrect XML Namespaces
Problem: Missing or incorrect namespaces can cause parsing errors.
Solution:
Include all required namespaces in the
<h:html>root elementUse the exact namespace URIs specified in the format requirements
5. ❌ Overly Complex Conditional Logic
Problem: Very complex relevant or required expressions are hard to maintain and debug.
Solution:
Break complex conditions into simpler, testable expressions
Use intermediate calculated fields when necessary
Document complex logic with comments (if XML comments are supported)
6. ❌ Missing Field Bindings
Problem: Fields defined in the body without corresponding <bind> statements may not work correctly.
Solution:
Always create a
<bind>element for each field in the form bodyEnsure nodeset paths match exactly between bind and input elements
Include appropriate type, required, and relevant attributes
7. ❌ Incorrect Multi-Select Value Storage
Problem: Expecting multi-select values to be stored as arrays when they're actually space-separated strings.
Solution:
Remember that
<select>(multi-select) values are stored as space-separated stringsWhen querying, use appropriate string operators
When displaying, split the string to get individual values
Example:
8. ❌ File Size Exceeding Limits
Problem: Surveys exceeding 10 MB will be rejected during upload.
Solution:
Keep surveys focused and avoid unnecessary fields
Optimize itext content (avoid duplicate text)
Remove unused fields and groups
Consider splitting very large surveys into multiple additional surveys
9. ❌ Missing Validation for Critical Fields
Problem: Critical fields (phone numbers, emails, etc.) without validation can lead to poor data quality.
Solution:
Always add regex constraints for phone numbers, emails, postal codes
Provide clear, helpful constraint messages
Test validation with various valid and invalid inputs
10. ❌ Using dateTime Type for Dates
Problem: Using dateTime type is not supported and may cause errors.
Solution:
Always use
type="date"for date fieldsIf time is needed, store it in a separate
stringfieldNote: The system may accept
dateTimein bind statements for metadata fields (like start/end timestamps), but usedatefor user-entered dates
11. ❌ Missing Incomplete Data Options
Problem: Not providing options for incomplete data collection makes it difficult to track why surveys are incomplete.
Solution:
Include an "Incomplete General Screener" or similar field at the beginning
Provide standard options for incomplete scenarios
Make other fields conditionally required based on completion status
12. ❌ Hardcoding Option Values
Problem: Using option labels as values makes data analysis difficult and error-prone.
Solution:
Always use lowercase, underscore-separated values
Keep labels human-readable but values consistent
Example: label="Female", value="female" (not "Female" as the value)
13. ❌ Not Using Groups for Related Fields
Problem: Flat field structures make surveys harder to navigate and understand.
Solution:
Group related fields using
<group>elementsCreate logical hierarchies (e.g.,
group_callback_contact/telephone_001)Use descriptive group names
14. ❌ Missing Meta Instance ID
Problem: Not including a meta/instanceID field makes it difficult to track survey instances.
Solution:
Always include a meta section with instanceID
Use
jr:preload="uid"to auto-generate unique IDsKeep it readonly
Example:
Field Naming Conventions
Recommended Naming Patterns
Use snake_case:
caller_age,first_time_caller,hear_about_211Be descriptive:
caller_frequencynotfreqUse prefixes for groups:
group_AARP_careprovider,group_kick_itUse suffixes for related fields:
telephone_001,email_001,givenName,familyNameKeep names concise: Avoid extremely long names, but prioritize clarity
Examples from Production Surveys
✅ Good Examples:
Incomplete_General_Screenercaller_frequencycaller_ageBTS_Dategroup_kick_itgroup_callback_contact
❌ Avoid:
Mixed case without separation:
callerAge,CallerFrequencySpaces:
caller age,first time callerSpecial characters:
caller-age,caller.ageToo generic:
field1,data,value
Survey Structure Guidelines
1. Logical Flow
Start with screener/incomplete data options
Group related questions together
Use conditional logic to show/hide sections
End with optional metadata fields
2. Required vs Optional Fields
Make fields required only when absolutely necessary
Use conditional required logic when appropriate
Consider data collection scenarios (incomplete calls, declined answers)
3. Group Organization
Use groups to organize related fields
Create nested groups for sub-sections
Name groups descriptively
4. Field Ordering
Order fields logically (general to specific, required to optional)
Keep conditional fields near their parent fields
Group similar field types together when possible
Testing and Validation
Before Uploading
Validate XML Structure
Check for well-formed XML
Verify all namespaces are present
Ensure all fields have corresponding bind statements
Test in Kobo Toolbox (Required)
Build/test surveys in Kobo Toolbox first
Verify all conditional logic works correctly
Test with various data inputs
Review Field Names
Ensure consistent naming convention
Check for typos in nodeset paths
Verify bind paths match input ref paths
Test Conditional Logic
Test all relevant/required conditions
Verify calculated fields work correctly
Check pre-loaded values populate
Check File Size
Ensure file is under 10 MB
Optimize if necessary
After Uploading
Test Survey Flow
Complete a test survey response
Verify all fields appear/disappear correctly
Check validation messages
Verify Data Storage
Submit a test response
Check that data is stored correctly
Verify multi-select values are stored properly
Test Querying
Test advanced search with survey fields
Verify date queries work correctly
Check select field filtering
Troubleshooting
Common Errors
1. "Only xml file is allowed"
Cause: File is not recognized as XML
Solution: Ensure file has
.xmlextension and correct MIME type (text/xml)
2. "Survey file must be provided"
Cause: No file was uploaded
Solution: Ensure file input has a valid file selected
3. "File size exceeds limit"
Cause: File is larger than 10 MB
Solution: Reduce file size by removing unused fields, optimizing text content, or splitting into multiple surveys
4. Survey fields not appearing in search
Cause: Field type may not be supported, or metadata not parsed correctly
Solution: Verify field uses supported type (string, int, date, select1, select)
5. Multi-select values not displaying correctly
Cause: Expecting array when values are space-separated strings
Solution: Split space-separated string when processing:
value.split(' ')
6. Date fields not queryable
Cause: Using dateTime type instead of date
Solution: Change to
type="date"in bind statement
Debugging Tips
Download Existing Survey
Use the "Download Survey" button to see the current survey XML
Compare with your new survey to identify differences
Check Survey Metadata
View survey metadata in the project settings
Verify all fields are listed with correct types
Test Incrementally
Start with a simple survey and add complexity gradually
Test after each major change
Review Logs
Check server logs for XML parsing errors
Look for specific field or namespace errors
Additional Resources
Kobo Toolbox: https://kobotoolbox.org (Recommended tool for building and testing surveys)
ODK XForms Specification: https://getodk.github.io/xforms-spec/
XForms Documentation: https://www.w3.org/TR/xforms/
Summary Checklist
When building a survey, ensure:
Last updated
Was this helpful?