11#!/usr/bin/python3
2- ''' Create SQL scripts to delete synthetic data.
3- '''
2+ """ Create SQL scripts to delete synthetic data.
3+ """
44
55import sys
6- from typing import List
7-
86
97# List of predefined Beneficiary IDs to delete and pattern of bene_ids to match in a NOT LIKE
108# clause. Source: https://jira.cms.gov/browse/BFD-1686
5856# Helpers
5957
6058
61- def make_bene_id_pattern (bene_ids : List [str ], pattern : str , cast_id : bool = False ) -> str :
62- '''Make the WHERE clause to handle bene_ids that are in the list or fit the pattern.
63- '''
64-
59+ def make_bene_id_pattern (bene_ids : list [str ], pattern : str , cast_id : bool = False ) -> str :
60+ """Make the WHERE clause to handle bene_ids that are in the list or fit the pattern.
61+ """
6562 output = ' bene_id IN (\' ' + '\' , \' ' .join (bene_ids ) + '\' )'
6663 if pattern is not None :
6764 bene_id = 'CAST(bene_id AS CHARACTER VARYING(15))' if cast_id else 'bene_id'
@@ -72,12 +69,11 @@ def make_bene_id_pattern(bene_ids: List[str], pattern: str, cast_id: bool = Fals
7269
7370def make_claims_sql (bene_id_clause : str , claims_table : str , claim_lines_table : str ,
7471 is_count : bool ) -> str :
75- ''' Create SQL to count or delete from a claims table and its corresponding claim_lines table.
72+ """ Create SQL to count or delete from a claims table and its corresponding claim_lines table.
7673
7774 We want to run the claims table after the claim_lines table, because we couldn't join / union
7875 if we don't.
79- '''
80-
76+ """
8177 # Generate SQL for Claims Lines
8278 output = f"-- { claim_lines_table } \n \n "
8379 if is_count :
@@ -101,8 +97,8 @@ def make_claims_sql(bene_id_clause: str, claims_table: str, claim_lines_table: s
10197
10298
10399def make_base_sql (bene_id_clause : str , base_table : str , is_count : bool ) -> str :
104- ''' Create SQL to count or delete from a table containing a bene_id clause.
105- '''
100+ """ Create SQL to count or delete from a table containing a bene_id clause.
101+ """
106102 output = f"-- { base_table } \n \n "
107103
108104 output += f"SELECT COUNT(*) AS { base_table } \n " if is_count else 'DELETE\n '
@@ -113,19 +109,17 @@ def make_base_sql(bene_id_clause: str, base_table: str, is_count: bool) -> str:
113109
114110
115111def help_text () -> str :
116- '''Provide help text if the user does not provide valid arguments or asks for help.
117- '''
118-
112+ """Provide help text if the user does not provide valid arguments or asks for help.
113+ """
119114 return 'Usage: make_sql.py [count | delete] [test|prod-sbx|prod]'
120115
121116
122117# Main
123118
124119
125- def main (args : List ):
126- '''Main function, called from the command line.
127- '''
128-
120+ def main (args : list ):
121+ """Main function, called from the command line.
122+ """
129123 if not args or len (args ) < 2 :
130124 print (help_text (), file = sys .stderr )
131125 sys .exit ()
0 commit comments