Product Code or Barcode on a report
Submitted by Ben_Charlton on Fri, 07/11/2014 - 14:13
Anyone know if its possible to return a product code or barcode on a report...
ie Product.entity.identity[0] or
openvpms.get(Product.entity, 'code')
Looking for a way to return a code/barcode on a report
Re: Product Code or Barcode on a report
Ben - if you are building a SQL data-source'd report then should be relatively simple to code the necessary SQL. If you need it in a OpenVPMS data-source'd document or an OO document, then I suspect you are out of luck - there is a party:getIdentities(party) - but that wants a party as the argument, not a product.
If you need some SQL generated, please yell.
Regards, Tim G
Re: Product Code or Barcode on a report
Nah unfortunately its using an object datasource...ie act so it needs to be a jxpath query. there is no jxpath functions for products as yet...probably need one..
I was trying to use a openvpms.get on the act to retrieve an identity but looks like it needs to be coded.
Wider applications? do we want this in the core?
I was thinking adding
getCodes
getBarcodes
getIdentities to the productRules and then adding a jxpath function list to return them.
Additionally and this is more dev based but I couldnt see how we are returning batch numbers from a sale in a report. Say for example I want to return the batch number and expiry of a vaccination certificate. The batch would be recorded against the ChargeItem, but we need a method to bring that data across to reporting.
Re: Product Code or Barcode on a report
You might be able to access barcodes using xpath expressions, although I think you can define a hidden node that does the filtering for you e.g.:
If you just want the first barcode, try:
For the first identity of any type:
See http://commons.apache.org/proper/commons-jxpath/users-guide.html for expression syntax.
For batches, given a charge item you can get the:
The "batch.entity" part resolves to an entity.productBatch.
The "batch.entity.product" resolves to an entityLink.batchProduct.
The expiry date is on the product relationship for implementation reasons; an indexed field was required to be able to sort batches on expiry.
Re: Product Code or Barcode on a report
Yeah thats good but we need to reference the batch numbers referencing from an Patient Letter.
which drills down to a act.PatientDocument* which was linked to a product....
Sounds like we need to create a jxpath function to bring in the batch number source it from the chargeitem the issue being that there may well be No charge item for a specific document....
Just to be clear why this is required...
Almost all veterinary boards in Australia at least recommend the inclusion of batch and expiry dates on vaccination certificates.
Re: Product Code or Barcode on a report
I haven't tried this so YMMV.
If the letter was generated from a invoice item, then there should be a link to it that you can access by adding a node on act.patientDocumentLetter:
Given the letter, you can then do:
The same should apply to act.patientDocumentForms.
Re: Product Code or Barcode on a report
I think I am going to try and generate a
1 patient document - or 1 letter and 1 form
1 customer doc (1 letter 1 form)
that simplely list out all the functions we can use to access data in an example form.
Provide that as a reference document.
Re: Product Code or Barcode on a report
I should have mentioned Tim's solution works as expected .
I will Jira the archetype change Tim - as I think this is a required change to support batch reporting in forms.
I would generally argue against hiding the node.
Re: Product Code or Barcode on a report
The default layout is a bit ordinary as the invoice item is rendered inline. If you display it, the node should also be read-only.
You can force it onto a separate tab using:
This will be displayed even if a letter has no invoice item linked to it. To avoid this:
1. subclass DocumentActLayoutStategy and DocumentActViewLayoutStrategy and provide an implementation of getArchetypeNodes() that excludes the invoice item node if it is empty (see ArchetypeNodes.excludeIfEmpty())
2. change PatientDocumentActEditor for patient documents, to create the appropriate patient document layout strategy. i.e. override createLayoutStrategy()
3. register the new view layout strategy in DefaultLayoutStrategyFactory.properties. This will replace the existing one for act.patientDocument*
Re: Product Code or Barcode on a report
I will put it on my projects todo list :) Do you want it in core?
Re: Product Code or Barcode on a report
Sure - sounds like a useful addition.
Re: Product Code or Barcode on a report
https://openvpms.atlassian.net/browse/OVPMS-1539
Further discussion can be found on the Developer forum.