11import { v4 as uuidv4 } from "uuid"
22import pino from "pino"
33import { getSharedAuthToken , getBody } from "./helper/psu.mjs"
4- import { allowedOdsCodes } from "./helper/allowed_odscodes .mjs"
4+ import { allowedOdsCodes , blockedOdsCodes } from "./helper/odscodes .mjs"
55
6- const logger = pino ( )
6+ export { getSharedAuthToken }
77
8- const NUM_ODS_CODES = 1000
8+ const logger = pino ( )
99
1010const LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
1111const DIGITS = "0123456789" ;
@@ -26,8 +26,8 @@ function buildFullOdsCodes(targetCount, seedCodes) {
2626 return Array . from ( codes ) ;
2727}
2828
29- /** The complete list of 10k ODS codes */
30- const fullOdsCodes = buildFullOdsCodes ( NUM_ODS_CODES , allowedOdsCodes ) ;
29+ // The complete list of ODS codes
30+ const fullOdsCodes = allowedOdsCodes . concat ( blockedOdsCodes )
3131
3232function computeCheckDigit ( nhsNumber ) {
3333 const factors = [ 10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 ]
@@ -71,11 +71,13 @@ export function initUser(context, events, done) {
7171 if ( prescriptionCount < 1 ) prescriptionCount = 1 // just truncate at 1.
7272 context . vars . prescriptionCount = prescriptionCount
7373
74+ logger . info ( `Patient ${ context . vars . nhsNumber } , ODS ${ context . vars . odsCode } has ${ context . vars . prescriptionCount } prescriptions` )
75+
7476 done ( )
7577}
7678
77- // beforeEach request
7879export function generatePrescData ( requestParams , context , ee , next ) {
80+ logger . info ( `Generating a prescription for patient ${ context . vars . nhsNumber } ` )
7981 const body = getBody (
8082 true , /* isValid */
8183 "ready to collect" , /* status */
@@ -91,8 +93,8 @@ export function generatePrescData(requestParams, context, ee, next) {
9193 let delay = sampleNormal ( 150 , 60 )
9294 if ( delay < 0 ) delay = 0
9395 context . vars . nextDelay = delay
96+ logger . info ( `Patient ${ context . vars . nhsNumber } will think for ${ context . vars . nextDelay } seconds` )
9497
9598 next ( )
9699}
97100
98- export { getSharedAuthToken }
0 commit comments