|
|
@ -8,113 +8,86 @@ class Scheme < ApplicationRecord |
|
|
|
scope :search_by_postcode, ->(postcode) { joins(:locations).where("locations.postcode ILIKE ?", "%#{postcode.delete(' ')}%") } |
|
|
|
scope :search_by_postcode, ->(postcode) { joins(:locations).where("locations.postcode ILIKE ?", "%#{postcode.delete(' ')}%") } |
|
|
|
scope :search_by, ->(param) { search_by_postcode(param).or(search_by_service_name(param)).or(search_by_code(param)).distinct } |
|
|
|
scope :search_by, ->(param) { search_by_postcode(param).or(search_by_service_name(param)).or(search_by_code(param)).distinct } |
|
|
|
|
|
|
|
|
|
|
|
SCHEME_TYPE = { |
|
|
|
enum sensitive: [:no, :yes] |
|
|
|
0 => "Missing", |
|
|
|
|
|
|
|
4 => "Foyer", |
|
|
|
REGISTERED_UNDER_CARE_ACT = { |
|
|
|
5 => "Direct Access Hostel", |
|
|
|
"No": 0, |
|
|
|
6 => "Other Supported Housing", |
|
|
|
"Yes – registered care home providing nursing care": 1, |
|
|
|
7 => "Housing for older people", |
|
|
|
"Yes – registered care home providing personal care": 2, |
|
|
|
|
|
|
|
"Yes – part registered as a care home": 3, |
|
|
|
}.freeze |
|
|
|
}.freeze |
|
|
|
|
|
|
|
|
|
|
|
PRIMARY_CLIENT_GROUP = { |
|
|
|
enum registered_under_care_act: REGISTERED_UNDER_CARE_ACT |
|
|
|
"O" => "Homeless families with support needs", |
|
|
|
|
|
|
|
"H" => "Offenders & people at risk of offending", |
|
|
|
SCHEME_TYPE = { |
|
|
|
"M" => "Older people with support needs", |
|
|
|
"Missing": 0, |
|
|
|
"L" => "People at risk of domestic violence", |
|
|
|
"Foyer": 4, |
|
|
|
"A" => "People with a physical or sensory disability", |
|
|
|
"Direct Access Hostel": 5, |
|
|
|
"G" => "People with alcohol problems", |
|
|
|
"Other Supported Housing": 6, |
|
|
|
"F" => "People with drug problems", |
|
|
|
"Housing for older people": 7, |
|
|
|
"B" => "People with HIV or AIDS", |
|
|
|
|
|
|
|
"D" => "People with learning disabilities", |
|
|
|
|
|
|
|
"E" => "People with mental health problems", |
|
|
|
|
|
|
|
"I" => "Refugees (permanent)", |
|
|
|
|
|
|
|
"S" => "Rough sleepers", |
|
|
|
|
|
|
|
"N" => "Single homeless people with support needs", |
|
|
|
|
|
|
|
"R" => "Teenage parents", |
|
|
|
|
|
|
|
"Q" => "Young people at risk", |
|
|
|
|
|
|
|
"P" => "Young people leaving care", |
|
|
|
|
|
|
|
"X" => "Missing", |
|
|
|
|
|
|
|
}.freeze |
|
|
|
}.freeze |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum scheme_type: SCHEME_TYPE, _suffix: true |
|
|
|
|
|
|
|
|
|
|
|
SUPPORT_TYPE = { |
|
|
|
SUPPORT_TYPE = { |
|
|
|
0 => "Missing", |
|
|
|
"Missing": 0, |
|
|
|
1 => "Resettlement Support", |
|
|
|
"Resettlement Support": 1, |
|
|
|
2 => "Low levels of support", |
|
|
|
"Low levels of support": 2, |
|
|
|
3 => "Medium levels of support", |
|
|
|
"Medium levels of support": 3, |
|
|
|
4 => "High levels of care and support", |
|
|
|
"High levels of care and support": 4, |
|
|
|
5 => "Nursing care services to a care home", |
|
|
|
"Nursing care services to a care home": 5, |
|
|
|
6 => "Floating Support", |
|
|
|
"Floating Support": 6, |
|
|
|
}.freeze |
|
|
|
}.freeze |
|
|
|
|
|
|
|
|
|
|
|
INTENDED_STAY = { |
|
|
|
enum support_type: SUPPORT_TYPE, _suffix: true |
|
|
|
"M" => "Medium stay", |
|
|
|
|
|
|
|
"P" => "Permanent", |
|
|
|
|
|
|
|
"S" => "Short Stay", |
|
|
|
|
|
|
|
"V" => "Very short stay", |
|
|
|
|
|
|
|
"X" => "Missing", |
|
|
|
|
|
|
|
}.freeze |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
REGISTERED_UNDER_CARE_ACT = { |
|
|
|
PRIMARY_CLIENT_GROUP = { |
|
|
|
0 => "No", |
|
|
|
"Homeless families with support needs": "O", |
|
|
|
1 => "Yes – registered care home providing nursing care", |
|
|
|
"Offenders & people at risk of offending": "H", |
|
|
|
1 => "Yes – registered care home providing personal care", |
|
|
|
"Older people with support needs": "M", |
|
|
|
1 => "Yes – part registered as a care home", |
|
|
|
"People at risk of domestic violence": "L", |
|
|
|
|
|
|
|
"People with a physical or sensory disability": "A", |
|
|
|
|
|
|
|
"People with alcohol problems": "G", |
|
|
|
|
|
|
|
"People with drug problems": "F", |
|
|
|
|
|
|
|
"People with HIV or AIDS": "B", |
|
|
|
|
|
|
|
"People with learning disabilities": "D", |
|
|
|
|
|
|
|
"People with mental health problems": "E", |
|
|
|
|
|
|
|
"Refugees (permanent)": "I", |
|
|
|
|
|
|
|
"Rough sleepers": "S", |
|
|
|
|
|
|
|
"Single homeless people with support needs": "N", |
|
|
|
|
|
|
|
"Teenage parents": "R", |
|
|
|
|
|
|
|
"Young people at risk": "Q", |
|
|
|
|
|
|
|
"Young people leaving care": "P", |
|
|
|
|
|
|
|
"Missing": "X", |
|
|
|
}.freeze |
|
|
|
}.freeze |
|
|
|
|
|
|
|
|
|
|
|
SENSITIVE = { |
|
|
|
enum primary_client_group: PRIMARY_CLIENT_GROUP, _suffix: true |
|
|
|
0 => "No", |
|
|
|
enum secondary_client_group: PRIMARY_CLIENT_GROUP, _suffix: true |
|
|
|
1 => "Yes", |
|
|
|
|
|
|
|
|
|
|
|
INTENDED_STAY = { |
|
|
|
|
|
|
|
"Medium stay": "M", |
|
|
|
|
|
|
|
"Permanent": "P", |
|
|
|
|
|
|
|
"Short Stay": "S", |
|
|
|
|
|
|
|
"Very short stay": "V", |
|
|
|
|
|
|
|
"Missing": "X", |
|
|
|
}.freeze |
|
|
|
}.freeze |
|
|
|
|
|
|
|
|
|
|
|
def scheme_types |
|
|
|
enum intended_stay: INTENDED_STAY, _suffix: true |
|
|
|
SCHEME_TYPE.values |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def care_act_types |
|
|
|
|
|
|
|
REGISTERED_UNDER_CARE_ACT.values |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def display_attributes |
|
|
|
def display_attributes |
|
|
|
[ |
|
|
|
[ |
|
|
|
{ name: "Service code", value: code }, |
|
|
|
{ name: "Service code", value: code }, |
|
|
|
{ name: "Name", value: service_name }, |
|
|
|
{ name: "Name", value: service_name }, |
|
|
|
{ name: "Confidential information", value: sensitive_display }, |
|
|
|
{ name: "Confidential information", value: sensitive }, |
|
|
|
{ name: "Managed by", value: organisation.name }, |
|
|
|
{ name: "Managed by", value: organisation.name }, |
|
|
|
{ name: "Type of scheme", value: scheme_type_display }, |
|
|
|
{ name: "Type of scheme", value: scheme_type }, |
|
|
|
{ name: "Registered under Care Standards Act 2000", value: registered_under_care_act_display }, |
|
|
|
{ name: "Registered under Care Standards Act 2000", value: registered_under_care_act }, |
|
|
|
{ name: "Total number of units", value: total_units }, |
|
|
|
{ name: "Total number of units", value: total_units }, |
|
|
|
{ name: "Primary client group", value: primary_client_group_display }, |
|
|
|
{ name: "Primary client group", value: primary_client_group }, |
|
|
|
{ name: "Secondary client group", value: secondary_client_group_display }, |
|
|
|
{ name: "Secondary client group", value: secondary_client_group }, |
|
|
|
{ name: "Level of support given", value: support_type_display }, |
|
|
|
{ name: "Level of support given", value: support_type }, |
|
|
|
{ name: "Intended length of stay", value: intended_stay_display }, |
|
|
|
{ name: "Intended length of stay", value: intended_stay }, |
|
|
|
] |
|
|
|
] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def scheme_type_display |
|
|
|
|
|
|
|
SCHEME_TYPE[scheme_type] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def sensitive_display |
|
|
|
|
|
|
|
SENSITIVE[sensitive] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def registered_under_care_act_display |
|
|
|
|
|
|
|
REGISTERED_UNDER_CARE_ACT[registered_under_care_act] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def primary_client_group_display |
|
|
|
|
|
|
|
PRIMARY_CLIENT_GROUP[primary_client_group] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def secondary_client_group_display |
|
|
|
|
|
|
|
PRIMARY_CLIENT_GROUP[secondary_client_group] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def support_type_display |
|
|
|
|
|
|
|
SUPPORT_TYPE[support_type] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def intended_stay_display |
|
|
|
|
|
|
|
INTENDED_STAY[intended_stay] |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|