~iratzio-gutierrez/oemedical/oemedical-csm

« back to all changes in this revision

Viewing changes to oemedical/oemedical_prescription_line/oemedical_prescription_line.py

  • Committer: Nhomar - Vauxoo
  • Date: 2013-10-23 03:02:27 UTC
  • mfrom: (83.1.120 openobject-oemedical)
  • Revision ID: nhomar@gmail.com-20131023030227-dwgs8z939r2f5al7
[MERGE] Federicos branch, several change and finishing a lot of concepts, sorry for the delay. Thanks, Note: See the commit log for the origin of the merge for more details.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
class OeMedicalPrescriptionLine(osv.Model):
27
27
    _name = 'oemedical.prescription.line'
28
28
 
 
29
 
 
30
 
 
31
    def _get_medicament(self, cr, uid, ids, name, args, context=None):
 
32
        print '_get_medicament', name, args, context, ids
 
33
        medication_obj = self.pool.get('oemedical.medication.template')
 
34
        result = {}
 
35
 
 
36
#        if name == 'form':
 
37
#            result = {'value': { 
 
38
#                        'form' : medication_obj.browse(cr, uid, medication, context = None).form.id ,
 
39
#                         } }
 
40
        return result
 
41
 
 
42
#    def _get_dose(self, cr, uid, ids, field_name, arg, context=None):
 
43
#        res = {}
 
44
#        for record in self.browse(cr, uid, ids, context=context):
 
45
#            res[record.id] = record.template.dose
 
46
#        return res
 
47
 
 
48
#    def _get_frecuency(self, cr, uid, ids, field_name, arg, context=None):
 
49
#        res = {}
 
50
#        for record in self.browse(cr, uid, ids, context=context):
 
51
#            res[record.id] = 1
 
52
#        return res
 
53
 
 
54
 
 
55
#    def _get_duration(self, cr, uid, ids, field_name, arg, context=None):
 
56
#        res = {}
 
57
#        for record in self.browse(cr, uid, ids, context=context):
 
58
#            res[record.id] = 1
 
59
#        return res
 
60
 
 
61
#    def _get_qty(self, cr, uid, ids, field_name, arg, context=None):
 
62
#        res = {}
 
63
#        for record in self.browse(cr, uid, ids, context=context):
 
64
#            res[record.id] = 1
 
65
#        return res
 
66
 
 
67
#    def _get_frecuency_unit(self, cr, uid, ids, field_name, arg, context=None):
 
68
#        res = {}
 
69
#        return res
 
70
 
 
71
#    def _get_admin_times(self, cr, uid, ids, name, args, context=None):
 
72
#        res = {}
 
73
#        return res
 
74
 
 
75
#    def _get_start_treatment(self, cr, uid, ids, field_name, arg, context=None):
 
76
#        ops = self.browse(cr, uid, ids, context=context)
 
77
#        res = {}
 
78
#        for op in ops:
 
79
#            res[op.id] = False
 
80
#        return res
 
81
 
 
82
#    def _get_end_treatment(self, cr, uid, ids, field_name, arg, context=None):
 
83
#        ops = self.browse(cr, uid, ids, context=context)
 
84
#        res = {}
 
85
#        for op in ops:
 
86
#            res[op.id] = False
 
87
#        return res
 
88
 
 
89
#    def _get_duration_period(self, cr, uid, ids, field_name, arg, context=None):
 
90
#        res = {}
 
91
#        for line in self.browse(cr, uid, ids, context=context):
 
92
#            res[line.id] = 'days'
 
93
#        return res
 
94
 
 
95
    def onchange_template(self, cr, uid, ids, medication, context=None):
 
96
        medication_obj = self.pool.get('oemedical.medication.template')
 
97
        res = {}
 
98
        res = {'value': { 
 
99
                        'indication' : medication_obj.browse(cr, uid, medication, context = None).indication.id ,
 
100
                        'form' : medication_obj.browse(cr, uid, medication, context = None).form.id ,
 
101
                        'route' : medication_obj.browse(cr, uid, medication, context = None).route.id ,
 
102
                        'dose' : medication_obj.browse(cr, uid, medication, context = None).dose ,
 
103
                        'dose_unit' : medication_obj.browse(cr, uid, medication, context = None).dose_unit.id ,
 
104
                        'qty' : medication_obj.browse(cr, uid, medication, context = None).qty ,
 
105
                        'admin_times' : medication_obj.browse(cr, uid, medication, context = None).admin_times ,
 
106
                        'common_dosage' : medication_obj.browse(cr, uid, medication, context = None).common_dosage.id ,
 
107
                        'frequency' : medication_obj.browse(cr, uid, medication, context = None).frequency ,
 
108
                        'frequency_unit' : medication_obj.browse(cr, uid, medication, context = None).frequency_unit ,
 
109
                         } }
 
