Created
July 7, 2016 23:28
-
-
Save Zhang/79c83fc33e8d1951a06b45fa4f7fcec3 to your computer and use it in GitHub Desktop.
ravi interview
This file contains 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
# Returns an array of arrays. The first element in each sub-array is the name of the payer, and the second element is | |
# the count. The payer must have been active during range. | |
def patient_payers(type, id, range, filters) | |
active_patients = patients(type, id, range, filters) | |
return_map = {} | |
for patient in active_patients: | |
for payer in patient.patient_payers: | |
for payer_history in payer.active_history: | |
if is_in_date_range(payer_history, range): | |
return_map.increment(payer.id) | |
break | |
return return_map | |
end | |
def is_in_date_range(ar, range): | |
if range.end_time >= ar.start_time and range.start_time <= ar.end: | |
return True | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment