Macro Question

Hi,

Macro issues/questions again.

I am trying to insert into our consultation templates either the time of admission or time the visit started

I have tried:

- openvpms:get(date:formatDateTime(/activityStartTime), /reason)

- concat(date:formatDate(/activityStartTime), /reason)

I got the latter working but then had the autoexpand problem again, and then it wouldn't expand at all when I put a $ before the expression.

Any help would be appreciated.

Thanks,

Adrian

Comment viewing options

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

Re: Macro Question

The first expression won't work, as the first argument to the openvpms:get() must be an archetyped object  (i.e. a party, act, etc). You are trying to supply a string.

What is the is the complete text of what you want to evaluate as a macro?

Where you intend to expand it? In a Note?

Re: Macro Question

Hi Tim,

We simply want a line that says:

PATIENT ADMISSION TIME: DD/MM/YYYY HH:MM AM/PM (where the date and time is when the patient was checked in).

At the moment we have a line that says: TIME AND DATE OF SOAP: DD/MM/YYYY HH:MM AM/PM that drops in the time the note was created. The problem is when a patient is admitted at lets say 10pm but the vet doesn't start a note until 3am this is misleading. Our current line doesn't tell you when the patient was admitted to hospital or the consult actually took place. This is better represented by the check in time.

We are trying to expand this into a note as part of a larger macro.

Thanks,

Adrian

Re: Macro Question

You can't get the admission time as such. You can get the time that the visit was created, which will be close enough most of the time.

E.g., create a macro named @visitTime with the following expression:

concat("PATIENT ADMISSION TIME: ", date:formatDateTime($visit.startTime))

 

If you want to call this macro from other macros, see Macros in Macros

 

Re: Macro Question

worked a treat. Thanks, adrian

Re: Macro Question

Hi Tim,

Can visit.startTime go into a patient document (OpenOffice)? ie like patient.entity.name etc.

If it can, can we also put the clinician associated with the visit go into the patient document? (rather than the clinician who is the associated with the document)?

 

Thanks,

Greta

Re: Macro Question

You could evaluate it as a macro in a report, but it is not directly available like patient.entity is.  This is due to context, generally a patient document is linked to a patient not to a visit although it may reference a visit

If you look at the archetype for a document.

<node name="event" path="/targetActRelationships" type="java.util.HashSet" baseName="TargetActRelationship"
              minCardinality="0" maxCardinality="1" hidden="true" filter="actRelationship.patientClinicalEventItem">
            <assertion name="archetypeRange">
                <propertyList name="archetypes">
                    <propertyMap name="archetype">
                        <property name="shortName" value="actRelationship.patientClinicalEventItem"/>
                    </propertyMap>
                </propertyList>
            </assertion>
        </node>

You can see the minimum is 0 this means it may not always be present...thus the macro may fail on occassion it just depends how you link the document.

So the document is linked to an event (which is a visit) then you might be able to retrieve it using.

openvpms:get(.,'event.source.startTime')

This is because it is actually linked to a act relationship which is linked via the source field to the actual event.

 

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: info[at]charltonit.com[dot]au

Re: Macro Question

Greta - we are travelling at the moment - hence apologies for the delay.

OK - first decision: what are we building, ie what environment are we operating in.  I will assume that you are generating a patient letter or patient form [remember that the two functionally differ only in terms of whether or not you want input parameters - in fact in Hong Kong we always set things as patient letters and not patient forms - even if no input parameters are required - this prevents the problem of users needing to think about should they select patient letter or patient form - everything is a letter]

 

Hence from http://www.openvpms.org/documentation/csh/1.7/reference/reportFields - the archetype we are dealing with is act.patientDocumentLetter

 

So 'startTime' is the start time of the patient letter.  To get at the visit start time we need to get to the visit, and then its start time. From http://www.openvpms.org/documentation/csh/1.7/reference/jxpath we can use the function party:getPatientVisit(patient) to get the visit given the patient - hence party:getPatientVisit(., openvpms:get(., "patient.entity")) should get us the visit

 

so then openvpms:get(party:getPatientVisit(., openvpms:get(., "patient.entity")),"startTime") should give us the visit start time

 

Similarly openvpms:get(party:getPatientVisit(., openvpms:get(., "patient.entity")),"clinician.entity.name")

Should give us the clinician for the visit

 

 

NOTES:

1) I cannot test the above since we are travelling

2) today we are in Bangalore - with good internet connectivity - but for the next 3 days we are out in the boonies in a place called Coorg and I suspect that it is on the information-dirt-lane rather than the information-super-highway

3) in 1.8 the above should get a lot easier because  of  the project http://www.openvpms.org/project/access-application-context-reports - which in spite of its 'seeking funding' status, is in fact fully funded.

 

Regards, Tim G

 

Re: Macro Question

There is a project to make these variables available to reports as well. See http://www.openvpms.org/project/access-application-context-reports

To access the current visit in a report, you would use OpenVPMS.visit.startTime.

To access the visit clinician, you would use OpenVPMS.visit.clinician.entity.name.

Syndicate content