110
        return res
 
111
 
 
112
 
29
113
    _columns = {
30
 
        'refills': fields.integer(string='Refills #'),
31
 
        'prescription_order_id': fields.many2one(
32
 
            'oemedical.prescription.order',
33
 
            string='Prescription ID', ),
 
114
        'name': fields.many2one('oemedical.prescription.order', string='Prescription ID', ),
 
115
        'template': fields.many2one('oemedical.medication.template', string='Medication', ),
 
116
        'indication': fields.many2one('oemedical.pathology', string='Indication', help='Choose a disease for this medicament from the disease list. It'\
 
117
                        ' can be an existing disease of the patient or a prophylactic.'),
34
118
        'allow_substitution': fields.boolean(string='Allow substitution'),
35
 
        'prnt': fields.boolean(string='Print',
36
 
                help='Check this box to print this line of the prescription.'),
 
119
        'prnt': fields.boolean(string='Print', help='Check this box to print this line of the prescription.'),
 
120
        'quantity': fields.integer(string='Units',  help="Number of units of the medicament. Example : 30 capsules of amoxicillin"),
 
121
        'active_component': fields.char(size=256, string='Active component', help='Active Component'),
 
122
        'start_treatment': fields.datetime(string='Start'),
 
123
        'end_treatment': fields.datetime(string='End'),
 
124
        'dose' : fields.float('Dose', digits=(16, 2), help="Amount of medication (eg, 250 mg) per dose"),
 
125
        'dose_unit': fields.many2one('product.uom', string='Dose Unit', help='Amount of medication (eg, 250 mg) per dose'),
 
126
        'qty' : fields.integer('x'),
 
127
        'form': fields.many2one('oemedical.drug.form', string='Form', help='Drug form, such as tablet or gel'),
 
128
        'route': fields.many2one('oemedical.drug.route', string='Route', help='Drug form, such as tablet or gel'),
 
129
        'common_dosage': fields.many2one('oemedical.medication.dosage', string='Frequency', help='Drug form, such as tablet or gel'),
 
130
            'admin_times' : fields.char('Admin Hours', size=255),
 
131
        'frequency' : fields.integer('Frequency'),
 
132
        'frequency_unit': fields.selection([
 
133
                                (None, ''),
 
134
                                ('seconds', 'seconds'),
 
135
                                ('minutes', 'minutes'),
 
136
                                ('hours', 'hours'),
 
137
                                ('days', 'days'),
 
138
                                ('weeks', 'weeks'),
 
139
                                ('wr', 'when required'),
 
140
                                    ],'Unit'),
 
141
        'frequency_prn': fields.boolean(string='Frequency prn', help=''),
 
142
        'duration' : fields.integer('Treatment duration'),
 
143
        'duration_period': fields.selection([
 
144
                                (None, ''),
 
145
                                ('minutes', 'minutes'),
 
146
                                ('hours', 'hours'),
 
147
                                ('days', 'days'),
 
148
                                ('months', 'months'),
 
149
                                ('years', 'years'),
 
150
                                ('indefinite', 'indefinite'),
 
151
                                    ],'Treatment period'),
 
152
        'refills': fields.integer(string='Refills #'), 
37
153
        'review': fields.datetime(string='Review'),
38
 
        'short_comment': fields.char(size=256, string='Comment',
39
 
                                     help='Short comment on the specific drug'),
40
 
        'template': fields.many2one('oemedical.medication.template',
41
 
                                    string='Medication Template', ),
42
 
        'quantity': fields.integer(string='Quantity'),
 
154
        'short_comment': fields.char(size=256, string='Comment', help='Short comment on the specific drug'),
 
155
 
43
156
    }
44
157
 
 
158
    _defaults = {
 
159
        'prnt' : True,
 
160
 
 
161
                }
 
162
 
 
163
 
45
164
OeMedicalPrescriptionLine()
46
165
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: