Skip to content

Commit

Permalink
Merge pull request #684 from neontribe/1.16/2096-increase-ethnicity-d…
Browse files Browse the repository at this point in the history
…ropdown-granularity-of-options

1.16/2096 increase ethnicity dropdown granularity of options
  • Loading branch information
lauragurney authored Jul 7, 2023
2 parents 44bf906 + 24dcce7 commit 1bdd181
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 75 deletions.
24 changes: 15 additions & 9 deletions app/Http/Controllers/Store/CentreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private function getCentreFamilyRegistrationsSummary(array $centre_ids, $dateFor

// Get full carer details as we need ethnicity and language
$pri_carer_full = Carer::where('name', $reg->family->pri_carer)->first(['name', 'ethnicity', 'language']);
$pri_carer_ethnicity = config('arc.ethnicity_long.' . $pri_carer_full->ethnicity);
$pri_carer_ethnicity = config('arc.ethnicity_desc.' . $pri_carer_full->ethnicity);

if ($pri_carer_full->language === null) {
// then they haven't answered
Expand Down Expand Up @@ -321,21 +321,21 @@ private function getCentreFamilyRegistrationsSummary(array $centre_ids, $dateFor
$bActiveDate = ($b['Last Collection'])
? Carbon::createFromFormat($dateFormats['lastCollection'], $b['Last Collection'])
: Carbon::parse('1970-01-01');
if (!isset($a['Centre'])) {
$a['Centre'] = '';
if (!isset($a['Distribution Centre'])) {
$a['Distribution Centre'] = '';
}
$hashA = strtolower(
$a['Area'] . '#' .
$a['Centre'] . '#' .
$a['Distribution Centre'] . '#' .
$aActiveDate->toDateString() . '#' .
$a['Primary Carer']
);
if (!isset($b['Centre'])) {
$b['Centre'] = '';
if (!isset($b['Distribution Centre'])) {
$b['Distribution Centre'] = '';
}
$hashB = strtolower(
$b['Area'] . '#' .
$b['Centre'] . '#' .
$b['Distribution Centre'] . '#' .
$bActiveDate->toDateString() . '#' .
$b['Primary Carer']
);
Expand Down Expand Up @@ -529,15 +529,21 @@ private function getCentreSPRegistrationsSummary(array $centre_ids, $dateFormats
? Carbon::createFromFormat($dateFormats['lastCollection'], $b['Last Collection'])
: Carbon::parse('1970-01-01');

if (!isset($a['Distribution Centre'])) {
$a['Distribution Centre'] = '';
}
$hashA = strtolower(
$a['Area'] . '#' .
$a['Centre'] . '#' .
$a['Distribution Centre'] . '#' .
$aActiveDate->toDateString() . '#' .
$a['Main Participant']
);
if (!isset($b['Distribution Centre'])) {
$b['Distribution Centre'] = '';
}
$hashB = strtolower(
$b['Area'] . '#' .
$b['Centre'] . '#' .
$b['Distribution Centre'] . '#' .
$bActiveDate->toDateString() . '#' .
$b['Main Participant']
);
Expand Down
44 changes: 27 additions & 17 deletions config/arc.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,34 @@

/*
|--------------------------------------------------------------------------
| Demographic fields for primary carer - ethnic background and main language
| Demographic fields for primary carer - ethnic background
|
|--------------------------------------------------------------------------
*/
'ethnicity' => [
'white',
'mixed',
'asian',
'black',
'other',
'not',
],
'ethnicity_long' => [
'white' => 'White: Scottish/ British / Irish / Traveller / Any other White background',
'mixed' => 'Mixed/Multiple ethnic groups: White and Black Caribbean / White and Black African / White and Asian / Latin American / Any other Mixed/Multiple ethnic background',
'asian' => 'Asian/Asian British: Indian / Pakistani / Bangladeshi / Chinese / Afghani / Any other Asian background',
'black' => 'Black/Black British: African / Caribbean / Moroccan / Somalian / Any other Black/British background',
'other' => 'Other ethnic group: Arabic / Turkish / Iranian / Syrian / Any other ethnic group',
'not' => 'Not answered',
],

'ethnicity_desc' => [
'MLAM' => 'Mixed - Latin American',
'MWAS' => 'Mixed - White and Asian',
'MWBA' => 'Mixed - White and Black African',
'MWBC' => 'Mixed - White and Black Caribbean',
'MOTH' => 'Mixed - Any other Mixed/Multiple background',
'AAFG' => 'Asian/Asian British - Afghani',
'ABAN' => 'Asian/Asian British - Bangladeshi',
'ACHN' => 'Asian/Asian British - Chinese',
'AIND' => 'Asian/Asian British - Indian',
'APKN' => 'Asian/Asian British - Pakistani',
'AOTH' => 'Asian/Asian British - Any other Asian background',
'BAFR' => 'Black/Black British - African',
'BCRB' => 'Black/Black British - Caribbean',
'BMOR' => 'Black/Black British - Moroccan',
'BSOM' => 'Black/Black British - Somalian',
'BOTH' => 'Black/Black British - Any other Black/British background',
'OARA' => 'Other ethnic group - Arab',
'OSYR' => 'Other ethnic group - Syrian',
'OTUR' => 'Other ethnic group - Turkish',
'OOTH' => 'Other ethnic group - Any other ethnic group',
'WBRI' => 'White - British',
'WOTH' => 'White - Any other White background',
'NOBT' => 'Not answered',
],
];
16 changes: 0 additions & 16 deletions resources/lang/en/arc.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,4 @@
'yes' => 'Yes',
'no' => 'No',
],
'ethnicity_short' => [
'white' => 'White',
'mixed' => 'Mixed',
'asian' => 'Asian',
'black' => 'Black',
'other' => 'Other ethnic group',
'not' => 'Not answered',
],
'ethnicity_long' => [
'white' => 'White: Scottish/ British / Irish / Traveller / Any other White background',
'mixed' => 'Mixed/Multiple ethnic groups: White and Black Caribbean / White and Black African / White and Asian / Latin American / Any other Mixed/Multiple ethnic background',
'asian' => 'Asian/Asian British: Indian / Pakistani / Bangladeshi / Chinese / Afghani / Any other Asian background',
'black' => 'Black/Black British: African / Caribbean / Moroccan / Somalian / Any other Black/British background',
'other' => 'Other ethnic group: Arabic / Turkish / Iranian / Syrian / Any other ethnic group',
'not' => 'Not answered',
],
];
23 changes: 7 additions & 16 deletions resources/views/store/partials/voucher_collectors.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,16 @@ class="@if($errors->has('pri_carer')) invalid @endif"
<label for="pri_carer_ethnicity">Main carer's ethnic background (optional)</label><br>
<select name="pri_carer_ethnicity[{{ $pri_carer->id }}]" id="pri_carer_ethnicity">
<option value=0>Please select</option>
@foreach (config('arc.ethnicity') as $ethnicity)
<option value="{{ $ethnicity }}"
@foreach (config('arc.ethnicity_desc') as $index => $ethnicity)
<option value="{{ $index }}"
@selected(
($pri_carer->ethnicity === $ethnicity)
($pri_carer->ethnicity === $index)
)
>@lang('arc.ethnicity_short.' . $ethnicity)
>{{ $ethnicity }}
</option>
@endforeach
</select>
<span class="clickable-span">(longer descriptions)</span>
<li class="collapsed" id="more-ethnicity-info">
<ul id="ethnicities">
<br></br>
@foreach(config('arc.ethnicity_long') as $ethnicity)
<li>{{$ethnicity}}</li>
@endforeach
</ul>
</li>
<br></br>
<br></br>
<label for="pri_carer_language">Carer's main language (optional)</label><br>
<input id="pri_carer_language"
name="pri_carer_language[{{ $pri_carer->id }}]"
Expand Down Expand Up @@ -67,8 +58,8 @@ class="@if($errors->has('pri_carer')) invalid @endif"
<label for="pri_carer_ethnicity">Main carer's ethnic background (optional)</label><br>
<select name="pri_carer_ethnicity" id="pri_carer_ethnicity">
<option value=0>Please select</option>
@foreach (config('arc.ethnicity') as $ethnicity)
<option value="{{ $ethnicity }}">@lang('arc.ethnicity_short.' . $ethnicity)
@foreach (config('arc.ethnicity_desc') as $index => $ethnicity)
<option value="{{ $index }}">{{ $ethnicity }}
</option>
@endforeach
</select><br></br>
Expand Down
12 changes: 6 additions & 6 deletions resources/views/store/partials/voucher_collectorsSP.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class="@if($errors->has('pri_carer'))invalid @endif"
<label for="pri_carer_ethnicity">Main participant's ethnic background (optional)</label><br>
<select name="pri_carer_ethnicity[{{ $pri_carer->id }}]" id="pri_carer_ethnicity">
<option value=0>Please select</option>
@foreach (config('arc.ethnicity') as $ethnicity)
<option value="{{ $ethnicity }}"
@foreach (config('arc.ethnicity_desc') as $index => $ethnicity)
<option value="{{ $index }}"
@selected(
($pri_carer->ethnicity === $ethnicity)
($pri_carer->ethnicity === $index)
)
>@lang('arc.ethnicity_short.' . $ethnicity)
> {{ $ethnicity }}
</option>
@endforeach
</select><br></br>
Expand Down Expand Up @@ -56,8 +56,8 @@ class="@if($errors->has('pri_carer'))invalid @endif"
<label for="pri_carer_ethnicity">Main participant's ethnic background (optional)</label><br>
<select name="pri_carer_ethnicity" id="pri_carer_ethnicity">
<option value=0>Please select</option>
@foreach (config('arc.ethnicity') as $ethnicity)
<option value="{{ $ethnicity }}">@lang('arc.ethnicity_short.' . $ethnicity)
@foreach (config('arc.ethnicity_desc') as $index => $ethnicity)
<option value="{{ $index }}">{{ $ethnicity }}
</option>
@endforeach
</select><br></br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ public function testItCanDeleteACentreUser()
->followRedirects()
->assertResponseOk()
->seePageIs(route('admin.centreusers.index'))
->see('Worker DELETED' . $cu->name . ' deleted')
->dontSee($cu->email)
->notSeeInDatabase('centre_users', [
'name' => $this->data['name'],
'email' => $this->data['email'],
'deleted_at' => null
->dontSeeInDatabase('centre_centre_user', [
'centre_user_id' => $cu->id,
'centre_id' => $this->altCentres->last()->id,
])
;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Controllers/Store/CentreControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testItCanDownloadAStandardRegistrationsSpreadsheet()
$expected_headers = [
"RVID",
"Area",
"Centre",
"Distribution Centre",
"Primary Carer",
"Entitlement",
"Last Collection",
Expand Down Expand Up @@ -152,7 +152,7 @@ function ($line) use ($headers) {
// Make a hash, test it and add it to the end
$hash =
$line["Area"] . '#' .
$line["Centre"] . '#' .
$line["Distribution Centre"] . '#' .
$line["Primary Carer"];

if (!empty($hashes)) {
Expand All @@ -170,7 +170,7 @@ function ($line) use ($headers) {
$this->assertNotFalse($reg);

// It has the correct centre name
$this->assertEquals($reg->centre->name, $line["Centre"]);
$this->assertEquals($reg->centre->name, $line["Distribution Centre"]);

// It has the correct area/sponsor name
$this->assertEquals($reg->centre->sponsor->name, $line["Area"]);
Expand Down Expand Up @@ -204,7 +204,7 @@ public function testItCanDownloadASocialPrescriptionsRegistrationsSpreadsheet()
$expected_headers = [
"RVID",
"Area",
"Centre",
"Distribution Centre",
"Main Participant",
"Entitlement",
"Last Collection",
Expand Down Expand Up @@ -255,7 +255,7 @@ function ($line) use ($headers) {
// Make a hash, test it and add it to the end
$hash =
$line["Area"] . '#' .
$line["Centre"] . '#' .
$line["Distribution Centre"] . '#' .
$line["Main Participant"];

if (!empty($hashes)) {
Expand All @@ -273,7 +273,7 @@ function ($line) use ($headers) {
$this->assertNotFalse($reg);

// It has the correct centre name
$this->assertEquals($reg->centre->name, $line["Centre"]);
$this->assertEquals($reg->centre->name, $line["Distribution Centre"]);

// It has the correct area/sponsor name
$this->assertEquals($reg->centre->sponsor->name, $line["Area"]);
Expand Down

0 comments on commit 1bdd181

Please sign in to comment.