Do you mean OCR/text layer extraction? yes.
- Log in to post comments
Do you mean OCR/text layer extraction? yes.
1. I have a PDF file which I need to read from a folder location as text and put data from PDF into HL7 message and send it to downstream system.
2. I have a PDF file which I need to read from a folder location encode it in base64 and put in OBX.5 of MDM message
Classmethod GetJWT() {
//Private key file
Set tFile=##Class(%File).%New("C:\keys\jwtRS512.key")
Do tFile.Close()
Set tStatus=tFile.Open("RU")
$$$ThrowOnError(tStatus)
Set tPrivateKey=tFile.Read()
Do tFile.Close()
set iat = ##class(%OAuth2.Utils).TimeInSeconds($ztimestamp,0)
set exp = ##class(%OAuth2.Utils).TimeInSeconds($ztimestamp,300)
set tClaims = {
"sub": "LS6Y4hA6KtDgWwTck5STRdGGVPCPV4Cp",
"iss": "LS6Y4hA6KtDgWwTck5STRdGGVPCPV4Cp",
"jti": (tGUID),
"aud": "https://int.api.service.nhs.uk/oauth2/token",
"exp": (exp)
}
Set JOSE("sigalg")="RS512"
Set tX509=##class(%SYS.X509Credentials).%New()
Do tX509.PrivateKeySet(tPrivateKey)
Set tStatus=##class(%OAuth2.JWKS).AddX509("RS512",tX509,.tPrivate)
Set arr=##class(%DynamicAbstractObject).%FromJSON(tPrivate)
Set iter=arr.%GetIterator()
Set newprivate={}
///Need to set KID at same index with other keys so re-creating new
While iter.%GetNext(.key,.value) {
Set newprivate.kty=value.keys.kty
Set newprivate.n=value.keys.n
Set newprivate.e=value.keys.e
Set newprivate.d=value.keys.d
Set newprivate.p=value.keys.p
Set newprivate.q=value.keys.q
Set newprivate.dp=value.keys.dp
Set newprivate.dq=value.keys.dq
Set newprivate.qi=value.keys.qi
Set newprivate.alg=value.keys.alg
Set newprivate.kid=..KID
}
Set JWKSPrivate={"keys":[]}
Do JWKSPrivate.keys.%Push(newprivate)
Set tPrivate=JWKSPrivate.%ToJSON()
///Customize this method to pass KID that will go to ..GetJWK 3rd argument
Set tStatus= ##class(KCH.TIE.Helper.PDSUtil).ObjectToJWT(.JOSE,tClaims,tPrivate,,.pJWTToken,..KID)
W !, pJWTToken
}
IS this solution worked for you ?
I am also trying the same with RSA512 but the JWT token has invalid signature
I tried with $ZF(-100) as well still I get code=1 (Syntax error)
same method while running from cache terminal works fine
whereas running from studio gives error
this is local installation
I did tried with complete python.exe path as well.
but when -ZF(-1) running from studio its not working
I have tried with full path as well still not working
d $zf(-1,"whoami > c:\temp\whoami.txt")
nt authority\system ( i dont know which user is this
Terminal
d $zf(-1,"whoami > c:\temp\whoami.txt")
give local user
Classmethod Test() {
set code = $zf(-1,"python C:\keys\GetToken.py")
W ! , code
}
Classmethod Test2() {
set code = $zf(-1,"echo hello>C:\keys\test.txt")
W ! , code
}
Studio Output Window
Do ##class(Test).Test()
1
Do ##class(Test).Test2()
0
Cache terminal
Do ##class(Test).Test()
0
Do ##class(Test).Test2()
0
this is what is happening
nope...code =0 means sucess
code =1 means syntax error
I am not sure how same method is behaving differently
Hi @Stefan Wittmann
IS this feature is released yet?
When do you think this will be released
I think the reason is because of file size my input message.
HL7 file size is 1mb, this code works fine for small messages
no I am not sure about that
Yes I am doing that, below is the code I am using
Set obj=##class(%Stream.FileBinary).%New()
Set input = ""
For i=1:1:$L(obx5,"\.br\")
{
Set decodeline=$system.Encryption.Base64Decode($P(obx5,"\.br\",i))
Set input = input_decodeline
}
Do obj.Write(input)