class DemoGenerator(object):
    def __init__(self, database=None):
        self.length = 820
        self.record = InsertableRecord(database, TABLENAME)

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        date_ = QtCore.QDate.currentDate().addMonths(-1)
        finish_date = date_.addMonths(6)
        while date_ < finish_date:
            dayno = date_.dayOfWeek()
            if dayno in (6,7):
                date_ = date_.addDays(1)
                continue
            if dayno == 2:
                start = QtCore.QDateTime(date_, QtCore.QTime(13,0))
                end_ = QtCore.QDateTime(date_, QtCore.QTime(19,0))
            else:
                start = QtCore.QDateTime(date_, QtCore.QTime(9,0))
                end_ = QtCore.QDateTime(date_, QtCore.QTime(17,0))
            self.record.clearValues()
            self.record.setValue('diary_id', 1)
            self.record.setValue('start', start)
            self.record.setValue('finish', end_)
            self.record.setValue('comment', 'demo session')
            yield self.record.insert_query
            date_ = date_.addDays(1)
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
class DemoGenerator(object):
    def __init__(self, database=None):
        self.length = 820
        self.record = InsertableRecord(database, TABLENAME)

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        date_ = QtCore.QDate.currentDate().addMonths(-1)
        finish_date = date_.addMonths(6)
        while date_ < finish_date:
            dayno = date_.dayOfWeek()
            if dayno in (6, 7):
                date_ = date_.addDays(1)
                continue
            if dayno == 2:
                start = QtCore.QDateTime(date_, QtCore.QTime(13, 0))
                end_ = QtCore.QDateTime(date_, QtCore.QTime(19, 0))
            else:
                start = QtCore.QDateTime(date_, QtCore.QTime(9, 0))
                end_ = QtCore.QDateTime(date_, QtCore.QTime(17, 0))
            self.record.clearValues()
            self.record.setValue('diary_id', 1)
            self.record.setValue('start', start)
            self.record.setValue('finish', end_)
            self.record.setValue('comment', 'demo session')
            yield self.record.insert_query
            date_ = date_.addDays(1)
Beispiel #4
0
class DemoGenerator(object):
    def __init__(self, database=None):
        self.length = 6

        self.record = InsertableRecord(database, TABLENAME)

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        for avatar in ("demo_neil.svg", "demo_andi.svg", "demo_blondie.svg",
                       "demo_helen.svg", "demo_me.svg", "demo_nattress.svg",
                       "demo_iceman.svg", "demo_frog.svg", "demo_jellyman.svg",
                       "demo_lucy.svg", "demo_negro.svg", "demo_ja.svg",
                       "demo_sally.svg"):
            f = QtCore.QFile(":avatars/%s" % avatar)
            f.open(QtCore.QIODevice.ReadOnly)
            ts = QtCore.QTextStream(f)

            self.record.clearValues()
            self.record.setValue("svg_data", ts.readAll())
            self.record.setValue("description", avatar)

            f.close()

            yield self.record.insert_query
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
Beispiel #6
0
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
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
Beispiel #8
0
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
Beispiel #9
0
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
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
Beispiel #11
0
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
Beispiel #12
0
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
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
class DemoGenerator(object):
    def __init__(self, database):
        self.length = 2

        self.record = InsertableRecord(database, TABLENAME)

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        for i in range(self.length):
            self.record.clearValues()
            self.record.setValue('status', 'open')
            yield self.record.insert_query
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
Beispiel #16
0
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
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
Beispiel #18
0
class DemoGenerator(object):
    def __init__(self, database=None):
        self.length = 2
        self.record = InsertableRecord(database, TABLENAME)
        self.record.remove(self.record.indexOf("active"))

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        year = QtCore.QDate.currentDate().year()

        for id in range(1, 3):
            self.record.clearValues()
            self.record.setValue('user_id', id)
            self.record.setValue('book_start', QtCore.QDate(year, 1, 1))
            self.record.setValue('book_end', QtCore.QDate(year + 2, 1, 1))
            self.record.setValue('comment', 'demo diary')
            yield self.record.insert_query
