Skip to content

Commit 946073c

Browse files
committed
Use valid dose count for patient status and dose tracking
dosesRemaining now uses scheduleSummary.dosesComplete (valid doses per programme rules) instead of vaccinationsGiven.length (all given doses). This fixes status, doseDue, and sequence for patients with ignored dose Also moves the status line from Procedures into the Vaccination record card, swaps the Programme column for Outcome in Procedures, adds linked dates and Age/Source columns to the Vaccination record table
1 parent 49e925f commit 946073c

4 files changed

Lines changed: 46 additions & 16 deletions

File tree

app/models/patient-programme.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ export class PatientProgramme {
236236
* @returns {number} Doses remaining
237237
*/
238238
get dosesRemaining() {
239-
if (this.vaccinationsGiven?.length > 0) {
240-
return this.dosesNeeded - this.vaccinationsGiven?.length
239+
const validCount = this.scheduleSummary.dosesComplete
240+
if (validCount > 0) {
241+
return this.dosesNeeded - validCount
241242
}
242243

243244
return this.dosesNeeded

app/views/patient/_vaccination-record.njk

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
heading: __("patientProgramme.vaccinationRecord.label"),
55
headingLevel: 3
66
}) %}
7+
{{ patientProgramme.formatted.statusWithNotes | nhsukMarkdown }}
8+
79
<p class="nhsuk-body">
810
{{ __mf("patientProgramme.vaccinationRecord.dosesComplete", {
911
complete: summary.dosesComplete,
@@ -31,7 +33,15 @@
3133
},
3234
{
3335
header: __("vaccination.createdAt.label"),
34-
text: ignored.vaccination.formatted.createdAt_date
36+
html: ignored.vaccination.link.createdAt
37+
},
38+
{
39+
header: __("vaccination.age.label"),
40+
text: patient.dob | age(at=ignored.vaccination.createdAt)
41+
},
42+
{
43+
header: __("vaccination.source.label"),
44+
text: ignored.vaccination.source
3545
}
3646
]) %}
3747
{% endfor %}
@@ -46,7 +56,15 @@
4656
},
4757
{
4858
header: __("vaccination.createdAt.label"),
49-
text: valid.vaccination.formatted.createdAt_date
59+
html: valid.vaccination.link.createdAt
60+
},
61+
{
62+
header: __("vaccination.age.label"),
63+
text: patient.dob | age(at=valid.vaccination.createdAt)
64+
},
65+
{
66+
header: __("vaccination.source.label"),
67+
text: valid.vaccination.source
5068
}
5169
]) %}
5270
{% endfor %}
@@ -70,6 +88,14 @@
7088
{
7189
header: __("vaccination.createdAt.label"),
7290
text: dateText
91+
},
92+
{
93+
header: __("vaccination.age.label"),
94+
text: ""
95+
},
96+
{
97+
header: __("vaccination.source.label"),
98+
text: ""
7399
}
74100
]) %}
75101
{% endfor %}
@@ -79,7 +105,9 @@
79105
responsive: true,
80106
head: [
81107
{ text: __("patientProgramme.vaccinationRecord.dose.label") },
82-
{ text: __("vaccination.createdAt.label") }
108+
{ text: __("vaccination.createdAt.label") },
109+
{ text: __("vaccination.age.label") },
110+
{ text: __("vaccination.source.label") }
83111
],
84112
rows: rows
85113
}) if rows.length }}

app/views/patient/programme.njk

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
}),
3535
headingLevel: 3
3636
}) %}
37-
{{ patientProgramme.formatted.statusWithNotes | nhsukMarkdown }}
38-
3937
{% if patientProgramme.vaccinationOutcomes.length %}
4038
{% set vaccinationRows = [] %}
4139
{% for vaccination in patientProgramme.vaccinationOutcomes %}
@@ -49,8 +47,8 @@
4947
text: patient.dob | age(at=vaccination.createdAt)
5048
},
5149
{
52-
header: __("vaccination.programme.label"),
53-
html: vaccination.formatted.programmeWithSequence
50+
header: __("vaccination.outcome.label"),
51+
html: vaccination.formatted.outcome
5452
},
5553
{
5654
header: __("vaccination.source.label"),
@@ -65,7 +63,7 @@
6563
head: [
6664
{ text: __("vaccination.createdAt.label") },
6765
{ text: __("vaccination.age.label") },
68-
{ text: __("vaccination.programme.label") },
66+
{ text: __("vaccination.outcome.label") },
6967
{ text: __("vaccination.source.label") }
7068
],
7169
rows: vaccinationRows

lib/create-data.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -722,18 +722,21 @@ function buildSeededMmrVaccination({
722722
patient_uuid,
723723
ageMonths,
724724
ageDays = 0,
725-
given
725+
given,
726+
service = false
726727
}) {
727728
const createdAt = addDays(addMonths(seededMmrDob, ageMonths), ageDays)
728729
return new Vaccination({
729730
uuid,
730731
createdAt,
731732
patient_uuid,
732733
programme_id: 'mmr',
733-
outcome: given ? VaccinationOutcome.AlreadyVaccinated : VaccinationOutcome.Unwell,
734-
source: given
735-
? VaccinationSource.NhsImmunisationsApi
736-
: VaccinationSource.Service
734+
outcome: given
735+
? (service ? VaccinationOutcome.Vaccinated : VaccinationOutcome.AlreadyVaccinated)
736+
: VaccinationOutcome.Unwell,
737+
source: service || !given
738+
? VaccinationSource.Service
739+
: VaccinationSource.NhsImmunisationsApi
737740
})
738741
}
739742

@@ -746,7 +749,7 @@ const seededMmrPatients = [
746749
doses: [
747750
// Case 1 — two valid doses
748751
{ uuid: 'mmr00001-v001-4000-8000-000000000001', ageMonths: 12, ageDays: 14, given: true },
749-
{ uuid: 'mmr00001-v002-4000-8000-000000000002', ageMonths: 15, ageDays: 7, given: true }
752+
{ uuid: 'mmr00001-v002-4000-8000-000000000002', ageMonths: 15, ageDays: 7, given: true, service: true }
750753
]
751754
},
752755
{

0 commit comments

Comments
 (0)