Invalid Status Code Structure Error

With help from others here I had developed some code to take a Base64 PDF within a OBX.5 and save it locally to the file structure on the server.

I had to make a change to the code to return me a String so I can pass the Path back into Ensemble to use it in the message. When I made this change I am getting " ERROR #5034: Invalid status code structure ("/ensemble/data/transfer/AncillaryPDF/TMSAUDIO/Apr-11-1/980512729TMSAUDIO1046784936436537800.pdf")"

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 FilePath = (FaxDateDir_FileName)
return FilePath
}

Am I missing something?

Thanks

Scott Roth

The Ohio State University Wexner Medical Center

  • 0
  • 0
  • 351
  • 0
  • 3

Answers

Here is how I am Calling the Method and Returning me the string

 

<transform sourceClass='EnsLib.HL7.Message' targetClass='osuwmc.Visit.DataStructures.InsertVisitAttachmentResult' sourceDocType='ORMORUPDF:OSU_ORMORU_PDF' create='new' language='objectscript' >
<assign value='context.TextIDTemp' property='target.TextID' action='set' />
<assign value='source.GetFieldStreamRaw(.tStream,"ORCgrp(1).OBRgrp(1).OBXgrp(1).OBX:ObservationValue(1).AlternateText",.tRemainder)' property='tSC' action='set' />
<assign value='##class(osuwmc.Functions).DecodeBase64HL7ToFile(tStream,source.{MSH:SendingApplication.NamespaceID},source.{PID:PatientIdentifierList(1).IDNumber}_context.TextIDTemp_".pdf")' property='tSC' action='set' />
<assign value='$Get(tSC)' property='target.Text' action='set' />
</transform>

 

You set tSC variable equal to a string:

"/ensemble/data/transfer/AncillaryPDF/TMSAUDIO/Apr-11-1/980512729TMSAUDIO1046784936436537800.pdf"

However, this variable was (probably) intended to be used as a %Status. Somewhere there is probably a check:

$$$ISERR(tSC)
$$$ISOK(tSC)

Or status variable is set from tSC.

I don't think your code is wrong per se, but you are using a variable tSC that is used elsewhere as a status value.

 

If you skip the assignment to tSC and put it straight into Target.text you will probably be ok.