Skip to content

Commit 2332888

Browse files
Fix generating vaccination data
1 parent b0f51de commit 2332888

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

app/generators/vaccination.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fakerEN_GB as faker } from '@faker-js/faker'
22

33
import vaccines from '../datasets/vaccines.js'
4-
import { PatientStatus, VaccinationOutcome } from '../enums.js'
4+
import { VaccinationOutcome } from '../enums.js'
55
import { Vaccination } from '../models.js'
66

77
/**
@@ -20,17 +20,14 @@ export function generateVaccination(patientSession, programme, batch, users) {
2020
let injectionSite
2121
let sequence
2222

23-
let outcome
24-
if (patientSession.report === PatientStatus.Due) {
25-
outcome = faker.helpers.weightedArrayElement([
26-
{ value: VaccinationOutcome.Vaccinated, weight: 7 },
27-
{ value: VaccinationOutcome.PartVaccinated, weight: 1 },
28-
{ value: VaccinationOutcome.Absent, weight: 1 },
29-
{ value: VaccinationOutcome.DoNotVaccinate, weight: 1 },
30-
{ value: VaccinationOutcome.Refused, weight: 1 },
31-
{ value: VaccinationOutcome.Unwell, weight: 1 }
32-
])
33-
}
23+
const outcome = faker.helpers.weightedArrayElement([
24+
{ value: VaccinationOutcome.Vaccinated, weight: 7 },
25+
{ value: VaccinationOutcome.PartVaccinated, weight: 1 },
26+
{ value: VaccinationOutcome.Absent, weight: 1 },
27+
{ value: VaccinationOutcome.DoNotVaccinate, weight: 1 },
28+
{ value: VaccinationOutcome.Refused, weight: 1 },
29+
{ value: VaccinationOutcome.Unwell, weight: 1 }
30+
])
3431

3532
if (programme.sequence) {
3633
sequence = programme.sequenceDefault

lib/create-data.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,10 @@ for (const patientSession of Object.values(context.patientSessions)) {
430430
}
431431

432432
for (const programme of session.programmes) {
433-
if (patientSession.vaccine) {
433+
if (
434+
patientSession.vaccine &&
435+
patientSession.report === PatientStatus.Due
436+
) {
434437
const batch = Object.values(context.batches)
435438
.filter(
436439
({ vaccine_snomed }) =>

0 commit comments

Comments
 (0)