Conditional Text Within OpenVPMS
Submitted by EastsideVetEmerg on Wed, 03/07/2013 - 01:06
Hi,
With the coming improvements to Macros it occured to me that much of the editing we currently do in OpenOffice could be done in OpenVPMS saving opening up another program as well as the problems that currently occur if extensive changes are made in OpenOffice/Word and a file needs to be re-saved into OpenVPMS.
Basically one of the things we do for discharge statements is set up fields in OpenOffice that refer to he/she or him/her depending on if a patient is Male or Female.
Is there any way we could get this sort of conditional formatting into OpenVPMS?
Thanks,
Adrian
Re: Conditional Text Within OpenVPMS
With report macros, you can just get Word/Open Office to do the conditional formatting for you.
For Word, see http://office.microsoft.com/en-us/word-help/examples-of-if-fields-HP0051...
For OpenOffice, see http://www.openvpms.org/forum/personal-pronouns-letters#comment-4866
For general macros, you can do conditional formatting, but its painful. (See http://www.openvpms.org/documentation/csh/1.7/reference/xpath )
If you're interested, I'll set up a project to make conditional formatting simpler through extension functions e.g.:
Evaluates some-condition, and if true, returns the result of then-expression.
E.g.:
cond:if(openvpms:get("sex") = 'Male', 'he')
Evaluates some-condition, and if true, returns the result of then-expression, otherwise returns the result of else-expression.
E.g.:
cond:if(openvpms:get("sex") = 'Male', 'he', 'she')
-Tim
Re: Conditional Text Within OpenVPMS
Hi Tim,
Thanks for that. Yes, I know how to do this via OO and Word. I am keen to see it done in OpenVPMS though as this means less stuffing around in OO.
I looked at the x-path page and my eyes began to water... This is too complex for me and I think for most general computer users.
Could you please set up this conditional formating project.
A few questions if I may:
1) Is is possible to simplify even further... e.g. cond:if(@patientSex = 'Male', 'he')
2) Can part of the project please be documentation.
3) Can we include simple calculation functions? Ideally would like OVPMS to be able to calculate Body Surface Area from weight (this would need to be able to multiply, divide and do "to the power of". Multiplication functions would also mean macros could be created to automatically calculate dose rates and the such for particular drugs/patients. Or is this a seperate project?
Re: Conditional Text Within OpenVPMS
Yep - xpath does require a bit of background knowledge.
To answer your questions:
1). It may be possible to simplify the expression further. If so, the expression would be:
I need to investigate however.
2). Sure.
3). What is the calculation? You can already multiply and divide.
For complex macros, I think its better to write a custom function. While its possible to do craft them using smaller math functions, they can get long and unwieldy.
-Tim
Re: Conditional Text Within OpenVPMS
Hi Tim,
Thank you.
The calculation for BSA depends on if you are calculating for a dog or cat (or other species) and what reference you read.
How do you multiply and divide?
Thanks,
Adrian
Re: Conditional Text Within OpenVPMS
To express it as a macro, you could have a macro expression:
If you give it a code @dogbsa, you would use it like:
5.1@dogbsa
This is assuming you are entering kilograms instead of grams.
You will end up with a lot of decimal places. To round to the nearest whole number put the expression in a round() i.e.:
You could do something similar in reports, except that there is no straight forward way of getting the patient's current weight as a numeric. This is where a dedicated function is much better.
-Tim
Re: Conditional Text Within OpenVPMS
Hi,
That is great. I will give it a go!
I don't entirely understand what you mean there is no straight forward way of getting a patient's current weight?
Can there not be a function @weight(kg) that draws the last weight entered for the patient?
Can this fit under the http://www.openvpms.org/project/make-current-context-available-macros project
Adrian
Re: Conditional Text Within OpenVPMS
There would need to be a few functions developed to do what you want to do, and do it efficiently:
In a macro, you would use these as follows:
-Tim
Re: Conditional Text Within OpenVPMS
Hi,
It seems this would be a good idea? It would allow weights to be used for functions both within OpenVPMS and presumably OO and Word as well?
In futureland surely it would also enable things like smart alerts when patients weights changed beyond certain parameters, allow graphing/charting of weights, etc?
Re: Conditional Text Within OpenVPMS
Yes - all of these functions could be used within OO and Word.
If you're happy with this, I'll create a project for them. I'll also include the 2 functions from http://www.openvpms.org/project/datetime-formatting-functions . They are useful, but aren't getting much interest funding-wise on their own.
-Tim
Re: Conditional Text Within OpenVPMS
Tim wrote:
>Yes - all of these functions could be used within OO and Word.
I must've missed this project:
does this mean I can get values in OO for vaccination certificates next vax due by using
date:format(value, "MMM yyyy") for "Sep 2014" and/or
date:format(value, "MMMMM yyyy") for "September 2014" ?
If so, I'll stump up the whole $355 (plus GST).
Yuri.
Re: Conditional Text Within OpenVPMS
Yep. There is a link on the http://www.openvpms.org/project/datetime-formatting-functions project page where you can pledge funding.
Regards,
Tim
Re: Conditional Text Within OpenVPMS
Hi,
Can we please get the weight formatting included in this project please and set up the conditional formatting project.
Thanks,
Adrian
Re: Conditional Text Within OpenVPMS
As the date functions project is now funded, I've put the functions discussed above into http://www.openvpms.org/project/condition-and-patient-weight-report-func...
I've had a look at what would be required to simplify the expressions, but at this stage I don't think its possible without breaking backwards compatibility.
-Tim