Question
· Apr 19, 2023

ERROR #5034: Invalid status code structure - Writing to File

I wrote a function awhile back to take Encoded Base 64 and write the PDF out to a file that could be sent to a faxing system to fax out. We are trying to test this code out in IRIS and I am seeing an error that I have not seen before... ERROR #5034: Invalid status code structure

Here is the code...

ClassMethod DecodeBase64HL7ToFile(base64 As %Stream.GlobalBinary, Ancillary As %String, FileName As %String) As %String

{

 

  set ArchDir = "/ensemble/data/transfer/AncillaryPDF/"

  set ArchAncDir = ArchDir_Ancillary_"/"

  set FaxDateDir = ArchAncDir_$PIECE($ZDATE($HOROLOG,7)," ",1)_"-"_$PIECE($ZDATE($HOROLOG,7)," ",2)_"-1/"

  if '##class(%Library.File).DirectoryExists(ArchDir)

  {

    do ##class(%Library.File).CreateDirectory(ArchDir)

 

  }

  if '##class(%Library.File).DirectoryExists(ArchAncDir)

  {

    do ##class(%Library.File).CreateDirectory(ArchAncDir)

 

  }

  if '##class(%Library.File).DirectoryExists(FaxDateDir)

  {

    do ##class(%Library.File).CreateDirectory(FaxDateDir)

 

  }

 

 

  set Oref = ##class(%FileBinaryStream).%New()

  ///$$$LOGINFO(FaxDateDir_FileName)

  set Oref.Filename = FaxDateDir_FileName

  Do base64.Rewind()

 

  While 'base64.AtEnd {

      set ln = base64.ReadLine()

      set lnDecoded = $system.Encryption.Base64Decode(ln)

    do Oref.Write(lnDecoded)

  }

 

  Do Oref.%Save()

  set PDFFilePath = FaxDateDir_FileName

  return PDFFilePath

}

Why is IRIS throwing an error? I want the Path returned to the DTL that it is being called from. Can I no longer return a string?

Product version: IRIS 2022.1
$ZV: IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2022.1 (Build 209U) Tue May 31 2022 12:13:24 EDT
Discussion (7)2
Log in or sign up to continue

Alex, 

I tried that but now I am receiveing... ERROR #5002: ObjectScript error: <UNDEFINED>zDecodeBase64HL7ToFile+22^osuwmc.Functions.1 *%C(10)

ClassMethod DecodeBase64HL7ToFile(base64 As %Stream.GlobalBinary, Ancillary As %String, FileName As %String) As %String

{

  set ArchDir = "/ensemble/data/transfer/AncillaryPDF/"

  set ArchAncDir = ArchDir_Ancillary_"/"

  set FaxDateDir = ArchAncDir_$PIECE($ZDATE($HOROLOG,7)," ",1)_"-"_$PIECE($ZDATE($HOROLOG,7)," ",2)_"-1/"

  if '##class(%Library.File).DirectoryExists(ArchDir)

  {

    do ##class(%Library.File).CreateDirectory(ArchDir)

  }

  if '##class(%Library.File).DirectoryExists(ArchAncDir)

  {

    do ##class(%Library.File).CreateDirectory(ArchAncDir)

  }

  if '##class(%Library.File).DirectoryExists(FaxDateDir)

  {

    do ##class(%Library.File).CreateDirectory(FaxDateDir)

  }

  set Oref = ##class(%FileBinaryStream).%New()

  ///$$$LOGINFO(FaxDateDir_FileName)

  set Oref.Filename = FaxDateDir_FileName

  Do base64.Rewind()

  While 'base64.AtEnd {

      set ln = base64.ReadLine()

      set:ln[%C(10) base64.LineTerminator=$C(10)

      set lnDecoded = $system.Encryption.Base64Decode(ln)

    do Oref.Write(lnDecoded)

  }

  Do Oref.%Save()

  set PDFFilePath = FaxDateDir_FileName

  return PDFFilePath

}

EDIT: Hah, I guess you posted your solution as I was typing this ... and yeah, sort of what I thought it might be laugh

Are you calling (and testing) this from a DTL? If yes, have you looked through the DTL rules to see if the returned string's variable is being used as an argument to something like $system.Status.GetErrorText()?

Does the same thing happen when you execute it from the IRIS prompt?

Set tStrm=##class(%Stream.GlobalBinary).%New()
Do tStrm.Write("SGVsbG8gV29ybGQh")
Do tStrm.Rewind()
Write ##class(<packagename>).DecodeBase64HL7ToFile(tStrm,"<ancillary>","</path/to/outputfile.ext>")

Replace <packagename>, <ancillary>, and </path/to/outputfile.ext> with values appropriate for what you're testing, of course ...