1.7A 5145 expr function question

I am trying to build a schedule view that shows the patient breed. I have

 concat(openvpms:get(., 'clinician.name'),': ',openvpms:get(., 'patient.name'),' ',openvpms:get(., 'customer.name'),' [',openvpms:lookup(openvpms:get(., "patient.objectReference"), "breed"),']','\n', openvpms:get(.,'scheduleType.name'), ' - ', openvpms:get(.,'act.reasonName'),' ', openvpms:get(.,'waiting'))  

which works wonderfully when I have a patient and displays like

However, when there is no patient - just a customer, I get an expression error - because although openvpms:get(.,'patient.name') returns null when there is no patient, the openvpms:lookup(openvpms:get(.,"patient.objectReference"),"breed") fails.

The new expr:var functions would seem to potentially offer a solution - however the first argument appears to have to be a variable name, not the above breed lookup.

Is there a way of writing the expression so that it will not fail when there is no patient?

Regards, Tim G

Comment viewing options

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

Re: 1.7A 5145 expr function question

The expr:var function is only provided to do variable evaluation. It won't help in this instance.

The openvpms:lookup function needs to be changed so that if a null is supplied, it returns null rather than throwing an exception.

Raised as https://openvpms.atlassian.net/browse/OBF-224

-Tim A

Re: 1.7A 5145 expr function question

Tim - it's a bit more general than this - openvpms:get also needs the 'if a null is supplied, it returns null rather than throwing an exception' treatment.

This would address the case where you want something that is not a lookup - eg the id using
openvpms:get(openvpms:get(., "patient.objectReference"), "id")

Note that I don't think that one really needs the default value facility you specified in OBF-224 [unless its really easy to do], after all openvpms:get(., 'patient.name')  does not have a variant openvpms:get(., 'patient.name',defaultvalue) - we are quite happy that it returns null if there is no patient.

Can you extend OBF-224 to also cover openvpms:get and tell me how much to get this done now.

[Note that I don't need openvpms:get fixed - though I do need openvpm:lookup fixed - but it seems silly not to address both problems.]

Regards, Tim G

Re: 1.7A 5145 expr function question

I'll implement it in the next day or so.

Regards,

Tim

Syndicate content