Beispiel #19
0
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
Beispiel #20
0
class DemoGenerator(object):
    def __init__(self, database=None):
        self.length = 2
        self.record = InsertableRecord(database, TABLENAME)
        self.record.remove(self.record.indexOf("active"))

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        year = QtCore.QDate.currentDate().year()

        for id in range(1, 3):
            self.record.clearValues()
            self.record.setValue('user_id', id)
            self.record.setValue('book_start', QtCore.QDate(year, 1, 1))
            self.record.setValue('book_end', QtCore.QDate(year+2, 1, 1))
            self.record.setValue('comment', 'demo diary')
            yield self.record.insert_query
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
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
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) * 24
        if self.length > 100:
            self.length = 100

        self.record = InsertableRecord(database, TABLENAME)

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        comments = ["big tooth", "little tooth", "rotated tooth"]
        list_len = len(comments)-1

        unique_teeth = set([])
        while len(unique_teeth) < self.length:
            pt = randint(self.min_patient_id, self.max_patient_id)
            tooth = randint(1,32)
            unique_teeth.add((pt, tooth))


        for pt, tooth in unique_teeth:
            self.record.clearValues()

            #set values, or allow defaults
            self.record.setValue('patient_id', pt)
            self.record.setValue('tooth', tooth)
            self.record.setValue('checked_by', 'demo_installer')
            self.record.setValue('comment', comments[randint(0, list_len)])
            self.record.remove(self.record.indexOf('checked_date'))

            yield self.record.insert_query
class DemoGenerator(object):
    def __init__(self, database=None):
        self.database = 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) * 3

        self.record = InsertableRecord(database, TABLENAME)
        self.record.remove(self.record.indexOf('date_charted'))


    def crown_list(self):
        CROWNS = SETTINGS.OM_TYPES["crowns"].allowed_values
        TEETH = SETTINGS.upper_back + SETTINGS.lower_back
        randno = len(TEETH) - 1
        for i in range(3):
            tooth = TEETH[randint(0, randno)]
            type_ = CROWNS[randint(0, len(CROWNS)-1)]
            crown = (tooth, type_)
            yield crown

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        for patient in xrange(self.min_patient_id, self.max_patient_id+1):
            for tooth, type_ in self.crown_list():
                self.record.clearValues()
                #set values, or allow defaults
                self.record.setValue('patient_id', patient)
                self.record.setValue('type', type_)
                self.record.setValue('tooth', tooth)
                self.record.setValue('comment', "generated by demo_installer")

                yield self.record.insert_query
Beispiel #25
0
class DemoGenerator(object):
    def __init__(self, database):
        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
        '''
        self.record.clearValues()
        self.record.setValue('patient_id', 1)
        self.record.setValue('fee', 20.50)
        self.record.setValue('type', 'treatment')
        yield self.record.insert_query

        self.record.clearValues()
        self.record.setValue('patient_id', 1)
        self.record.setValue('fee', 4.50)
        self.record.setValue('type', 'sundries')
        yield self.record.insert_query
Beispiel #26
0
class DemoGenerator(object):
    def __init__(self, database):
        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
        '''
        self.record.clearValues()
        self.record.setValue('patient_id', 1)
        self.record.setValue('fee', 20.50)
        self.record.setValue('type', 'treatment')
        yield self.record.insert_query

        self.record.clearValues()
        self.record.setValue('patient_id', 1)
        self.record.setValue('fee', 4.50)
        self.record.setValue('type', 'sundries')
        yield self.record.insert_query
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) * 24
        if self.length > 100:
            self.length = 100

        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
        '''
        descriptions = SETTINGS.OM_TYPES["root_description"].allowed_values
        d_len = len(descriptions)-1

        unique_roots =  set([])
        while len(unique_roots) < self.length:
            pt = randint(self.min_patient_id, self.max_patient_id)
            root = randint(1,32)
            unique_roots.add((pt, root))

        for pt, root in unique_roots:
            self.record.clearValues()
            #set values, or allow defaults
            self.record.setValue('patient_id', pt)
            self.record.setValue('tooth', root)
            self.record.setValue('checked_by', 'demo_installer')
            self.record.setValue('description', descriptions[randint(0, d_len)])

            yield self.record.insert_query
Beispiel #28
0
class DemoGenerator(object):
    def __init__(self, database):
        self.database = database
        self.length = 40
        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
        '''
        for i in xrange(self.length):
            self.record.clearValues()

            addr1, addr2, city, pcde = random_addy()
            self.record.setValue('addr1', addr1)
            self.record.setValue('addr2', addr2)
            self.record.setValue('city', city)
            self.record.setValue('postal_cd', pcde)
            self.record.setValue('modified_by', 'demo')

            yield self.record.insert_query
