@@ -18,7 +18,7 @@ def person_rows_builder( # noqa:PLR0913
1818 gender : Gender | None = ...,
1919 postcode : str | None = ...,
2020 cohorts : Sequence [str ] | None = ...,
21- vaccines : Sequence [ tuple [str , date ]] | None = ...,
21+ vaccines : dict [ str , dict [str , str | None ]] | None = ...,
2222 icb : str | None = ...,
2323 gp_practice : str | None = ...,
2424 pcn : str | None = ...,
@@ -36,8 +36,6 @@ def person_rows_builder( # noqa:PLR0913
3636 date_of_birth = date_of_birth if date_of_birth is not ... else faker .date_of_birth (minimum_age = 18 , maximum_age = 99 )
3737 gender = gender if gender is not ... else choice (get_args (Gender ))
3838 postcode = postcode if postcode is not ... else faker .postcode ()
39- cohorts = cohorts if cohorts is not ... else ["cohort-a" , "cohort-b" ]
40- vaccines = vaccines if vaccines is not ... else [("RSV" , faker .past_date ("-5y" )), ("COVID" , faker .past_date ("-5y" ))]
4139 icb = icb if icb is not ... else faker .icb ()
4240 gp_practice = gp_practice if gp_practice is not ... else faker .gp_practice ()
4341 pcn = pcn if pcn is not ... else faker .pcn ()
@@ -64,26 +62,28 @@ def person_rows_builder( # noqa:PLR0913
6462 "MSOA" : msoa ,
6563 "LSOA" : lsoa ,
6664 },
67- {
68- "NHS_NUMBER" : key ,
69- "ATTRIBUTE_TYPE" : "COHORTS" ,
70- "COHORT_MEMBERSHIPS" : [
71- {"COHORT_LABEL" : cohort , "DATE_JOINED" : faker .past_date ().strftime ("%Y%m%d" )} for cohort in cohorts
72- ],
73- },
7465 ]
75- rows .extend (
76- {
77- "NHS_NUMBER" : key ,
78- "ATTRIBUTE_TYPE" : vaccine ,
79- "LAST_SUCCESSFUL_DATE" : (
80- last_successful_date .strftime ("%Y%m%d" ) if last_successful_date else last_successful_date
81- ),
82- "OPTOUT" : choice (["Y" , "N" ]),
83- "LAST_INVITE_DATE" : faker .past_date ("-5y" ).strftime ("%Y%m%d" ),
84- }
85- for vaccine , last_successful_date in vaccines
86- )
66+
67+ if cohorts is not ... and cohorts :
68+ rows .append (
69+ {
70+ "NHS_NUMBER" : key ,
71+ "ATTRIBUTE_TYPE" : "COHORTS" ,
72+ "COHORT_MEMBERSHIPS" : [
73+ {"COHORT_LABEL" : cohort , "DATE_JOINED" : faker .past_date ().strftime ("%Y%m%d" )} for cohort in cohorts
74+ ],
75+ }
76+ )
77+
78+ if vaccines is not ... and vaccines :
79+ rows .extend (
80+ {
81+ "NHS_NUMBER" : key ,
82+ "ATTRIBUTE_TYPE" : vaccine_name ,
83+ ** details ,
84+ }
85+ for vaccine_name , details in vaccines .items ()
86+ )
8787
8888 shuffle (rows )
8989
0 commit comments