Hi everyone,
     To automate the fetch of the insurance plan on the health services
form I proposed to update the on_change_patient function and add an
on_change_insurance_holder. I think it will be a time saving for the
end-user.

      At the most cases the patient record has a current insurance field,
once you select the patient on the health services the insurance holder
will be selected like the party of the patient (like it currently does)
plus it will select and fill the patient current insurance as the insurance
plan field.

      If the insurance holder is not the party of the patient, then it will
blank the insurance plan field.

     It could be something like this:

    @fields.depends('patient', 'insurance_holder')
    def on_change_patient(self):
        if self.patient and not self.insurance_holder:
            self.insurance_holder = self.patient.name
            self.insurance_plan = \
                self.patient.current_insurance and
self.patient.current_insurance.id
        else:
            self.insurance_holder = None
            self.insurance_plan = None

    @fields.depends('insurance_holder', 'patient')
    def on_change_insurance_holder(self):
        if not self.insurance_holder or \
            self.insurance_holder and self.patient and \
            self.insurance_holder.id != self.patient.name.id :
            self.insurance_plan = None
        if self.insurance_holder and self.patient and \
            self.insurance_holder.id == self.patient.name.id:
            self.insurance_plan = \
                self.patient.current_insurance and \
                self.patient.current_insurance.id

   Regards
       Francisco

Reply via email to