@@ -38,6 +38,8 @@ def _find_patients(
3838 params : dict [str , Any ] = {
3939 "TableName" : table_name ,
4040 "PaginationConfig" : {"PageSize" : 50 },
41+ "Select" : "SPECIFIC_ATTRIBUTES" ,
42+ "AttributesToGet" : ["custodian" , "nhs_number" , "type" ],
4143 }
4244
4345 total_scanned_count = 0
@@ -49,35 +51,9 @@ def _find_patients(
4951
5052 for page in paginator .paginate (** params ):
5153 for item in page ["Items" ]:
52- document = item .get ("document" , {}).get ("S" , "" )
53- # TODO - Dont need to use doc for these attrs - switch to other attrs
54-
55- # Do validations
56- try :
57- docref = DocumentReference .model_validate_json (document )
58- except Exception :
59- continue
60-
61- patient_number = (
62- docref .subject .identifier .value
63- if docref .subject
64- and docref .subject .identifier
65- and docref .subject .identifier .value
66- else "unknown"
67- )
68- producer = (
69- docref .custodian .identifier .value
70- if docref .custodian
71- and docref .custodian .identifier
72- and docref .custodian .identifier .value
73- else "unknown"
74- )
75- type_coding = (
76- docref .type .coding [0 ] if docref .type and docref .type .coding else None
77- )
78- type_str = (
79- f"{ type_coding .system } |{ type_coding .code } " if type_coding else "unknown"
80- )
54+ patient_number = item .get ("nhs_number" , {}).get ("S" , "" )
55+ producer = item .get ("custodian" , {}).get ("S" , "" )
56+ type_str = item .get ("type" , {}).get ("S" , "" )
8157
8258 if producer != org_ods_code or type_str != pointer_type :
8359 continue
0 commit comments