go to post Marc Mundt · Apr 26, 2021 You can definitely do the OAuth requests using basic HTTP calls. Doing it in OnInit won't work because the token you receive has an expiration time. You'll need to:- For every message your Operation receives you'll need to check if the cached token's expiration time has passed (or if there's no cached token).- If you need a new token, do your POST call to get a new token and cache it.
go to post Marc Mundt · Apr 15, 2021 You need to instantiate that class as an object and then you can call methods on the object:https://docs.intersystems.com/irisforhealthlatest/csp/docbook/Doc.View.c...
go to post Marc Mundt · Mar 31, 2021 If you're working with an Ensemble SQL operation, then pResultSet is an EnsLib.SQL.GatewayResultSet object. Have a look at the HasDataStream and GetDataStream methods.
go to post Marc Mundt · Mar 17, 2021 Here's a working example based on Craig's original sample. It sends a request with 3 mime parts: a form variable with a value, an XML file, and a PDF file loaded from disk. set tURL="http://some.url/path/to/upload" set tHttpRequest = ##class(%Net.HttpRequest).%New() // ---------------------------------------- // Instantiate reportId MIME Part Set reportId = ##class(%Net.MIMEPart).%New() // Define/Set the Content-Disposition header indicating how this MIME part is encoded and what it contains. // Final string looks like: form-data; name="reportId" S tContentDisp = "form-data; name="_$CHAR(34)_"reportId"_$CHAR(34) Do reportId.SetHeader("Content-Disposition", tContentDisp) // Write the reportId to the MIME Part body. Set reportId.Body = ##class(%GlobalCharacterStream).%New() Do reportId.Body.Write("RptID12345") // ---------------------------------------- // Instantiate file1 (XML Doc) MIME Part Set file1 = ##class(%Net.MIMEPart).%New() // Define/Set the Content-Disposition header indicating how this MIME part is encoded and what it contains. // Final string looks like: form-data; name="file1"; filename="<pRequest.CaseNumber>.xml" S tContentDisp = "form-data; name="_$CHAR(34)_"file1"_$CHAR(34)_"; filename="_$CHAR(34)_"xmlfile.xml"_$CHAR(34) Do file1.SetHeader("Content-Disposition", tContentDisp) // Write XML to the MIME Part body. Set file1.Body = ##class(%GlobalCharacterStream).%New() Set file1.ContentType = "application/xml" do file1.Body.Write("<myXML><element1>value</element1></myXML>") // ---------------------------------------- // Instantiate file1 (PDF Report) MIME Part Set file2 = ##class(%Net.MIMEPart).%New() // Define/Set the Content-Disposition header indicating how this MIME part is encoded and what it contains. // Final string looks like: form-data; name="file1"; filename="<pRequest.CaseNumber>.xml" S tContentDisp = "form-data; name="_$CHAR(34)_"file2"_$CHAR(34)_"; filename="_$CHAR(34)_"PDFFile.pdf"_$CHAR(34) Do file2.SetHeader("Content-Disposition", tContentDisp) // Get the content for the PDF file set tFile=##class(%Stream.FileBinary).%New() do tFile.LinkToFile("C:\Projects\test.pdf") // Write PDF content to the MIME Part body. Set file2.Body = ##class(%GlobalBinaryStream).%New() Set file2.ContentType = "application/pdf" do file2.Body.CopyFrom(tFile) // ---------------------------------------- // Pack everything up and send the request // Package sub-MIME Parts into Root MIME Part Set rootMIME = ##class(%Net.MIMEPart).%New() Do rootMIME.Parts.Insert(reportId) Do rootMIME.Parts.Insert(file1) Do rootMIME.Parts.Insert(file2) // Write out Root MIME Element (containing sub-MIME parts) to HTTP Request Body. Set writer = ##class(%Net.MIMEWriter).%New() Set sc = writer.OutputToStream(tHttpRequest.EntityBody) if $$$ISERR(sc) {do $SYSTEM.Status.DisplayError(sc) Quit} Set sc = writer.WriteMIMEBody(rootMIME) if $$$ISERR(sc) {do $SYSTEM.Status.DisplayError(sc) Quit} // Specify the Content-Type and Root MIME Part Boundary (required for multipart/form-data encoding.) Set tContentType = "multipart/form-data; boundary="_rootMIME.Boundary Set tSC = tHttpRequest.SetHeader("Content-Type",tContentType) // Call SendFormDataArray method in the adapter to execute POST. Response contained in tHttpResponse Set tSC=tHttpRequest.Post(tURL) If $$$ISERR(tSC) { // Oops, an error. Do something }
go to post Marc Mundt · Mar 9, 2021 You can use %Stream.FileBinary to create a file-based stream and then copy the contents from the %CSP.BinaryStream to it. Set stream=##class(%Stream.FileBinary).%New() Set sc=stream.LinkToFile("c:\myfile.txt") Set sc=stream.CopyFromAndSave(myCSPBinaryStream)
go to post Marc Mundt · Mar 8, 2021 Yone, try removing this line and test if it works: Set pOutput=##class(%GlobalBinaryStream).%New()
go to post Marc Mundt · Feb 25, 2021 Sample code using Embedded SQL: set tName="EMRNameA" set tEMRNameLike="%"_tName &SQL(SELECT DataValue INTO :tValue FROM Ens_Util.LookupTable WHERE TableName = 'EMRName' AND KeyName LIKE :tEMRNameLike) if (SQLCODE = 0) { write "tValue:",tValue,! } else { write tName_" Not found",! }
go to post Marc Mundt · Feb 23, 2021 Just a quick thought: if everything is being passed in the URL then this should probably be a GET rather than a POST. You can call ..Adapter.Get() instead, passing it pFormVarNames as a list of form/URL variable names and pData with the actual values. https://docs.intersystems.com/healthconnectlatest/csp/documatic/%25CSP.D...
go to post Marc Mundt · Feb 18, 2021 A visual trace URL takes the form of: EnsPortal.VisualTrace.zen?SESSIONID=12818 You'll need to run some queries (once in the router namespace and once in the edge namespace) to find the session ID that corresponds to your control ID.You can find messages with that control id by querying the search table.First you need to get the search table property ID for the MSHControlID. Change the value of ClassExtent to match whatever your local search table class is if you're not using the default: SELECT PropId from Ens_Config.SearchTableProp WHERE ClassExtent='EnsLib.HL7.SearchTable' AND Name='MSHControlID' Let's say that returns a PropId of 1 You can then query the search table for the control ID you're looking for where PropValue is the control id. If you have a custom search table you'll need to use your custom table name here instead of the default EnsLib_HL7.SearchTable: SELECT DocId FROM EnsLib_HL7.SearchTable WHERE PropId=1 AND PropValue='123456789' This gives you the ID for the message body. Let's say it returned a DocId of 98765. You can then query the message header table to get the session ID that that message body belongs to: SELECT DISTINCT(SessionId) FROM Ens.MessageHeader WHERE MessageBodyID = 98765 Keep in mind that the URL for the Visual Trace could change in future versions, so you're doing this at your own risk.
go to post Marc Mundt · Feb 18, 2021 Currently the most common approach for creating a web application/page which sources data from IRIS is to use one of the popular client side web application frameworks such as Angular, React, or vue.js. In IRIS you would build a web service which your app would call to get data. Creating REST Serviceshttps://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=GREST
go to post Marc Mundt · Feb 17, 2021 To do this in a way that will perform well, I'd suggest making sure MSH:4 is included in your HL7 Search Table. Then you can just query the search table. You could do a join on Ens.MessageHeader to filter by date. https://docs.intersystems.com/irisforhealthlatest/csp/docbook/DocBook.UI...
go to post Marc Mundt · Feb 9, 2021 It's fairly common to use mutual TLS authentication as well. In a nutshell, both sides validate the other's cert before allowing a connection.
go to post Marc Mundt · Feb 5, 2021 %SQL.Statement's %Execute method returns a result set (%SQL.StatementResult) object, not a %Status. You can check if any rows were returned by checking %ROWCOUNT or %Next() in the StatementResult.
go to post Marc Mundt · Jan 29, 2021 I suspect that some of the binary bytes are getting converted to UTF-8, and this is what the "u" option in the sixth argument of %WriteJSONStreamFromObject specifies. You can try removing the "u" and see if that helps, but even if it does I believe you will find other problems because JSON isn't meant to carry raw binary data. Generally binary data is base 64 encoded when putting it in JSON. One example of the problem with binary data is that the value of binario needs to be enclosed in quotes "". But the binary data could include a byte which is the same code as a quote, which would cause the JSON recipient to think that the value of binario has ended. My suggestion is to base 64 encode the binary data.
go to post Marc Mundt · Jan 28, 2021 No, you should only stop a process using the IRIS process management tools unless instructed otherwise by the WRC.
go to post Marc Mundt · Jan 27, 2021 In Studio, go to File -> Change Namespace In the Cache Connection Manager window, click "Connect"In the Server Connection window, select the same server and click "OK"Here you can untick "Remember Password" and login again
go to post Marc Mundt · Jan 25, 2021 You were on the right track with %WriteJSONFromObject(), but you'll want to use %WriteJSONStreamFromObject() instead. I don't see what purpose the Body property in your request class serves. You can just create a stream object variable instead. set myTempStream=##class(%Stream.GlobalCharacter).%New() set tSC=##class("%ZEN.Auxiliary.altJSONProvider").%WriteJSONStreamFromObject(.myTempStream, pRequest) if $$$ISERR(tSC) { quit tSC } ...then later: Set tSC=..Adapter.PostURL(tURL,.tHttpResponse, , myTempStream)