You can calculate such property on a class side, something like this. Index by CitizenRef and RelocationDate, and method which looking for the next date, and returns true if nothing found.
Index CitizenRelocation On (CitizenRef, RelocationDate);
Property IsLastKnownRecord As %Boolean [ Calculated, SqlComputeCode = {set {*}=##class({%%CLASSNAME}).IsLastKnownRecordCheck({CitizenRef}, {RelocationDate})}, SqlComputed ];
Method IsLastKnownRecordGet() As %Boolean
{
quit ..IsLastKnownRecordCheck(i%CitizenRef, i%RelocationDate)
}
ClassMethod IsLastKnownRecordCheck(CitizenRef As %Integer, RelocationDate As %Date) As %Boolean [ CodeMode = objectgenerator ]
{
set storagename="Default"
set storageInd=%class.Storages.FindObjectId(%classname_"||"_storagename)
set storage=%class.Storages.GetAt(storageInd)
set indexLocation=storage.IndexLocation
set indexLocation=$name(@indexLocation@("CitizenRelocation"))
do %code.WriteLine($c(9)_"quit $order(@($name("_indexLocation_"))@(CitizenRef, RelocationDate))=""""")
quit $$$OK
}
And result you can see below

- Log in to post comments
