1414
1515C4DIC_LOGO_EXT = "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-Logo-extension"
1616C4DIC_ADDL_CARD_INFO_EXT = "http://hl7.org/fhir/us/insurance-card/StructureDefinition/C4DIC-AdditionalCardInformation-extension"
17- CMS_VAR_PTC_CNTRCT_ID_01 = "https://bluebutton.cms.gov/resources/variables/ptc_cntrct_id_01"
18- CMS_VAR_PTD_CNTRCT_ID_01 = "https://bluebutton.cms.gov/resources/variables/ptdcntrct01"
17+ CMS_VAR_CREC = "https://bluebutton.cms.gov/resources/variables/crec"
1918CMS_VAR_REF_YR = "https://bluebutton.cms.gov/resources/variables/rfrnc_yr"
2019
2120BENE_DENIED_ACCESS = "access_denied"
@@ -168,6 +167,29 @@ def get_patient_eob():
168167 else :
169168 return {}
170169
170+
171+ @app .route ('/api/bluebutton/loadDefaults' , methods = ['GET' ])
172+ def load_default_data ():
173+ logged_in_user ['dicPatientData' ] = load_data_file ("Dataset 1" , "c4dicPatient" )
174+ logged_in_user ['dicCoverageData' ] = load_data_file ("Dataset 1" , "c4dicCoverage" )
175+ logged_in_user ['eobData' ] = load_data_file ("Dataset 1" , "eobData" )
176+ return get_fe_redirect_url ()
177+
178+
179+ @app .route ('/api/bluebutton/loadDefaults2' , methods = ['GET' ])
180+ def load_default_data2 ():
181+ logged_in_user ['dicPatientData' ] = load_data_file ("Dataset 2" , "c4dicPatient" )
182+ logged_in_user ['dicCoverageData' ] = load_data_file ("Dataset 2" , "c4dicCoverage" )
183+ logged_in_user ['eobData' ] = load_data_file ("Dataset 2" , "eobData" )
184+ return get_fe_redirect_url ()
185+
186+
187+ def load_data_file (dataset_name , resource_file_name ):
188+ response_file = open ("./default_datasets/{}/{}.json" .format (dataset_name , resource_file_name ), 'r' )
189+ resource = json .load (response_file )
190+ response_file .close ()
191+ return resource
192+
171193@app .route ('/api/data/insurance' , methods = ['GET' ])
172194def get_patient_insurance ():
173195 """
@@ -178,7 +200,6 @@ def get_patient_insurance():
178200 * Coverage (fetched from the BB2 server and cached in logged_in_user), and
179201 * sent back to FE to render a CMS insurance 'card'
180202 """
181-
182203 print_setting ()
183204
184205 ## C4DIC patient and coverage where to extract PII and coverage plans & eligibilities
@@ -265,13 +286,13 @@ def get_patient_insurance():
265286 c_contract_id = "" ## Part A and Part B does not have contract number
266287 if c_coverageClass == "Part C" :
267288 c_contract_id = lookup_1_and_get ("$.resource.class[?(@.type.coding[0].code=='plan')]" , "value" , c )
268- # c_contract_id = lookup_1_and_get(f"$.resource.extension[?(@.url=='{CMS_VAR_PTC_CNTRCT_ID_01}')]", "valueCoding", c).get('code')
269289 if c_coverageClass == "Part D" :
270290 c_contract_id = lookup_1_and_get ("$.resource.class[?(@.type.coding[0].code=='plan')]" , "value" , c )
271- # c_contract_id = lookup_1_and_get(f"$.resource.extension[?(@.url=='{CMS_VAR_PTD_CNTRCT_ID_01}')]", "valueCoding", c).get('code')
272291 coverage ['contractId' ] = c_contract_id
273292 c_reference_year = lookup_1_and_get (f"$.resource.extension[?(@.url=='{ CMS_VAR_REF_YR } ')]" , "valueDate" , c )
274293 coverage ['referenceYear' ] = c_reference_year
294+ c_entitlement_reason = lookup_1_and_get (f"$.resource.extension[?(@.url=='{ CMS_VAR_CREC } ')]" , "valueCoding" , c ).get ('display' )
295+ coverage ['entitlementReason' ] = c_entitlement_reason
275296 # color palettes extension
276297 c_color_palette_ext = lookup_by_path (f"$.resource.extension[?(@.url=='{ C4DIC_COLOR_PALETTE_EXT } ')]" , c )
277298 if c_color_palette_ext [0 ]:
0 commit comments