Thanks for the great article Sebastian!
I tried this myself for an Encounter property, and Step 4 can require a good bit of practice and digging through the frame-source HTML and the ^CacheTemp.HS.ViewerStreamlet global to really understand how it all works. Grabbing the streamletID for an Encounter requires some different code than grabbing the streamletID for an Allergy. For my use case the code for Step 4 was something like:
ClassMethod GetTransferredFromEDViewerTransform(patientID, episodeID) As %String
{
set agkey= $g(^CacheTemp.HS.ViewerStreamlet("HSACCESS","P",patientID))
set streamletID= $g(^CacheTemp.HS.ViewerStreamlet("HSACCESS","V",agkey,"ENC",episodeID))
set obj=##class(HS.SDA3.Streamlet.Encounter).%OpenId(streamletID)
set encounterSDA3=##class(HS.SDA3.Encounter).%New()
set st=encounterSDA3.XMLImportSDAString(obj.SDAString)
set fromED=encounterSDA3.TransferredFromED
if (fromED = 1) return "yes"
return "no"
}
and the expression for Step 5 was something like:
set val=##class(Test.Viewer.Transforms).GetTransferredFromEDViewerTransform($g(rs.Data("PatientID")),$g(rs.Data("EpisodeID")))
I just had to do this again to grab the SDA value Procedure.EnteredAt.Code
In case it's useful to anyone out there, my code for Step #4 was...
ClassMethod GetEnteredAtCodeViewerTransform(procedureID) As %String
{
set patientid = %request.Data("PatientID",1)
//merge ^CacheTempUser.WRC923241($zdatetime($horolog),"PatientID") = patientid
//merge ^CacheTempUser.WRC923241($zdatetime($horolog),"ProcedureID") = procedureID
set streamletID = ##class(web.SDA3.Loader).GetStreamletId(,patientid,"PRC",procedureID)
//merge ^CacheTempUser.WRC923241($zdatetime($horolog),"StreamletID") = streamletID
set tSC = ##class(HS.SDA3.Container).LoadSDAObject(streamletID,.procedureSDA3)
//merge ^CacheTempUser.WRC923241($zdatetime($horolog),"procedureSDA3") = procedureSDA3
set EnteredAtCode = procedureSDA3.EnteredAt.Code
quit EnteredAtCode
}
and the expression for Step 5 was:
set val=##class(Test.WRC.W923241.Transforms).GetEnteredAtCodeViewerTransform($g(rs.Data("PROC_RowId")))