Refactor patient-graphs.js