How to access customer account type in reminder letter?

I want to be able to change the content (specifically the letterhead) in a reminder letter depending on the customer's account type. [All our house-call customers have a specific account type.]  When doing a reminder run, one cannot select reminders by account type, so the only way I can see to change the letterhead is to access the account type and then change what is printed as a function of this.

I have had a look at http://www.openvpms.org/forum/correct-syntax-retreiving-customerpatient-id and guessed that openvpms:lookup(openvpms:get(., 'customer.objectReference'), 'type') might do the trick but no joy.

I it possible to access the account type, and if so how?

Regards, Tim G

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: How to access customer account type in reminder letter?

For a single reminder, the reminder template is supplied with an instance of act.patientReminder, so you have access to everything specified in the act.patientReminder archetype.

To get the patient you use:

 openvpms:get(.,'patient.entity')

You can use the result of this to get customer using party:getPatientOwner() i.e:

 party:getPatientOwner(openvpms:get(.,'patient.entity'))

Once you have the customer, you can get their account type code using:

openvpms:get(party:getPatientOwner(openvpms:get(.,'patient.entity')), "type.code")

You can probably leave it at that, unless you want to get the lookup name. In this case you would do:

 openvpms:lookup(party:getPatientOwner(openvpms:get(.,'patient.entity')), "type") 

In a grouped reminder template, you get the customer in the supplied data so you just need:

 openvpms:get(openvpms:get(., "customer"), "type.code")

-Tim A

Re: How to access customer account type in reminder letter?

Tim - thanks for your quick response and the explanation.  However, it doesn't work.  Below is the snippet showing the iReport screen. This is a hack of the standard Patient Reminders Report altered to generate address labels. This works fine except for the Type field (ie if I remove this, then it runs happily).  This means that the syntax [openvpms:get(party:getPatientOwner(.),'initials')] works happily - however [openvpms:get(party:getPatientOwner(.),'type')] does not.  The error message is:

Failed to generate report: Error evaluating expression :
Source text : $F{[openvpms:get(party:getPatientOwner(.),'type')]}

If I switch to the longer syntax, I get:

Failed to generate report: Error evaluating expression :
Source text : $F{[openvpms:get(party:getPatientOwner(openvpms:get(.,'patient.entity')), 'type')]}
 

Conclusion: one can access initials, lastName, title etc using this syntax, but not type. Is this possibly because initials etc are in the details path but type is in the classifications path?

Regards, Tim G

Re: How to access customer account type in reminder letter?

I've updated my answer; it was missing the code node.

-Tim A

Re: How to access customer account type in reminder letter?

Thanks Tim - that did the trick.  I have the reminder mailing labels printing happily with a tag on the bottom saying that this is for a Creature Comforts customer (and no tag for a normal customer) so the staff can select the correct postcard to put it on.  I have yet to do the actual reminder letters (switching letterhead depending on account type) but I don't anticipate any problem.

Regards, Tim

Syndicate content