"header":"Which of these best describes the tenant's gender identity?",
"header":"Which of these best describes the tenant's gender identity?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -56,6 +59,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"tenant_ethnic_group":{
"tenant_ethnic_group":{
"check_answer_label":"Ethnicity",
"header":"What is the tenant's ethnic group?",
"header":"What is the tenant's ethnic group?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -88,6 +92,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"tenant_nationality":{
"tenant_nationality":{
"check_answer_label":"Nationality",
"header":"What is the tenant's nationality?",
"header":"What is the tenant's nationality?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -117,6 +122,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"tenant_economic_status":{
"tenant_economic_status":{
"check_answer_label":"Work",
"header":"Which of these best describes the tenant's working situation?",
"header":"Which of these best describes the tenant's working situation?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -141,6 +147,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"household_number_of_other_members":{
"household_number_of_other_members":{
"check_answer_label":"Number of Other Household Members",
"header":"How many other people are there in the household?",
"header":"How many other people are there in the household?",
"hint_text":"The maximum number of others is 7",
"hint_text":"The maximum number of others is 7",
"type":"numeric",
"type":"numeric",
@ -285,6 +292,10 @@
"1":"Yes - a reserve",
"1":"Yes - a reserve",
"2":"No",
"2":"No",
"3":"Prefer not to say"
"3":"Prefer not to say"
},
"conditional_for":{
"armed_forces_active":["Yes - a regular","Yes - a reserve"],
"armed_forces_injured":["Yes - a regular","Yes - a reserve"]
}
}
},
},
"armed_forces_active":{
"armed_forces_active":{
@ -326,7 +337,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"medical_conditions":{
"medical_conditions":{
"header":"Does anyone in the household have a physical condition, mental health condition, or other illness that they expect to last for 12 months or more?",
"header":"Does anyone in the household have any of the following that they expect to last for 12 months or more:<ul><li>Physical Condition</li><li>Mental Health Condition</li><li>Other Illness</li></ul>",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
"answer_options":{
"answer_options":{
@ -416,6 +427,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"tenancy_code":{
"tenancy_code":{
"check_answer_label":"What is the tenancy code?",
"header":"What is the tenancy code?",
"header":"What is the tenancy code?",
"hint_text":"",
"hint_text":"",
"type":"text"
"type":"text"
@ -427,6 +439,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"tenancy_start_date":{
"tenancy_start_date":{
"check_answer_label":"When is the tenancy start date?",
"header":"What is the tenancy start date?",
"header":"What is the tenancy start date?",
"hint_text":"For example, 27 3 2007",
"hint_text":"For example, 27 3 2007",
"type":"date"
"type":"date"
@ -438,6 +451,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"starter_tenancy":{
"starter_tenancy":{
"check_answer_label":"Is this a starter or introductory tenancy?",
"header":"Is this a starter tenancy?",
"header":"Is this a starter tenancy?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -453,6 +467,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"fixed_term_tenancy":{
"fixed_term_tenancy":{
"check_answer_label":"If the main tenancy is a fixed term tenancy, please provide the length of the fixed term (to the nearest year) excluding any starter/introductory period",
"header":"If fixed-term, what is the length of the fixed-term tenancy after any starter period?",
"header":"If fixed-term, what is the length of the fixed-term tenancy after any starter period?",
"hint_text":"To the nearest year",
"hint_text":"To the nearest year",
"type":"numeric",
"type":"numeric",
@ -467,6 +482,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"tenancy_type":{
"tenancy_type":{
"check_answer_label":"Type of main tenancy (after any starter/introductory period)",
"header":"What is the type of tenancy after the starter period has ended?",
"header":"What is the type of tenancy after the starter period has ended?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -486,6 +502,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"letting_type":{
"letting_type":{
"check_answer_label":"Type of letting",
"header":"Which type of letting is this?",
"header":"Which type of letting is this?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -505,6 +522,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"letting_provider":{
"letting_provider":{
"check_answer_label":"Provider",
"header":"Who is the letting provider?",
"header":"Who is the letting provider?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -525,6 +543,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_location":{
"property_location":{
"check_answer_label":"Property Location",
"header":"Property location",
"header":"Property location",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -851,6 +870,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_postcode":{
"property_postcode":{
"check_answer_label":"What was the previous postcode?",
"header":"What is the property's postcode?",
"header":"What is the property's postcode?",
"hint_text":"",
"hint_text":"",
"type":"text"
"type":"text"
@ -862,6 +882,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_relet":{
"property_relet":{
"check_answer_label":"Which type was the property most recently let as?",
"header":"Is this property a relet?",
"header":"Is this property a relet?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -877,6 +898,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_vacancy_reason":{
"property_vacancy_reason":{
"check_answer_label":"What is the reason for the property vacancy?",
"header":"What is the reason for the property vacancy?",
"header":"What is the reason for the property vacancy?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -904,6 +926,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_reference":{
"property_reference":{
"check_answer_label":"What’s the property reference?",
"header":"What's the property reference?",
"header":"What's the property reference?",
"hint_text":"",
"hint_text":"",
"type":"text"
"type":"text"
@ -915,6 +938,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_unit_type":{
"property_unit_type":{
"check_answer_label":"Which type of unit is the property?",
"header":"Which type of unit is the property?",
"header":"Which type of unit is the property?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -936,6 +960,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_number_of_bedrooms":{
"property_number_of_bedrooms":{
"check_answer_label":"How many bedrooms are there in the property?",
"header":"How many bedrooms are there in the property?",
"header":"How many bedrooms are there in the property?",
"hint_text":"If shared accommodation, enter number of bedrooms occupied by this household; a bed-sit has 1 bedroom",
"hint_text":"If shared accommodation, enter number of bedrooms occupied by this household; a bed-sit has 1 bedroom",
"type":"numeric",
"type":"numeric",
@ -950,6 +975,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_major_repairs":{
"property_major_repairs":{
"check_answer_label":"Were major repairs carried out during the void period?",
"header":"Were any major repairs completed during the void period?",
"header":"Were any major repairs completed during the void period?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -965,6 +991,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_major_repairs":{
"property_major_repairs":{
"check_answer_label":"What was the major repairs completion date?",
"header":"What was the major repairs completion date?",
"header":"What was the major repairs completion date?",
"hint_text":"For example, 27 3 2007",
"hint_text":"For example, 27 3 2007",
"type":"date"
"type":"date"
@ -976,6 +1003,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_number_of_times_relet":{
"property_number_of_times_relet":{
"check_answer_label":"How many times has this unit been previously offered since becoming available for relet since the last tenancy ended or as a first let?",
"header":"How many times has this unit been previously offered since becoming available for relet since the last tenancy ended or as a first let? ",
"header":"How many times has this unit been previously offered since becoming available for relet since the last tenancy ended or as a first let? ",
"hint_text":"For an Affordable Rent or Intermediate Rent Letting, only include number of offers as that type. For a property let at the first attempt enter '0' ",
"hint_text":"For an Affordable Rent or Intermediate Rent Letting, only include number of offers as that type. For a property let at the first attempt enter '0' ",
"type":"numeric",
"type":"numeric",
@ -990,6 +1018,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"property_wheelchair_accessible":{
"property_wheelchair_accessible":{
"check_answer_label":"Is property built or adapted to wheelchair user standards?",
"header":"Is property built or adapted to wheelchair user standards?",
"header":"Is property built or adapted to wheelchair user standards?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -1015,6 +1044,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"net_income":{
"net_income":{
"check_answer_label":"Income",
"header":"What is the tenant’s /and partner’s combined income after tax?",
"header":"What is the tenant’s /and partner’s combined income after tax?",
"hint_text":"",
"hint_text":"",
"type":"numeric",
"type":"numeric",
@ -1022,6 +1052,7 @@
"step":"1"
"step":"1"
},
},
"net_income_frequency":{
"net_income_frequency":{
"check_answer_label":"Income Frequency",
"header":"How often do they receive this income?",
"header":"How often do they receive this income?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -1038,6 +1069,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"net_income_uc_proportion":{
"net_income_uc_proportion":{
"check_answer_label":"Benefits as a proportion of income",
"header":"How much of the tenant’s income is from Universal Credit, state pensions or benefits?",
"header":"How much of the tenant’s income is from Universal Credit, state pensions or benefits?",
"header":"Is the tenant likely to be in receipt of any of these housing-related benefits?",
"header":"Is the tenant likely to be in receipt of any of these housing-related benefits?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -1080,6 +1113,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"rent_frequency":{
"rent_frequency":{
"check_answer_label":"Rent Period",
"header":"Which period are rent and other charges due?",
"header":"Which period are rent and other charges due?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -1097,6 +1131,7 @@
}
}
},
},
"basic_rent":{
"basic_rent":{
"check_answer_label":"Basic Rent",
"header":"What is the basic rent?",
"header":"What is the basic rent?",
"hint_text":"Eligible for housing benefit or Universal Credit",
"hint_text":"Eligible for housing benefit or Universal Credit",
"type":"numeric",
"type":"numeric",
@ -1104,6 +1139,7 @@
"step":1
"step":1
},
},
"service_charge":{
"service_charge":{
"check_answer_label":"Service Charge",
"header":"What is the service charge?",
"header":"What is the service charge?",
"hint_text":"Eligible for housing benefit or Universal Credit",
"hint_text":"Eligible for housing benefit or Universal Credit",
"type":"numeric",
"type":"numeric",
@ -1111,6 +1147,7 @@
"step":1
"step":1
},
},
"personal_service_charge":{
"personal_service_charge":{
"check_answer_label":"Personal Service Charge",
"header":"What is the personal service charge?",
"header":"What is the personal service charge?",
"hint_text":"Not eligible for housing benefit or Universal Credit. For example, hot water excluding water rates.",
"hint_text":"Not eligible for housing benefit or Universal Credit. For example, hot water excluding water rates.",
"type":"numeric",
"type":"numeric",
@ -1118,6 +1155,7 @@
"step":1
"step":1
},
},
"support_charge":{
"support_charge":{
"check_answer_label":"Support Charge",
"header":"What is the support charge?",
"header":"What is the support charge?",
"hint_text":"This is to fund housing-related support services included in the tenancy agreement",
"hint_text":"This is to fund housing-related support services included in the tenancy agreement",
"type":"numeric",
"type":"numeric",
@ -1125,6 +1163,7 @@
"step":1
"step":1
},
},
"total_charge":{
"total_charge":{
"check_answer_label":"Total Charge",
"header":"Total charge?",
"header":"Total charge?",
"hint_text":"This is the total of rent and all charges",
"hint_text":"This is the total of rent and all charges",
"type":"numeric",
"type":"numeric",
@ -1132,6 +1171,7 @@
"step":1
"step":1
},
},
"outstanding_amount":{
"outstanding_amount":{
"check_answer_label":"After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?",
"header":"After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?",
"header":"After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -1157,6 +1197,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"time_lived_in_la":{
"time_lived_in_la":{
"check_answer_label":"How long has the household continuously lived in the local authority area where the new letting is located?",
"header":"How long has the household continuously lived in the local authority area where the new letting is located?",
"header":"How long has the household continuously lived in the local authority area where the new letting is located?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -1178,6 +1219,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"time_on_la_waiting_list":{
"time_on_la_waiting_list":{
"check_answer_label":"How long has the household been on the local authority waiting list where the new letting is located?",
"header":"How long has the household been on the local authority waiting list where the new letting is located?",
"header":"How long has the household been on the local authority waiting list where the new letting is located?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -1199,6 +1241,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"previous_la":{
"previous_la":{
"check_answer_label":"The LA in which household lived immediately before this letting\t",
"header":"Which local authority area did the household live in immediately before this letting?",
"header":"Which local authority area did the household live in immediately before this letting?",
"hint_text":"Includes temporary accommodation",
"hint_text":"Includes temporary accommodation",
"type":"radio",
"type":"radio",
@ -1525,6 +1568,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"previous_postcode":{
"previous_postcode":{
"check_answer_label":"Postcode of previous accomodation if the household has moved from settled accommodation",
"header":"Postcode for the previous accommodation",
"header":"Postcode for the previous accommodation",
"hint_text":"If the household has moved from settled accommodation immediately prior to being re-housed",
"hint_text":"If the household has moved from settled accommodation immediately prior to being re-housed",
"type":"text"
"type":"text"
@ -1536,6 +1580,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"reasonable_preference":{
"reasonable_preference":{
"check_answer_label":"Was the household given Reasonable Preference (i.e. priority) for housing by the Local Authority?",
"header":"Was the household given reasonable preference by the local authority?",
"header":"Was the household given reasonable preference by the local authority?",
"hint_text":"",
"hint_text":"",
"type":"radio",
"type":"radio",
@ -1545,6 +1590,7 @@
}
}
},
},
"reasonable_preference_reason":{
"reasonable_preference_reason":{
"check_answer_label":"Reason for reasonable preference",
"header":"Why were they given reasonable preference?",
"header":"Why were they given reasonable preference?",
"hint_text":"Select all that apply",
"hint_text":"Select all that apply",
"type":"checkbox",
"type":"checkbox",
@ -1564,6 +1610,7 @@
"description":"",
"description":"",
"questions":{
"questions":{
"cbl_letting":{
"cbl_letting":{
"check_answer_label":"Choice-based letting?",
"header":"Was the letting made under choice-based lettings (CBL)? ",
"header":"Was the letting made under choice-based lettings (CBL)? ",
We will initially try to model the form as a JSON structure that should describe all the information needed to display the form to the user. That means it will need to describe the sections, subsections, pages, questions, answer options etc.
The idea is to decouple the code that creates the required routes, controller methods, views etc to display the form from the actual wording of questions or order of pages such that it becomes possible to make changes to the form with little or no code changes.
This should also mean that in the future it could be possible to create a UI that can construct the JSON config, which would open up the ability to make form changes to a wider audience. Doing this fully would require generating and running the necessary migrations for data storage, generating the required ActiveRecord methods to validate the data server side, and generating/updating API endpoints and documentation. All of this is likely to be beyond the scope of initial MVP but could be looked at in the future.
Since initially the JSON config will not create database migrations or ActiveRecord model validations, it will instead assume that these have been correctly created for the config provided. The reasoning for this is the following assumptions:
- The form will be tweaked regularly (amending questions wording, changing the order of questions or the page a question is displayed on)
- The actual data collected will change very infrequently. Time series continuity is very important to ADD (Analysis and Data Directorate) so the actual data collected should stay largely consistent i.e. in general we can change the question wording in ways that makes the intent clearer or easier to understand, but not in ways that would make the data provider give a different answer.
A form parser class will parse this config into ruby objects/methods that can be used as an API by the rest of the application, such that we could change the underlying config if needed (for example swap JSON for YAML or for DataBase objects) without needing to change the rest of the application.
#### JSON Structure
First pass of a form definition
```
{
form_type: [lettings/sales]
start_year: yyyy
end_year: yyyy
sections: {
snake case section name string: {
label: string,
subsections: {
snake case subsection name string: {
label: string,
pages: {
snake case page name string: {
header: string,
description: string,
questions: {
snake case question name string: {
header: string,
hint_text: string,
type: [text / numeric / radio / checkbox / date ],
min: integer, (numeric only),
max: integer, (numeric only),
step: integer (numeric only),
answer_options: { (checkbox and radio only)
"0": string,
"1": string
}
}
}
}
}
}
}
}
}
}
```
Assumptions made by the format:
- All forms have at least 1 section
- All sections have at least 1 subsection
- All subsections have at least 1 page
- All pages have at least 1 question
- The ActiveRecord case log model has a field for each question name (must match)
- Text not required by a page/question such as a header or hint text should be passed as an empty string
We have opted to save values to the database directly instead of saving keys/numbers that need to be converted with enums in models using active record.
### Saving values to the database
There are a few reasons we have opted to save the values directly, they are as follows
- The data will be easier to consume and analyse for anyone associated with the project who needs to do so but does not necessarily have the technical skills to access it through Rails i.e. A person could get the data directly from the database and it would require no additional work to be usable for reporting purposes
- Currently there is no need to abstract the data as the data should be safe from being accessed by anyone external to the project
- It doesn't require additional dev work to map keys/numbers to values, we can just pull the values out directly and use them in the code, for example on the check answers page
### Drawbacks
- Changing the wording/casing of the answers could result in discrepancies in the database
- There is a small risk that if the database is accessed by someone unauthorised they would have access to personally identifiable information if we were to collect Any. We will be mitigating this risk by encrypting the production database
This decision is not too difficult to change and can be revisited in the future if there is sufficient reason to switch to storing keys/numbers and using enums and active record to convert those to the appropriate values.