Thanks @Shanshan Yu
for your help, time, and explanations.
Thanks @Ashok Kumar for your thoughts and time, trying to help us.
We have tested it, as follows:
; 08/11/2023 We try to encode the signature with base64Url
set base64urlSignature = ##class(%OAuth2.Utils).Base64UrlEncode(signature)
$$$LOGASSERT("base64urlSignature: "_base64urlSignature)
It shows the following output:
base64urlSignature: cvj48UMDm3jtp9amY7rO1eyXmutC9wjMZzREmQOGIL0
So, you are right, it looks like it removes the "=" character at the end, because when we use:
set bas64signature = $system.Encryption.Base64Encode(signature)
$$$LOGINFO("bas64signature: "_bas64signature)
It shows us, the next outpout which contains "=" at the end:
bas64signature: cvj48UMDm3jtp9amY7rO1eyXmutC9wjMZzREmQOGIL0=
However it does not fix why the JWT's third part is different thant the one provided the simulator and tested with JWT.io
We think the difference is due to this line, the one which retrieves the signature:
set signature = $SYSTEM.Encryption.HMACSHA(256, unsignedToken, key)
$$$LOGINFO("signature: "_signature)
How could we understand, deeply understand, and solve this need?
Thanks for your help, time, and effort.
Thanks @Ashok Kumar , for your kind help.
We have developed it as follows:
ClassMethod HL7ToCustomEnsReq(request As EnsLib.HL7.Message) As Mensajes.Request.Peticiones.Derivaciones.EnvioPeticiones.operacionRequest { #dim xml As %Stream.GlobalCharacter set tSC = ##class(HS.Gateway.HL7.HL7ToSDA3).GetSDA(request,.xml) $$$ThrowOnError(tSC) set reqObj = ##class(Mensajes.Request.Peticiones.Derivaciones.EnvioPeticiones.operacionRequest).%New() do reqObj.XMLImportSDAString(xml.Read()) set tSC = reqObj.%Save() $$$ThrowOnError(tSC) $$$LOGINFO("reqObj.MSH.MSH1.content: "_reqObj.MSH.MSH1.content) quit reqObj }
Where the Request is as follows:
Class Mensajes.Request.Peticiones.Derivaciones.EnvioPeticiones.operacionRequest Extends (Ens.Request, HS.SDA3.QuickXML) [ ProcedureBlock ] { Parameter RESPONSECLASSNAME = "Mensajes.Response.Peticiones.Derivaciones.EnvioPeticiones.operacionResponse"; Property MSH As hl7.MSH.CONTENT; Property NTE As list Of hl7.NTE.CONTENT; Property ORMO01PATIENT As hl7.ORMO01.PATIENT.CONTENT; Property ORMO01ORDER As list Of hl7.ORMO01.ORDER.CONTENT; Property SFT As list Of hl7.SFT.CONTENT; Property MSA As hl7.MSA.CONTENT; Property ERR As list Of hl7.ERR.CONTENT;
And the Transformation invokes the HL7ToCustomEnsReq() functions like this:
Class Transformaciones.HL7.Peticiones.Derivacion.Mensaje.ORM01 Extends Ens.DataTransformDTL [ DependsOn = (EnsLib.HL7.Message, Mensajes.Request.Peticiones.Derivaciones.EnvioPeticiones.operacionRequest) ] { Parameter IGNOREMISSINGSOURCE = 1; Parameter REPORTERRORS = 1; Parameter TREATEMPTYREPEATINGFIELDASNULL = 0; XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl" ] { <transform sourceClass='EnsLib.HL7.Message' targetClass='Mensajes.Request.Peticiones.Derivaciones.EnvioPeticiones.operacionRequest' sourceDocType='2.5:ORM_O01' targetDocType='2.5:ORM_O01' create='new' language='objectscript' > <assign value='##class(Util.FuncionesComunes).HL7ToCustomEnsReq(source)' property='target' action='set' /> </transform> } }
However we do see the $$$LOGINFO("reqObj.MSH.MSH1.content: "_reqObj.MSH.MSH1.content) totally empty:
Being a warning issued as:
Could not generate EncounterNumber, skipping Encounter
What have we done wrong?
How could we understand, improve and fix it?
Is this the recommended way to convert an official HL7 Message, to a Ens.Request which is similar to a HL7 message but where each segment and field is an Ensemble class?
Thanks for your time, help and effort.
We have also read carefully: https://docs.intersystems.com/irisforhealthlatest/csp/documatic/%25CSP.D...
Again thanks @Ashok Kumar for your help.