go to post Eduard Lebedyuk · Sep 22, 2022 If I'm using an objectgenerator, is there a way to check the compile flags and have it behave differently based on which flags are set? A very exciting way to introduce some unexpected behavior down the line. What is your use case? And as a tangent, is there a list somewhere of what compile flags there are? Sure: do $system.OBJ.ShowFlags() do $system.OBJ.ShowQualifiers()
go to post Eduard Lebedyuk · Sep 22, 2022 If you get access error on Linux: javaldx failed! Warning: failed to read path from javaldx LibreOffice 7.3 - Fatal Error: The application cannot be started. User installation could not be completed. LibreOffice user installation could not be processed due to missing access rights. Please make sure that you have sufficient access rights for the following location and restart LibreOffice. Add this to LibreOffice parameters: set args($i(args)) = "-env:UserInstallation=file:///tmp/libreofficehome/" where /tmp/libreofficehome is any empty folder InterSystems IRIS has write access to.
go to post Eduard Lebedyuk · Sep 22, 2022 If there's a text layer use LibreOffice to convert to txt (InterSystems IRIS wrapper), for OCR you'll need some thirdparty tool, for example Tesseract can be easily used with Embedded Python. UPD: LibreOffice can't extract text from PDFs unfortunately. Here's Embedded Python solution: Class User.PDF { /// zw ##class(User.PDF).GetText("/tmp/example.pdf", .text) ClassMethod GetText(file, Output text) As %Status { try { #dim sc As %Status = $$$OK kill text set dir = $system.Util.ManagerDirectory()_ "python" do ##class(%File).CreateDirectoryChain(dir) // pip3 install --target /data/db/mgr/python --ignore-requires-python typing==3.10.0.0 try { set pypdf2 = $system.Python.Import("PyPDF2") } catch { set cmd = "pip3" set args($i(args)) = "install" set args($i(args)) = "--target" set args($i(args)) = dir set args($i(args)) = "PyPDF2==2.10.0" set args($i(args)) = "dataclasses" set args($i(args)) = "typing-extensions==3.10.0.1" set args($i(args)) = "--upgrade" set sc = $ZF(-100,"", cmd, .args) set pypdf2 = $system.Python.Import("PyPDF2") } return:'$d(pypdf2) $$$ERROR($$$GeneralError, "Unable to load PyPDF2") kill pypdf2 set text = ..GetTextPy(file) } catch ex { set sc = ex.AsStatus() } quit sc } ClassMethod GetTextPy(file) [ Language = python ] { from PyPDF2 import PdfReader reader = PdfReader(file) text = "" for page in reader.pages: text += page.extract_text() + "\n" return text } }
go to post Eduard Lebedyuk · Sep 22, 2022 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. Do you mean OCR/text layer extraction? 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 Do it like this.
go to post Eduard Lebedyuk · Sep 19, 2022 Have you tried executing the same code from the InterSystems terminal? Also try: text = self.db.run_class_method("%SYSTEM.Status", "GetErrorText", res) print(text)
go to post Eduard Lebedyuk · Sep 19, 2022 The only success status is 1. Anything else is an error or invalid status.
go to post Eduard Lebedyuk · Sep 16, 2022 Try to reload like this: set importlib = ##class(%SYS.Python).Import("importlib") do importlib.reload(helloWorld) Also, it not an IRIS-specific behavior, you'll get the same results in any python interpreter: import helloWorld helloWorld.helloWorld() >'Hello world' del helloWorld # modify helloWorld.py in text editor import helloWorld helloWorld.helloWorld() >'Hello world'
go to post Eduard Lebedyuk · Sep 13, 2022 I'm sure pattern matching can do better but no idea how: ClassMethod findShort(s) As %Integer [ ProcedureBlock = 0 ] { s s=" "_s_" " for i=1:1 {x "s q=(s?.E1P"_i_"A1P.E)" q:q} q i }
go to post Eduard Lebedyuk · Sep 13, 2022 Check this example. In short: Create class extending %SYS.Task.Definition Add properties - that's task settings Implement OnTask method, which returns %Status Set TaskName parameter After that you can add a task of TaskName type from the SMP.
go to post Eduard Lebedyuk · Sep 9, 2022 Will it run in the same Windows process? Yes. Will there be any issues with multitasking (considering python doesn't seem very good at this)? GIL still exists and applies. If you write async code it would only be executed while control flow is on a python side of things. You can't spawn async task in python, go to InterSystems ObjectScript to do something else and then come to a completed python task. Also, is there a performance penalty to pay for running embedded python vs "using IRIS APIs from Python". IRIS APIs from Python (Native SDK/Native API) can be invoked either in-shared-memory or over TCP. TCP comes with a performance penalty. Another question is what python interpreter the embedded python is using? Is it an Intersystems one or the regular c.python? CPython. Version? Use sys.version to check. Recently it was Python 3.9.5 on Windows and 3.8.10 on Linux.
go to post Eduard Lebedyuk · Sep 6, 2022 Assuming you have an EnsLib.HL7.Message object, call OutputHTMLZen method for it.