Multiple Claims and Removal of a Claim by Index


I am pretty stuck here and would appreciate any help or advice on an approach to this...

I have a single claim file, ingested that has 7 claims inside of it, I am pulling each claim out based on a qualifier, then want to remove all of the others and do something with the one that is left over.

My problem is I cant seem to figure out how to Remove the Claims programatically...

ClassMethod PCRemoveClaim(pTargetDocument As EnsLib.EDI.X12.Document, tCount As %Numeric) As %Status
     Set tStatus = $$$OK
     Try {
            Set tStatus = pTargetDocument.SetValueAt("", "loop2000A("_ tCount _")", "remove")

     } Catch eException {

            Set tStatus = eException.AsStatus()

Quit tStatus

The above results in:

<Ens>ErrGeneral)No segment found at path 'loop2000A(1)'8
CHCLAIMS)6e ^zremoveSegmentBy

I can still enumerate the number of claims right before it by using:

Set tNumClaims = pTargetDocument.GetValueAt("loop2000A(*)")

so I really don't think its the schema.

Can anybody give me some advice on how I remove a single claim by index ?

I will include my approach below conceptually, this sorta/pseudo code represents the approach and is fairly solid except for the above is not working.

// I build a list of the qualifying claims I wish to process.
// So, below, Claim 2, 6, and 7 I find relevant

Set tSC = $$$OK
Set tList = ##class(%Library.ListOfDataTypes).%New()
Do tList.Insert("2")
Do tList.Insert("6")
Do tList.Insert("7")

// simulated claim file, with 7 claims init.
Set tClaim = ##class(%Library.ListOfDataTypes).%New()
Do tClaim.Insert("1")
Do tClaim.Insert("2")
Do tClaim.Insert("3")
Do tClaim.Insert("4")
Do tClaim.Insert("5")
Do tClaim.Insert("6")
Do tClaim.Insert("7")

// loop over all our qualifying
for i=1:1:tList.Count() {

   // Loop over all the claims
   for j=1:1:tClaim.Count() {
       if (tList.GetAt(i) '=j) {
       // pseudo removal of claim
       Do tClaim.SetAt("",j)


//here I have one claim left in the Claim
w tClaim.Count() // = 1

  • 0
  • 0
  • 84
  • 0
  • 1


I'm not sure if I'm missing something but you are actually not removing anything, you are simply setting the value at index xyz to the empty string.

If I understand correctly I think you could use

#dim i,cnt as %Integer = tList.Count()

for i=1:1:cnt

#dim key as %Integer = tClaim.Find(tList.GetAt(i))
do:(key>0) tClaim.RemoveAt(key)


As I said. if I understand your question correctly, that is actually removing everything from tClaim that is part of tList.