Beispiel #29
0
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 telephone", database)
        if q_query.first():
            self.min_tel_id = q_query.value(0).toInt()[0]
            self.max_tel_id = q_query.value(1).toInt()[0]
        else:
            self.min_tel_id, self.max_tel_id = 0,0

        self.length = self.max_patient_id - self.min_patient_id

        self.record = InsertableRecord(database, TABLENAME)
        self.record.remove(self.record.indexOf('tel_cat'))

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        sql_list = []
        for patient_id in xrange(self.min_patient_id, self.max_patient_id+1):
            self.record.clearValues()
            tel_id = (randint(self.min_tel_id, self.max_tel_id))

            #set values, or allow defaults
            self.record.setValue("patient_id", patient_id)
            self.record.setValue("tel_id", tel_id)

            sql_list.append(self.record.insert_query)

        return sql_list
Beispiel #30
0
class DemoGenerator(object):
    def __init__(self, database=None):
        self.length = 6

        self.record = InsertableRecord(database, TABLENAME)

    def demo_queries(self):
        """
        return a list of queries to populate a demo database
        """
        for avatar in (
            "demo_neil.svg",
            "demo_andi.svg",
            "demo_blondie.svg",
            "demo_helen.svg",
            "demo_me.svg",
            "demo_nattress.svg",
            "demo_iceman.svg",
            "demo_frog.svg",
            "demo_jellyman.svg",
            "demo_lucy.svg",
            "demo_negro.svg",
            "demo_ja.svg",
            "demo_sally.svg",
        ):
            f = QtCore.QFile(":avatars/%s" % avatar)
            f.open(QtCore.QIODevice.ReadOnly)
            ts = QtCore.QTextStream(f)

            self.record.clearValues()
            self.record.setValue("svg_data", ts.readAll())
            self.record.setValue("description", avatar)

            f.close()

            yield self.record.insert_query
Beispiel #31
0
class DemoGenerator(object):
    def __init__(self, database=None):
        self.length = 820
        self.record = InsertableRecord(database, TABLENAME)
        self.record.remove(self.record.indexOf("active"))

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        year = QtCore.QDate.currentDate().year()
        date_ = QtCore.QDate(year, 1, 1)
        finish_year = year + 3
        while date_.year() < finish_year:
            if date_.dayOfWeek() < 6:
                start = QtCore.QDateTime(date_, QtCore.QTime(13,0))
                self.record.clearValues()
                self.record.setValue('diary_id', 1)
                self.record.setValue('start', start)
                self.record.setValue('finish', start.addSecs(3600))
                self.record.setValue('etype', 'lunch')
                yield self.record.insert_query
            date_ = date_.addDays(1)

        # now an entry for an exam done on patient one yesterday
        # (or previous work day)
        self.record.clearValues()
        date_ = QtCore.QDate.currentDate().addDays(-1)
        while date_.dayOfWeek() > 6:
            date_ = date_.addDays(-1)
        start = QtCore.QDateTime(date_, QtCore.QTime(9,0))
        self.record.setValue('diary_id', 1)
        self.record.setValue('start', start)
        self.record.setValue('finish', start.addSecs(60*15))
        self.record.setValue('etype', 'appointment')
        yield self.record.insert_query
