Adding Batch Number to Invoice?
Hi all,
We require batch numbers of any medication to be put on invoices. I have changed act.patientMedication.adl to include:
<node name="batch" displayName="Batch Number" path="/details/batch" type="java.lang.String" minCardinality="1" maxLength="20"/>
and set minCardinality="0" as per Tim A's suggestion.
So I editted the label template in iReport (as per attached) to include the batch field that would be entered in the medication screen. To do this I added a field called "batch" and set the field class to "java.lang.String". Saved and uploaded template and it works perfectly.
Now want I need to do is get the batch and expiry date of that product on the invoice template. So as per the attached invoiceitems.jrxml I adjusted it as follows:
Created field called "target.patientMedication.entity.batch" and set the field class as "java.lang.String", and added "target.patient.Medication.entity.endTime" and set this field class as "java.util.Date". Inserted them in designer as I did with the label and saved. However I can't seem to figure out where I've gone wrong. Obviously I missed something or set the wrong field name, I am not sure.
When I go to print the invoice, this is the error that shows up:
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $F{target.patient.Medication.entity.endTime}
As mentioned above, the label works perfectly.
Anyone have any ideas as to what I missed?
Thanks
Re: Adding Batch Number to Invoice?
Gor - its a timestamp not a date - here is a snippet from my invoice line item - I am using the startTime (and I don't bother with the end time). First the field definition:
Now the text element definition:
Note that you can use just target.endTime rather than target.patient.Medication.entity.endTime
Regards, Tim G
Re: Adding Batch Number to Invoice?
The field names aren't quite right.
The invoice items report gets passed a list of actRelationship.customerAccountInvoiceItem archetypes. The "target" node resolves to an act.customerAccountInvoiceItem.
From there you can get the act.patientMedication act via the dispensing node. i.e "target.dispensing.target". Here. the "target.dispensing" refers to an actRelationship.invoiceItemDispensing relationship.
So the batch node would be: "target.dispensing.target.batch".
The medication expiry: " target.dispensing.target.endTime".
Also note that java.sql.Timestamp subclasses from java.util.Date, so I don't think you'll have any problems using java.util.Date.
-Tim A