Skip to content

Commit 90ecc23

Browse files
committed
update generator to ensure we have ltst_trans_flag
1 parent 7f2cb10 commit 90ecc23

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

apps/bfd-model/bfd-model-idr/sample-data/generator/generator_util.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def create_base_patient(self):
149149
patient = {}
150150
self.set_timestamps(patient, datetime.date(year=2017, month=5, day=20))
151151
patient["CNTCT_LANG_CD"] = random.choice(["~", "ENG", "SPA"])
152+
patient["IDR_LTST_TRANS_FLG"] = "Y"
152153
address = self.gen_address()
153154
for component in address:
154155
patient[component] = address[component]
@@ -196,12 +197,15 @@ def handle_mbis(self, patient, num_mbis, custom_first_mbi=None):
196197
)
197198
mbi_obj["BENE_MBI_OBSLT_DT"] = obslt_dt.strftime("%Y-%m-%d")
198199

199-
# Create historical entry for the OLD MBI (not the new one)
200-
historical_patient = copy.deepcopy(patient)
201-
historical_patient["BENE_MBI_ID"] = previous_mbi if previous_mbi else patient["BENE_MBI_ID"]
202-
# Set the obsolescence timestamp for the historical entry
203-
self.set_timestamps(historical_patient, obslt_dt)
204-
self.bene_hstry_table.append(historical_patient)
200+
if previous_mbi and previous_mbi != current_mbi:
201+
historical_patient = copy.deepcopy(patient)
202+
historical_patient["BENE_MBI_ID"] = previous_mbi
203+
historical_patient["IDR_LTST_TRANS_FLG"] = "N"
204+
205+
self.set_timestamps(historical_patient, obslt_dt)
206+
historical_patient["IDR_TRANS_OBSLT_TS"] = str(obslt_dt) + "T00:00:00.000000+0000"
207+
self.bene_hstry_table.append(historical_patient)
208+
205209

206210
previous_obslt_dt = obslt_dt # Store for next iteration
207211
else:
@@ -308,6 +312,7 @@ def save_output_files(self):
308312
"GEO_ZIP5_CD",
309313
"GEO_USPS_STATE_CD",
310314
"CNTCT_LANG_CD",
315+
"IDR_LTST_TRANS_FLG",
311316
"IDR_TRANS_EFCTV_TS",
312317
"IDR_INSRT_TS",
313318
"IDR_UPDT_TS",

apps/bfd-model/bfd-model-idr/sample-data/generator/patient_generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@
180180
old_bene_sk = prior_patient["BENE_SK"]
181181
pt_bene_sk = generator.gen_bene_sk()
182182
prior_patient["BENE_SK"] = str(pt_bene_sk)
183+
prior_patient["IDR_LTST_TRANS_FLG"] = "N"
183184
generator.used_bene_sk.append(pt_bene_sk)
184185

185186
generator.generate_bene_xref(pt_bene_sk, old_bene_sk)

0 commit comments

Comments
 (0)