This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | patient_df = pd.DataFrame(columns = ['Diagnosis_data']) | |
| patient_df['Diagnosis_data'] = pd.concat([patient_data["ClmDiagnosisCode_1"],patient_data["ClmDiagnosisCode_2"],patient_data["ClmDiagnosisCode_3"],patient_data["ClmDiagnosisCode_4"],patient_data["ClmDiagnosisCode_5"],patient_data["ClmDiagnosisCode_6"],patient_data["ClmDiagnosisCode_7"],patient_data["ClmDiagnosisCode_8"],patient_data["ClmDiagnosisCode_9"],patient_data["ClmDiagnosisCode_10"]],axis=0) | |
| patient_df = patient_df.dropna() | |
| plt.figure(figsize=(10, 7)) | |
| patient_df['Diagnosis_data'].value_counts().head(30).plot(x=patient_df['Diagnosis_data'] , kind = 'bar' , color = 'blue') | |
| plt.title('Diagnosis Codes vs Count') | |
| plt.xlabel('Diagnosis Codes') | |
| plt.show() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | patient_df = pd.DataFrame(columns = ['Procedure_data']) | |
| patient_df['Procedure_data'] = pd.concat([patient_data["ClmProcedureCode_1"],patient_data["ClmProcedureCode_2"],patient_data["ClmProcedureCode_3"],patient_data["ClmProcedureCode_4"],patient_data["ClmProcedureCode_5"],patient_data["ClmProcedureCode_6"]],axis=0) | |
| patient_df = patient_df.dropna() | |
| plt.figure(figsize=(10, 7)) | |
| patient_df['Procedure_data'].value_counts().head(30).plot(x=patient_df['Procedure_data'] , kind = 'bar' , color = 'purple') | |
| plt.title('Procedure Codes vs Count') | |
| plt.xlabel('Procedure Codes') | |
| plt.show() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | train_d_inpatient['whether_admitted'] = 1 | |
| train_d_outpatient['whether_admitted'] = 0 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | att_physician_count = patient_data['AttendingPhysician'].value_counts().to_dict() | |
| patient_data['attend_physician_count']=patient_data['AttendingPhysician'].map(att_physician_count) | |
| oper_physician_count = patient_data['OperatingPhysician'].value_counts().to_dict() | |
| patient_data['operate_physician_count']=patient_data['OperatingPhysician'].map(oper_physician_count) | |
| ben_count = patient_data['BeneID'].value_counts().to_dict() | |
| patient_data['BeneID_count']=patient_data['BeneID'].map(ben_count) | |
| prov_count = patient_data['Provider'].value_counts().to_dict() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | patient_data['Claim_Start'] = pd.to_datetime(patient_data['ClaimStartDt'] , format = '%Y-%m-%d') | |
| patient_data['Claim_End'] = pd.to_datetime(patient_data['ClaimEndDt'],format = '%Y-%m-%d') | |
| patient_data['DOB'] = pd.to_datetime(patient_data['DOB'] , format = '%Y-%m-%d') | |
| patient_data['DOD'] = pd.to_datetime(patient_data['DOD'],format = '%Y-%m-%d') | |
| patient_data['Claim_Days'] = ((patient_data['Claim_End'] - patient_data['Claim_Start']).dt.days) + 1 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | patient_data['Admission_Date'] = pd.to_datetime(patient_data['AdmissionDt'] , format = '%Y-%m-%d') | |
| patient_data['Discharge_Date'] = pd.to_datetime(patient_data['DischargeDt'],format = '%Y-%m-%d') | |
| patient_data['hospitalization_days'] = ((patient_data['Discharge_Date'] - patient_data['Admission_Date']).dt.days) + 1 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | reimb_amount = patient_data['IPAnnualReimbursementAmt'] + patient_data['OPAnnualReimbursementAmt'] | |
| deduct_amount = patient_data['IPAnnualDeductibleAmt'] + patient_data['OPAnnualDeductibleAmt'] | |
| patient_data['total_diff_amount'] = reimb_amount - deduct_amount | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | diagnosis_codes = patient_data[['ClmDiagnosisCode_1', 'ClmDiagnosisCode_2', 'ClmDiagnosisCode_3', | |
| 'ClmDiagnosisCode_4', 'ClmDiagnosisCode_5', 'ClmDiagnosisCode_6', | |
| 'ClmDiagnosisCode_7', 'ClmDiagnosisCode_8', 'ClmDiagnosisCode_9', | |
| 'ClmDiagnosisCode_10']] | |
| procedure_codes = patient_data[['ClmProcedureCode_1','ClmProcedureCode_2','ClmProcedureCode_3','ClmProcedureCode_4','ClmProcedureCode_5','ClmProcedureCode_6']] | |
| Seven_diag_codes = ['4019','25000','2724','V5869','4011','42731','V5861'] # from EDA | |
| patient_df = pd.DataFrame(columns = ['procedure']) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | patient_data['is_primary'] = np.where(patient_data['AttendingPhysician'].notnull(),1,0) | |
| patient_data['is_secondary'] = np.where(patient_data['OperatingPhysician'].notnull(),1,0) | |
| patient_data['is_tertiary'] = np.where(patient_data['OtherPhysician'].notnull(),1,0) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | patient_data['PotentialFraud'] = np.where(patient_data['PotentialFraud']=='Yes',1,0) | |
| patient_data['RenalDiseaseIndicator'] = np.where(patient_data['RenalDiseaseIndicator']=='Y',1,0) |