This code snippet provides a ZEN page that downloads a stream from its database directly:
/// We assume that you have stored your data within this schema:
/// MyApp.Model.Storage: Filename,FileSize,Content,ContentType
Class zen.downloadStream Extends (%ZEN.Component.page,%CSP.StreamServer)
{
/// Wrapper to get the id of the download, we assume that the id is passed to this zen page
/// as a URI parameter, i.e.: MyApp.Downloads.cls?OID=1234
ClassMethod GetId()
{
Quit $Get(%request.Data("OID",1))
}
/// Set the appropriate header for the file.
ClassMethod OnPreHTTP() As %Boolean
{
Set tId = ..GetId()
If ##Class(MyApp.Model.Storage).%ExistsId(tId) {
Set tStream = ##Class(MyApp.Model.Storage).%OpenId(tId)
// You could "guess" the content type by its file extension
// or you can store it (before) in the database separately (like in this example).
// Set Extension = $Piece(tStream.Filename,".",$Length(tStream.Filename,"."))
// Set ContentType = ..FileClassify(Extension)
Set %response.ContentType = tStream.ContentType
Do %response.SetHeader("content-disposition","attachment; filename="_tStream.Filename)
Do %response.SetHeader("Content-Length",tStream.FileSize)
}
Else {
Set %response.Status="404 File Not Found"
Quit 0
}
Quit $$$OK
}
ClassMethod OnPage() As %Status
{
Set Download = ##Class(MyApp.Model.Storage).%OpenId(..GetId())
Do Download.Content.OutputToDevice()
Quit $$$OK
}
}
Attached is an example of a web service client that can be used to do a lookup against the CMS NPPES database to validate and retrieve information about a given National Provider Identification (NPI).
I've been having a blast with the Advent of Code puzzles this year - though I'll be heading into a busy span of time with family soon and will probably drop off toward the end. (At least, that's what always seems to happen - it's a good thing, though!)
The simple answer is: a custom widget. A portlet can exist by itself on a DeepSee dashboard, it can be used along side standard DeepSee widgets, or along side other portlets. The rendering of the custom widget is completely user defined. This means you can embed a web page, create a form to perform any sort of action needed based on the data on your dashboard, use third party charting libraries, or simply display data from outside of a DeepSee cube.
The input in today's challenge consists of an encrypted name, a dash, a sectorID, a dash and a checksum between brackets. A name is real if the checksum is equal to the five most common letters in the encypted name.
The attached code package provides a simple implementation of a web service client that utilizes the USPS Shipping API to normalize an address.
This code requires the developer to obtain a USPS Shipping API user ID which can be obtained from the USPS shipping API website. The assigned User Id can either be passed into the web service call as a parameter or can be coded as a parameter into the Request object.
Recently I needed a classmethod that returns annotation value based on a name of a activity.
As doing it at runtime seemed inefficient, I wrote compile-time utility that iterates over all business process activities and generates relevant code.
This code could be used in a variety of situations when you need to iterate over business process activities, just add it as a secondary superclass to your BPL processes.
The challenge of day 5 is to calculate a password of 8 characters by finding the MD5 hash of the input and an increasing integer index. The password is constructed by taking the 6th character of the first 8 hashes that start with 5 zeroes (in hex representation).
The traditional use of an IRIS production is for an inbound adapter to receive input from an external source, send that input to an IRIS service, then have that service send that input through the production.
Do not let the title of this article confuse you; we are not planning to take the InterSystems staff out to a fine Italian restaurant. Instead, this article will cover the principles of working with date and time data types in IRIS. When we use these data types, we should be aware of three different conversion issues:
Converting between internal and ODBC formats.
Converting between local time, UTC, and Posix time.
Converting to and from various date display formats.
The challenge today is about some basic cryptography : you will have to generate data for a one-time pad (OTP) (see https://en.wikipedia.org/wiki/One-time_pad for more info).
We have a yummy dataset with recipes written by multiple Reddit users, however most of the information is free text as the title or description of a post. Let's find out how we can very easily load the dataset, extract some features and analyze it using features from OpenAI large language model within Embedded Python and the Langchain framework.
If you work with Productions, highlighting connections between Business Hosts is a very convenient feature, allowing developers to get a visual representation of a data flow.
This feature works by default with all system Business Hosts. If a user writes their own Business Services, Processes, or Operations, they must implement the OnGetConnections method for this functionality to work with their custom Business Hosts (or use Ens.DataType.ConfigName properties for connections). That said, the SMP shows only the first layer of connections of the selected Business Host. Sometimes, we need to get connections of connections recursively to build a complete data flow graph. Or we might need this connection information to check which downstream systems might be affected by a change upstream.
In this article, I'll show you how to run code at compile time with ObjectScript macros.
Here's a use case that recently led me to use this feature:
As part of a medical application developed for more than 20 years, we have a large number of parameters. Although we have procedures for documenting these settings, it can be helpful to have a quick view of which settings are actually used by the application code.
The following code walks a DOM using %XML.Node. It also prevents %XML.Writer to change whitespace. Run the code using the class method "test":
Class objectscript.walkDOM Extends %Persistent
{
ClassMethod dfs(node As %XML.Node)
{
s entrynode=node.NodeId
do {
//element nodes with one whitespacetyped child are the ones we want to change
if (node.NodeType=$$$xmlELEMENTNODE){
s snode=node.NodeId
if (node.MoveToFirstChild())
{
i ('node.MoveToNextSibling()){
i (node.NodeType=$$$xmlWHITESPACENODE){
s node.NodeType=$$$xmlTEXTNODE
s node.NodeId=snode
}
}
}
s node.NodeId=snode
}
if (node.HasChildNodes()){
d node.MoveToFirstChild()
d ..dfs(node)
}
} while (node.NodeType'="" && node.MoveToNextSibling())
s node.NodeId=entrynode
}
ClassMethod test()
{
set xml = "abcdefg<![CDATA[ ]]>"
s reader=##class(%XML.Reader).%New()
do reader.OpenString(xml)
set writer = ##class(%XML.Writer).%New()
//do some magic
d ..dfs(reader.Document)
w !,"with indent=1:",!
set writer.Indent = 1
do writer.OutputToString()
do writer.Document(reader.Document)
w writer.GetXMLString()
set writer.Indent = 0
w !,"with indent=0:",!
do writer.OutputToString()
do writer.Document(reader.Document)
w writer.GetXMLString()
}
}