def makeNotes(n=1, z=1): generator = getattr(lipsum, { 0: 'generate_words', 1: 'generate_sentences' }.get(random.randint(0, 1))) return { 'nuid': tf.getUUID(), 'cuid': tf.getUUID(), 'history': [{ 'content': generator(random.randint(1, 4)), 'uuid': tf.getUUID(), 'time': random.randint(1613066000, 1628618000) } for x in range(random.randint(max(n, 1), z))] }
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 updateCol(self, dat=None): # new col requested newDat = {k: v for k, v in self.dat.items()} if not dat: newDat['cols'].append({ 'type': 0, 'title': '(none)', 'active': True, 'width': 200, 'cuid': tf.getUUID() }) else: newDat['cols'][af.kmap(newDat['cols'], 'cuid').index(dat['cuid'])].update(dat) self.updateList(newDat=newDat) return True
def createList(self): self.luid = tf.getUUID() self.aes = En()._rnd(32) self.shareList(1, uuids=[self.auth.userDict['uuid']], first=True) self.updateList(newDat={ 'name': f"(nameless list)", 'cols': [] }, newActive=1) # add empty col self.updateCol() # check if one list displayed else display this one if not self.auth.sql.fetch( f"SELECT luid FROM lists WHERE luid IN (SELECT luid FROM rights WHERE uuid = '{self.auth.userDict['uuid']}' AND disp = 1) AND active = 1" ): self.auth.sql.wesc('UPDATE rights SET disp* WHERE uuid* AND luid*', v=[(True, self.auth.userDict['uuid'], self.luid) ])
def addUser(self, email): if not re.fullmatch(re.compile('^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w+$'), email): return False query = self.sql.fetch(f"SELECT uuid FROM users WHERE email = '{email}'") if query: return query[0][0] newUUID = tf.getUUID() self.sql.replaceRows('users', { 'uuid': newUUID, 'email': email, 'priv': None, 'pub': None, 'dat': tf.jb({'name': email}), 'pwrdchange': 1, 'active': 0 }) self.requestPwrdReset(newUUID, newAccount=True) return newUUID
def makePt(cols=5, n=1, z=1): return { 'puid': tf.getUUID(), 'name': re.sub(r'[,\.\?!]', r'', lipsum.generate_words(2)), 'notes': [makeNotes(n, z) for x in range(cols)] }