<commit_before># -*- coding: utf-8 -*-
import logging
from datetime import datetime, timedelta, date
from openerp.osv import fields, osv, orm
from openerp.tools.translate import _
import arrow
import inspect
import numpy as np
import pytz
import time
import rt5100 as rt

_logger = logging.getLogger(__name__)

class oph_motive(orm.Model):
    """Motives for a crm.meeting"""
    _name = 'oph.motive'

    _columns = {
              'name':fields.char('Name', size = 32,),
              'comment':fields.text('Comment'),
              }
    _sql_constraints = [
                      ('name_uniq', 'unique(name)', 'The motive must be unique.'),
                      ]

class crm_meeting(orm.Model):
    _inherit = "crm.meeting"
    _description = "consultations meetings"
    _order = "date asc"

    def get_rt5100(self, cr, uid, ids, context = None):
        """Get the datas from the RT-5100
        
        """
        _logger.info("in ge_rt5100 method of class crm.meeting")
        _logger.info('context:{}')
        _logger.info("check that I can import methods from rt5100")
        _logger.info('cuttingDict:%s' % (rt.cuttingDict,))

        finalDict = rt.map2odoofields()
        _logger.info("finalDict:%s", finalDict)
        #

        for va_type in finalDict.keys():
            records = self.browse(cr, uid, ids, context)
            for record in records:
                _logger.info('record.name:%s', record.name)
                _logger.info('record.partner_id:%s', record.partner_id)
                _logger.info('record.meeting_id:%s', record.id)
                val_measurement = {'va_type':va_type,
                                   'type_id':2,  # 2 is the ID for all about refraction and visual acuity.
                                   'meeting_id':record.id,
                                   }
                _logger.info('val_measurement:%s', val_measurement)
                _logger.info('LOOK AT :finalDict[va_type]:%s', finalDict[va_type])

                for i in finalDict[va_type]:
                    _logger.info('LOOK AT i:%s', i)
                    val_measurement.update(i)
                    _logger.info('val_measurement:%s', val_measurement)
                _logger.info('val_measurement before near vision values:%s', val_measurement)

                # compute the field sph_near_vision, cyl_near_vision, axis_near_vision
                # and add those new values in FinalDict
                # for va_type == Rx
                if va_type == 'Rx':
                    _logger.info('va_type:%s', va_type)
                    if val_measurement.get('cyl_od') is not None:
                        val_measurement.update({'cyl_near_or':val_measurement.get('cyl_od')})
                    if val_measurement.get('axis_od') is not None:
                        val_measurement.update({'axis_near_or':val_measurement.get('axis_od')})
                    if val_measurement.get('cyl_os') is not None:
                        val_measurement.update({'cyl_near_os':val_measurement.get('cyl_os')})
                    if val_measurement.get('axis_os') is not None:
                        val_measurement.update({'axis_near_os':val_measurement.get('axis_os')})
                    
                    # fix axis set to None for axix = 0°
                    # set axis back to 0 when cyl is not None
                    #OR
                    if val_measurement.get('cyl_od') is not None and val_measurement.get('axis_od') is None:
                        val_measurement.update({'axis_od':'0'})
                    #OS
                    if val_measurement.get('cyl_os') is not None and val_measurement.get('axis_os') is None:
                        val_measurement.update({'axis_os':'0'})
                        
                    # compute sph_near
                    # OR
                    if val_measurement.get('add_od')is not None:
                        if val_measurement.get('sph_od') is not None:
                            _logger.info("val_measurement.get('sph_od') is:%s", val_measurement.get('sph_od'))
                            sph_near = float(val_measurement.get('add_od')) + float(val_measurement.get('sph_od'))
                            if sph_near < 0:
                                sph_near = str(sph_near)
                            else:
                                sph_near = '+' + str(sph_near)
                        else:
                            sph_near = str(val_measurement.get('add_od'))
                        val_measurement.update({'sph_near_or':sph_near})
                    # OG
                    if val_measurement.get('add_os'):<commit_msg>fix set to zero should not<commit_after># -*- coding: utf-8 -*-
