本文整理汇总了Python中lib_openmolar.common.db_orm.InsertableRecord.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Python InsertableRecord.indexOf方法的具体用法?Python InsertableRecord.indexOf怎么用?Python InsertableRecord.indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib_openmolar.common.db_orm.InsertableRecord
的用法示例。
在下文中一共展示了InsertableRecord.indexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database):
q_query= QtSql.QSqlQuery(
"select min(ix), max(ix) from patients", database)
if q_query.first():
min_patient_id = q_query.value(0).toInt()[0]
max_patient_id = q_query.value(1).toInt()[0]
self.patient_id = randint(min_patient_id, max_patient_id)
else:
self.patient_id = 0
self.length = 1
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf('checked_date'))
self.record.remove(self.record.indexOf('is_erupted'))
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
self.record.clearValues()
#set values, or allow defaults
self.record.setValue('patient_id', self.patient_id)
self.record.setValue('mesial_neighbour', 9)
self.record.setValue('distal_neighbour', 10)
self.record.setValue('checked_by', 'demo_installer')
yield self.record.insert_query
示例2: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database):
q_query = QtSql.QSqlQuery("select min(ix), max(ix) from patients", database)
if q_query.first():
self.min_patient_id = q_query.value(0).toInt()[0]
self.max_patient_id = q_query.value(1).toInt()[0]
else:
self.min_patient_id, self.max_patient_id = 0, 0
self.length = self.max_patient_id - self.min_patient_id
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf("dent_key"))
self.record.remove(self.record.indexOf("checked_date"))
def demo_queries(self):
"""
return a list of queries to populate a demo database
"""
for patient_id in xrange(self.min_patient_id, self.max_patient_id + 1):
self.record.clearValues()
# set values, or allow defaults
self.record.setValue("patient_id", patient_id)
self.record.setValue("checked_by", "demo_installer")
yield self.record.insert_query
示例3: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database=None):
q_query= QtSql.QSqlQuery(
"select min(ix), max(ix) from patients", database)
if q_query.first():
self.min_patient_id = q_query.value(0).toInt()[0]
self.max_patient_id = q_query.value(1).toInt()[0]
else:
self.min_patient_id, self.max_patient_id = 0,0
self.length = 300
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf('type'))
self.record.remove(self.record.indexOf('commit_time'))
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
today = QtCore.QDateTime.currentDateTime()
for i in xrange(0, self.length):
self.record.clearValues()
self.record.setValue('line',
u"This is a test Line of Reception Notes")
self.record.setValue('patient_id',
randint(self.min_patient_id, self.max_patient_id))
self.record.setValue('author', 1)
t_stamp = today.addSecs(- randint(0, 86400))
t_stamp = t_stamp.addDays(- randint(0, 4000))
self.record.setValue('open_time', t_stamp)
yield self.record.insert_query
示例4: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database):
self.length = 4
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf("date_issued"))
self.record.remove(self.record.indexOf("discount"))
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
self.record.clearValues()
self.record.setValue('patient_id', 1)
self.record.setValue('status_id', 1)
self.record.setValue('total_fees', 20.50)
self.record.setValue('amount_payable', 20.50)
yield self.record.insert_query
self.record.clearValues()
self.record.setValue('patient_id', 1)
self.record.setValue('status_id', 2)
self.record.setValue('total_fees', 4.50)
self.record.setValue('amount_payable', 4.50)
yield self.record.insert_query
示例5: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database):
q_query = QtSql.QSqlQuery(
"""select ix from patients
where last_name='POTTER' and first_name='HARRY' """,
database,
)
self.length = 0
self.patient_id = None
if q_query.first():
self.length = 1
self.patient_id = q_query.value(0).toInt()[0]
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf("checked_date"))
def demo_queries(self):
"""
return a list of queries to populate a demo database
"""
sql_list = []
if self.patient_id:
self.record.setValue("patient_id", self.patient_id)
self.record.setValue("memo", "Nasty scar on forehead, present since birth")
self.record.setValue("checked_by", "demo_installer")
sql_list.append(self.record.insert_query)
return sql_list
示例6: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database=None):
q_query= QtSql.QSqlQuery(
'''select ix from patients
where last_name='POTTER' and first_name='HARRY' ''', database)
self.length = 0
self.patient_id = None
if q_query.first():
self.length = 1
self.patient_id = q_query.value(0).toInt()[0]
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf('checked_date'))
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
if self.patient_id:
self.record.setValue('patient_id', self.patient_id)
self.record.setValue('memo', "legal guardian is Mr Vernon Dursley")
self.record.setValue('checked_by', 'demo_installer')
return [self.record.insert_query]
return []
示例7: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database=None):
q_query= QtSql.QSqlQuery(
"select min(ix), max(ix) from patients", database)
if q_query.first():
self.min_patient_id = q_query.value(0).toInt()[0]
self.max_patient_id = q_query.value(1).toInt()[0]
else:
self.min_patient_id, self.max_patient_id = 0,0
self.length = self.max_patient_id - self.min_patient_id
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf('checked_date'))
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
for pt in range(self.min_patient_id, self.max_patient_id):
self.record.clearValues()
#set values, or allow defaults
self.record.setValue('patient_id', pt)
self.record.setValue('checked_by', 'demo_installer')
self.record.setValue('values', "1234*-")
yield self.record.insert_query
示例8: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database=None):
q_query = QtSql.QSqlQuery("select min(ix), max(ix) from patients", database)
if q_query.first():
self.min_patient_id = q_query.value(0).toInt()[0]
self.max_patient_id = q_query.value(1).toInt()[0]
else:
self.min_patient_id, self.max_patient_id = 0, 0
q_query = QtSql.QSqlQuery("select min(ix), max(ix) from addresses", database)
if q_query.first():
self.max_address_id = q_query.value(1).toInt()[0]
self.min_address_id = q_query.value(0).toInt()[0]
# reserve id number 1 for the practice address.
if self.min_address_id == 1 and self.max_address_id > 1:
self.min_address_id == 2
else:
self.min_address_id, self.max_address_id = 0, 0
self.length = self.max_patient_id - self.min_patient_id
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf("address_cat"))
self.record.remove(self.record.indexOf("to_date"))
self.record.remove(self.record.indexOf("from_date"))
self.record.remove(self.record.indexOf("mailing"))
def demo_queries(self):
"""
return a list of queries to populate a demo database
"""
for patient_id in xrange(self.min_patient_id, self.max_patient_id + 1):
self.record.clearValues()
address_id = randint(self.min_address_id, self.max_address_id)
# set values, or allow defaults
self.record.setValue("patient_id", patient_id)
self.record.setValue("address_id", address_id)
yield self.record.insert_query
示例9: import_users
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
def import_users(self, ignore_errors=False):
table_name = "users"
LOGGER.info("importing %s"% table_name)
try:
filepath = os.path.abspath(
os.path.join(self.import_directory, "%s.xml"% table_name))
dom = minidom.parse(filepath)
except IOError:
LOGGER.error(
"Unable to import users - no such file %s"% filepath)
raise self.ImportWarning
record = InsertableRecord(self.om2_session, table_name)
record.include_ix = True
record.remove(record.indexOf("time_stamp"))
ps_query, values = record.insert_query
psql_query = QtSql.QSqlQuery(self.om2_session)
rows = dom.getElementsByTagName(table_name.rstrip("s"))
errors_encountered = False
for row in rows:
psql_query.prepare(ps_query)
for node in ('ix', 'abbrv_name', 'role', 'title', 'last_name',
'middle_name', 'first_name', 'qualifications', 'registration',
'correspondence_name', 'sex', 'dob',
'status', 'comments', 'avatar_id', 'display_order'):
vals = row.getElementsByTagName(node)
try:
val = vals[0].firstChild.data.strip()
if node == "ix":
ix = int(val)
elif node == "abbrv_name":
user = val
self.USER_DICT[user] = ix
except IndexError:
val = None
except AttributeError:
val = ""
psql_query.addBindValue(val)
psql_query.addBindValue("imported from xml")
psql_query.exec_()
if not ignore_errors and psql_query.lastError().isValid():
LOGGER.warning("ERROR IMPORTING User \n\t%s\t%s"% (
row.toprettyxml(),
psql_query.lastError().text()))
errors_encountered = True
LOGGER.debug(self.USER_DICT)
if errors_encountered:
raise self.ImportWarning
self.register_progress("import_users", 100)
示例10: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database):
self.length = 4
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf("px_date"))
self.record.remove(self.record.indexOf("added_by"))
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
self.record.clearValues()
self.record.setValue('patient_id', 1)
self.record.setValue('om_code', "A01")
self.record.setValue('completed', True)
self.record.setValue('px_clinician', 1)
self.record.setValue('tx_clinician', 1)
self.record.setValue('tx_date', "now()")
yield self.record.insert_query
self.record.clearValues()
self.record.setValue('patient_id', 1)
self.record.setValue('om_code', "D02")
self.record.setValue('completed', False)
self.record.setValue('px_clinician', 1)
yield self.record.insert_query
self.record.clearValues()
self.record.setValue('patient_id', 1)
self.record.setValue('om_code', "F10")
self.record.setValue('completed', False)
self.record.setValue('px_clinician', 1)
yield self.record.insert_query
self.record.clearValues()
self.record.setValue('patient_id', 1)
self.record.setValue('om_code', "E01")
self.record.setValue('completed', False)
self.record.setValue('px_clinician', 1)
yield self.record.insert_query
示例11: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database=None):
q_query= QtSql.QSqlQuery(
"select min(ix), max(ix) from patients", database)
if q_query.first():
self.min_patient_id = q_query.value(0).toInt()[0]
self.max_patient_id = q_query.value(1).toInt()[0]
else:
self.min_patient_id, self.max_patient_id = 0,0
q_query= QtSql.QSqlQuery('''select ix from practitioners
where type='dentist' ''', database)
self.dentist_ids = []
while q_query.next():
self.dentist_ids.append(q_query.value(0).toInt()[0])
self.length = self.max_patient_id - self.min_patient_id
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf('address_cat'))
self.record.remove(self.record.indexOf('end_date'))
self.record.remove(self.record.indexOf('start_date'))
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
for patient_id in xrange(self.min_patient_id, self.max_patient_id+1):
self.record.clearValues()
dent_id = choice(self.dentist_ids)
#set values, or allow defaults
self.record.setValue('patient_id', patient_id)
self.record.setValue('practitioner_id', dent_id)
self.record.setValue('contract_type', "dentist")
self.record.setValue('comments', "random")
yield self.record.insert_query
示例12: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database=None):
q_query= QtSql.QSqlQuery(
"select min(ix), max(ix) from patients", database)
if q_query.first():
self.min_patient_id = q_query.value(0).toInt()[0]
self.max_patient_id = q_query.value(1).toInt()[0]
else:
self.min_patient_id, self.max_patient_id = 0,0
self.clinicians = []
q_query= QtSql.QSqlQuery(
"select user_id from view_practitioners", database)
while q_query.next():
self.clinicians.append(q_query.value(0).toInt()[0])
self.authors = []
q_query= QtSql.QSqlQuery(
"select ix from users", database)
while q_query.next():
self.authors.append(q_query.value(0).toInt()[0])
for clinician in self.clinicians:
self.authors.remove(clinician)
self.length = 500
self.record = InsertableRecord(database, TABLENAME)
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
today = QtCore.QDateTime.currentDateTime()
self.record.remove(self.record.indexOf('type'))
for i in xrange(0, self.length):
self.record.clearValues()
self.record.setValue('line',
u"a line of clinical notes. \nrandom %06d"% randint(1,10000))
self.record.setValue('patient_id',
randint(self.min_patient_id, self.max_patient_id))
self.record.setValue('author', choice(self.clinicians))
self.record.setValue('co_author', choice(self.authors + [None]))
t_stamp = today.addSecs(- randint(0, 86400))
t_stamp = t_stamp.addDays(- randint(0, 4000))
self.record.setValue('open_time', t_stamp)
self.record.setValue('commit_time', t_stamp)
self.record.setValue('comitted', True)
yield self.record.insert_query
示例13: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database=None):
self.database = database
self.length = 3
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf("trt2"))
self.record.remove(self.record.indexOf("memo"))
def get_diary_id(self):
'''
poll the database for the demo exam diary_entry
'''
LOGGER.debug("polling diary_entries table for an appointment")
q_query= QtSql.QSqlQuery(
"select ix from diary_entries where etype='appointment' limit 1",
self.database)
if q_query.first():
return q_query.value(0).toInt()[0]
else:
LOGGER.warning("No exam appointment found in diary table")
return None
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
self.record.clearValues()
self.record.setValue('patient_id', 1)
self.record.setValue('trt1', "exam")
self.record.setValue('len', 15)
self.record.setValue('preferred_practitioner', 1)
self.record.setValue('diary_entry_id', self.get_diary_id())
yield self.record.insert_query
self.record.clearValues()
self.record.setValue('patient_id', 1)
self.record.setValue('trt1', "fill")
self.record.setValue('len', 30)
self.record.setValue('preferred_practitioner', 1)
yield self.record.insert_query
self.record.clearValues()
self.record.setValue('patient_id', 1)
self.record.setValue('trt1', "hyg")
self.record.setValue('len', 30)
self.record.setValue('preferred_practitioner', 3)
yield self.record.insert_query
示例14: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database=None):
self.length = 4
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf("time_stamp"))
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
## practitioner 1
self.record.setValue('user_id', 1)
self.record.setValue('type',"dentist")
self.record.setValue('status', "active")
self.record.setValue('modified_by', "demo_installer")
yield self.record.insert_query
self.record.clearValues()
## practitioner 2
self.record.setValue('user_id', 2)
self.record.setValue('type',"dentist")
self.record.setValue('status', "active")
self.record.setValue('modified_by', "demo_installer")
yield self.record.insert_query
self.record.clearValues()
## practitioner 3
self.record.setValue('user_id', 3)
self.record.setValue('type',"dentist")
self.record.setValue('speciality', 'Orthodontics')
self.record.setValue('status', "active")
self.record.setValue('modified_by', "demo_installer")
yield self.record.insert_query
self.record.clearValues()
## practitioner 4
self.record.setValue('user_id', 4)
self.record.setValue('type',"hygienist")
self.record.setValue('status', "active")
self.record.setValue('modified_by', "demo_installer")
yield self.record.insert_query
示例15: DemoGenerator
# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import indexOf [as 别名]
class DemoGenerator(object):
def __init__(self, database):
self.length = 40
self.record = InsertableRecord(database, TABLENAME)
self.record.remove(self.record.indexOf('checked_date'))
def demo_queries(self):
'''
return a list of queries to populate a demo database
'''
for i in range(self.length):
self.record.clearValues()
#set values, or allow defaults
self.record.setValue('number',
u"0%04d %06d"% (randint(1000,9999), randint(100000,999999)))
self.record.setValue('checked_by', "demo_installer")
yield self.record.insert_query