I'm not sure exactly what you need, but if you need to loop on a repeating segment in code and take an action, you can do this:
for i = 1:1:source.GetValueAt("OBR(*)") {
d target.SetValueAt(source.GetValueAt("OBR("_i_"):4.1"),"OBR("_i_"):4.1")
}
Thanks!
Matt Simpson
Information Systems | Inland Imaging Business Associates
Tel: 509.363.7759 | Cell: 509.370.7141 | Fax: 509.363.7082
Hi,
Regards
Andy
--
You received this message because you are subscribed to the Google Groups "InterSystems: Ensemble in Healthcare Community" group.
To post to this group, send email to Ensemble-in...@googlegroups.com
To unsubscribe from this group, send email to Ensemble-in-Healt...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Ensemble-in-Healthcare?hl=en
This electronic transmission and any documents accompanying this electronic transmission may contain information that is confidential and/or legally privileged. The information is intended only for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on or regarding the contents of this electronically transmitted information is strictly prohibited. If you have received this e-mail in error, please notify the sender and delete this message immediately.
And if you have many nested structures something like this
Hi
In Caché ObjectScript syntax you would use nested loops along the lines of:
for i=1:1 {
if pRequest.GetSegmentAt("PIDgrp(i).PID")=""
quit
for j=1:1 {
if
pRequest.GetSegmentAt("PIDgrp(i).ORCgrp("_j_").ORC")="" quit
for k=1:1 {
if
pRequest.GetSegmentAt("PIDgrp("_i_").ORCgrp("_j_").OBXgrp(“_k_")")="" quit
if
pRequest.GetValueAt("PIDgrp("_i_").ORCgrp("_j_").OBXgrp("_k_”).
OBX:ObservResultStatus ")=”F” {
; Do code
}
}
}
}
To navigate
And of course the similar logic to create segments
Here is a snippet of code from one of my productions where I have looping
structures
if orderobj.MicroType'="C" {
set result="",resultcounter=1
for {
set
resultobj=orderobj.Results.GetNext(.result) quit:result=""
set interpretive="",general="" if
$d(^LabTrak.CulturesD(orderobj.TestID))#10 set
interpretive=$lg(^(orderobj.TestID),5),general=$lg(^(orderobj.TestID),6)
// If the test item is not a general
comment then it is going to be handled as an OBX
// with a Result Type of "I" if it
is an interpretive result and "RP" if it is a stain result
if
general'[resultobj.ObservationIdentifier {
set
resulttype=$s(interpretive[resultobj.ObservationIdentifier:"I",1:"RP")
set
tSC=tRequest.SetValueAt(resultcounter,"PIDgrpgrp(1).ORCgrp(1).OBRgrp("_obrco
unt_").OBXgrp("_resultcounter_").OBX:SetIDOBX","set","") if 'tSC goto End
set
tSC=tRequest.SetValueAt(resultobj.ValueType,"PIDgrpgrp(1).ORCgrp(1).OBRgrp("
_obrcount_").OBXgrp("_resultcounter_").OBX:ValueType","set","") if 'tSC goto
End
set
tSC=tRequest.SetValueAt(orderobj.TestID,"PIDgrpgrp(1).ORCgrp(1).OBRgrp("_obr
count_").OBXgrp("_resultcounter_").OBX:ObservationIdentifier.identifier","se
t","") if 'tSC goto End
set
tSC=tRequest.SetValueAt(orderobj.TestIDName,"PIDgrpgrp(1).ORCgrp(1).OBRgrp("
_obrcount_").OBXgrp("_resultcounter_").OBX:ObservationIdentifier.text","set"
,"") if 'tSC goto End
set
tSC=tRequest.SetValueAt(resulttype,"PIDgrpgrp(1).ORCgrp(1).OBRgrp("_obrcount
_").OBXgrp("_resultcounter_").OBX:ObservationIdentifier.nameofcodingsystem",
"set","") if 'tSC goto End
set
tSC=tRequest.SetValueAt(resultcounter,"PIDgrpgrp(1).ORCgrp(1).OBRgrp("_obrco
unt_").OBXgrp("_resultcounter_").OBX:ObservationSubID","set","") if 'tSC
goto End
if resulttype'="I" {
set
tSC=tRequest.SetValueAt(resultobj.ObservationIdentifier,"PIDgrpgrp(1).ORCgrp
(1).OBRgrp("_obrcount_").OBXgrp("_resultcounter_").OBX:ObservationValue(1)",
"set","") if 'tSC goto End
// If there is an
Observation Value and an Observation text then we write both
// to the messge.
Otherwise we only write the Observation Value and we put it
// into the 'Text'
field in the segment. This is the only way that Meditech can
// handle results
with a value that are not standard comments such as PH or Semen count
if
resultobj.ObservationText'="" {
set
tSC=tRequest.SetValueAt(resultobj.ObservationValue,"PIDgrpgrp(1).ORCgrp(1).O
BRgrp("_obrcount_").OBXgrp("_resultcounter_").OBX:Units","set","") if 'tSC
goto End
set
tSC=tRequest.SetValueAt($e(resultobj.ObservationText,1,60),"PIDgrpgrp(1).ORC
grp(1).OBRgrp("_obrcount_").OBXgrp("_resultcounter_").OBX:ReferencesRange","
set","") if 'tSC goto End
}
else {
set
tSC=tRequest.SetValueAt(resultobj.ObservationValue,"PIDgrpgrp(1).ORCgrp(1).O
BRgrp("_obrcount_").OBXgrp("_resultcounter_").OBX:ReferencesRange","set","")
if 'tSC goto End
}
}
else {
set
tSC=tRequest.SetValueAt(resultobj.ObservationText,"PIDgrpgrp(1).ORCgrp(1).OB
Rgrp("_obrcount_").OBXgrp("_resultcounter_").OBX:ObservationValue(1)","set",
"") if 'tSC goto End
}
set
tSC=tRequest.SetValueAt(resultobj.Units,"PIDgrpgrp(1).ORCgrp(1).OBRgrp("_obr
count_").OBXgrp("_resultcounter_").OBX:Probability","set","") if 'tSC goto
End
set
tSC=tRequest.SetValueAt(orderobj.ObservationResultStatus,"PIDgrpgrp(1).ORCgr
p(1).OBRgrp("_obrcount_").OBXgrp("_resultcounter_").OBX:ObservResultStatus",
"set","") if 'tSC goto End
for
comment=1:1:resultobj.Comments.Count() {
set
text=resultobj.Comments.GetAt(comment)
set
tSC=tRequest.SetValueAt(comment,"PIDgrpgrp(1).ORCgrp(1).OBRgrp("_obrcount_")
.OBXgrp("_resultcounter_").NTE("_comment_"):SetIDNotesandComments","set","")
if 'tSC goto End
set
tSC=tRequest.SetValueAt("L","PIDgrpgrp(1).ORCgrp(1).OBRgrp("_obrcount_").OBX
grp("_resultcounter_").NTE("_comment_"):SourceofComment","set","") if 'tSC
goto End
set
tSC=tRequest.SetValueAt(text,"PIDgrpgrp(1).ORCgrp(1).OBRgrp("_obrcount_").OB
Xgrp("_resultcounter_").NTE("_comment_"):Comment(1)","set","") if 'tSC goto
End
do
tRequest.commitSegmentByPath("PIDgrpgrp(1).ORCgrp(1).OBRgrp("_obrcount_").OB
Xgrp("_resultcounter_").NTE("_comment_")")
kill text
}
}
Sorry about the formatting
Can send an xml export of the whole class if you need
Nigel Timothy Bloom-Salm
Nigel Timothy Bloom-Salm
Technical Specialist
I'm not sure I get what the problem is. Do your methods create HL7 segments
or a collection of normal hierarchical Caché classes representing each type
of segment?
Maybe you could send me your classes so I can see the contents more clearly.
You can send them privately to nigel...@intersystems.com
Thanks