import logging
from datetime import datetime, timedelta, date
from openerp.osv import fields, osv, orm
from openerp.tools.translate import _
import arrow
import inspect
import numpy as np
import pytz
import time
import rt5100 as rt

_logger = logging.getLogger(__name__)

class oph_motive(orm.Model):
    """Motives for a crm.meeting"""
    _name = 'oph.motive'

    _columns = {
              'name':fields.char('Name', size = 32,),
              'comment':fields.text('Comment'),
              }
    _sql_constraints = [
                      ('name_uniq', 'unique(name)', 'The motive must be unique.'),
                      ]

class crm_meeting(orm.Model):
    _inherit = "crm.meeting"
    _description = "consultations meetings"
    _order = "date asc"

    def get_rt5100(self, cr, uid, ids, context = None):
        """Get the datas from the RT-5100
        
        """
        _logger.info("in ge_rt5100 method of class crm.meeting")
        _logger.info('context:{}')
        _logger.info("check that I can import methods from rt5100")
        _logger.info('cuttingDict:%s' % (rt.cuttingDict,))

        finalDict = rt.map2odoofields()
        _logger.info("finalDict:%s", finalDict)
        #

        for va_type in finalDict.keys():
            records = self.browse(cr, uid, ids, context)
            for record in records:
                _logger.info('record.name:%s', record.name)
                _logger.info('record.partner_id:%s', record.partner_id)
                _logger.info('record.meeting_id:%s', record.id)
                val_measurement = {'va_type':va_type,
                                   'type_id':2,  # 2 is the ID for all about refraction and visual acuity.
                                   'meeting_id':record.id,
                                   }
                _logger.info('val_measurement:%s', val_measurement)
                _logger.info('finalDict[va_type]:%s', finalDict[va_type])

                for i in finalDict[va_type]:
                    _logger.info('i:%s', i)
                    val_measurement.update(i)
                    _logger.info('val_measurement:%s', val_measurement)
                
                
                # fix axis set to None for axix = 0°
                    # set axis back to 0 when cyl is not None
                    #OR
                    _logger.info('In the fix for OR')           
                    if val_measurement.get('cyl_od') is not None and val_measurement.get('axis_od') is None:
                        val_measurement.update({'axis_od':'0'})
                    #OS
                    _logger.info('In the fix for OS')
                    if val_measurement.get('cyl_os') is not None and val_measurement.get('axis_os') is None:
                        val_measurement.update({'axis_os':'0'})

                # compute the field sph_near_vision, cyl_near_vision, axis_near_vision
                # and add those new values in FinalDict
                # for va_type == Rx
                _logger.info('val_measurement before near vision values:%s', val_measurement)
                if va_type == 'Rx':
                    _logger.info('va_type:%s', va_type)
                    if val_measurement.get('cyl_od') is not None:
                        val_measurement.update({'cyl_near_or':val_measurement.get('cyl_od')})
                    if val_measurement.get('axis_od') is not None:
                        val_measurement.update({'axis_near_or':val_measurement.get('axis_od')})
                    if val_measurement.get('cyl_os') is not None:
                        val_measurement.update({'cyl_near_os':val_measurement.get('cyl_os')})
                    if val_measurement.get('axis_os') is not None:
                        val_measurement.update({'axis_near_os':val_measurement.get('axis_os')})
                    
                    
                        
                    # compute sph_near
                    # OR
                    if val_measurement.get('add_od')is not None:
                        if val_measurement.get('sph_od') is not None:
                            _logger.info("val_measurement.get('sph_od') is:%s", val_measurement.get('sph_od'))
                            sph_near = float(val_measurement.get('add_od')) + float(val_measurement.get('sph_od'))
                            if sph_near < 0:
                                sph_near = str(sph_near)
                            else:
                                sph_near = '+' + str(sph_near)
                        else:
                            sph_near = str(val_measurement.get('add_od'))
                        val_measurement.update({'sph_near_or':sph_near})
                    # OG
                    if val_measurement.get('add_os'):
{'fraction_non_alphanumeric': 0.10470265710670604, 'fraction_numerical': 0.0065373260227752005, 'mean_word_length': 1.5830610021786493, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2471844', 'n_tokens_mistral': 2841, 'n_tokens_neox': 2613, 'n_words': 566}