New fields for prescriptions on labels?

The staff love the new prescription functionality in 1.7. They've asked that I put the number of refills remaining on the medication label. Do we have a way to do this currently? I didn't see anything in the label jrxml, but might be missing it.

Cheers, Paul

Comment viewing options

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

Re: New fields for prescriptions on labels?

See the attached. I've modified the Prescription.odt to include the Times dispensed, and Dispenses remaining.

 

AttachmentSize
Prescription.odt 17.96 KB

Re: New fields for prescriptions on labels?

 

Thanks Tim,

This is the prescription form (ODT)... I'm thinking of the medication label (jrxml). Not entirely sure how to translate the ODT fields (repeats and get(.,'dispensing')) to jrxml.  Will this just pass through as "<field name="repeats" class="java.math.BigDecimal"/>"? I imagine if that works, I could do a "<variable ..... openvpms:get(...dispensing...)...>" or something like this.

Cheers, Paul

Re: New fields for prescriptions on labels?

Paul - I am 99.9% certain that what you want is not possible.  The problem is that the label is printed from the archetype act.patientMedication and the prescription from act.patientPrescription.  To do what you want (include the repeat info on the label) requires accessing the act.patientPrescription information.

From the act.patientMedication info one can get the patient and medication, but this does not lead directly to the prescription.

I think that the only way to do what you want is for Tim A to add an optional prescription field to act.patientMedication which if present points at the prescription.  You could the get the info you want as prescription.dispensing and prescription.repeats+1-prescription.dispensing

Regards, Tim G

[Isn't it amazing - no matter how carefully how one specs a facility, there is always some useful feature that gets forgotten until the facility is actually in use in real life.]

Re: New fields for prescriptions on labels?

Okay. Thanks Tim. Let's just treat as an enhancement request then. We'll be just fine without it for now. It's still useful for the staff to have it in the system, just not as useful to the end customer.

Cheers, Paul

Re: New fields for prescriptions on labels?

Its doable with an archetype change. The link between the prescription and medication is there, just not accessible at present.

Modify act.patientMedication.adl to add the following:

         <node name="prescription" path="/targetActRelationships" type="java.util.HashSet" baseName="TargetActRelationship"
              minCardinality="0" maxCardinality="1" hidden="true" filter="actRelationship.patientPrescriptionMedication"/>

This will enable to you to refer to the prescription within the label template.

In the label template, define a new field:

 $F{[openvpms:get(.,'prescription.source.repeats') + 1  - count(openvpms:get(.,'prescription.source.dispensing'))]} 

This will always be 1 if the medication isn't linked to a prescription so you'll need to suppress it if:

count(openvpms:get(.,'prescription.source.dispensing'))

is 0.

-Tim A

Re: New fields for prescriptions on labels?

Tim - I finally got around to incorporating the above.  As per the attached jrxml, I did things slightly differently by defining two new fields, one for the repeats and one for the dispense count.  The repeats works happily [indicating that the archetype is modified to pick up the prescription] but as you can see below, it does not like the count() function.  Although count() is not listed in http://www.openvpms.org/documentation/csh/1.7/reference/xpath, count() is an xpath 1.0 function and its omission from the CSH page is my fault for dropping it as one of the "Others are defined but are not relevant to our use."

What am I doing wrong?  Note that I am aiming from something like

however the attached jrxml is currently set to just print the dispensed count while I am debugging.

Regards, Tim G

 

AttachmentSize
Label-Dymo.jrxml 6.57 KB

Re: New fields for prescriptions on labels?

The underlying error is:

 Caused by: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

This is because the field is defined as a java.lang.Integer, but evaluates to a Double. You can change it to java.lang.Number and not worry about the concrete type.

Re: New fields for prescriptions on labels?

Thanks Tim - I just learnt two things: a) what the Number type is for; b) always read all of the stack dump. I now have things running.

However, because of the way the dispense count is being done, the information displayed on the label changes.

  • if the label is printed as the item is being dispensed, then count() will be zero the first time the item is dispensed [because the dispensing record has not been written at the time the New Medication screen is presented with its Print Label button] - so on the first dispense it is not possible (in the jrxml code) to tell the difference between a medication with a perscription and one without
  • if the label is printed from the Investigations tab, then the dispensing record has been created and the jrxml code can tell the difference between a medication with a perscription and one without, however, the labels for each of the individual dispenses will all see the same dispense count

Given the above, I think it best to discard the idea of putting the prescription count on the label.

One can improve the 'prescription visibility' by adjusting the description field for the act.patientMedication archetype so as to show which medications resulted from a prescription.

Changing this to

 concat(openvpms:get(.,'product.entity.name'), ' - Qty: ',/details/quantity,' Expiry: ', expr:if(boolean(/activityEndTime), date:formatDate(/activityEndTime), 'None'),expr:if(count(openvpms:get(.,'prescription.source.dispensing'))>0,' *P')) 

gets you the following (where the Baytril 150Mg was not a result of a prescription, but the others were):

If I try to be more sexy and display the repeat and dispense counts, then the derived field length exceeds 255 characters. The only way past this would be to provide a function to get the data - ie party:getDispensed(act) returns null if there was no prescription and say D/R (where D is the dispensed count and R the number of repeats) if there was.

Note that this approach (ie showing the D/R information rather than just the *P flag) is not immune from problems. If the medication record is ever edited, then the description will be recalculated and will now show the current dispense count rather than that at the time the medication record was created.

Hence it is probably better just to stay with the *P approach - this being a hint to staff that there is a prescription involved and they should look at the prescription tab for further information.

Regards, Tim G

Re: New fields for prescriptions on labels?

The other thing you can do is check if the label has been saved. If the id node is -1, it hasn't, and so prescription information should be suppressed.

If you are reprinting a label, I don't think it matters that the dispense count has changed since the time it was originally dispensed. Its probably desirable that it reflects the latest dispense count.

Re: New fields for prescriptions on labels?

Tim - thanks for this hint (act id=-1 if this is the label print at creation time). This has allowed me to correct the dispense count.  The attached jrxml prints the repeat number in the form "[Repeat r of t]" where r is the repeat number and t the total number of repeats.

At the initial dispense this is omitted if the label is printed as the medication record is being created. If you then select the dispensed line and again print the label it will show "[Repeat 0 of t]" - as this is the initial dispense and not a repeat.

If you dispense a second time (ie 1st repeat) it shows "[Repeat 1 of t]" irrespective of whether you print as the medication record is being created or from the dispensed line.

Note however, that if you now reprint from the FIRST dispense line, it will also show "[Repeat 1 of t]" - ie the repeat count alway shows the total number of times the prescription has been repeated.

WARNING: the attached jrxml uses the Arial Unicode MS font so that I can display chinese characters on the label. It also get the vet's name from the clinician description field (rather than using the name) - this follows our usage of initials for the clinician selection.

Regards, Tim G

AttachmentSize
Label-Dymo-Prescription.jrxml 7.65 KB

Re: New fields for prescriptions on labels?

Here's an alternative version that displays the number of repeats remaining as <N> Rpts , or No Rpts if there are no repeats.

AttachmentSize
label Dymo.jrxml 12.94 KB
Syndicate content