def get_regimen_code_arr(str_regimen): """ Helper function to decode regimens for both the old style regimens (in REGIMEN_CHOICES) as well as the new style regimens as required in the technical specs above. should return an array of day slot indices. """ if str_regimen is None or str_regimen == '' or str_regimen == 'None': return [] #legacy handling if str_regimen.lower() == 'qd': return [0] elif str_regimen.lower() == 'qd-am': return [0] elif str_regimen.lower() == 'qd-pm': return [2] elif str_regimen.lower() == 'bid': return [0, 2] elif str_regimen.lower() == 'qid': return [0, 1, 2, 3] elif str_regimen.lower() == 'tid': return [0, 1, 2] elif str_regimen.lower() == '': return [] #newer handling, a split string splits = str_regimen.split(',') ret = [] for x in splits: if x in DAY_SLOTS_BY_TIME.keys(): ret.append(DAY_SLOTS_BY_TIME[x]) else: logging.error( "value error, the regimen string is incorrect for the given patient, returning blank" ) ret = [] return ret
def get_regimen_code_arr(str_regimen): """ Helper function to decode regimens for both the old style regimens (in REGIMEN_CHOICES) as well as the new style regimens as required in the technical specs above. should return an array of day slot indices. """ if str_regimen is None or str_regimen == '' or str_regimen == 'None': return [] #legacy handling if str_regimen.lower() == 'qd': return [0] elif str_regimen.lower() == 'qd-am': return [0] elif str_regimen.lower() == 'qd-pm': return [2] elif str_regimen.lower() == 'bid': return [0, 2] elif str_regimen.lower() == 'qid': return [0, 1, 2, 3] elif str_regimen.lower() == 'tid': return [0, 1, 2] elif str_regimen.lower() == '': return [] #newer handling, a split string splits = str_regimen.split(',') ret = [] for x in splits: if x in DAY_SLOTS_BY_TIME.keys(): ret.append(DAY_SLOTS_BY_TIME[x]) else: logging.error("value error, the regimen string is incorrect for the given patient, returning blank") ret = [] return ret