How to use lookup tag on getting the lastEncounter with Date | Html Form Entry

Hello folks ,

Am trying to check if a patient has ever encountered a form fill-out and found this :point_down:t6:

https://wiki.openmrs.org/display/docs/HTML+Form+Entry+Module+Reference#:~:text=fn.latestEncounter(EncounterType%20type%2C%20String,4eaf-85e3-87cfad31bfa6'%2C%20%24encounterDate)"/>


`First MDR-TB Encounter: <lookup expression=` `"fn.latestEncounter('ee95dbbf-5aec-4eaf-85e3-87cfad31bfa6', '2021-06-30')"` `/>`

`The method also accepts a velocity variable may be a date or a string`

`First MDR-TB Encounter: <lookup expression=` `"fn.latestEncounter('ee95dbbf-5aec-4eaf-85e3-87cfad31bfa6', $encounterDate)"` `/>`

However wanted to know if the encounter type talked about here

ee95dbbf-5aec-4eaf-85e3-87cfad31bfa6

is the formEncounterType or any conceptId

also $encounterDate is it just a variable or its defined within the Html form Entry

cc @dkayiwa @sharif @mozzy

Cross check in here wiki?. It have details about encounterDate widget and how it can be used in HTMLFORM

Yes that is FormEncounterType uuid.

1 Like

Hey @sharif wat i meant here is

First MDR-TB Encounter: <lookup expression= "fn.latestEncounter('ee95dbbf-5aec-4eaf-85e3-87cfad31bfa6', $encounterDate)" />

this $encounterDate used up there is it a variable or its defined within the Html form Entry

It is defined with in htmlform.

1 Like

So does this turn out to be the most recent encounter Date

Yes, you can use to get current date of an encounter.

thanks @sharif have tried to use $encounterDate and $encounter.encounterDatetime but these were returning ’ ’ for my latestEncounter

So Ended up using $visit.startDatetime and this seems fine thank u brother :slight_smile:

lookup expression="fn.latestEncounter('ee95dbbf-5aec-4eaf-85e3-87cfad31bfa6', $visit.startDatetime)"/>
1 Like