Beispiel #32
0
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
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
Beispiel #34
0
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
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
Beispiel #36
0
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('title', "Dr.")
        self.record.setValue('last_name',"McCavity")
        self.record.setValue('first_name',"Phil")
        self.record.setValue('full_name', "Dr. McCavity")
        self.record.setValue('abbrv_name',"PM")
        self.record.setValue('sex', "M")
        self.record.setValue('role',"dentist")
        self.record.setValue('dob',QtCore.QDate(1969,12,9))
        self.record.setValue('qualifications', "BDS, LDS")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 1)

        yield self.record.insert_query
        self.record.clearValues()

        ## practitioner 2
        self.record.setValue('title', "Mr.")
        self.record.setValue('last_name',"AllOut")
        self.record.setValue('first_name',"Rippem")
        self.record.setValue('full_name', "Mr Rippem AllOut")
        self.record.setValue('abbrv_name',"RA")
        self.record.setValue('sex', "M")
        self.record.setValue('role',"dentist")
        self.record.setValue('dob',QtCore.QDate(1988,11,10))
        self.record.setValue('qualifications', "BDS")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 2)

        yield self.record.insert_query
        self.record.clearValues()

        ## practitioner 3
        self.record.setValue('title', "Miss")
        self.record.setValue('last_name',"Straight")
        self.record.setValue('first_name',"Muzby")
        self.record.setValue('full_name', "Miss Muzby Straight")
        self.record.setValue('abbrv_name',"MS")
        self.record.setValue('role',"dentist")
        self.record.setValue('sex', "F")
        self.record.setValue('dob',QtCore.QDate(1990,3,10))
        self.record.setValue('qualifications', "BDS, DipOrth")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 3)

        yield self.record.insert_query
        self.record.clearValues()

        ## practitioner 4
        self.record.setValue('title', "Miss")
        self.record.setValue('last_name',"Clean")
        self.record.setValue('first_name',"Crystal")
        self.record.setValue('full_name', "Miss Clean")
        self.record.setValue('abbrv_name',"CC")
        self.record.setValue('sex', "F")
        self.record.setValue('role',"hygienist")
        self.record.setValue('dob',QtCore.QDate(1992,12,9))
        self.record.setValue('qualifications', "MRCH")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 4)

        yield self.record.insert_query

        ## practitioner 1
        self.record.clearValues()
        self.record.setValue('title', "Miss")
        self.record.setValue('last_name',"Smith")
        self.record.setValue('first_name',"Jane")
        self.record.setValue('abbrv_name',"JS")
        self.record.setValue('sex', "F")
        self.record.setValue('dob',QtCore.QDate(1969,12,9))
        self.record.setValue('qualifications', "")
        self.record.setValue('role', "receptionist")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 6)
        yield self.record.insert_query

        self.record.clearValues()
        self.record.setValue('title', "Miss")
        self.record.setValue('last_name',"Jones")
        self.record.setValue('first_name',"Emma")
        self.record.setValue('abbrv_name',"EJ")
        self.record.setValue('sex', "F")
        self.record.setValue('dob',QtCore.QDate(1969,12,9))
        self.record.setValue('qualifications', "")
        self.record.setValue('role', "nurse")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 8)
        yield self.record.insert_query

        self.record.clearValues()
        self.record.setValue('title', "Mr")
        self.record.setValue('last_name',"Baipusi")
        self.record.setValue('first_name',"Mawimba")
        self.record.setValue('abbrv_name',"MB")
        self.record.setValue('sex', "M")
        self.record.setValue('dob',QtCore.QDate(1969,12,9))
        self.record.setValue('qualifications', "")
        self.record.setValue('role', "nurse")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 5)
        yield self.record.insert_query

        self.record.clearValues()
        self.record.setValue('title', "Mr")
        self.record.setValue('last_name',"Andrews")
        self.record.setValue('first_name',"Jim")
        self.record.setValue('abbrv_name',"JA")
        self.record.setValue('sex', "M")
        self.record.setValue('dob',QtCore.QDate(1969,12,9))
        self.record.setValue('qualifications', "")
        self.record.setValue('role', "nurse")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 9)
        yield self.record.insert_query

        self.record.clearValues()
        self.record.setValue('title', "Mrs")
        self.record.setValue('last_name',"Smart")
        self.record.setValue('first_name',"Julie")
        self.record.setValue('abbrv_name',"Jules")
        self.record.setValue('sex', "F")
        self.record.setValue('dob',QtCore.QDate(1969,12,9))
        self.record.setValue('qualifications', "")
        self.record.setValue('role', "nurse")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 7)
        yield self.record.insert_query
