@@ -6,24 +6,20 @@ const { generateBSUAppropriateAddress } = require('./address-generator');
66
77// Generate a UK phone number
88const generateUKPhoneNumber = ( ) => {
9- // 80% mobile, 20% landline
10- if ( Math . random ( ) < 0.8 ) {
11- // Mobile number formats
12- const formats = [
13- '07### ######' , // Standard UK mobile
14- '07#########' , // No spaces
15- '+447### ######' // International format
16- ] ;
17- return faker . phone . number ( faker . helpers . arrayElement ( formats ) ) ;
9+ const numberTypes = {
10+ 'mobile' : 0.8 ,
11+ 'landline' : 0.2
12+ }
13+
14+ if ( weighted . select ( numberTypes ) === 'mobile' ) {
15+ const suffix = faker . number . int ( { min : 900000 , max : 900999 } ) ;
16+ return `07700${ suffix } ` ; // Ofcom reserved range
1817 } else {
19- // Get the BSU's area code from their phone number
20- // Fallback to standard area codes if not available
21- const areaCodes = [ '0118' , '01865' , '0114' , '020' ] ;
22- const areaCode = faker . helpers . arrayElement ( areaCodes ) ;
23- return faker . phone . number ( areaCode + ' ### ####' ) ;
18+ const areaCode = faker . helpers . arrayElement ( [ '0118' , '01865' ] ) ;
19+ const suffix = faker . number . int ( { min : 0 , max : 999 } ) . toString ( ) . padStart ( 3 , '0' ) ;
20+ return `${ areaCode } 4960${ suffix } ` ; // Ofcom reserved range
2421 }
2522} ;
26-
2723// Helper functions for name formatting
2824const formatName = ( person ) => ( {
2925 get fullName ( ) {
@@ -96,7 +92,7 @@ const generateParticipant = ({ ethnicities, breastScreeningUnits }) => {
9692 } ) . toISOString ( ) ,
9793 address : generateBSUAppropriateAddress ( assignedBSU ) ,
9894 phone : generateUKPhoneNumber ( ) ,
99- email : `${ faker . internet . userName ( ) . toLowerCase ( ) } @example.com` ,
95+ email : `${ faker . internet . username ( ) . toLowerCase ( ) } @example.com` ,
10096 ethnicGroup,
10197 ethnicBackground
10298 } ,
0 commit comments