Skip to content

Instantly share code, notes, and snippets.

@Zhang
Created July 19, 2016 22:41
Show Gist options
  • Save Zhang/15a540a3f559d6ab07dbadca51608151 to your computer and use it in GitHub Desktop.
Save Zhang/15a540a3f559d6ab07dbadca51608151 to your computer and use it in GitHub Desktop.
payers
def patient_payers(type, id, range, filters)
ArrayList<Patient> patientList = patients(type, id, range, filters);
HashMap<Payer, Integer> dict = new HashMap<Payer, Integer>();
for (Patient patient : patientList) {
ArrayList<Payers> payerList = patient.patientPayers();
for (Payer payer : payerList) {
if (isInRange(payer, range)) {
if (dict.containsKey(payer)) {
dict.put(payer, ++dict.get(payer));
}
else {
dict.put(payer, 1);
}
}
}
}
return dict;
end
def isInRange(patientPayer, range)
ArrayList<ActiveHistory> activeHistoryList = patientPayer.active_history;
Date admitDt = range[0];
Date dischargeDt = range[1];
boolean latestStatus = false;
for (ActiveHistory blob : activeHistoryList) {
if (blob.updated_at < admitDt) {
latestStatus = blob.value;
}
if (blob.updated_at > admitDt && blob.updated_at < dischargeDt) {
return true;
}
}
return latestStatus;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment