def modifyCols(cols: Cols, req: Request, scso: Optional[str] = Cookie(None)): auth = authso.AuthSo(cookie=scso, req=req) if not auth.priv: return closeAjax(auth.setResponse({'success': False}), noCookie=True) lst = lists.SOList(auth, cols.luid) # seems like a cross-site forgery if False if cols.action == 'new' else not cols.dat['cuid'] in af.kmap( lst.dat['cols'], 'cuid'): closeAjax(auth.setResponse({'success': False}), noCookie=True) if cols.action in ['new', 'edit']: lst.updateCol(dat=cols.dat if hasattr(cols, 'dat') else None) if re.fullmatch(r'^unitaction-[a-z_]+$', cols.action): lst.unitAction(cols.action, cols.dat) for action, kwargs in { 'new': [('setLists', { 'summary': False, 'specific': cols.luid })], 'edit': [('setLists', { 'summary': False, 'specific': cols.luid })], 'unitaction': [('setLists', { 'summary': False, 'specific': cols.luid })] }.get(cols.action.split('-')[0]): getattr(auth, action)(**(kwargs if kwargs else {})) return closeAjax(auth.setResponse({}))
def modifySolsts(solst: Solst, req: Request, scso: Optional[str] = Cookie(None)): auth = authso.AuthSo(cookie=scso, req=req) lst = lists.SOList(auth, solst.luid) if solst.action in ['select', 'deselect']: lst.selection(solst.action == 'select') if solst.action == 'changename': lst.dat['name'] = solst.dat['name'] lst.updateList(newDat=lst.dat) for action, kwargs in { 'new': [('setLists', { 'summary': True })], 'select': [('setLists', { 'summary': False })], 'deselect': [('setLists', { 'summary': False })], 'changename': [('setLists', { 'summary': None })] }.get(solst.action): getattr(auth, action)(**(kwargs if kwargs else {})) return closeAjax(auth.setResponse({}))
def setLists(self, summary = None, specific = None): self.sql.reconnect() for typeLst in [True, False] if summary is None else [summary]: luids = list(set(self.getLuids(disp = not typeLst)).intersection(set(af.iwList(specific)))) if specific else self.getLuids(disp = not typeLst) solsts = [lists.SOList(self, luid) for luid in luids] self.response[f"{'s' if specific else ''}{'s' if typeLst else 'd'}lists"] = [solst.vueList(typeLst) for solst in solsts]
def __init__(self, auth, puid, luid = None, skipRights = False): self.auth, self.puid, self.skipRights = auth, puid, skipRights # no puid -> create pt if not self.puid: # rights for list self.luid = luid self.getRights() if not self.canEdit: return None self.newPt(luid) else: pt = self.auth.sql.getOneDataDict('pts', 'puid', self.puid) if not pt: return None self.puid, self.luid, self.active = [pt[k] for k in ['puid', 'luid', 'active']] if False if not luid else not self.luid == luid: return None self.getRights() self.list = lists.SOList(self.auth, self.luid) self.dat, self.hx = [tf.bj(pt[k], self.list.aes) for k in ['dat', 'hx']]
def newPt(self, luid): self.luid = luid self.list = lists.SOList(self.auth, luid) self.puid = tf.getUUID() self.dat = { 'baseline': [{ '_by': self.auth.userDict['uuid'], '_at': af.mytime(time.time(), 'a'), 'name': 'new', 'surname': 'patient', 'mrn': '', 'insurance': '', 'dob': '', 'age': '', 'gender': '', 'room': '', 'admit': af.mytime(time.time(), 1), 'info': '' }] } self.hx = {} self.active = 1 self.savePt()
def modifyCols(rights: Rights, req: Request, scso: Optional[str] = Cookie(None)): auth = authso.AuthSo(cookie=scso, req=req) if not auth.priv: return closeAjax(auth.setResponse({'success': False}), noCookie=True) lst = lists.SOList(auth, rights.luid) uuid = rights.dat.get('uuid') if rights.action == 'new': uuid = auth.addUser(rights.dat['email']) rights.dat.update({'uuid': uuid, 'priv': 4}) lst.shareList(rights.dat.get('priv'), uuids=[rights.dat.get('uuid')]) auth.setLists(summary=False, specific=lst.luid) return closeAjax(auth.setResponse({}))