Example #1
0
    def commit_db(self, database, treatment_id):
        record = InsertableRecord(database, "treatment_teeth")

        record.setValue("treatment_id", treatment_id)
        record.setValue("tooth", self.tooth)
        record.setValue("tx_type", self.tx_type)

        query, values = record.insert_query

        q_query = QtSql.QSqlQuery(database)
        q_query.prepare(query + "returning ix")
        for value in values:
            q_query.addBindValue(value)
        q_query.exec_()

        if q_query.lastError().isValid():
            error = q_query.lastError()
            database.emit_caught_error(error)
            return False

        if self.is_fill:
            q_query.first()
            ix = q_query.value(0).toInt()[0]

            record = InsertableRecord(database, "treatment_fills")

            record.setValue("tooth_tx_id", ix)
            record.setValue("surfaces", self.surfaces)
            record.setValue("material", self.material)

            query, values = record.insert_query

            q_query = QtSql.QSqlQuery(database)
            q_query.prepare(query)
            for value in values:
                q_query.addBindValue(value)
            q_query.exec_()

            if q_query.lastError().isValid():
                error = q_query.lastError()
                database.emit_caught_error(error)
                return False
Example #2
0
    def commit_db(self, database, treatment_id):
        record = InsertableRecord(database, "treatment_teeth")

        record.setValue("treatment_id", treatment_id)
        record.setValue("tooth", self.tooth)
        record.setValue("tx_type", self.tx_type)

        query, values = record.insert_query

        q_query = QtSql.QSqlQuery(database)
        q_query.prepare(query + "returning ix")
        for value in values:
            q_query.addBindValue(value)
        q_query.exec_()

        if q_query.lastError().isValid():
            error = q_query.lastError()
            database.emit_caught_error(error)
            return False

        if self.is_fill:
            q_query.first()
            ix = q_query.value(0).toInt()[0]

            record = InsertableRecord(database, "treatment_fills")

            record.setValue("tooth_tx_id", ix)
            record.setValue("surfaces", self.surfaces)
            record.setValue("material", self.material)

            query, values = record.insert_query

            q_query = QtSql.QSqlQuery(database)
            q_query.prepare(query)
            for value in values:
                q_query.addBindValue(value)
            q_query.exec_()

            if q_query.lastError().isValid():
                error = q_query.lastError()
                database.emit_caught_error(error)
                return False
Example #3
0
    def commit_to_db(self, database):
        '''
        :param: database

        write this item to the database

        will raise an exception if item is not :func:`is_valid`

        '''

        valid, reason = self.check_valid()
        if not valid:
            raise Exception, "Invalid Treatment Item <hr />%s" % reason

        record = InsertableRecord(database, "treatments")

        record.setValue("patient_id", SETTINGS.current_patient.patient_id)
        record.setValue("om_code", self.code.code)
        record.setValue("completed", self.is_completed)
        record.setValue("px_clinician", self.px_clinician)
        record.setValue("tx_clinician", self.tx_clinician)
        record.setValue("px_date", QtCore.QDate.currentDate())
        record.setValue("tx_date", self.cmp_date)
        record.setValue("added_by", SETTINGS.user)
        record.setValue("comment", self.comment)

        query, values = record.insert_query

        q_query = QtSql.QSqlQuery(database)
        q_query.prepare(query + " returning ix")
        for value in values:
            q_query.addBindValue(value)
        q_query.exec_()

        if q_query.lastError().isValid():
            logging.error(query)
            error = q_query.lastError()
            database.emit_caught_error(error)
            return False

        q_query.first()
        ix = q_query.value(0).toInt()[0]

        for data in self.metadata:
            data.commit_db(database, ix)

        return True
Example #4
0
    def commit_to_db(self, database):
        '''
        :param: database

        write this item to the database

        will raise an exception if item is not :func:`is_valid`

        '''

        valid, reason = self.check_valid()
        if not valid:
            raise Exception, "Invalid Treatment Item <hr />%s"% reason

        record = InsertableRecord(database, "treatments")

        record.setValue("patient_id", SETTINGS.current_patient.patient_id)
        record.setValue("om_code", self.code.code)
        record.setValue("completed", self.is_completed)
        record.setValue("px_clinician", self.px_clinician)
        record.setValue("tx_clinician", self.tx_clinician)
        record.setValue("px_date", QtCore.QDate.currentDate())
        record.setValue("tx_date", self.cmp_date)
        record.setValue("added_by", SETTINGS.user)
        record.setValue("comment", self.comment)

        query, values = record.insert_query

        q_query = QtSql.QSqlQuery(database)
        q_query.prepare(query+ " returning ix")
        for value in values:
            q_query.addBindValue(value)
        q_query.exec_()

        if q_query.lastError().isValid():
            logging.error(query)
            error = q_query.lastError()
            database.emit_caught_error(error)
            return False

        q_query.first()
        ix = q_query.value(0).toInt()[0]

        for data in self.metadata:
            data.commit_db(database, ix)

        return True