1.6b3 (4901) - Need advice on custom demographic update

4901 has OPVMS-1264 fixed and Tim A referred me to OPVMS-814.  So I added the Example Custom Fields to species Dog, and then created a Demographic update called Vaccination Date with Expression:

openvpms:setObjectNode(.,"lastVaccinationDate",java.util.Date.new())

and node  'entity.customPatientExample'.

I then added this update to a product, and invoiced that product to a dog. 

I got a failure which included the message:

<message>org.openvpms.archetype.rules.product.DemographicUpdateException: Failed to evaluate demographic update: Vaccination Date; nested exception is RuleException(javax.rules.InvalidRuleSessionException: org.openvpms.archetype.rules.product.DemographicUpdateException: Failed to evaluate demographic update: Vaccination Date), root cause(org.drools.spi.ConsequenceException: org.openvpms.archetype.rules.product.DemographicUpdateException: Failed to evaluate demographic update: Vaccination Date)</message>

 

I am absolutely certain that I have the node set incorrectly. [I notice that for the standard demographice updates the node is set to 'patient.entity' - but there is no such archetype in the system.  So there must be some magic about the naming convention for the node.]

Can someone tell me what I use to get to the entity.customPatientExample field lastVaccinationDate.

Thanks, Tim

Comment viewing options

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

Re: 1.6b3 (4901) - Need advice on custom demographic update

The "patient.entity" is used when the demographic update is evaluated against an invoice item.

The "patient" part refers to the act.customerAccountInvoiceItem archetype's "patient" node. The "entity" part refers to the corresponding "participation.patient" archetype's "entity" node.

In your case, you will need a node string like:

 patient.entity.customFields.target 

Here:

  • "patient" resolves to a participation.patient
  • "entity" resolves to a party.patientpet
  • "customFields" resolves to an entityRelationship.customPatientFields
  • "target" resolves to an entity.customPatient* (an entity.customPatientExample in your case)

The expression you need to use is:

 openvpms:set(.,"lastVaccinationDate",java.util.Date.new()) 

The "." above is the object resolved by "target".

-Tim A

Re: 1.6b3 (4901) - Need advice on custom demographic update

Tim A - it still fails.  At the invoice finalise stage I get 'Failed to save invoice' with the text "Failed to execute the business rules for URI archetypeService.save.act.customerAccountChargesInvoice.after.".

I have the demographic update set as follows:
 

which as far as I can see matches your advice.

In the stack trace there is:
<cause>
<type>javax.rules.InvalidRuleSessionException</type>
<message>org.openvpms.archetype.rules.product.DemographicUpdateException: Cannot evaluate demographic update: Vaccination Date. No object to update</message>

Looking at the source, this is being thrown by line 89 of DemograpicUpdater.java, and I think means that the NameResolver call in line 84 didn't work.  In turn, I think that this means that the resolve funtion at line 106 of NameResolver.java had a problem - but at that stage I get lost and cannot figure out the problem.

Over to you.

Regards, Tim

Re: 1.6b3 (4901) - Need advice on custom demographic update

The target object has to exist in order for the demographic update to work.

In your case, the patient doesn't have an entity.customPatientExample linked to it. If you edit the patient and save it, it should be created, and the demographic update should subsequently work.

 

-Tim A

Syndicate content