This is how i solved the issue


 Set tSC = pRequest.NewResponse(.tResponse)  Quit:$$$ISERR(tSC) tSC
 Set tResponse.encodedMessage = $get(encodedMessage)
 set dMsg = $SYSTEM.Encryption.Base64Decode(tResponse.encodedMessage)
 set pResponse = ##class(EnsLib.HL7.Message).%New()
 set pResponse = ##class(EnsLib.HL7.Message).ImportFromString($Get(dMsg))
 set pResponse.DocType = ##class(EnsLib.HL7.Schema).ResolveSchemaTypeToDocType(pResponse.TypeVersion,pResponse.Name)

This is how I solved the issue...

 Set tSC = pRequest.NewResponse(.tResponse)  Quit:$$$ISERR(tSC) tSC
 Set tResponse.encodedMessage = $get(encodedMessage)
 set dMsg = $SYSTEM.Encryption.Base64Decode(tResponse.encodedMessage)
 set pResponse = ##class(EnsLib.HL7.Message).%New()
 set pResponse = ##class(EnsLib.HL7.Message).ImportFromString($Get(dMsg))
 set pResponse.DocType = ##class(EnsLib.HL7.Schema).ResolveSchemaTypeToDocType(pResponse.TypeVersion,pResponse.Name)

I was able to get it to work. I found that in Cache I need to call %Get("<column>") name vs what I am doing in a BPL.

 s Loc = ""
 s tStatement = ##class(%SQL.Statement).%New()
 s execall= "CALL osuwmc_Utils_EnterpriseDirDb.InterfaceCheckConnectMedCtrID(?)"
 s qStatus = tStatement.%Prepare(execall)
 if $$$ISERR(qStatus) {write "%Prepare failed:" do $SYSTEM.Status.DisplayError(qStatus) quit}
 set rset = tStatement.%Execute(pInput)
 while rset.%Next() {
 set Loc = rset.%Get("OSUguestRoleDTL")
 }
 if $Length(Loc) = 0 {
    set Loc = "OSUWMC"
 }

With some help from the Developer community, below is a Function I wrote for our needs to take a Base64 and write it out to a PDF.

ClassMethod DecodeBase64HL7ToFileFaxing(base64 As %Stream.GlobalBinary, Ancillary As %String, FileName As %String) As %String
{
	set ArchDir = <directory>
	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(%Stream.FileBinary).%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()
	do ##class(%File).SetAttributes(Oref,33261,.return)
	set Oref = "" // Close file
	set PDFFilePath = "/Fax/PDFFiles/"_Ancillary_"/"_$PIECE($ZDATE($HOROLOG,7)," ",1)_"-"_$PIECE($ZDATE($HOROLOG,7)," ",2)_"-1/"_FileName
	return PDFFilePath
}

While thinking about this, I am wondering if using an encryption key might be a possible solution as well that way there is limited access to the password, and the key would just have to be regulated to be updated every so often. With using a AD service account, the password still needs to be updated or kept up to date, and still needs to be passed into the shell script for Terminal to open.

I have submitted the following IDEA...

https://ideas.intersystems.com/ideas/DPI-I-466