Beispiel #37
0
class DemoGenerator(object):
    def __init__(self, database):
        self.length = 61

        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
        '''
        for name in (u"MR HARRY POTTER",
        u"MR SIRIUS BLACK",
        u"MR BLOODY BARON", u"MR TERRY BOOT",
        u"MR VINCENT CRABBE",
        u"MR DEDALUS DIGGLE",
        u"PROFESSOR ALBUS DUMBLEDORE", u"MR DUDLEY DURSLEY",
        u"MR VERNON DURSLEY",
        u"THE FAT FRIAR",
        u"MR ARGUS FILCH", u"MR JUSTIN FINCH-FLETCHLEY", u"MR SEAMUS FINNIGAN",
        u"MR NICOLAS FLAMEL", u"MR MARCUS FLINT",
        u"MR CORNELIUS FUDGE", u"MR GREGORY GOYLE",
        u"PROFESSOR RUBEUS HAGRID", u"MR TERENCE HIGGS",
        u"MR ARSENIUS JIGGER",
        u"MR DRACO MALFOY",
        u"MR NEVILLE LONGBOTTOM", u"MR NEARLY-HEADLESS NICK",
        u"MR PIERS POLKISS",
        u"MR JAMES POTTER", u"MR ADRIAN PUCEY",
        u"PROFESSOR SEVERUS SNAPE", u"MR DEAN THOMAS", u"MR TOM THE-BARTENDER",
        u"MR QUENTIN TRIMBLE",
        u"MR VINDICTUS VIRIDIAN",
        u"MR ADALBERT WAFFLING", u"MR ARTHUR WEASLEY", u"MR BILL WEASLEY",
        u"MR CHARLIE WEASLEY",
        u"MR FRED WEASLEY", u"MR GEORGE WEASLEY",
        u"MR PERCY WEASLEY", u"MR RON WEASLEY",
        u"MR OLIVER WOOD"):
            self.record.clearValues()
            title, fname, sname = name.split(" ")
            self.record.setValue("title", title)
            self.record.setValue("first_name", fname)
            self.record.setValue("last_name", sname)
            self.record.setValue("sex", 'M')
            dob = QtCore.QDate(randint(1930,2010), randint(1,12), randint(1,28))
            self.record.setValue("dob", dob)
            self.record.setValue("status", "active")
            if name in ("PROFESSOR ALBUS DUMBLEDORE", 'MR JAMES POTTER'):
                self.record.setValue("status", "deceased")
            self.record.setValue("modified_by", "demo_installer")

            yield self.record.insert_query

        for name in (u"MISS HANNAH ABBOTT",
            u"MISS BATHILDA BAGSHOT", u"MISS KATIE BELL",
            u"MISS SUSAN BONES",
            u"MISS MANDY BROCKLEHURST", u"MISS LAVENDER BROWN",
            u"MISS MILLICENT BULSTRODE",
            u"MISS DORIS CROCKFORD",
            u"MRS PETUNIA DURSLEY",
            u"THE FAT LADY",
            u"MISS MIRANDA GOSHAWK",
            u"MISS HERMIONE GRAINGER",
            u"MISS ANGELINA JOHNSON",
            u"PROFESSOR MINERVA MCGONAGALL",
            u"MRS LILY POTTER",
            u"MISS ALICIA SPINNET", u"MISS PHYLLIDA SPORE",
            u"MISS EMERIC SWITCH",
            u"MISS LISA TURPIN", u"MISS GINNY WEASLEY",
            u"MRS MOLLY WEASLEY", u"MISS BLAISE ZABINI"):
                self.record.clearValues()
                title, fname, sname = name.split(" ")
                self.record.setValue("title", title)
                self.record.setValue("first_name", fname)
                self.record.setValue("last_name", sname)
                self.record.setValue("sex", 'F')
                dob = QtCore.QDate(randint(1930,2010), randint(1,12), randint(1,28))
                self.record.setValue("dob", dob)
                self.record.setValue("status", "active")
                if name in ("MRS LILY POTTER"):
                    self.record.setValue("status", "deceased")
                self.record.setValue("modified_by", "demo_installer")

                yield self.record.insert_query
Beispiel #38
0
class DemoGenerator(object):
    def __init__(self, database):
        self.length = 61

        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
        '''
        for name in (u"MR HARRY POTTER", u"MR SIRIUS BLACK",
                     u"MR BLOODY BARON", u"MR TERRY BOOT",
                     u"MR VINCENT CRABBE", u"MR DEDALUS DIGGLE",
                     u"PROFESSOR ALBUS DUMBLEDORE", u"MR DUDLEY DURSLEY",
                     u"MR VERNON DURSLEY", u"THE FAT FRIAR", u"MR ARGUS FILCH",
                     u"MR JUSTIN FINCH-FLETCHLEY", u"MR SEAMUS FINNIGAN",
                     u"MR NICOLAS FLAMEL", u"MR MARCUS FLINT",
                     u"MR CORNELIUS FUDGE", u"MR GREGORY GOYLE",
                     u"PROFESSOR RUBEUS HAGRID", u"MR TERENCE HIGGS",
                     u"MR ARSENIUS JIGGER", u"MR DRACO MALFOY",
                     u"MR NEVILLE LONGBOTTOM", u"MR NEARLY-HEADLESS NICK",
                     u"MR PIERS POLKISS", u"MR JAMES POTTER",
                     u"MR ADRIAN PUCEY", u"PROFESSOR SEVERUS SNAPE",
                     u"MR DEAN THOMAS", u"MR TOM THE-BARTENDER",
                     u"MR QUENTIN TRIMBLE", u"MR VINDICTUS VIRIDIAN",
                     u"MR ADALBERT WAFFLING", u"MR ARTHUR WEASLEY",
                     u"MR BILL WEASLEY", u"MR CHARLIE WEASLEY",
                     u"MR FRED WEASLEY", u"MR GEORGE WEASLEY",
                     u"MR PERCY WEASLEY", u"MR RON WEASLEY",
                     u"MR OLIVER WOOD"):
            self.record.clearValues()
            title, fname, sname = name.split(" ")
            self.record.setValue("title", title)
            self.record.setValue("first_name", fname)
            self.record.setValue("last_name", sname)
            self.record.setValue("sex", 'M')
            dob = QtCore.QDate(randint(1930, 2010), randint(1, 12),
                               randint(1, 28))
            self.record.setValue("dob", dob)
            self.record.setValue("status", "active")
            if name in ("PROFESSOR ALBUS DUMBLEDORE", 'MR JAMES POTTER'):
                self.record.setValue("status", "deceased")
            self.record.setValue("modified_by", "demo_installer")

            yield self.record.insert_query

        for name in (u"MISS HANNAH ABBOTT", u"MISS BATHILDA BAGSHOT",
                     u"MISS KATIE BELL", u"MISS SUSAN BONES",
                     u"MISS MANDY BROCKLEHURST", u"MISS LAVENDER BROWN",
                     u"MISS MILLICENT BULSTRODE", u"MISS DORIS CROCKFORD",
                     u"MRS PETUNIA DURSLEY", u"THE FAT LADY",
                     u"MISS MIRANDA GOSHAWK", u"MISS HERMIONE GRAINGER",
                     u"MISS ANGELINA JOHNSON", u"PROFESSOR MINERVA MCGONAGALL",
                     u"MRS LILY POTTER", u"MISS ALICIA SPINNET",
                     u"MISS PHYLLIDA SPORE", u"MISS EMERIC SWITCH",
                     u"MISS LISA TURPIN", u"MISS GINNY WEASLEY",
                     u"MRS MOLLY WEASLEY", u"MISS BLAISE ZABINI"):
            self.record.clearValues()
            title, fname, sname = name.split(" ")
            self.record.setValue("title", title)
            self.record.setValue("first_name", fname)
            self.record.setValue("last_name", sname)
            self.record.setValue("sex", 'F')
            dob = QtCore.QDate(randint(1930, 2010), randint(1, 12),
                               randint(1, 28))
            self.record.setValue("dob", dob)
            self.record.setValue("status", "active")
            if name in ("MRS LILY POTTER"):
                self.record.setValue("status", "deceased")
            self.record.setValue("modified_by", "demo_installer")

            yield self.record.insert_query
