Fix js error when adding episodes for existing patients

Refs openhealthcare/elcid#372