Skip to content

Commit

Permalink
[IMP] connector_carepoint: Void Rx handling
Browse files Browse the repository at this point in the history
* Add handling for voided prescriptions
* Simplify medical.prescription.order mappers
  • Loading branch information
lasley committed Oct 28, 2016
1 parent 4a5c08c commit 6e9e335
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions connector_carepoint/models/medical_prescription_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
ExportMapper,
none,
convert,
backend_to_m2o,
)
from ..unit.backend_adapter import CarepointCRUDAdapter
from ..unit.mapper import CarepointImportMapper
Expand Down Expand Up @@ -70,30 +71,24 @@ class MedicalPrescriptionOrderImportMapper(CarepointImportMapper):

direct = [
('start_date', 'date_prescription'),
('rx_id', 'carepoint_id'),
(backend_to_m2o('pat_id', binding='carepoint.medical.patient'),
'patient_id'),
(backend_to_m2o('md_id', binding='carepoint.medical.physician'),
'physician_id'),

]

@mapping
def patient_id(self, record):
binder = self.binder_for('carepoint.medical.patient')
patient_id = binder.to_odoo(record['pat_id'])
return {'patient_id': patient_id}

@mapping
def physician_id(self, record):
binder = self.binder_for('carepoint.medical.physician')
physician_id = binder.to_odoo(record['md_id'])
return {'physician_id': physician_id}
def active(self, record):
return {'active': record['status_cn'] == 3}

@mapping
def partner_id(self, record):
binder = self.binder_for('carepoint.carepoint.store')
store = binder.to_odoo(record['store_id'], browse=True)
return {'partner_id': store.pharmacy_id.id}

@mapping
def carepoint_id(self, record):
return {'carepoint_id': record['rx_id']}


@carepoint
class MedicalPrescriptionOrderImporter(CarepointImporter):
Expand All @@ -116,6 +111,7 @@ class MedicalPrescriptionOrderExportMapper(ExportMapper):
direct = [
(convert('date_prescription', fields.Datetime.from_string),
'start_date'),
('carepoint_id', 'pat_id'),
(none('qty'), 'written_qty'),
(none('frequency'), 'freq_of_admin'),
(none('quantity'), 'units_per_dose'),
Expand All @@ -125,8 +121,9 @@ class MedicalPrescriptionOrderExportMapper(ExportMapper):
]

@mapping
def pat_id(self, record):
return {'pat_id': record.carepoint_id}
def status_cn(self, record):
if not record.active:
return {'status_cn': 3}


@carepoint
Expand Down

0 comments on commit 6e9e335

Please sign in to comment.