Beispiel #39
0
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('title', "Dr.")
        self.record.setValue('last_name', "McCavity")
        self.record.setValue('first_name', "Phil")
        self.record.setValue('full_name', "Dr. McCavity")
        self.record.setValue('abbrv_name', "PM")
        self.record.setValue('sex', "M")
        self.record.setValue('role', "dentist")
        self.record.setValue('dob', QtCore.QDate(1969, 12, 9))
        self.record.setValue('qualifications', "BDS, LDS")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 1)

        yield self.record.insert_query
        self.record.clearValues()

        ## practitioner 2
        self.record.setValue('title', "Mr.")
        self.record.setValue('last_name', "AllOut")
        self.record.setValue('first_name', "Rippem")
        self.record.setValue('full_name', "Mr Rippem AllOut")
        self.record.setValue('abbrv_name', "RA")
        self.record.setValue('sex', "M")
        self.record.setValue('role', "dentist")
        self.record.setValue('dob', QtCore.QDate(1988, 11, 10))
        self.record.setValue('qualifications', "BDS")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 2)

        yield self.record.insert_query
        self.record.clearValues()

        ## practitioner 3
        self.record.setValue('title', "Miss")
        self.record.setValue('last_name', "Straight")
        self.record.setValue('first_name', "Muzby")
        self.record.setValue('full_name', "Miss Muzby Straight")
        self.record.setValue('abbrv_name', "MS")
        self.record.setValue('role', "dentist")
        self.record.setValue('sex', "F")
        self.record.setValue('dob', QtCore.QDate(1990, 3, 10))
        self.record.setValue('qualifications', "BDS, DipOrth")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 3)

        yield self.record.insert_query
        self.record.clearValues()

        ## practitioner 4
        self.record.setValue('title', "Miss")
        self.record.setValue('last_name', "Clean")
        self.record.setValue('first_name', "Crystal")
        self.record.setValue('full_name', "Miss Clean")
        self.record.setValue('abbrv_name', "CC")
        self.record.setValue('sex', "F")
        self.record.setValue('role', "hygienist")
        self.record.setValue('dob', QtCore.QDate(1992, 12, 9))
        self.record.setValue('qualifications', "MRCH")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 4)

        yield self.record.insert_query

        ## practitioner 1
        self.record.clearValues()
        self.record.setValue('title', "Miss")
        self.record.setValue('last_name', "Smith")
        self.record.setValue('first_name', "Jane")
        self.record.setValue('abbrv_name', "JS")
        self.record.setValue('sex', "F")
        self.record.setValue('dob', QtCore.QDate(1969, 12, 9))
        self.record.setValue('qualifications', "")
        self.record.setValue('role', "receptionist")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 6)
        yield self.record.insert_query

        self.record.clearValues()
        self.record.setValue('title', "Miss")
        self.record.setValue('last_name', "Jones")
        self.record.setValue('first_name', "Emma")
        self.record.setValue('abbrv_name', "EJ")
        self.record.setValue('sex', "F")
        self.record.setValue('dob', QtCore.QDate(1969, 12, 9))
        self.record.setValue('qualifications', "")
        self.record.setValue('role', "nurse")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 8)
        yield self.record.insert_query

        self.record.clearValues()
        self.record.setValue('title', "Mr")
        self.record.setValue('last_name', "Baipusi")
        self.record.setValue('first_name', "Mawimba")
        self.record.setValue('abbrv_name', "MB")
        self.record.setValue('sex', "M")
        self.record.setValue('dob', QtCore.QDate(1969, 12, 9))
        self.record.setValue('qualifications', "")
        self.record.setValue('role', "nurse")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 5)
        yield self.record.insert_query

        self.record.clearValues()
        self.record.setValue('title', "Mr")
        self.record.setValue('last_name', "Andrews")
        self.record.setValue('first_name', "Jim")
        self.record.setValue('abbrv_name', "JA")
        self.record.setValue('sex', "M")
        self.record.setValue('dob', QtCore.QDate(1969, 12, 9))
        self.record.setValue('qualifications', "")
        self.record.setValue('role', "nurse")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 9)
        yield self.record.insert_query

        self.record.clearValues()
        self.record.setValue('title', "Mrs")
        self.record.setValue('last_name', "Smart")
        self.record.setValue('first_name', "Julie")
        self.record.setValue('abbrv_name', "Jules")
        self.record.setValue('sex', "F")
        self.record.setValue('dob', QtCore.QDate(1969, 12, 9))
        self.record.setValue('qualifications', "")
        self.record.setValue('role', "nurse")
        self.record.setValue('status', "active")
        self.record.setValue('modified_by', "demo_installer")
        self.record.setValue('avatar_id', 7)
        yield self.record.insert_query
Beispiel #40
0
class DemoGenerator(object):
    def __init__(self, database):
        self.length = 44

        self.record = InsertableRecord(database, TABLENAME)

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        this_year = QtCore.QDate.currentDate().year()

        for year in (this_year-1, this_year, this_year+1, this_year+2):
            self.record.clearValues()
            self.record.setValue('date_id', QtCore.QDate(year,12,25))
            self.record.setValue('event', "Christmas Day")

            yield self.record.insert_query

            self.record.setValue('date_id', QtCore.QDate(year,12,26))
            self.record.setValue('event', "Boxing Day")

            yield self.record.insert_query

        for year in (this_year-1, this_year, this_year+1, this_year+2):
            self.record.clearValues()

            self.record.setValue('date_id', QtCore.QDate(year,1,1))
            self.record.setValue('event', "New Year's Day")

            yield self.record.insert_query

        for date, event  in (
            (QtCore.QDate(2009,4,10), "Good Friday"),
            (QtCore.QDate(2009,4,13), "Easter Monday"),
            (QtCore.QDate(2009,5,4), "Bank Holiday (UK)"),
            (QtCore.QDate(2009,5,25), "Bank Holiday (UK)"),
            (QtCore.QDate(2009,8,31), "Bank Holiday (UK)"),
            (QtCore.QDate(2009,12,27), "Bank Holiday (UK)"),
            (QtCore.QDate(2009,12,28), "Bank Holiday (UK)"),

            (QtCore.QDate(2010,1,3), "Bank Holiday (UK)"),
            (QtCore.QDate(2010,1,4), "Bank Holiday (SCOT)"),
            (QtCore.QDate(2010,4,2), "Good Friday"),
            (QtCore.QDate(2010,4,5), "Easter Monday"),
            (QtCore.QDate(2010,5,3), "Bank Holiday (UK)"),
            (QtCore.QDate(2010,5,31), "Bank Holiday (UK)"),
            (QtCore.QDate(2010,8,30), "Bank Holiday (UK)"),
            (QtCore.QDate(2010,12,27), "Bank Holiday (UK)"),
            (QtCore.QDate(2010,12,28), "Bank Holiday (UK)"),

            (QtCore.QDate(2011,1,3), "Bank Holiday (UK)"),
            (QtCore.QDate(2011,1,4), "Bank Holiday (SCOT)"),
            (QtCore.QDate(2011,4,22), "Good Friday"),
            (QtCore.QDate(2011,4,25), "Easter Monday"),
            (QtCore.QDate(2011,5,2), "Bank Holiday (UK)"),
            (QtCore.QDate(2011,5,30), "Bank Holiday (UK)"),
            (QtCore.QDate(2011,6,5), "Queen's Diamon Jubilee (UK)"),
            (QtCore.QDate(2011,8,29), "Bank Holiday (UK)"),
            (QtCore.QDate(2012,12,27), "Bank Holiday (UK)"),

            (QtCore.QDate(2012,1,2), "Bank Holiday (UK)"),
            (QtCore.QDate(2012,1,3), "Bank Holiday (SCOT)"),
            (QtCore.QDate(2012,4,6), "Good Friday"),
            (QtCore.QDate(2012,4,9), "Easter Monday"),
            (QtCore.QDate(2012,5,7), "Bank Holiday (UK)"),
            (QtCore.QDate(2012,6,4), "Bank Holiday (UK)"),
            (QtCore.QDate(2012,8,27), "Bank Holiday (UK)")):
                self.record.clearValues()

                self.record.setValue('date_id', date)
                self.record.setValue('event', event)

                yield self.record.insert_query
Beispiel #41
0
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) * 8

        self.record = InsertableRecord(database, TABLENAME)
        self.record.remove(self.record.indexOf('date_charted'))

    def fill_list(self):
        for val in self.backteeth_fill_list():
            yield val
        for val in self.frontteeth_fill_list():
            yield val

    def backteeth_fill_list(self):
        SURFACES = ("MO","O","B","OB","DO","MOD", "MODL", "MOB", "MODB", "MODBL")
        MATERIALS = ("AM", "AM", "CO", "GL", "GO", "PO")
        TEETH = SETTINGS.upper_back + SETTINGS.lower_back
        randno = len(TEETH) -1
        for i in range(4):
            tooth = TEETH[randint(0, randno)]
            surfaces = SURFACES[randint(0, len(SURFACES)-1)]
            material = MATERIALS[randint(0, len(MATERIALS)-1)]
            fill = (tooth, surfaces, material)
            yield fill

    def frontteeth_fill_list(self):
        SURFACES = ("MO","M","B","D","MOB","DOB", "OL", "L", "DB", "MB")
        MATERIALS = ("CO", "CO", "CO", "GL", "GO")
        TEETH = SETTINGS.upper_front + SETTINGS.lower_front
        randno = len(TEETH) -1
        for i in range(4):
            tooth = TEETH[randint(0, randno)]
            surfaces = SURFACES[randint(0, len(SURFACES)-1)]
            material = MATERIALS[randint(0, len(MATERIALS)-1)]
            fill = (tooth, surfaces, material)

            yield fill

    def demo_queries(self):
        '''
        return a list of queries to populate a demo database
        '''
        for patient in xrange(self.min_patient_id, self.max_patient_id+1):
            for tooth, fill, material in self.fill_list():
                self.record.clearValues()
                #set values, or allow defaults
                self.record.setValue('patient_id', patient)
                self.record.setValue('surfaces', fill)
                self.record.setValue('material', material)
                self.record.setValue('tooth', tooth)
                self.record.setValue('comment', "generated by demo_installer")

                yield self.record.insert_query