<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: InterSystems</title>
    <description>The latest articles on DEV Community by InterSystems (intersystems).</description>
    <link>https://dev.to/intersystems</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F2450%2F5c611adb-602d-4948-b84b-5fe47046fd5c.png</url>
      <title>DEV Community: InterSystems</title>
      <link>https://dev.to/intersystems</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/intersystems"/>
    <language>en</language>
    <item>
      <title>Indexes for Beginners in InterSystems IRIS: Which One to Use and When</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Tue, 24 Nov 2026 15:11:39 +0000</pubDate>
      <link>https://dev.to/intersystems/indexes-for-beginners-in-intersystems-iris-which-one-to-use-and-when-3lkp</link>
      <guid>https://dev.to/intersystems/indexes-for-beginners-in-intersystems-iris-which-one-to-use-and-when-3lkp</guid>
      <description>&lt;p&gt;InterSystems IRIS is, among other things, a relational DBMS. This is why it supports all standard SQL indexes together with some additional ones. For beginners, the variety of index types in IRIS can feel a bit overwhelming. Thus, the goal of this article is to clarify when to use each and provide clear code examples.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fugj3wvge4bxjv04x51jz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fugj3wvge4bxjv04x51jz.png" alt=" " width="800" height="427"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;h2&gt;1. Standard Index&lt;/h2&gt;
&lt;p&gt;This is the default index type in InterSystems IRIS. It functions similarly to a traditional SQL index and is best used for the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;High-Cardinality Data:&lt;/strong&gt; Fields with many unique values, such as names, email addresses, Social Security Numbers, or GUID strings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Range Queries and Exact Lookups:&lt;/strong&gt; Queries using &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;&lt;/code&gt;, or &lt;code&gt;BETWEEN&lt;/code&gt; on non-numeric or high-cardinality fields.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Frequently Modified Properties:&lt;/strong&gt; Fields that constantly change values, as standard indexes are highly efficient during fast-paced insert, update, and delete loops.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can define a standard index using either InterSystems ObjectScript (in persistent classes) or standard DDL (Data Definition Language).&lt;/p&gt;
&lt;p&gt;ObjectScript Definition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class User.Patient Extends %Persistent &lt;br&gt;
{ &lt;br&gt;
Property MedicalRecordNumber As %String; &lt;br&gt;
Property LastName As %String; 

&lt;p&gt;/// A unique standard index for MRN &lt;br&gt;
Index MRNIdx On MedicalRecordNumber [ Unique ]; &lt;/p&gt;

&lt;/code&gt;&lt;p&gt;&lt;code&gt;/// A regular standard index for LastName &lt;br&gt;&lt;br&gt;
Index LastNameIdx On LastName;&lt;br&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;SQL DDL Definition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;CREATE INDEX LastNameIdx ON User.Patient (LastName)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The IRIS query optimizer bypasses a full table scan and jumps directly to the &lt;code&gt;LastNameIdx&lt;/code&gt; structure to isolate the matching records.&lt;/p&gt;
&lt;h2&gt;2. Bitmap Index&lt;/h2&gt;
&lt;p&gt;This index uses a series of bit vectors (strings of 0s and 1s), with each bit position corresponding to an internal Row ID. If a row possesses a specific value, its bit is set to &lt;code&gt;1&lt;/code&gt;. IRIS compresses these bitmaps using an advanced proprietary scheme, making them incredibly lightweight in memory and on disk. It is best used for the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Low-Cardinality Data:&lt;/strong&gt; Properties with a limited number of distinct values across your dataset, such as Gender, Marital Status, Order Status (e.g., Pending, Shipped, Delivered), or US States.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The 10,000 Rule:&lt;/strong&gt; As a rule of thumb, for tables with more than 1 million records, avoid bitmap indexes on fields containing more than 10,000 unique values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complex Combinations:&lt;/strong&gt; Queries that utilize multiple boolean operations (&lt;code&gt;AND&lt;/code&gt;, &lt;code&gt;OR&lt;/code&gt;, &lt;code&gt;NOT&lt;/code&gt;) on low-cardinality fields. IRIS can perform bitwise logic directly on the index maps in memory before fetching the actual data rows.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;⚠️ Warning: Do not use bitmap indexes on highly transactional tables where rows are continuously inserted or deleted by multiple threads, as this can introduce locking contention within the bitmap chunks.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;ObjectScript Definition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class User.Patient Extends %Persistent &lt;br&gt;&lt;br&gt;
{ &lt;br&gt;&lt;br&gt;
Property Status As %String(VALUELIST = ",Active,Discharged"); &lt;br&gt;&lt;br&gt;
/// Define a bitmap index using the Type keyword &lt;br&gt;&lt;br&gt;
Index StatusIdx On Status [ Type = bitmap ];

&lt;/code&gt;&lt;p&gt;&lt;code&gt;Property Gender As %String(VALUELIST = ",M,F"); &lt;br&gt;&lt;br&gt;
/// Define a bitmap index using the Type keyword &lt;br&gt;&lt;br&gt;
Index GenderIdx On Gender [ Type = bitmap ];&lt;br&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;SQL DDL Definition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;CREATE BITMAP INDEX StatusIdx ON User.Patient (Status)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can use these indices in the following case:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT COUNT(&lt;em&gt;) FROM SQLUser.Patient WHERE Status = 'Active' AND Gender = 'M'&lt;/em&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;IRIS will perform a bitwise &lt;code&gt;AND&lt;/code&gt; operation on the &lt;code&gt;Status&lt;/code&gt; and &lt;code&gt;Gender&lt;/code&gt; bitmaps. The calculation is completed entirely within the index structure, allowing it to return the exact count instantly.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;&lt;em&gt;2. Bitmap Extent Index&lt;/em&gt;&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;This is a specialized bitmap index that tracks the rows of the table itself rather than the values of a specific field. Each bit represents a sequential RowID integer value, where 1 or 0 simply indicates whether the corresponding row exists in the database. A table can have, at most, one bitmap extent index. It is best used for the following:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;&lt;strong&gt;Counting Table Rows&lt;/strong&gt;: InterSystems SQL relies heavily on this index to optimize COUNT(&lt;/em&gt;) operations by scanning a compressed bitstring rather than traversing row data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tracking Record Existence&lt;/strong&gt;: Automatically validating whether specific internal RowIDs are active or have been deleted.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;&lt;p&gt;💡 Note: Tables defined via SQL CREATE TABLE automatically receive a bitmap extent index. Tables defined via Persistent Classes do not generate one automatically unless you add a traditional bitmap index to the class, which prompts IRIS to auto-create an extent index.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This index will be used&amp;nbsp;automatically in the following Select statement:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT COUNT(*) FROM SQLUser.Patient&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Instead of executing a costly table scan, the query planner reads the single BITMAPEXTENT structure to calculate the total record count.&lt;/p&gt;
&lt;h2&gt;3. Bitslice Index&lt;/h2&gt;
&lt;p&gt;This is a unique, highly specialized version of a bitmap index designed exclusively for numeric data. Instead of creating a bitmap for each distinct number, a bitslice index breaks the numeric value into its binary components and creates a "bit plane" position for each bit. It is best used for the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Numeric Aggregations:&lt;/strong&gt; Columns where you regularly run mathematical operations like &lt;code&gt;SUM()&lt;/code&gt;, &lt;code&gt;AVG()&lt;/code&gt;, or range checks on large quantities of rows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Massive Datasets:&lt;/strong&gt; Tables containing millions of rows, where dynamic totals would be too slow to calculate via traditional row-by-row scanning.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;ObjectScript Definition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class User.Patient Extends %Persistent &lt;br&gt;&lt;br&gt;
{ &lt;br&gt;&lt;br&gt;
Property Visits As %Numeric; &lt;br&gt;&lt;br&gt;
/// Define a bitslice index using the Type keyword &lt;br&gt;&lt;br&gt;
Index VisitsIdx On Visits [ Type = bitslice ];&lt;br&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;&lt;p&gt;💡 Note: Bitslice indexes cannot be directly created using standard SQL DDL syntax in IRIS; they must be defined via the persistent class architecture.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;We can use these indices in the following Select statement:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT SUM(Visits) FROM SQLUser.Patient WHERE Gender = 'M'&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Instead of pulling every row into memory and adding up the amounts, IRIS natively shifts and tallies the bit vectors, computing massive aggregations up to 100 times faster than a standard scan.&lt;/p&gt;
&lt;h2&gt;4. Columnar Index&lt;/h2&gt;
&lt;p&gt;This index is designed for fields frequently queried analytically but stored in a table with an underlying row storage structure. By default, IRIS stores table rows horizontally as a $LIST structure within a single global subscript. A columnar index flips this strategy for a specific column, saving its data vertically in a highly compressed, vectorized format.&lt;/p&gt;
&lt;p&gt;While a columnar index functions similarly to a bitmap index, it is slightly less efficient for strict equality conditions (=) since it requires a vectorized operation to extract bitstrings. However, it shines dramatically brighter than bitmap indexes for range conditions (&amp;gt;, &amp;lt;, BETWEEN), which can compute ranges in a single vectorized pass rather than combining multiple separate bitstrings.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;⚠️ Limitation: A columnar index cannot be defined on a serial property or a subclass. Yet, you can freely determine one on a non-serial property of a subclass (e.g., an %Integer or %Numeric).&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;It is best used for the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid Data Models&lt;/strong&gt;: Tables that experience heavy transactional row inserts but still require complex analytical querying on specific columns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Range Conditions&lt;/strong&gt;: Queries looking for numbers, dates, or prices within specific upper and lower bounds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Targeted Aggregations&lt;/strong&gt;: Queries that compute metrics on a single column while ignoring the rest of the row data.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;ObjectScript Definition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class User.Patient Extends %Persistent &lt;br&gt;&lt;br&gt;
{ &lt;br&gt;&lt;br&gt;
Property Amount As %Numeric(SCALE = 2); &lt;br&gt;&lt;br&gt;
/// Define a columnar index using the Type keyword &lt;br&gt;&lt;br&gt;
Index AmountIndex On Amount [ Type = columnar ];&lt;br&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;SQL DDL Definition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;CREATE COLUMNAR INDEX AmountIndex ON SQLUser.Patient(Amount)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can use these indices in the following Select statement:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT AVG(Amount) FROM SQLUser.Patient WHERE Status = 'Active'&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With the AmountIndex active, the query optimizer computes the AVG directly from the compressed, vectorized index data, entirely bypassing row storage.&lt;/p&gt;
&lt;h2&gt;Summary Cheat Sheet&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Index Type&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Data Profile&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Primary Use Case&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Performance Strength&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Standard&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High cardinality (names, IDs, unique strings)&lt;/td&gt;
&lt;td&gt;Exact lookups, inequality matches, fast write speeds&lt;/td&gt;
&lt;td&gt;Single row fetches and targeted ranges&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Bitmap&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Low cardinality (&amp;lt;10,000 unique values; status, flags)&lt;/td&gt;
&lt;td&gt;Combining filters using &lt;code&gt;AND&lt;/code&gt;/&lt;code&gt;OR&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Rapid Boolean operations on large datasets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Bitslice&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Numeric fields (amounts, ages, scores)&lt;/td&gt;
&lt;td&gt;Running aggregations like &lt;code&gt;SUM()&lt;/code&gt; and &lt;code&gt;AVG()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Aggregates without reading raw data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Columnar&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fields on row-tables used for heavy scanning/ranges&lt;/td&gt;
&lt;td&gt;Scans, single-column math, and range conditions&lt;/td&gt;
&lt;td&gt;High-speed vectorized data operations&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;I hope this article will shed some light on the basics of indices and their usage in IRIS. You can read more in the documentation listed below.&lt;/p&gt;


</description>
      <category>beginners</category>
      <category>indexing</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Calling Business Operations and Services from the Terminal: Testing, Debugging, and OnTask</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Tue, 24 Nov 2026 15:08:01 +0000</pubDate>
      <link>https://dev.to/intersystems/calling-business-operations-and-services-from-the-terminal-testing-debugging-and-ontask-270d</link>
      <guid>https://dev.to/intersystems/calling-business-operations-and-services-from-the-terminal-testing-debugging-and-ontask-270d</guid>
      <description>&lt;p&gt;A Practical Guide to InterSystems IRIS Interoperability: Terminal Invocation, Custom Adapters with OnTask, Context Mocking, and Debugging Workflows (2026)&lt;/p&gt;
&lt;h2&gt;TL;DR / Quick Answer&lt;/h2&gt;
&lt;p&gt;InterSystems IRIS Interoperability hosts (Services, Processes, Operations) run in separate background jobs and communicate via persistent message queues. Developers can test and debug these items directly from the IRIS Terminal using&amp;nbsp;Ens.Director.CreateBusinessService for adapterless services,&amp;nbsp;%New("ConfigName") for direct operation calls, and&amp;nbsp;EnsLib.Testing.Service.SendTestRequest for full queue pipelines. Custom inbound adapters poll external sources by overriding OnTask(). For local terminal execution where system headers are unpopulated,&amp;nbsp;developers can manually mock the %SessionId and %RequestHeader properties.&lt;/p&gt;
&lt;h2&gt;Who This Article Is For&lt;/h2&gt;
&lt;p&gt;This guide is designed for IRIS integration developers, system engineers, and solutions architects who want to invoke Business Services and Operations from the IRIS Terminal, implement custom polling logic via OnTask(), and systematically test or debug production hosts.&lt;/p&gt;
&lt;h2&gt;Main Topic / Question #1: Terminal Execution Protocols for Business Hosts&lt;/h2&gt;
&lt;p&gt;InterSystems IRIS Interoperability hosts can be programmatically instantiated and executed directly inside an active Terminal process.&lt;/p&gt;
&lt;p&gt;Because unlike regular class method invocation, Business Services, Processes, and Operations serve different roles in a production, each requires a specific invocation strategy when executed from the terminal:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Business Services (Adapterless): Programmatically instantiated via Ens.Director.CreateBusinessService() and executed through .ProcessInput(). The production must be running, and the service must be adapterless or configured with Pool Size = 0.&lt;/li&gt;
&lt;li&gt;Business Operations: Instantiated directly using class(My.Operation).%New("ConfigName"). You must pass the item's production configuration name to %New(). Execution bypasses message queues and triggers .OnMessage() or a MessageMap method directly in the terminal process.&lt;/li&gt;
&lt;li&gt;Business Processes (BPs): Cannot be executed in isolation via %New() because they rely on internal state and message router engines. BPs must be triggered from the terminal by sending a request through an adapterless Business Service or by using EnsLib.Testing.Service.SendTestRequest() targeted directly at the BP config name.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;OnTask() and Custom Inbound Adapters&lt;/h2&gt;
&lt;p&gt;The OnTask() method is the core execution-loop mechanism used by IRIS Interoperability adapters to handle physical transport protocols.&lt;/p&gt;
&lt;p&gt;In Business Services and Operations, the framework (Ens.Job) manages OnTask () internally to poll queues or monitor connections. However, when writing a Custom Inbound Adapter, OnTask() is the documented entry point where developers can write custom polling or listening logic.&lt;/p&gt;
&lt;h3&gt;Custom Inbound Adapter Implementation&lt;/h3&gt;
&lt;p&gt;To create a custom inbound adapter, extend Ens.InboundAdapter and override OnTask():&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class Custom.Adapter.FileWatcher Extends Ens.InboundAdapter 
{ 

/// Custom OnTask method executed periodically based on CallInterval 
Method OnTask() As %Status 
{ 
    Set tSC = $$$OK 
    Try { 
        // 1. Check for incoming data (e.g., scan directory or check queue) 
        Set tHasData = ..CheckForNewData(.tPayload) 
        
        If tHasData { 
            // 2. Pass payload to the parent Business Service via ProcessInput 
            Set tSC = ..BusinessHost.ProcessInput(tPayload) 
        } 
    } 
    Catch ex { 
        Set tSC = ex.AsStatus() 
    } 
    Quit tSC 
} 

Method CheckForNewData(Output pPayload As %RegisteredObject) As %Boolean 
{ 
    // Custom check logic here 
    Quit 0 
} 

} 
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;How OnTask() Executes Under the Hood&amp;nbsp;&lt;/h3&gt;
&lt;p&gt;The background job (Ens.Job) running a Business Service executes an infrastructure loop. The complete execution chain flows show below:&amp;nbsp;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Job Loop&amp;nbsp; Business Service: The underlying system process continuously calls&amp;nbsp;OnTask() on&amp;nbsp;Ens.BusinessService.&lt;/li&gt;
&lt;li&gt;Business Service&amp;nbsp; Inbound Adapter:&amp;nbsp;Ens.BusinessService.OnTask() delegates execution to&amp;nbsp;..Adapter.OnTask().&lt;/li&gt;
&lt;li&gt;Inbound Adapter&amp;nbsp; Business Service Callback: When your adapter's&amp;nbsp;OnTask() finds data, it calls&amp;nbsp;..BusinessHost.ProcessInput(payload). (..BusinessHost is automatically set to&amp;nbsp;$this parent service instance upon initialization).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Terminal Context Initialization &amp;amp; Mocking Strategy&lt;/h2&gt;
&lt;p&gt;When invoking a Business Operation directly from the Terminal using %New("ConfigName"), execution occurs entirely within the terminal process rather than through the queue engine (MessageHeaderHandler).&lt;/p&gt;
&lt;p&gt;As a result, framework-populated context properties are uninitialized by default:&lt;/p&gt;
&lt;p&gt;* ..%SessionId is "" (empty).&lt;/p&gt;
&lt;p&gt;* ..%RequestHeader is NIL (Oref does not exist).&lt;/p&gt;
&lt;p&gt;* ..Adapter properties (HTTP Server, SSL Config, Credentials) are not loaded from production settings.&lt;/p&gt;
&lt;h3&gt;Mocking Context and Adapter Setup in Terminal&lt;/h3&gt;
&lt;p&gt;If your operation code relies on ..%SessionId or ..%RequestHeader, mock these properties manually before calling .OnMessage():&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ZN "YOURNAMESPACE" 

// 1. Instantiate Operation with Config Name 
Set op = class(Test.Interop.Operation.TestOperation).%New("Test.Interop.Operation.TestOperation") 
If op = "" Do $System.Status.DisplayError(%objlasterror) Quit 

// 2. Initialize Adapter Properties manually for terminal test 
Do op.OnInit() 
Set op.Adapter = class(EnsLib.HTTP.OutboundAdapter).%New() 
Set op.Adapter.HTTPServer = "server.example.com" 
Set op.Adapter.HTTPPort = 443 
Set op.Adapter.SSLConfig = "MySSL" 
Set op.Adapter.BusinessHost = op 

// 3. Mock Session ID and Request Header 
Set op.%SessionId = 99999 
Set header = class(Ens.MessageHeader).%New() 
Set header.SourceConfigName = "TerminalTestService" 
Set header.TargetConfigName = "Test.Interop.Operation.TestOperation" 
Set op.%RequestHeader = header 

// 4. Construct Request Payload &amp;amp; Execute 
Set req = class(Test.Interop.Msg.Request.TestOperationRequest).%New() 
Set req.PersonId = "1001" 

Set sc = op.OnMessage(req, .resp) 
If 'sc Do $System.Status.DisplayError(sc) 
Zw resp 
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Production Message Replay &amp;amp; Terminal Unit Testing&lt;/h2&gt;
&lt;p&gt;The fastest way to reproduce production issues is to extract a failed request body from persistent storage and re-execute it against an operation instance in the terminal.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Step 1: Fetch failed Message Header by ID (found via Message Viewer or SQL) 
Set hdr = class(Ens.Request).%OpenId(98765) 
Write "Message Class: ", hdr.MessageBodyClassName, " ID: ", hdr.MessageBodyId, ! 
Set req = class(Test.Interop.Operation.TestRequest).%New() 
Set op = class(Test.Interop.Operation.TestOperation).%New("Test.Interop.Operation.TestOperation") 
If op = "" Do $System.Status.DisplayError(%objlasterror) Quit 

Set sc = op.OnMessage(req, .resp) 
If 'sc Do $System.Status.DisplayError(sc) 
Zwrite resp 
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Terminal Breakpoints and Stepping Diagnostics&lt;/h2&gt;
&lt;p&gt;When running code in the terminal process, you can set dynamic breakpoints without editing class source files:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Set dynamic breakpoint on line 3 of OnMessage in compiled routine 
ZBREAK zOnMessage+3^Test.Interop.Operation.TestOperation.1 

// Display active breakpoints 
ZBREAK 

// Clear all active breakpoints 
ZBREAK /CLEAR &lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Comprehensive Debugging &amp;amp; Diagnostics Workflow&lt;/h2&gt;
&lt;p&gt;Systematic production troubleshooting follows a fixed four-step progression: locate the error message, review its Visual Trace graph, replay the message in the terminal, and attach the interactive debugger.&lt;/p&gt;
&lt;h3&gt;Logging Macros Reference&lt;/h3&gt;
&lt;p&gt;The following built-in macros are available in any class extending an&amp;nbsp;Ens.* host component. In plain ObjectScript routines, you can manually include them with&amp;nbsp;#include Ensemble.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Method OnMessage(pRequest As Test.Interop.Msg.Request.TestOperationRequest, Output pResponse As Ens.Response) As %Status 
{ 
    Set tSC = $$$OK 
    Try { 
        // Trace execution details 
        $$$TRACE("Start: Session="_..%SessionId_" From="_..%RequestHeader.SourceConfigName) 
        $$$catTRACE("http", "Request PersonId="_pRequest.PersonId) 

        // Validate condition 
        $$$LOGASSERT(pRequest.PersonId '= "") 

        // Outbound call 
        Set tSC = ..CallExternal(pRequest, .tResult) 
        If $$$ISERR(tSC) { 
            $$$LOGSTATUS(tSC) 
            Quit 
        } 

        $$$LOGINFO("Successfully processed PersonId: "_pRequest.PersonId) 
    } 
    Catch ex { 
        Set tSC = ex.AsStatus() 
        $$$LOGERROR("Exception encountered: "_ex.DisplayString()) 
    } 
    Quit tSC 
}&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;Detailed Macro Descriptions&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.intersystems.com/iris20262/csp/docbook/DocBook.UI.Page.cls?KEY=EGDV_logtrace#EGDV_prog_trace_adding" rel="noopener noreferrer"&gt;$$$TRACE("msg")&lt;/a&gt;&amp;nbsp; -&amp;nbsp;Writes a trace entry to the Event Log.&lt;ul&gt;&lt;li&gt;Behavior: Outputs only when&amp;nbsp;Log Trace Events is explicitly enabled in the host item or production settings. Stays inactive in standard production runs to optimize performance.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;$$$catTRACE("cat", "msg") -&amp;nbsp;Writes a trace entry under a specific category name (e.g.,&amp;nbsp;"http",&amp;nbsp;"db",&amp;nbsp;"xml").&lt;ul&gt;&lt;li&gt;Behavior: Outputs only when trace logging is enabled and the global category is activated in the terminal:&lt;ul&gt;
&lt;li&gt;Enable:&amp;nbsp;Set ^Ens.Debug("TraceCat","http") = 1&lt;/li&gt;
&lt;li&gt;Disable:&amp;nbsp;Kill ^Ens.Debug("TraceCat","http")&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.intersystems.com/iris20262/csp/docbook/DocBook.UI.Page.cls?KEY=EGDV_logtrace#EGDV_prog_event_log_generating_objectscript" rel="noopener noreferrer"&gt;$$$LOGINFO("msg")&lt;/a&gt; -&amp;nbsp;Writes an informational log entry to the Event Log (Ens_Util.Log).&lt;ul&gt;&lt;li&gt;Behavior: Always logs regardless of trace settings. Used for high-level workflow milestones.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;$$$LOGWARNING("msg") -&amp;nbsp;Writes a warning log entry to the Event Log (Ens_Util.Log).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Behavior: Always logs. Utilized for non-fatal irregularities (e.g., fallback logic used, missing non-critical parameters).&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;
&lt;a href="https://docs.intersystems.com/iris20262/csp/docbook/DocBook.UI.Page.cls?KEY=EGDV_logtrace#EGDV_prog_event_log_generating_objectscript" rel="noopener noreferrer"&gt;$$$LOGERROR("msg") &lt;/a&gt;-&amp;nbsp;Writes an error log entry to the Event Log (Ens_Util.Log).&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Behavior: Always logs. Used inside&amp;nbsp;Catch blocks or exception handlers to record critical runtime failures.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;$$$LOGSTATUS(sc) -&amp;nbsp;Evaluates a&amp;nbsp;%Status variable (sc) and logs its formatted error text to the Event Log.Behavior: Logs an entry only if&amp;nbsp;sc represents an error condition ($$$ISERR(sc) is true). It automatically formats system error codes into human-readable text.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.intersystems.com/iris20262/csp/docbook/Doc.View.cls?KEY=EGDV_logtrace#EGDV_prog_event_log_generating" rel="noopener noreferrer"&gt;$$$LOGASSERT(cond) &lt;/a&gt;-&amp;nbsp;Evaluates a boolean condition (cond).&lt;ul&gt;&lt;li&gt;Behavior: Logs an assertion failure to the Event Log only if&amp;nbsp;cond evaluates to false (0). Utilized for verifying runtime invariants during integration testing.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Terminal Macro Usage Caution&lt;/h3&gt;
&lt;p&gt;In a plain terminal process, standard&amp;nbsp;$$$* macros may not be compiled in your workspace routine. Check status values manually in terminal scripts using ObjectScript functions rather than macros.&lt;/p&gt;
&lt;h2&gt;Log Inspection SQL Queries&lt;/h2&gt;
&lt;p&gt;Query the system log and message tables directly via SQL in the Management Portal or $system.SQL.Shell():&lt;/p&gt;
&lt;p&gt;-- Query recent errors and warnings for a specific host&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT TOP 50 TimeLogged, Type, ConfigName, SessionId, SourceMethod, Text
FROM Ens_Util.Log

WHERE ConfigName = 'Test.Interop.Operation.TestOperation' AND Type IN (2, 3)

ORDER BY ID DESC;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-- Query failed messages by target config name&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT TOP 50 ID, SessionId, SourceConfigName, TimeCreated, Status, ErrorStatus, MessageBodyClassName, MessageBodyId

FROM Ens.MessageHeader

WHERE TargetConfigName = 'Test.Interop.Operation.TestOperation' AND IsError = 1

ORDER BY ID DESC;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="https://docs.intersystems.com/iris20262/csp/docbook/DocBook.UI.Page.cls?KEY=ITECHREF_production#ITECHREF_production_available_tools" rel="noopener noreferrer"&gt;Production Control Commands&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;zn "YOURNAMESPACE"&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.intersystems.com/iris20262/csp/documatic/%25CSP.Documatic.cls?LIBRARY=ENSLIB&amp;amp;CLASSNAME=Ens.Director#METHOD_GetProductionStatus" rel="noopener noreferrer"&gt;##class(Ens.Director).GetProductionStatus(.prod, .state)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.intersystems.com/iris20262/csp/documatic/%25CSP.Documatic.cls?LIBRARY=ENSLIB&amp;amp;CLASSNAME=Ens.Director#METHOD_StartProduction" rel="noopener noreferrer"&gt;##class(Ens.Director).StartProduction("My.Production")&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.intersystems.com/iris20262/csp/documatic/%25CSP.Documatic.cls?LIBRARY=ENSLIB&amp;amp;CLASSNAME=Ens.Director#METHOD_StopProduction" rel="noopener noreferrer"&gt;##class(Ens.Director).StopProduction(10, 1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.intersystems.com/iris20262/csp/documatic/%25CSP.Documatic.cls?LIBRARY=ENSLIB&amp;amp;CLASSNAME=Ens.Director#METHOD_UpdateProduction" rel="noopener noreferrer"&gt;##class(Ens.Director).UpdateProduction()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.intersystems.com/iris20262/csp/documatic/%25CSP.Documatic.cls?LIBRARY=ENSLIB&amp;amp;CLASSNAME=Ens.Director#METHOD_EnableConfigItem" rel="noopener noreferrer"&gt;##class(Ens.Director).EnableConfigItem("MyOp", 1, 1)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Invoking an Adapterless Business Service:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ens.Director.CreateBusinessService("MyServiceConfigName", .tService)&lt;/li&gt;
&lt;li&gt;Ens.StringRequest (payload initialization)&lt;/li&gt;
&lt;li&gt;tService.ProcessInput(tInput, .tOutput)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Common Mistakes&lt;/h2&gt;
&lt;p&gt;Key operational pitfalls when calling hosts from the Terminal or writing custom adapters include the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Calling %New() Without a Config Name: Executing class(My.Operation).%New() without supplying the production item configuration name causes %OnNew() to fail and return "".&lt;/li&gt;
&lt;li&gt;Invoking MessageHeaderHandler() Directly: Attempting to call op.MessageHeaderHandler() manually in the terminal throws errors because it requires an active Ens.MessageHeader instance and background process job context.&lt;/li&gt;
&lt;li&gt;Calling OnTask() Manually: Triggering adapter.OnTask() directly in custom terminal scripts rather than letting the host process invoke it automatically causes issues.&lt;/li&gt;
&lt;li&gt;Swallowing Errors in Operation Catch Blocks: Returning $$$OK when handling exceptions prevents the production engine from marking messages as Error or executing retries.&lt;/li&gt;
&lt;li&gt;Forgetting to Restart Hosts After Compilation: Recompiling host class code without restarting the item in Production Monitor or calling Ens.Director.UpdateProduction() leaves background processes running older compiled routines.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Frequently Asked Questions (FAQ)&lt;/h2&gt;
&lt;p&gt;Q:&amp;nbsp;Why does class(My.Operation).%New() return an empty string ("") in the terminal?&lt;/p&gt;
&lt;p&gt;A: Pass the item's configured production name to %New(), e.g., Set op = class(My.Operation).%New("MyOperationConfigName"). If it still returns "", check %objlasterror or verify that adapter settings (such as SSL configurations or credentials) are valid.&lt;/p&gt;
&lt;p&gt;Q: Can I test a Business Process directly using %New() in the Terminal?&lt;/p&gt;
&lt;p&gt;A: No. Business Processes rely on routing engine states and queue envelopes. To test a BP from the terminal, pass a request through an adapterless Business Service or call EnsLib.Testing.Service.SendTestRequest() with the BP's configuration name.&lt;/p&gt;
&lt;p&gt;Q:&amp;nbsp;How do I test an Inbound Adapter that uses OnTask() from the terminal?&lt;/p&gt;
&lt;p&gt;A: Instead of calling OnTask() directly, execute the parent Business Service using Ens.Director.CreateBusinessService() and pass mock data into .ProcessInput().&lt;/p&gt;
&lt;p&gt;Q: Why are %SessionId and %RequestHeader empty during direct operation calls?&lt;/p&gt;
&lt;p&gt;Direct terminal calls are executed within your terminal process, bypassing the production queue engine (MessageHeaderHandler).You must manually mock %SessionId and %RequestHeader properties in your test script if your operation code requires them.&lt;/p&gt;
&lt;p&gt;Q: How can I capture raw outbound HTTP or SOAP traffic during debugging?&lt;/p&gt;
&lt;p&gt;A: For HTTP, use httpRequest.Send("POST", "/api", 1) (setting the test flag to 1 prints the request payload without sending). For SOAP, enable logging globally by setting Set &lt;a href="https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=GSOAP_debug" rel="noopener noreferrer"&gt;^ISCSOAP("LogFile")&lt;/a&gt; = "/tmp/soap.log" and Set ^ISCSOAP("Log") = "ios".&lt;/p&gt;
&lt;h2&gt;H2 — Practical Recommendations &amp;amp; Checklist&lt;/h2&gt;
&lt;p&gt;Follow this workflow checklist when developing, calling, and debugging InterSystems IRIS host components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Isolate Core Logic: Place core business logic in standalone class methods (e.g., My.Util.Parser.Process(req)) so you can unit test logic without relying on production adapter settings or system queues.&lt;/li&gt;
&lt;li&gt;Mock Context in Terminal: When executing operations from the terminal, explicitly instantiate adapter settings and mock %SessionId and %RequestHeader before calling .OnMessage().&lt;/li&gt;
&lt;li&gt;Clean Up Debug Markers and %variables: Remove BREAK statements, temporary $STACK trace logging loops, and global debug flags (^Ens.Debug, ^ISCSOAP) before deploying code to production environments.&lt;/li&gt;
&lt;li&gt;Verify Namespace and Config Names: Ensure case-sensitive accuracy for configuration names passed to SendRequestSync, %New, and SendTestRequest.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Effectively testing and debugging InterSystems IRIS Interoperability hosts requires choosing the right invocation strategy for each host type. Adapterless Business Services are executed via CreateBusinessService, Operations are tested directly using %New("ConfigName") with mocked context properties, and custom polling behavior is implemented by overriding OnTask() in custom inbound adapters.&lt;/p&gt;

</description>
      <category>soap</category>
      <category>ai</category>
      <category>testing</category>
      <category>webdev</category>
    </item>
    <item>
      <title>ObjectScript LLM Benchmark: Execution-Graded Results for 14 Models</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Tue, 17 Nov 2026 16:21:49 +0000</pubDate>
      <link>https://dev.to/intersystems/objectscript-llm-benchmark-execution-graded-results-for-14-models-4hf4</link>
      <guid>https://dev.to/intersystems/objectscript-llm-benchmark-execution-graded-results-for-14-models-4hf4</guid>
      <description>&lt;p&gt;We've published the first open benchmark measuring LLM competence on InterSystems ObjectScript&lt;br&gt;
and the IRIS platform: &lt;a href="https://github.com/isc-nmitchko/ObjectScript-LLM-Benchmark" rel="noopener noreferrer"&gt;ObjectScript LLM Benchmark&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/isc-nmitchko/ObjectScript-LLM-Benchmark" rel="noopener noreferrer"&gt;ObjectScript LLM Benchmark&lt;/a&gt; evaluates 14 LLMs on 140 hand-written items covering ObjectScript and the InterSystems IRIS platform. The benchmark tests code generation, comprehension, and bug fixing. 93 items are execution-graded on a live IRIS instance, while 47 comprehension items are evaluated by a rubric-driven LLM judge. Overall accuracy ranges from 0.515 to 0.851, with the top 9 models forming a statistically overlapping cluster. Code generation is the most difficult and discriminating task family. Model cost varies substantially even among models with similar accuracy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why benchmark LLMs on ObjectScript and IRIS?
&lt;/h2&gt;

&lt;p&gt;Established coding benchmarks — SWE-bench, LiveCodeBench, Terminal-Bench — draw from Python,&lt;br&gt;
JavaScript, and shell. None cover ObjectScript, IRIS SQL, Embedded Python, or &lt;code&gt;%CSP.REST&lt;/code&gt;.&lt;br&gt;
Published coding scores don't transfer to the IRIS platform. This is a first attempt to&lt;br&gt;
measure that gap directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the benchmark measures
&lt;/h2&gt;

&lt;p&gt;140 hand-written items across three families: code generation, code comprehension, and bug fix.&lt;br&gt;
The primary grader is a live IRIS instance — model responses are compiled and executed, and&lt;br&gt;
output is compared to an expected string. No subjective scoring for the 93 execution-graded&lt;br&gt;
items. The 47 comprehension items use a rubric-driven LLM judge.&lt;/p&gt;

&lt;p&gt;We ran 14 models (Claude 4.x/5, GPT-5 variants, and three self-hosted Qwen3/DeepSeek models)&lt;br&gt;
at their highest available reasoning configurations, one response per item at temperature 0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overall results
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fayfg8hhn66pjix8ccl4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fayfg8hhn66pjix8ccl4w.png" alt="Overall accuracy by model with 95% bootstrap confidence intervals" width="800" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Overall accuracy ranged from 0.515 to 0.851. The top nine models cluster between 0.737 and&lt;br&gt;
0.851 with overlapping bootstrap 95% confidence intervals — at n=140 we can't separate them&lt;br&gt;
from each other, only distinguish the top cluster from the bottom five.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results by task family
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmu791xwlucauwkhuz6uk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmu791xwlucauwkhuz6uk.png" alt="Accuracy by task family, models in overall rank order" width="799" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code generation is the hardest family (ceiling 0.745, range 0.511 across models) and the most&lt;br&gt;
discriminating. Bug fix was the least discriminating (range 0.196). Every model scores higher&lt;br&gt;
on comprehension than on generation — the gap runs from ~0.03 to ~0.25, though part of that&lt;br&gt;
reflects different grading regimes for each family, not just capability.&lt;/p&gt;

&lt;p&gt;A few observations worth calling out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DeepSeek-v4-flash (self-hosted) ties for first on code generation&lt;/strong&gt; (0.745) and leads on
bug fix (0.913), placing 7th overall. Its comprehension score is lower (0.774 vs 0.91–0.96
for top Claude models), graded by a different judge, so interpret that comparison carefully.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost efficiency varies more than raw accuracy.&lt;/strong&gt; Among models scoring above 0.80,
&lt;code&gt;claude-sonnet-5&lt;/code&gt; runs at $4.61 per 1,000 correct answers vs. $17.54 for &lt;code&gt;gpt-5-6-sol&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cost vs. accuracy
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9et2pvujm3iwz3s3noee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9et2pvujm3iwz3s3noee.png" alt="Cost per request vs. overall accuracy; marker area proportional to latency" width="800" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cost per request across the 10 priced models spans $0.0009–$0.0144, a 15× range. Normalizing&lt;br&gt;
by accuracy compresses that to 12× and changes the ordering.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Small corpus.&lt;/strong&gt; 140 items is a limited sample; the confidence intervals reflect that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pass\@1 only.&lt;/strong&gt; One response per item, temperature 0. Run-to-run variance for reasoning
models is not captured.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-referential judge.&lt;/strong&gt; Comprehension is graded by a pinned &lt;code&gt;claude-opus-4-8&lt;/code&gt;, which
also records the highest comprehension score (0.960). The execution-graded items are
unaffected, but the comprehension column should be read with that in mind.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Coverage gaps.&lt;/strong&gt; No Interoperability (productions/HL7/DTL), no large-context tasks,
no SQL-only work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contamination going forward.&lt;/strong&gt; Items were unpublished at run time; this release publishes
them, so future runs against these items carry contamination risk.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The ObjectScript LLM Benchmark provides an open benchmark specifically for LLM performance on ObjectScript and the InterSystems IRIS platform.&lt;/li&gt;
&lt;li&gt;Overall accuracy across the 14 evaluated models ranges from 0.515 to 0.851, with the top 9 models showing overlapping 95% confidence intervals.&lt;/li&gt;
&lt;li&gt;Code generation is the hardest and most discriminating task family, while bug fixing shows less variation between models.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;What is the ObjectScript LLM Benchmark?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The ObjectScript LLM Benchmark is an open benchmark designed to measure how well LLMs perform on ObjectScript and the InterSystems IRIS platform. It includes 140 hand-written tasks across code generation, code comprehension, and bug fixing.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;How are LLM responses graded in the benchmark?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For 93 execution-graded items, model responses are compiled and executed on a live InterSystems IRIS instance and their output is compared with an expected result. The remaining 47 comprehension tasks are evaluated using a rubric-driven LLM judge.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Which type of ObjectScript task is hardest for LLMs?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Code generation is the hardest and most discriminating task family in the benchmark. Every evaluated model scores higher on code comprehension than on code generation.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Which LLM performed best on the ObjectScript benchmark?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Overall accuracy ranges from 0.515 to 0.851. However, the top 9 models have overlapping 95% bootstrap confidence intervals, so the benchmark does not provide enough evidence to statistically separate models within that top cluster.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Does a more expensive LLM perform better on ObjectScript tasks?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Not necessarily. The benchmark shows substantial differences in cost even among models with similar overall accuracy. For models scoring above 0.80, the reported cost per 1,000 correct answers ranges from $4.61 for claude-sonnet-5 to $17.54 for gpt-5-6-sol.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Business Rules Deep Dive: Routing Logic for Streams - Part (3)</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Tue, 17 Nov 2026 16:19:32 +0000</pubDate>
      <link>https://dev.to/intersystems/business-rules-deep-dive-routing-logic-for-streams-part-3-9j</link>
      <guid>https://dev.to/intersystems/business-rules-deep-dive-routing-logic-for-streams-part-3-9j</guid>
      <description>&lt;p&gt;Hi, Community!&lt;/p&gt;
&lt;p&gt;In Part 1 of this series, we built a production using the HL7 Messaging type and created a BPL Business Process that enriches an incoming HL7 message with a &lt;code&gt;%DynamicObject&lt;/code&gt;. In Part 2, we demonstrated seven real-world property-access pitfalls that cause silent failures when working with dynamic objects.&lt;/p&gt;
&lt;p&gt;This article closes the series with something different. Instead of a structured HL7 message, we deal with raw stream content &lt;code&gt;%Stream.Object&lt;/code&gt; that arrives unparsed. The challenge here is that Business Rules work best against simple values. You cannot call parsing methods inside a rule condition. So the approach is to read the stream, extract the routing values in the Business Process, and pass clean context variables to the rule.&lt;/p&gt;
&lt;p&gt;We will build a second flow alongside the HL7 flow from Parts 1 and 2, add a custom Business Service that reads raw files as streams, a Business Process that extracts routing values, and a Business Operation that logs what it receives. By the end, both flows will be running side by side and visible in the same Message Viewer.&lt;/p&gt;

&lt;h2&gt;TL;DR&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;%Stream.Object&lt;/code&gt; in IRIS is raw, unparsed content—unlike a structured HL7 message; it has no field map.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;Read()&lt;/code&gt; to pull stream content into a string — for payloads larger than 32KB, read in chunks using a loop. Use &lt;code&gt;Rewind()&lt;/code&gt; to reset the pointer so the stream can be read again.&lt;/li&gt;
&lt;li&gt;Extract routing values from raw content using &lt;code&gt;$Piece()&lt;/code&gt; in the Business Process before the routing rule evaluates them.&lt;/li&gt;
&lt;li&gt;Business Rule conditions must evaluate simple values; never try to parse a stream directly inside a rule condition.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Who This Article Is For&lt;/h2&gt;
&lt;p&gt;This guide is for IRIS Interoperability developers who need to route messages based on raw stream content and want to understand how to read, inspect, and extract values from a &lt;code&gt;%Stream.Object&lt;/code&gt; before passing them to a routing rule.&lt;/p&gt;

&lt;h2&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;Complete Part 1 and Part 2 of this series first. The &lt;code&gt;Demo.HL7RulesDemo&lt;/code&gt; production must be running with all components from both previous articles in place.&lt;/p&gt;

&lt;h2&gt;What Is a Stream in IRIS?&lt;/h2&gt;
&lt;p&gt;A &lt;code&gt;%Stream.Object&lt;/code&gt; in IRIS is raw binary or character data that has not been parsed into a structured message class. When a file adapter reads a non-standard format, or when an HTTP adapter receives a raw request body, the content arrives as a stream. Your code must read it, inspect its contents, and decide what to do with it before passing it to the next component.&lt;br&gt;&lt;br&gt;This is different from what we did in Part 1, where &lt;code&gt;HL7FileService&lt;/code&gt; parsed the file into an &lt;code&gt;EnsLib.HL7.Message&lt;/code&gt; before our code ran. In this article, the stream arrives completely raw, and our Business Service is responsible for reading it.&lt;/p&gt;

&lt;h2&gt;The Flow We Will Add&lt;/h2&gt;
&lt;p&gt;We will add a second, independent flow to the existing production:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;StreamRouterService:&lt;/strong&gt; A custom Business Service that reads raw &lt;code&gt;.txt&lt;/code&gt; files from a dedicated folder.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;StreamRouter:&lt;/strong&gt; A custom Business Process that reads the stream, extracts routing values, and makes the routing decision.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;StreamOperation:&lt;/strong&gt; A custom Business Operation that receives the routed message and logs what it received.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The HL7 flow from Parts 1 and 2 keeps running alongside this. Both flows share the same production canvas.&lt;/p&gt;

&lt;h2&gt;The Raw Stream Test Files&lt;/h2&gt;
&lt;p&gt;The test files are plain text with pipe-separated values, simulating a raw payload from an external system that has not been parsed yet.&lt;/p&gt;
&lt;p&gt;We create them from the IRIS terminal to avoid line-ending issues:&lt;/p&gt;objectscript&lt;pre&gt;&lt;code&gt;// Create a high-priority test file for the stream routing demo
Set file = ##class(%File).%New("C:\stream\test_high.txt")

// Open in write mode - NWS means New file, Write, Stream
If 'file.Open("NWS") {
    Write "Error: Could not open file for writing", !
    Quit
}

Do file.WriteLine("PRIORITY:HIGH|DEPT:CARDIOLOGY|PATIENT:MRN001|TYPE:ADMISSION")

Do file.Close()
Write "File created: C:\stream\test_high.txt", !

// Create a low-priority test file for the default route demo
Set file = ##class(%File).%New("C:\stream\test_low.txt")

// Open in write mode - NWS means New file, Write, Stream
If 'file.Open("NWS") {
    Write "Error: Could not open file for writing", !
    Quit
}

Do file.WriteLine("PRIORITY:LOW|DEPT:GENERAL|PATIENT:MRN002|TYPE:DISCHARGE")

Do file.Close()
Write "File created: C:\stream\test_low.txt", !
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 1: Write and Add the Business Service&lt;/h2&gt;
&lt;p&gt;The Business Service reads the raw file as a &lt;code&gt;%Stream.Object&lt;/code&gt;. It does not parse it. Instead, it reads the raw content, logs it, extracts the routing values, and forwards them to the Business Process.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class Demo.StreamRouterService Extends Ens.BusinessService 
{ 

Parameter ADAPTER = "EnsLib.File.InboundAdapter"; 

Method OnProcessInput(pInput As %Stream.Object, 
    Output pOutput As %RegisteredObject) As %Status 
{ 
    Set sc = $$$OK 
    Try { 
        // Make sure we actually received something before processing 
        If '$IsObject(pInput) || (pInput.Size = 0) { 
            $$$LOGWARNING("Received empty or invalid stream - skipping") 
            Quit 
        } 

        // Routing values only come from the first line, so keep reading 
        // chunks until the first line break (or end of file) rather than 
        // loading the whole file, however long the first line is 
        Set chunk = "" 
        While (chunk '[ $Char(10)) &amp;amp;&amp;amp; 'pInput.AtEnd { 
            Set chunk = chunk _ pInput.Read(32000) 
        } 
        // Strip a trailing CR so both CRLF and LF line endings work 
        Set line = $ZStrip($Piece(chunk, $Char(10), 1), "&amp;gt;", $Char(13)) 
        $$$LOGINFO("Stream size: " _ pInput.Size _ " / first line length: " _ $Length(line)) 
        $$$LOGINFO("First line: " _ $Extract(line, 1, 500)) 

        // Extract routing values by field name, so field order doesn't matter 
        // Expected format: PRIORITY:HIGH|DEPT:CARDIOLOGY|PATIENT:MRN001|TYPE:ADMISSION 
        Set priority = "", department = "" 
        For i = 1:1:$Length(line, "|") { 
            Set field = $Piece(line, "|", i) 
            Set key   = $ZConvert($ZStrip($Piece(field, ":", 1), "&amp;lt;&amp;gt;W"), "U") 
            Set value = $ZStrip($Piece(field, ":", 2, $Length(field, ":")), "&amp;lt;&amp;gt;W") 
            If key = "PRIORITY" { 
                Set priority = value 
            } ElseIf key = "DEPT" { 
                Set department = value 
            } 
        } 

        // Validate extracted values before forwarding 
        If (priority = "") || (department = "") { 
            $$$LOGWARNING("Could not extract Priority or Department from first line: " _ $Extract(line, 1, 500)) 
            Quit 
        } 

        $$$LOGINFO("Extracted Priority: " _ priority _ " / Department: " _ department) 

        // Build a StringRequest to carry the extracted values to StreamRouter 
        Set request = ##class(Ens.StringRequest).%New() 
        Set request.StringValue = "PRIORITY:" _ priority _ "|DEPT:" _ department 

        // Send asynchronously so the service is not blocked waiting for a response 
        Set sc = ..SendRequestAsync("StreamRouter", request) 

    } Catch ex { 
        // Log the full error detail and return the status so IRIS can handle it 
        $$$LOGERROR("Unexpected error in StreamRouterService: " _ ex.DisplayString()) 
        Set sc = ex.AsStatus() 
    } 
    Quit sc 
} 

} 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One important note on &lt;code&gt;Read()&lt;/code&gt;: calling &lt;code&gt;Read(32000)&lt;/code&gt; on its own reads only the first 32KB of the stream and silently truncates the rest. For production use, always read in a loop until &lt;code&gt;AtEnd&lt;/code&gt; is true as shown in the code above. For small test files like ours, this makes no difference, but for a real 4MB payload the single &lt;code&gt;Read()&lt;/code&gt; call would drop most of the content with no error or warning.&lt;br&gt;&lt;br&gt;In VS Code, create and compile this class:&lt;/p&gt;
&lt;p&gt;Go to the production canvas. Click &lt;strong&gt;Add&lt;/strong&gt; in the Services section:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Service Class&lt;/strong&gt;: &lt;code&gt;Demo.StreamRouterService&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service Name&lt;/strong&gt;: &lt;code&gt;StreamRouterService&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;: &lt;code&gt;Reads raw text files as streams, extracts routing values, and forwards to StreamRouter.&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enable Now&lt;/strong&gt;: Checked.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click &lt;strong&gt;OK&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Click on &lt;code&gt;StreamRouterService&lt;/code&gt; in the canvas. Set the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File Path&lt;/strong&gt;: &lt;code&gt;C:\stream\in\&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File Spec&lt;/strong&gt;: &lt;code&gt;*.txt&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Call Interval&lt;/strong&gt;: &lt;code&gt;5&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click &lt;strong&gt;Apply&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frn7tw8dxsvwrxg8bwjbi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frn7tw8dxsvwrxg8bwjbi.png" alt=" " width="505" height="661"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;Step 2: Write and Add the Business Operation&lt;/h2&gt;
&lt;p&gt;The Business Operation receives the routed message and logs what it received. Create and compile the class below:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class Demo.StreamOperation Extends Ens.BusinessOperation &lt;br&gt;
{ 

&lt;p&gt;Method OnMessage(pRequest As Ens.StringRequest, &lt;br&gt;
    Output pResponse As Ens.Response) As %Status &lt;br&gt;
{ &lt;br&gt;
    Set sc = $$$OK &lt;br&gt;
    Try { &lt;br&gt;
        // Validate the incoming request before processing &lt;br&gt;
        If '$IsObject(pRequest) || pRequest.StringValue = "" { &lt;br&gt;
            $$$LOGWARNING("Received empty or invalid request - skipping") &lt;br&gt;
            Quit &lt;br&gt;
        } &lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // Log the routed message content for verification in the Event Log 
    $$$LOGINFO("StreamOperation received: " _ pRequest.StringValue) 

    // Extract individual values for any further processing if needed 
    Set priority   = $Piece($Piece(pRequest.StringValue, "|", 1), ":", 2) 
    Set department = $Piece($Piece(pRequest.StringValue, "|", 2), ":", 2) 

    $$$LOGINFO("Routing confirmed - Priority: " _ priority _ " Department: " _ department) 

} Catch ex { 
    // Log the full error detail and return the status so IRIS can handle it 
    $$$LOGERROR("Unexpected error in StreamOperation: " _ ex.DisplayString()) 
    Set sc = ex.AsStatus() 
} 
Quit sc 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;} &lt;/p&gt;

&lt;/code&gt;&lt;p&gt;&lt;code&gt;XData MessageMap &lt;br&gt;&lt;br&gt;
{ &lt;br&gt;&lt;br&gt;
&amp;lt;MapItems&amp;gt; &lt;br&gt;&lt;br&gt;
    &amp;lt;MapItem MessageType="Ens.StringRequest"&amp;gt; &lt;br&gt;&lt;br&gt;
        &amp;lt;Method&amp;gt;OnMessage&amp;lt;/Method&amp;gt; &lt;br&gt;&lt;br&gt;
    &amp;lt;/MapItem&amp;gt; &lt;br&gt;&lt;br&gt;
&amp;lt;/MapItems&amp;gt; &lt;br&gt;&lt;br&gt;
} &lt;br&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;Go to the production canvas. Click &lt;strong&gt;Add&lt;/strong&gt; in the Operations section:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Operation Class&lt;/strong&gt;: &lt;code&gt;Demo.StreamOperation&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operation Name&lt;/strong&gt;: &lt;code&gt;StreamOperation&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;: &lt;code&gt;Receives routed stream messages and logs the result.&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enable Now&lt;/strong&gt;: Checked.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click &lt;strong&gt;OK&lt;/strong&gt;.&lt;br&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Step 3: Write and Add the Business Process&lt;/h2&gt;
&lt;p&gt;The Business Process receives the extracted values from the Business Service and makes the routing decision. Create and compile the following class:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class Demo.StreamRouter Extends Ens.BusinessProcess &lt;br&gt;&lt;br&gt;
{ 

&lt;p&gt;Method OnRequest(pRequest As Ens.StringRequest, &lt;br&gt;
    Output pResponse As Ens.Response) As %Status &lt;br&gt;
{ &lt;br&gt;
    Set sc = $$$OK &lt;br&gt;
    Try { &lt;br&gt;
        // Validate the incoming request before processing &lt;br&gt;
        If ('$IsObject(pRequest)) || (pRequest.StringValue = "") { &lt;br&gt;
            $$$LOGWARNING("StreamRouter received empty or invalid request - skipping") &lt;br&gt;
            Quit &lt;br&gt;
        } &lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // Extract priority and department from the string passed by the service 
    // Expected format: PRIORITY:HIGH|DEPT:CARDIOLOGY 
    Set priority   = $Piece($Piece(pRequest.StringValue, "|", 1), ":", 2) 
    Set department = $Piece($Piece(pRequest.StringValue, "|", 2), ":", 2) 

    // Validate extracted values before making a routing decision 
    If (priority = "") || (department = "") { 
        $$$LOGWARNING("StreamRouter could not extract routing values from: " _ pRequest.StringValue) 
        Quit 
    } 

    $$$LOGINFO("StreamRouter - Priority: " _ priority _ " Dept: " _ department) 

    // Route based on extracted stream values 
    // Rule 1: High priority cardiology messages get dedicated routing 
    If (priority = "HIGH") &amp;amp;amp;&amp;amp;amp; (department = "CARDIOLOGY") { 
        $$$LOGINFO("Rule matched: HIGH priority CARDIOLOGY - routing to StreamOperation") 

    // Default: all other messages fall through to the standard route 
    } Else { 
        $$$LOGINFO("No specific rule matched - taking default route to StreamOperation") 
    } 

    // Send to StreamOperation regardless of which rule matched 
    // In a real production, you would send to different targets per rule 
    // No response is needed, so pass 0 for pResponseRequired; 
    // otherwise the reply triggers OnResponse, which this class doesn't implement 
    Set sc = ..SendRequestAsync("StreamOperation", pRequest, 0) 

} Catch ex { 
    // Log the full error detail and return the status so IRIS can handle it 
    $$$LOGERROR("Unexpected error in StreamRouter: " _ ex.DisplayString()) 
    Set sc = ex.AsStatus() 
} 
Quit sc 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;} &lt;/p&gt;

&lt;/code&gt;&lt;p&gt;&lt;code&gt;Storage Default &lt;br&gt;&lt;br&gt;
{ &lt;br&gt;&lt;br&gt;
&amp;lt;Type&amp;gt;%Storage.Persistent&amp;lt;/Type&amp;gt; &lt;br&gt;&lt;br&gt;
} &lt;br&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;Go to the production canvas. Click &lt;strong&gt;Add&lt;/strong&gt; in the Processes section:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Process Class&lt;/strong&gt;: &lt;code&gt;Demo.StreamRouter&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Process Name&lt;/strong&gt;: &lt;code&gt;StreamRouter&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;: &lt;code&gt;Extracts priority and department from stream content and makes the routing decision.&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enable Now&lt;/strong&gt;: Checked.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click &lt;strong&gt;OK&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The production now has both flows running side by side.&lt;/p&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fonfoz6w33gw78npf6dp9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fonfoz6w33gw78npf6dp9.png" alt=" " width="800" height="185"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;How It All Fits Together&lt;/h2&gt;
&lt;p&gt;Before testing, it helps to see how the stream flow compares to the HL7 flow from Part 1.&lt;/p&gt;
&lt;p&gt;In the HL7 flow, &lt;code&gt;HL7FileService&lt;/code&gt; parses the file into a structured &lt;code&gt;EnsLib.HL7.Message&lt;/code&gt; before our code runs. By the time &lt;code&gt;HL7Router&lt;/code&gt; receives it, the message has a full field map, and we can call &lt;code&gt;GetValueAt("MSH:MessageType.MessageCode")&lt;/code&gt; directly.&lt;/p&gt;
&lt;p&gt;In the stream flow, nothing is parsed upfront. &lt;code&gt;StreamRouterService&lt;/code&gt; receives the file as a raw &lt;code&gt;%Stream.Object&lt;/code&gt;. Our code reads it with &lt;code&gt;Read()&lt;/code&gt;, rewinds it with &lt;code&gt;Rewind()&lt;/code&gt;, pulls the routing values out using &lt;code&gt;$Piece()&lt;/code&gt;, and passes them as a plain &lt;code&gt;Ens.StringRequest&lt;/code&gt; to &lt;code&gt;StreamRouter,&lt;/code&gt;which then makes the routing decision based on those extracted values.&lt;/p&gt;
&lt;p&gt;The routing logic never sees the raw stream. It only evaluates simple string values, which is exactly how Business Rules are designed to work.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Step 4: Test the Full Stream Flow&lt;/h2&gt;
&lt;p&gt;Start the production if it is not already running. Drop &lt;code&gt;test_high.txt&lt;/code&gt; into &lt;code&gt;C:\stream\in&amp;lt;/code&amp;gt;.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Go to &lt;strong&gt;Management Portal &amp;gt; Interoperability &amp;gt; View &amp;gt; Messages&lt;/strong&gt;. You will see messages from both &lt;code&gt;HL7FileService&lt;/code&gt; and &lt;code&gt;StreamRouterService&lt;/code&gt; in the same list.&lt;/code&gt;&lt;/p&gt;

&lt;code&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fif3bknsny7p674eoqgpa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fif3bknsny7p674eoqgpa.png" alt=" " width="800" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the message from &lt;code&gt;StreamRouterService&lt;/code&gt; to open the Visual Trace. You will see the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;StreamRouterService&lt;/code&gt; reads the raw file as a stream.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;StreamRouter&lt;/code&gt; receives the extracted values and makes the routing decision.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;StreamOperation&lt;/code&gt; receives and logs the result.&lt;/li&gt;
&lt;/ul&gt;

![ ](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/za21o3q37jb18d5tkaul.png)
&lt;p&gt;Mark the &lt;strong&gt;Show Events&lt;/strong&gt; checkbox at the top. Expand each component to see the log entries.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F45nduf636htct03b3au1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F45nduf636htct03b3au1.png" alt=" " width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go to &lt;strong&gt;Management Portal &amp;gt; Interoperability &amp;gt; View &amp;gt; Event Log&lt;/strong&gt;. Filter by &lt;code&gt;StreamRouterService&lt;/code&gt; to see the stream processing entries for the LOW-priority file:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq9fr49cgpul7fdmuivt7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq9fr49cgpul7fdmuivt7.png" alt=" " width="799" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now drop &lt;code&gt;test_low.txt&lt;/code&gt;. The Event Log for this one should show the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyc4d88xxyormuiyx27nf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyc4d88xxyormuiyx27nf.png" alt=" " width="800" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both routing paths are confirmed.&lt;br&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Why Extract Before Routing?&lt;/h2&gt;
&lt;p&gt;A question that comes up regularly: why not read the stream directly inside the routing rule condition?&lt;/p&gt;
&lt;p&gt;The answer is that Business Rule conditions are expressions, not code blocks. You cannot call &lt;code&gt;Read()&lt;/code&gt; or &lt;code&gt;$Piece()&lt;/code&gt; inside a rule condition in the visual editor. Trying to do so either throws a compile error or silently evaluates to empty.&lt;/p&gt;
&lt;p&gt;The correct pattern is always the same: extract and clean the values in the Business Process, store them in a request or context variable, and let the routing rule evaluate simple values. This also makes the rules readable. Six months from now, whoever opens the Rule Editor will understand &lt;code&gt;priority = "HIGH"&lt;/code&gt; immediately. Raw stream parsing logic inside a condition would be much harder to untangle.&lt;/p&gt;

&lt;h2&gt;Common Mistakes&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Not calling Rewind() after Read():&lt;/strong&gt; Once you call &lt;code&gt;Read()&lt;/code&gt; on a stream, the internal pointer moves to the end. If another component tries to read the same stream after your method, it gets nothing. Always call &lt;code&gt;Rewind()&lt;/code&gt; after reading if the stream might be needed downstream.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Trying to parse stream content inside a routing rule:&lt;/strong&gt; The rule expression editor is for simple conditions. Any parsing logic belongs in a Business Process or in &lt;code&gt;OnProcessInput()&lt;/code&gt; before the routing rule fires.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using EnsLib.HL7.Service.FileService for non-HL7 files: &lt;/strong&gt;&lt;code&gt;EnsLib.HL7.Service.FileService&lt;/code&gt; expects HL7-formatted content and tries to parse every file it picks up as an HL7 message. For raw text or non-HL7 files, always use a custom Business Service extending &lt;code&gt;Ens.BusinessService&lt;/code&gt; with &lt;code&gt;EnsLib.File.InboundAdapter&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reading only a part of the stream: &lt;/strong&gt;Calling &lt;code&gt;Read(32000)&lt;/code&gt; once reads only the first 32KB and silently truncates everything after that. No error, no warning — the rest of the content is simply gone. For any payload that could exceed 32KB, always read in a loop.&lt;/p&gt;

&lt;h2&gt;Practical Recommendations&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Always call &lt;code&gt;Rewind()&lt;/code&gt; after &lt;code&gt;Read()&lt;/code&gt; if the stream might be consumed by another component downstream.&lt;/li&gt;
&lt;li&gt;Extract routing values in &lt;code&gt;OnProcessInput()&lt;/code&gt; or a BPL Code activity, never inside a rule condition.&lt;/li&gt;
&lt;li&gt;Use a custom Business Service with &lt;code&gt;EnsLib.File.InboundAdapter&lt;/code&gt; for any non-HL7 file content.&lt;/li&gt;
&lt;li&gt;Log the raw stream content and the extracted values separately in the Event Log during development; seeing both side by side makes it easy to confirm the extraction is working correctly.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;$Piece()&lt;/code&gt; for simple delimiter-separated content. For JSON streams, use &lt;code&gt;%DynamicObject.%FromJSON()&lt;/code&gt; after reading the content into a string.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;FAQ&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Q: What is the difference between &lt;/strong&gt;&lt;code&gt;&lt;strong&gt;Read()&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt; and &lt;/strong&gt;&lt;code&gt;&lt;strong&gt;ReadLine()&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt;?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A: &lt;code&gt;Read(n)&lt;/code&gt; reads up to n characters from the current stream position regardless of line breaks. &lt;code&gt;ReadLine()&lt;/code&gt; reads up to the next line terminator and stops. For a single-line payload like our test files, either works. For multi-line content where each line carries different data, &lt;code&gt;ReadLine()&lt;/code&gt; in a loop is the cleaner approach.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q: Can I pass the raw stream directly to a Business Operation instead of extracting values first?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A: You can, but the operation would then need to do the parsing itself. The neater pattern is to extract and clean the values in the Business Process so the operation receives structured data it can act on immediately. It also makes the operation reusable since it does not need to know anything about the original stream format.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q: What if my stream content is JSON instead of pipe-separated values?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A: Read the stream into a string with &lt;code&gt;Read()&lt;/code&gt;, then parse it with &lt;code&gt;##class(%DynamicObject).%FromJSON(content)&lt;/code&gt;. From there, access properties using &lt;code&gt;%Get()&lt;/code&gt; as covered in Part 2. The stream reading part is identical; only the parsing step changes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q: How do I handle streams larger than 32,000 characters?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A: Read them in chunks using a loop:&lt;/p&gt;objectscript&lt;pre&gt;&lt;code&gt; Set chunk = ""&amp;nbsp;
 While (chunk '[ $Char(10)) &amp;amp;&amp;amp; 'pInput.AtEnd {&amp;nbsp;
      Set chunk = chunk _ pInput.Read(32000)&amp;nbsp;
 } &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This builds the full content string regardless of stream size. For very large files, consider processing line by line with &lt;code&gt;ReadLine()&lt;/code&gt; instead.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q: Can I use this same pattern for HTTP streams?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A: Yes. When an HTTP adapter passes a request body as a stream, the same &lt;code&gt;Read()&lt;/code&gt; and &lt;code&gt;Rewind()&lt;/code&gt; pattern applies. The Business Service reads the stream, extracts what it needs, and forwards structured values to the next component. By the time &lt;code&gt;OnProcessInput()&lt;/code&gt; runs, it is just a &lt;code&gt;%Stream.Object&lt;/code&gt; regardless of transport.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q: Why use &lt;/strong&gt;&lt;code&gt;&lt;strong&gt;Ens.StringRequest&lt;/strong&gt;&lt;/code&gt;&lt;strong&gt; to pass values between components rather than a custom request class?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A: For this demo, &lt;code&gt;Ens.StringRequest&lt;/code&gt; is the simplest option without defining a new class. In a real production integration, you would typically define a custom request class with typed properties so the receiving component can access each value by name rather than parsing a string. The stream reading and routing logic would stay exactly the same; only the carrier object changes.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Stream routing comes down to one principle: read first, route later. The stream arrives raw. Your Business Service reads it, extracts what the routing rule needs, and passes clean values forward. The routing rule evaluates those values and makes the decision. Nothing in between needs to know what a stream looks like.&lt;/p&gt;
&lt;p&gt;This is also the last article in the Business Rules Deep Dive series. Part 1 covered dynamic objects and production setup. Part 2 described seven property-access pitfalls. Part 3 explained stream routing. Together, they address the three scenarios where Business Rules most commonly misbehave in production—all caused by the same pattern: wrong input reaching the rule condition silently.&lt;/p&gt;
&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;/code&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Model Context Protocol (MCP) with InterSystems IRIS - From Zero to Hero</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Sat, 31 Oct 2026 20:45:42 +0000</pubDate>
      <link>https://dev.to/intersystems/model-context-protocol-mcp-with-intersystems-iris-from-zero-to-hero-1nnb</link>
      <guid>https://dev.to/intersystems/model-context-protocol-mcp-with-intersystems-iris-from-zero-to-hero-1nnb</guid>
      <description>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Today, coding assistants like Claude, GitHub Copilot and Cursor have transformed the way developers write code. However, these tools are limited by being isolated from the systems and data sources that developers work with daily. This limitation can be overcome through the &lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt;, an open standard designed to connect AI assistants to external data sources and tools in a secure and standardized way.&lt;/p&gt;
&lt;p&gt;In this review article, we'll explore the current state-of-the-art regarding the MCP within the InterSystems ecosystem. Moreover, we will examine how this open standard connects AI assistants to external data sources, presenting a first example of a custom MCP server developed in Python and integrated with the &lt;span&gt;&lt;code&gt;intersystems-irispython&lt;/code&gt;&amp;nbsp;&lt;/span&gt;package.&lt;/p&gt;
&lt;h2&gt;Table of Contents&lt;/h2&gt;&amp;nbsp;&lt;p&gt;Table of Contents&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Part 1: What is the Model Context Protocol?&lt;ul&gt;
&lt;li&gt;1.1 Origins and Background&lt;/li&gt;
&lt;li&gt;1.2 Why MCP Matters&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Part 2: Understanding MCP Architecture&lt;ul&gt;
&lt;li&gt;2.1 The Client-Host-Server Model&lt;/li&gt;
&lt;li&gt;2.2 Transport Layer&lt;/li&gt;
&lt;li&gt;2.3 Data Layer&lt;/li&gt;
&lt;li&gt;2.4 Core Primitives&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Part 3: Building MCP Servers from Scratch with Python&lt;ul&gt;
&lt;li&gt;3.1 Using uv to Create a New Python Package&lt;/li&gt;
&lt;li&gt;3.2 Basic MCP Server Structure&lt;/li&gt;
&lt;li&gt;3.3 Implementing Core Primitives&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Part 4: Using MCP with AI Development Tools&lt;ul&gt;&lt;li&gt;4.1 Configuring MCP Servers&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Part 5: Distributing and Running MCP Servers with uv and uvx&lt;ul&gt;
&lt;li&gt;5.1 Local Clone (Development Mode)&lt;/li&gt;
&lt;li&gt;5.2 GitHub Repository&lt;/li&gt;
&lt;li&gt;5.3 PyPI&lt;ul&gt;&lt;li&gt;5.3.1 Publishing a Package to PyPI&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Part 6: MCP and InterSystems IRIS&lt;ul&gt;&lt;li&gt;6.1 Existing MCP Servers for IRIS&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Part 7: Building Your Own MCP Server for IRIS&lt;ul&gt;
&lt;li&gt;7.1 The Blueprint Implementation of an IRIS MCP Server&lt;/li&gt;
&lt;li&gt;7.2 Highlights of the Code&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Part 8: Conclusion&lt;/li&gt;
&lt;li&gt;Part 9: Sources&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Part 1: What is the Model Context Protocol?&lt;/h2&gt;
&lt;h3&gt;1.1 Origins and Background&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;Model Context Protocol (MCP)&lt;/strong&gt; was introduced by &lt;strong&gt;Anthropic&lt;/strong&gt; on November 25, 2024 &lt;a href="https://www.anthropic.com/news/model-context-protocol" rel="noopener noreferrer"&gt;[1]&lt;/a&gt; as open-source with the goal of connecting AI systems to data sources, replacing fragmented integrations. Before MCP, every AI application required custom integrations to access each data source, like a database or an API. MCP solves this by providing a single, standardized protocol that any AI application can use to connect to compatible servers.&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;1.2 Why MCP Matters&lt;/h3&gt;
&lt;p&gt;The protocol addresses three key challenges:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Standardization&lt;/strong&gt;: It is no longer necessary to write custom integrations for every new tool. Any AI assistant can use MCP servers that expose specific capabilities to interact with various resources in a standardized format that LLMs can easily understand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security&lt;/strong&gt;: MCP isolates each server, meaning the AI can only access the specific context required for the immediate task and cannot access other servers or the full conversation history.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Seamless Integration&lt;/strong&gt;: Since it is an open protocol, you can easily combine multiple servers at the same time, allowing you to build modular, customized AI workflows without overly complicating your architecture.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Official Resources:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.anthropic.com/news/model-context-protocol" rel="noopener noreferrer"&gt;Anthropic Announcement: Introducing the Model Context Protocol [1]&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://modelcontextprotocol.io/specification/latest" rel="noopener noreferrer"&gt;Model Context Protocol - Specification [2]&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/modelcontextprotocol" rel="noopener noreferrer"&gt;GitHub Repository - Model Context Protocol [3]&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://modelcontextprotocol.io/docs/getting-started/intro" rel="noopener noreferrer"&gt;What is the Model Context Protocol (MCP)? [4]&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Part 2: Understanding MCP Architecture&lt;/h2&gt;
&lt;h3&gt;2.1 The Client-Host-Server Model&lt;/h3&gt;
&lt;p&gt;MCP follows a &lt;strong&gt;client-host-server architecture &lt;/strong&gt;&lt;a href="https://modelcontextprotocol.io/docs/learn" rel="noopener noreferrer"&gt;[5]&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MCP Host&lt;/strong&gt;: The AI application (Claude Desktop, Cursor, VS Code, etc.) that coordinates and manages one or more MCP clients.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MCP Client&lt;/strong&gt;: A component within the host that maintains a dedicated connection to an MCP server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MCP Server&lt;/strong&gt;: A program that provides some functionalities to MCP clients. MCP servers can run locally on your machine or remotely.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each host can create multiple clients, with each client maintaining a &lt;strong&gt;1:1 dedicated connection&lt;/strong&gt; with its corresponding server.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For example, Cursor acts as an MCP Host. When Cursor establishes a connection to an MCP server it instantiates an MCP client object that maintains the connection to that specific MCP server. When Cursor later connects to a different MCP server, it instantiates an additional MCP client object to maintain the new connection.&lt;/p&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh8hjmpe0jfws49dj318z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh8hjmpe0jfws49dj318z.png" alt=" " width="800" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find the original image source &lt;a href="https://mcpcat.io/blog/mcp-server-client-host/" rel="noopener noreferrer"&gt;here [6]&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;2.2 Transport Layer&lt;/h3&gt;
&lt;p&gt;MCP supports two transport mechanisms:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local servers&lt;/strong&gt;: this uses standard Standard Input/Output (STDIO) streams for direct process communication between local processes on the same machine. Since this avoids avoids network overhead, it is a better choice for local integrations or CLI utilities. MCP currently uses STDIO as the default transport layer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote servers&lt;/strong&gt;: this uses Streamable HTTP to manage interactions over a network. The client sends messages via &lt;span&gt;&lt;span&gt;HTTP POST, while the server optionally uses Server-Sent Events (SSE) for streaming data. This&lt;/span&gt;&lt;/span&gt; transport allows MPC servers to run remotely (on a different machine, in the cloud, etc.) and to be accessible via a URL.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;2.3 Data Layer&lt;/h3&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;In MCP, the message structure and semantics is based on &lt;/span&gt;&lt;/span&gt;&lt;strong&gt;JSON-RPC 2.0&lt;/strong&gt; protocol &lt;a href="https://www.jsonrpc.org/" rel="noopener noreferrer"&gt;&lt;span&gt;&lt;span&gt;[7]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span&gt;&lt;span&gt;. &lt;/span&gt;&lt;span&gt;All communication follows a structure like the following:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&amp;nbsp;&lt;p&gt;JSON-RPC 2.0&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "query_database",
    "arguments": {
      "sql": "SELECT * FROM Patient LIMIT 10"
    }
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;2.4 Core Primitives&lt;/h3&gt;
&lt;p&gt;MCP defines three core primitives that servers can expose &lt;a href="https://modelcontextprotocol.io/docs/learn" rel="noopener noreferrer"&gt;[5]&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tools&lt;/strong&gt;: The functions your AI agent can call to perform actions according to user requests. Tools can for example write to the database, call APIs or modify files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: Passive data sources that provide contextual information to AI applications offering read-only access to file contents, database schemas or API documentation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompts&lt;/strong&gt;: Pre-built instruction templates that tell the model to work with specific tools and resources helping the user to structure interactions with the AI agent.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Part 3: Building MCP Servers from scratch with Python&lt;/h2&gt;
&lt;p&gt;Before diving into code examples, let's understand how to build MCP servers in Python.&lt;/p&gt;
&lt;p&gt;MCP provides official SDKs for multiple programming languages, including TypeScript, Java, and Python &lt;a href="https://modelcontextprotocol.io/docs/sdk" rel="noopener noreferrer"&gt;[8]&lt;/a&gt;. In this article, we'll focus on &lt;strong&gt;Python&lt;/strong&gt; as it's widely used in the InterSystems community and integrates well with IRIS through the Native SDK &lt;a href="https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=PAGE_python_native" rel="noopener noreferrer"&gt;[9]&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;3.1 Using uv to create a new Python package&lt;/h3&gt;
&lt;p&gt;Before talking about code, we should understand how to create a proper environment for our application, which won't just contain the Python code, but it also includes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;dependencies&lt;/li&gt;
&lt;li&gt;Python version&lt;/li&gt;
&lt;li&gt;entry points&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To set up the environment we will use the &lt;code&gt;uv&lt;/code&gt; Python package manager, a modern Python package manager that simplifies environment creation, dependency resolution, and reproducible execution of MCP servers &lt;a href="https://docs.astral.sh/uv/concepts/projects/dependencies/" rel="noopener noreferrer"&gt;[10]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can initialize properly your folder structure for your MCP project using the &lt;code&gt;uv init&lt;/code&gt; statement.&lt;/p&gt;&amp;nbsp;&lt;p&gt;Init package with uv&lt;/p&gt;
&lt;p&gt;You can initialize a new project with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uv init --package my-mcp-server&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Where the &lt;code&gt;--package&lt;/code&gt; option tells &lt;code&gt;uv&lt;/code&gt; to create a Python package.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This command generates the following folder tree:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;my-mcp-server/
├── pyproject.toml      
├── README.md
├── .python-version     
└── src/
    └── my_mcp_server/
        └── __init__.py&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;.python-version&lt;/code&gt; file specifies which Python version the project should use.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;__init__.py&lt;/code&gt; file marks a directory as a Python package. Since Python packages are expected to contain one or more Python modules, which are directories containing an &lt;code&gt;__init__.py&lt;/code&gt;, each subfolder of the project needs an &lt;code&gt;__init__.py&lt;/code&gt; (can be empty) to be importable as a package.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;pyproject.toml&lt;/code&gt; contains the metadata and configuration for the project. It defines how the package is built, its dependencies, and the Python version requirements. It is composed by several sections like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;[build-system]&lt;/code&gt;: specifies how the package is built. &lt;code&gt;uv&lt;/code&gt; uses &lt;em&gt;hatchling &lt;/em&gt;as the default build backend for Python packages &lt;a href="https://docs.astral.sh/uv/concepts/build-backend/" rel="noopener noreferrer"&gt;[11]&lt;/a&gt;.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[project]&lt;/code&gt;: contains metadata and dependency definitions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is an example of &lt;code&gt;pyproject.toml&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[build-system] 
requires = ["hatchling"] 
build-backend = "hatchling.build" 

[project] 
name = "my-mcp-server" 
version = "0.1.0" 
description = "" 
readme = "README.md" 
requires-python = "&amp;gt;=3.12" 
dependencies = []&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After creating the structure, you can add dependencies to the project using the &lt;code&gt;uv add&lt;/code&gt; statement.&lt;/p&gt;&amp;nbsp;&lt;p&gt;Add server dependencies&lt;/p&gt;
&lt;p&gt;You can use the &lt;code&gt;uv add&lt;/code&gt; statement to add dependencies:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uv add fastmcp intersystems-irispython requests&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This command:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Adds the packages to &lt;code&gt;[project.dependencies]&lt;/code&gt; in &lt;code&gt;pyproject.toml&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Resolves all transitive dependencies and writes a &lt;code&gt;uv.lock&lt;/code&gt; file. This is used to recreate the environment while building your project on another machine.&lt;/li&gt;
&lt;li&gt;Installs everything into a local &lt;code&gt;.venv/&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After this step, the &lt;code&gt;pyproject.toml&lt;/code&gt; will contain a new section for all your dependencies:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[project]
...
dependencies = [
    "fastmcp&amp;gt;=3.2",
    "intersystems-irispython&amp;gt;=5.3",
    "requests&amp;gt;=2.32",
]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;While the &lt;code&gt;pyproject.toml&lt;/code&gt; contains all the direct dependencies, the &lt;code&gt;uv.lock&lt;/code&gt; is a file that contains all resolved dependencies, namely the exact versions of all the direct and transitive dependencies in the project.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;At build time, instead of resolving dependencies again, &lt;code&gt;uv&lt;/code&gt; reads &lt;code&gt;uv.lock&lt;/code&gt; and installs exactly what’s written there.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;uv.lock&lt;/code&gt; file looks like the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[[package]]
name = "fastmcp"
version = "3.2.1"
dependencies = [
    "pydantic",
    "typing-extensions",
]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, it's time to add an entry point to start the server.&lt;/p&gt;&amp;nbsp;&lt;p&gt;Adding an entry point for the MCP server&lt;/p&gt;
&lt;p&gt;To make the MCP server executable, define a CLI entry point in &lt;code&gt;pyproject.toml&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[project.scripts]
my-mcp-server = "my_mcp_server.entrypoint:main"&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This maps a command name (&lt;code&gt;my-mcp-server&lt;/code&gt;) to a Python function using the format &lt;code&gt;module.path:function&lt;/code&gt;. So, when the command is executed, Python imports &lt;code&gt;my_mcp_server.entrypoint&lt;/code&gt; and runs the &lt;code&gt;main()&lt;/code&gt; function.&lt;/p&gt;
&lt;h3&gt;3.2 Basic MCP Server Structure&lt;/h3&gt;
&lt;p&gt;Let's now take a look at the available packages that we can use to implement the MCP server. While the official &lt;code&gt;mcp&lt;/code&gt; package provides the core protocol implementation &lt;a href="https://pypi.org/project/mcp/" rel="noopener noreferrer"&gt;[12]&lt;/a&gt;, &lt;code&gt;FastMCP&lt;/code&gt; package has emerged as one of the easiest and fastest frameworks for building MCP servers with Python &lt;a href="https://gofastmcp.com/" rel="noopener noreferrer"&gt;[13]&lt;/a&gt;. This article will provide the minimal structure of an MCP server using FastMCP.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A server is defined by three main steps:&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;initializing the server&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;defining tools, resources and prompt decorating the functions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;running the process&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;&amp;nbsp;&lt;p&gt;FastMCP first example&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from fastmcp import FastMCP

# 1. Create the MCP server instance
mcp = FastMCP(name="My MCP Server")

# 2. Define tools, resources and prompts using decorators
@mcp.tool
def my_tool(param: str) -&amp;gt; str:
    """Description of what this tool does. This text is sent to the LLM."""
    return f"Result: {param}"

# 3. Run the server (defaults to STDIO transport)
if __name__ == "__main__":
    mcp.run()&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;3.4 Implementing Core Primitives&lt;/h3&gt;
&lt;p&gt;Let's see how to implement each primitive type:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;
&lt;strong&gt;Tools&lt;/strong&gt;: &lt;u&gt;Tools allow the AI to perform actions.&lt;/u&gt; In this example we define a tool that the AI agent can use to query the database using the &lt;code&gt;@mcp.tool&lt;/code&gt; decorator. Note that the docstring becomes the tool's description shown to the AI. In fact, when using this decorator, FastMCP automatically generates a JSON schema from Python type hints and docstrings, telling the AI exactly how to use the function.&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;&lt;p&gt;Tools Example&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@mcp.tool
def query_database(sql: str) -&amp;gt; str:
    """
    Execute an SQL query against the database.
    
    Args:
        sql: The SQL query to execute
    
    Returns:
        Query results as a string
    """
    # Logic to connect to IRIS and execute SQL goes here
    return execute_query(sql)&lt;/code&gt;&lt;/pre&gt;
&lt;ol start="2"&gt;&lt;li&gt;
&lt;strong&gt;Resources&lt;/strong&gt;: &lt;u&gt;Resources are passive data sources that the AI can read to gather context before it takes an action. They act as background information.&lt;/u&gt; In this example we define a resource using the &lt;code&gt;@mcp.resource("uri")&lt;/code&gt; decorator and assigning it a unique URI.&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;&lt;p&gt;Resource Example&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@mcp.resource("resource://database/schema")
def get_schema() -&amp;gt; dict:
    """Provides the database schema information to help the AI write better SQL."""
    return {
        "tables": {
            "Patient": ["id", "first_name", "last_name", "dob"],
            "Encounter": ["id", "patient_id", "date", "reason"],
            "Observation": ["id", "encounter_id", "type", "value"]
        },
        "version": "1.0",
        "storage_type": "relational"
    }&lt;/code&gt;&lt;/pre&gt;
&lt;ol start="3"&gt;&lt;li&gt;
&lt;strong&gt;Prompts&lt;/strong&gt;: &lt;u&gt;Prompts are reusable templates that help the user to interact with the AI.&lt;/u&gt; In this example we define a prompt through the &lt;code&gt;@mcp.prompt&lt;/code&gt; decorator that can guide the AI assistant to perform specific repetitive tasks like writing queries or importing data into the database.&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;&lt;p&gt;Prompt Example&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@mcp.prompt()
def sql_assistant() -&amp;gt; str:
    """A prompt template for IRIS SQL query assistance."""
    return """You are an expert SQL developer specializing in InterSystems IRIS.
    When writing queries:
    - Use proper IRIS SQL syntax (e.g., handle schema names correctly).
    - Favor performance-optimized indices.
    - Explain your reasoning if the query is complex."""&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Part 4: Using MCP with AI Development Tools&lt;/h2&gt;
&lt;p&gt;AI development tools are rapidly evolving from simple chat interfaces into sophisticated orchestrators capable of interacting with your local environment and remote servers by adopting the MCP protocol. Currently, while several platforms now support the protocol, the setup process is generally standardized across them.&lt;/p&gt;
&lt;p&gt;Most popular platforms nowadays are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cursor&lt;/strong&gt;: An AI-powered IDE built on Visual Studio Code that includes AI agent's capabilities and MCP integrations into the code editor &lt;a href="https://cursor.com/" rel="noopener noreferrer"&gt;[14]&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Claude Desktop&lt;/strong&gt;: Anthropic's official client, which uses MCP to give Claude "skills" like searching your local files or databases &lt;a href="https://claude.com/download" rel="noopener noreferrer"&gt;[15]&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Claude Code&lt;/strong&gt;: A CLI-based agent that can integrate MCP servers directly from the terminal &lt;a href="https://claude.com/product/claude-code" rel="noopener noreferrer"&gt;[16]&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;4.1 Configuring MCP servers&lt;/h3&gt;Both Cursor and Claude Desktop are configured through a JSON file, and the content of that file is the same for both platforms.&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Cursor &lt;/em&gt;allows you to configure MCP servers at two different levels:&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Project-level configuration&lt;/strong&gt;: Uses a local &lt;code&gt;.cursor/mcp.json&lt;/code&gt; file within your repository.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Global configuration&lt;/strong&gt;: Defined in user settings (found at &lt;code&gt;~/.cursor/mcp.json&lt;/code&gt; on macOS/Linux or the equivalent AppData path on Windows).&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Claude Desktop &lt;/em&gt;supports only a &lt;strong&gt;single user-level configuration file&lt;/strong&gt;, called &lt;code&gt;claude_desktop_config.json&lt;/code&gt;, that you can find within the application itself using the menu&lt;ol&gt;&lt;li&gt;Settings → Developer → Edit Config.&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The following JSON structure shows how to connect Cursor or Claude to an IRIS MCP server:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
  "mcpServers": {
    "my-server-name": {
      "command": "executable-or-runtime",
      "args": ["path/to/script-or-package", "--option", "value"],
      "env": {
        "KEY_1": "value-1",
        "KEY_2": "value-2"
      }
    }
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Every MCP server configuration is based on a few key fields that tell the AI how to launch and communicate with the server.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Let's look at the JSON fields to understand how this configuration works:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;mcpServers&lt;/code&gt;: The root object that lists all your connected servers. You can have multiple servers running simultaneously (for example: one for IRIS, one for Google Drive, one for Atlassian, etc.).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;command&lt;/code&gt;: The command used to start the server. Common examples include &lt;code&gt;python&lt;/code&gt;, &lt;code&gt;node&lt;/code&gt;, &lt;code&gt;uvx&lt;/code&gt;, or &lt;code&gt;npx&lt;/code&gt;. In particular, use &lt;code&gt;uvx&lt;/code&gt; (for Python) or &lt;code&gt;npx&lt;/code&gt; (for Node.js) to run packages directly from the web without manually installing them (see the next chapter for more information).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;args&lt;/code&gt;: An array of arguments passed to the command. This usually includes the MCP server file path or the name of a package to execute.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;env&lt;/code&gt;: An array containing your environment variables. This is the standard way to pass sensitive or environment-specific data like hostnames, port numbers, and credentials without hardcoding them into the server logic itself.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once you have this configured, the AI assistant can directly interact with your IRIS database, execute queries, and access schema information without you manually copying and pasting context.&lt;/p&gt;

&lt;h2&gt;Part 5: Distributing and running MCP servers with uv and uvx&lt;/h2&gt;The configuration JSON file tells the client what to launch, but you also need to decide where the client should point to reach the server. Three distribution modes cover the vast majority of real-world setups, and all three rely on the &lt;code&gt;pyproject.toml&lt;/code&gt; and &lt;code&gt;uv.lock&lt;/code&gt; ee already created in Part 3.1, which is what makes the MCP server runnable as a single command.&amp;nbsp;&lt;h3&gt;5.1 Local clone (development mode)&lt;/h3&gt;Use this mode while you are actively writing or debugging the server. The user clones the repository, and the client points at the local working copy with &lt;code&gt;uv run&lt;/code&gt;:&lt;pre&gt;&lt;code&gt;{
  "command": "uv",
  "args": ["run", "&amp;lt;mcp-server-name&amp;gt;"],
  "env": { "...": "..." }
}&lt;/code&gt;&lt;/pre&gt;The CLI is launched directly from your live source tree, so any change to a tool, prompt, or resource is picked up the next time you reload the server in the client, without having to rebuild or reinstall. This is the only mode that lets in-progress edits take effect immediately.&lt;h3&gt;5.2 GitHub repository&lt;/h3&gt;
&lt;p&gt;Once the repo is pushed, anyone with &lt;code&gt;uv&lt;/code&gt; installed can run the server without cloning it by pointing &lt;code&gt;uvx&lt;/code&gt; at the GitHub URL:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
  "command": "uvx",
  "args": [
    "--from", "git+https://github.com/&amp;lt;repository&amp;gt;.git",
    "&amp;lt;mcp-server-name&amp;gt;"
  ],
  "env": { "...": "..." }
}&lt;/code&gt;&lt;/pre&gt;The first time the client launches, &lt;code&gt;uvx&lt;/code&gt; clones the repo into an isolated cache, builds the wheel, and runs the entry-point. Subsequent launches reuse the cache and start quickly.&lt;h3&gt;5.3 PyPI&lt;/h3&gt;After publishing the package to PyPI, the configuration collapses to its simplest form:&lt;pre&gt;&lt;code&gt;{
  "command": "uvx",
  "args": ["&amp;lt;mcp-server-name&amp;gt;"],
  "env": { "...": "..." }
}&lt;/code&gt;&lt;/pre&gt;
&lt;code&gt;uvx&lt;/code&gt; resolves the latest wheel over HTTP and Git is not required at runtime. The first start is the fastest of the three modes and the install instructions consist only in one line.&amp;nbsp;&lt;h3&gt;5.3.1 Publishing a package to PyPI&lt;/h3&gt;Publishing the package follows three commands, all run from the project root:&amp;nbsp;&lt;p&gt;Publishing on PyPI&lt;/p&gt;Bump the version (PyPI rejects re-uploads of an existing version)&lt;pre&gt;&lt;code&gt;# Use --bump patch / minor / major depending on the change
uv version --bump patch&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Build the wheel and the source distribution into ./dist&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uv build&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Upload to PyPI using an API token&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#    Export the token as an env var so it does not end up in shell history
#    uv publish reads it automatically from UV_PUBLISH_TOKEN. 
export UV_PUBLISH_TOKEN=pypi-&amp;lt;your-token&amp;gt;     # Linux / macOS / Git Bash 
$env:UV_PUBLISH_TOKEN = "pypi-&amp;lt;your-token&amp;gt;"   # PowerShell 
uv publish &lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Part 6: MCP and InterSystems IRIS&lt;/h2&gt;
&lt;p&gt;Nowadays we already have several example of MCP servers working with InterSystems IRIS. Since IRIS is a multi-model database, it’s a perfect candidate for this protocol. Instead of just giving an AI your code, you’re giving it a live connection to your data, your globals, and your system metrics.&lt;/p&gt;
&lt;h3&gt;6.1 Existing MCP Server for IRIS&lt;/h3&gt;
&lt;p&gt;Several developers have shared MCP implementations or MCP-related tools on the InterSystems Developer Community. Among these, the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://openexchange.intersystems.com/package/mcp-server-iris" rel="noopener noreferrer"&gt;mcp-server-iris [17]&lt;/a&gt; by &lt;span&gt;&lt;span&gt;&lt;a class="mentioned-user" href="https://dev.to/dmitry"&gt;@dmitry&lt;/a&gt;.Maslennikov&lt;/span&gt;&lt;/span&gt;: An MCP server to monitor and manage Interoperability productions using natural language&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://openexchange.intersystems.com/package/intersystems-objectscript-mcp" rel="noopener noreferrer"&gt;intersystems-objectscript-mcp [18]&lt;/a&gt; by &lt;a href="https://github.com/cjy513203427" rel="noopener noreferrer"&gt;Chen Jinyao&lt;/a&gt;: An MCP server that fetches compiled routines (&lt;code&gt;.int&lt;/code&gt;, &lt;code&gt;.mac&lt;/code&gt;, &lt;code&gt;.inc&lt;/code&gt;) directly from the IRIS server.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/esalas-devel/iris-mcp-atelier" rel="noopener noreferrer"&gt;iris-mcp-atelier [19]&lt;/a&gt; by &lt;span&gt;&lt;span&gt;&lt;a class="mentioned-user" href="https://dev.to/ernest"&gt;@ernest&lt;/a&gt;.Salas&lt;/span&gt;&lt;/span&gt;: A specialized MCP server that uses the Atelier REST API to give AI assistants direct read/write access to ObjectScript code on a live IRIS instance.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://openexchange.intersystems.com/package/gj-::-servAI" rel="noopener noreferrer"&gt;servAI [20]&lt;/a&gt; by &lt;span&gt;&lt;span&gt;&lt;a class="mentioned-user" href="https://dev.to/john"&gt;@john&lt;/a&gt;.Murray&lt;/span&gt;&lt;/span&gt;: A VS Code extension that acts as a secure credential wrapper for MCP servers, automatically pulling connection details and passwords from the InterSystems Server Manager and avoiding the need to hardcode sensitive credentials in configuration JSON files.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://openexchange.intersystems.com/package/IRIS-MCP-Server-Suite-2" rel="noopener noreferrer"&gt;IRIS MCP Server Suite [21]&lt;/a&gt; by &lt;span&gt;&lt;span&gt;&lt;a class="mentioned-user" href="https://dev.to/joshua"&gt;@joshua&lt;/a&gt;.Brandt&lt;/span&gt;&lt;/span&gt;: A comprehensive suite of services to work with InterSystems IRIS including five different MCP servers related to different domains.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/intersystems-community/ai-hub-eap" rel="noopener noreferrer"&gt;InterSystems IRIS AI Hub [22]&lt;/a&gt;: currently in Early Access and recently presented at READY 2026, it provides a unified SDK and MCP Server integration to securely connect AI models and external agents with InterSystems IRIS business logic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Feel free to cite in the comments all the applications and developers you believe worth to be mentioned.&lt;/p&gt;

&lt;h2&gt;Part 7: Building Your Own MCP Server for IRIS&lt;/h2&gt;
&lt;p&gt;While the community tools are excellent, you may eventually need a server tailored to your specific application logic or you may want to understand how the previously mentioned tools work. In this section I'm providing an example of how to implement an MCP server to work with InterSystems IRIS.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To build an MCP server for InterSystems IRIS I recommend you to follow two main approaches:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Using the &lt;strong&gt;InterSystems Python Native SDK &lt;/strong&gt;&lt;a href="https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=PAGE_python_native" rel="noopener noreferrer"&gt;[9]&lt;/a&gt;&lt;a href="https://pypi.org/project/intersystems-irispython/" rel="noopener noreferrer"&gt;[23]&lt;/a&gt;: &lt;code&gt;intersystems-irispython&lt;/code&gt; is the official Python package to connect with InterSystems IRIS providing a lightweight interface to access through Python all the resources once only available to ObjectScript, like Globals or Class Methods. This is best for heavy data operations, manipulating Globals, calling existing Business Logic and high-speed SQL execution.&lt;/li&gt;
&lt;li&gt;Using the &lt;strong&gt;Source Code File REST API&lt;/strong&gt; (a.k.a. &lt;strong&gt;Atelier API&lt;/strong&gt;) &lt;a href="https://docs.intersystems.com/iris20261/csp/docbook/DocBook.UI.Page.cls?KEY=GSCF_intro" rel="noopener noreferrer"&gt;[24]&lt;/a&gt;: The Atelier API provides a RESTful interface (&lt;code&gt;/api/atelier/&lt;/code&gt;) designed specifically for source code management. This was originally built for the Atelier IDE (and now it is used by the InterSystems Server Manager VS Code extension) and it is useful to work with source code files, compile classes, or manage development workflows.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;7.1 The blueprint implementation of an IRIS MCP server&lt;/h3&gt;To put hands on the patterns exposed from Parts 3 to 6, the rest of this article walks through a working example of an MCP server that talks to a local IRIS instance through both the Native Python SDK and the Atelier REST API called &lt;strong&gt;iris-mcp-blueprint&lt;/strong&gt;. The full source code can be found on Open Exchange or GitHub and is linked to this article.What you'll see is intentionally a &lt;strong&gt;blueprint&lt;/strong&gt;, not a production-ready MCP server. The set of tools, prompts, and resources is deliberately small, aimed only to show the patterns. Treat the code as a starting point: clone it, modify it and adapt it to implement your own MCP server tailored to your IRIS application.For full setup instructions (Docker, environment variables, prerequisites), the exact &lt;code&gt;mcp.json&lt;/code&gt; snippets for Cursor and Claude Desktop in each of the three distribution modes, the list of every tool and prompt with example arguments refer to the repository's README.&lt;h3&gt;7.2 Highlights of the code&lt;/h3&gt;The blueprint implements all three MCP primitives: &lt;strong&gt;Tools&lt;/strong&gt;, &lt;strong&gt;Prompts&lt;/strong&gt;, and &lt;strong&gt;Resources&lt;/strong&gt;. Tools act as the "hands" of the AI, using the Native SDK to perform actions like querying SQL or reading Globals. They are grouped into five macro categories, each focused on a different IRIS surface:&amp;nbsp;&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SQL data access&lt;/strong&gt; (&lt;code&gt;sql.py&lt;/code&gt;)&lt;ul&gt;&lt;li&gt;The Native SDK provides a fast way to run SQL from Python using a DB-API cursor. You can perform queries both on custom and system tables. The latter, for example the &lt;code&gt;INFORMATION_SCHEMA&lt;/code&gt;, can be used to retrieve information and helping the AI to write its own SQL queries later.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Direct global access&lt;/strong&gt; (&lt;code&gt;globals.py&lt;/code&gt;)&lt;ul&gt;&lt;li&gt;Globals are IRIS's physical storage layer. The blueprint reads them through the Native SDK helpers:&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;iris_obj.isDefined("^GlobalName")&lt;/code&gt; to check global status (it returns &lt;strong&gt;0&lt;/strong&gt; if node is empty, &lt;strong&gt;1 &lt;/strong&gt;if node has a value, &lt;strong&gt;10&lt;/strong&gt; if node has children (subscripts), &lt;strong&gt;11&lt;/strong&gt; if node has both a value and children).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;iris_obj.get("^Global", sub1)&lt;/code&gt; and &lt;code&gt;iris_obj.set(val, "^Global", sub1)&lt;/code&gt; to get or set values from/in a global subscript.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Executing existing Logic via ClassMethods &lt;/strong&gt;(&lt;code&gt;class_methods.py&lt;/code&gt;)&lt;ul&gt;&lt;li&gt;You can execute already existing &lt;em&gt;ClassMethods &lt;/em&gt;in IRIS using the &lt;code&gt;iris_obj.classMethodValue("Package.Class", "MethodName", *args)&lt;/code&gt;. This effectively turns your entire IRIS codebase into a library of functions the AI can call, including both custom and built-in methods.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Atelier REST API usage &lt;/strong&gt;(&lt;code&gt;atelier_api.py&lt;/code&gt;)&lt;ul&gt;&lt;li&gt;The Atelier API provides a REST interface for source code management and it is used by the InterSystems Server Manager VS Code extension as well.&amp;nbsp;The API has a lot of different features, but the blueprint shows two representative endpoints used to:&amp;nbsp;&lt;ul&gt;
&lt;li&gt;fetch the raw &lt;code&gt;.cls&lt;/code&gt; class definition to explain the ObjectScript logic&lt;/li&gt;
&lt;li&gt;search for a specific string into the codebase&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interoperability productions&lt;/strong&gt; (&lt;code&gt;interoperability.py&lt;/code&gt;)&amp;nbsp;&lt;ul&gt;&lt;li&gt;Beyond data access, the blueprint also provide a set of simple tools to manage an IRIS Production environment without the user ever open the Management Portal.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;Beyond the tools, Prompts were designed as structured workflows including the instructions on how to use the provided tools (for example, the logical steps to create a table importing a .csv file from a specified local folder). Resources are a read-only context providing the AI with system information, such as the IRIS version or namespace details, without requiring an active tool call.&amp;nbsp;&lt;p&gt;This implementation contains a limited number of use cases designed to explain of how to use both the native Python SDK and the Atelier API. Again, this example is not a complete implementation of services but rather a blueprint to be used as a guide to develop your own MCP server, tailored to satisfy the specific needs of your project.&lt;/p&gt;
&lt;p&gt;If you want more information about how this blueprint work, check the related video on YouTube:
&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/h20YIDVeVK4" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;Part 8: Conclusion&lt;/h2&gt;The Model Context Protocol turns InterSystems IRIS from a database the AI knows nothing about into a live system the AI can query, inspect, and even modify on demand through SQL, Globals, ClassMethods, the Atelier API or Interoperability productions. The blueprint that accompanies this article shows how few moving parts are actually needed to get there. From here, every project will pull in different domain logic — your own Business Processes, your own queries, your own globals. But the protocol, the transport, the FastMCP decorators, and the deployment story stay the same.
&lt;h2&gt;Part 9: Sources&lt;/h2&gt;&amp;nbsp;&lt;p&gt;The following list contains all the cited sources&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.anthropic.com/news/model-context-protocol" rel="noopener noreferrer"&gt;Introducing the Model Context Protocol&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://modelcontextprotocol.io/specification/latest" rel="noopener noreferrer"&gt;MCP Specification&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/modelcontextprotocol" rel="noopener noreferrer"&gt;MCP GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://modelcontextprotocol.io/docs/getting-started/intro" rel="noopener noreferrer"&gt;What is the Model Context Protocol (MCP)?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://modelcontextprotocol.io/docs/learn" rel="noopener noreferrer"&gt;MCP Architecture overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://mcpcat.io/blog/mcp-server-client-host/" rel="noopener noreferrer"&gt;MCP Server, Client and Host&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.jsonrpc.org/" rel="noopener noreferrer"&gt;JSON RPC&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://modelcontextprotocol.io/docs/sdk" rel="noopener noreferrer"&gt;MCP SDKs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=PAGE_python_native" rel="noopener noreferrer"&gt;InterSystems Native SDK for Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.astral.sh/uv/concepts/projects/dependencies/" rel="noopener noreferrer"&gt;uv Managing dependencies&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.astral.sh/uv/concepts/build-backend/" rel="noopener noreferrer"&gt;uv Build backend&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pypi.org/project/mcp/" rel="noopener noreferrer"&gt;PyPI MCP Python SDK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gofastmcp.com/" rel="noopener noreferrer"&gt;FastMCP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cursor.com/" rel="noopener noreferrer"&gt;Cursor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://claude.com/download" rel="noopener noreferrer"&gt;Claude Desktop&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://claude.com/product/claude-code" rel="noopener noreferrer"&gt;Claude Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://openexchange.intersystems.com/package/mcp-server-iris" rel="noopener noreferrer"&gt;mcp-server-iris&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://openexchange.intersystems.com/package/intersystems-objectscript-mcp" rel="noopener noreferrer"&gt;intersystems-objectscript-mcp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/esalas-devel/iris-mcp-atelier" rel="noopener noreferrer"&gt;iris-mcp-atelier&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://openexchange.intersystems.com/package/gj-::-servAI" rel="noopener noreferrer"&gt;servAI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://openexchange.intersystems.com/package/IRIS-MCP-Server-Suite-2" rel="noopener noreferrer"&gt;IRIS-MCP-Server-Suite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/intersystems-community/ai-hub-eap" rel="noopener noreferrer"&gt;InterSystems IRIS AI Hub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pypi.org/project/intersystems-irispython/" rel="noopener noreferrer"&gt;PyPI Intersystem IRIS Native Python SDK (intersystems-irispython)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.intersystems.com/iris20261/csp/docbook/DocBook.UI.Page.cls?KEY=GSCF_intro" rel="noopener noreferrer"&gt;Source Code File REST API (a.k.a. Atelier API)&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;


</description>
      <category>ai</category>
      <category>productivity</category>
      <category>resources</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Intro to AI Hub, Part 3: Stateful Tools</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Tue, 27 Oct 2026 16:42:31 +0000</pubDate>
      <link>https://dev.to/intersystems/intro-to-ai-hub-part-3-stateful-tools-1gpf</link>
      <guid>https://dev.to/intersystems/intro-to-ai-hub-part-3-stateful-tools-1gpf</guid>
      <description>&lt;p&gt;Hi all! This is the third installment in my series introducing the AI Hub, which is currently in an early access program. In this article, we are going into detail on a pattern which I think is super cool: &lt;strong&gt;Stateful Tools&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;As with the previous articles, the following disclaimer applies:&amp;nbsp;&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Disclaimer: AI Hub is an early access preview, with features likely to change before production releases, any issues identified can be raised as issues on the documentation GitHub repo linked above. The EAP preview is not to be used in production settings.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;And to give the links again: &lt;a href="https://evaluation.intersystems.com/Eval/early-access/AIHub" rel="noopener noreferrer"&gt;EAP Site&lt;/a&gt; for download, &lt;a href="https://github.com/intersystems-community/ai-hub-eap/tree/master" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;, and to add one new link, there is now a &lt;a href="https://discord.com/channels/698987699406766170/1521152420963418122" rel="noopener noreferrer"&gt;Discord channel&lt;/a&gt; to share ideas and ask questions.&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;A recap on %AI.Tool&lt;/h2&gt;
&lt;p&gt;I introduced tools in my first article in this series, but to recap, an AI agent tool is a function which can be directly called by the agent. Large Language Models have been trained to read tool definitions, including a tool name, description and required parameters, and respond in JSON structured output requesting a tool call. The tool then executes and the output is returned to the agent.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Tools are what allows modern AI Agents to actually &lt;em&gt;do&lt;/em&gt; things, rather than just &lt;em&gt;"say"&lt;/em&gt; things. They can be anything, like reading a file, performing a web search, querying a database or something more complex and bespoke like opening a specific application and taking a screenshot. Anything that can be abstracted down to a small number of input parameters, a coded function and an output can be turned into a tool.&lt;/p&gt;
&lt;p&gt;It's super easy to create tools with AI Hub. All you need to do is extend &lt;code&gt;%AI.Tool&lt;/code&gt; and write custom methods, class methods or queries. You can also use &lt;code&gt;%AI.ToolSet&lt;/code&gt; to define and organise tools, add external tools and combine with custom policies.&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;What Are Stateful Tools in AI Hub?&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;%AI.Tool&lt;/code&gt; and &lt;code&gt;%AI.ToolSet&lt;/code&gt; classes can be &lt;strong&gt;stateful&lt;/strong&gt;, meaning that they remember the state between executions. Information or data can be stored as a &lt;code&gt;Property&lt;/code&gt; of the tool, meaning it can be used or recalled later.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;%AI.Tool&lt;/code&gt; or &lt;code&gt;%AI.ToolSet&lt;/code&gt; class in question is instantiated &lt;em&gt;when an agent is instantiated&lt;/em&gt; and remains alive for the life of the agent. This provides a way for agents to save information which will last across sessions. Any properties are stored and can be accessed by tools which are defined as methods (note, ClassMethods and Query Components can't access instance properties).&lt;/p&gt;
&lt;h3&gt;&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;Providing Tool Memory&lt;/h3&gt;
&lt;p&gt;The example in the documentation shows stateful tools being used for notes that an agent can autonomously read and write. You can do this with the following (&lt;a href="https://github.com/intersystems-community/ai-hub-eap/blob/master/ObjectScript_SDK_Guide.md#stateful-tools-instance-methods" rel="noopener nofollow noreferrer"&gt;adapted from the documentation&lt;/a&gt;):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class Sample.Memories Extends %AI.Tool&lt;br&gt;
{&lt;br&gt;
Property Memories As %String(MAXLEN = "");

&lt;p&gt;// Ensure the tool is registered to be stateful. This is set by default by the inclusion of instance methods.&amp;nbsp;&lt;br&gt;
PARAMETER STATEFUL=1;&lt;/p&gt;

&lt;p&gt;///  Save to memory&lt;br&gt;
Method SaveToMemory(memory As %String(DESCRIPTION = "Note to store in memory")) As %String&lt;br&gt;
{&lt;br&gt;
Set ..Memories = ..Memories &lt;em&gt;memory&lt;/em&gt;$C(10)&lt;br&gt;
return "Memory"&lt;br&gt;
}&lt;/p&gt;

&lt;/code&gt;&lt;p&gt;&lt;code&gt;/// Recall Saved Memories&lt;br&gt;&lt;br&gt;
Method RecallMemories() As %String&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
Return ..Memories&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;This means the agent can create and retrieve memories which are specific to the agent instance. For example:&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;set agent = ##class(Sample.Agent).%New()&lt;br&gt;&lt;br&gt;
do agent.%Init()&amp;nbsp;&lt;br&gt;&lt;br&gt;
do agent.ToolManager.AddTool(##class(Sample.Memories).%New())&lt;br&gt;&lt;br&gt;
set s1 = agent.CreateSession()

&lt;p&gt;do agent.Chat(s1, "Write a memory about a trip to Peru to see some llamas to your memory bank")&lt;/p&gt;

&lt;p&gt;kill s1 // Even if we delete the original session, the memory is kept by the tool&lt;/p&gt;

&lt;p&gt;set s2 = agent.CreateSession()&lt;br&gt;
set response = agent.Chat(s2, "Tell me whats in your memory bank")&lt;/p&gt;

&lt;/code&gt;&lt;p&gt;&lt;code&gt;write response.Content&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;Outputted:&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Ahoy, matey! Here be what me memory bank holds right now:

&lt;p&gt;Memory log: Peru llama encounter&lt;/p&gt;

&lt;p&gt;We set sail from the coast and dropped anchor in the highlands near Cusco. The air was thin, sharp as a cutlass, and the mountains rose like towering waves. In the Sacred Valley, we found a small herd of llamas on the hillside. Their patient, curious eyes watched us as I approached slowly, offering a bit of maize. A sturdy llama led the way, its bells jangling softly, and a wary cria peeked from behind its mother. I patted the soft fleece and felt a warm shiver of adventure run through my bones. We traded stories with a kindly herder, and I bought a woven scarf as a treasure to remind me of the quiet grace of these beasts. Sunset bled across the peaks, turning the snow-capped summits to gold, and the llamas stood as silent sentinels of the day. Aye, that memory stays with me, a calm voyage ashore in the heart of Peru.&lt;/p&gt;

&lt;/code&gt;&lt;p&gt;&lt;code&gt;If ye want to add more memories, just name the voyage, and I shall chart it in yer memory bank.&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;I guess now would be a good time to mention that I've been playing around with a "&lt;strong&gt;Talk like a Pirate&lt;/strong&gt;" system prompt...&lt;/p&gt;
&lt;h2&gt;&amp;nbsp;&lt;/h2&gt;
&lt;h2&gt;Setting properties deterministically&amp;nbsp;&lt;/h2&gt;
&lt;p&gt;Now I don't deny, the saving memories is pretty nice, but you could easily achieve this by setting a global, with the added advantage that the data would persist across agent instances.&lt;/p&gt;
&lt;p&gt;The biggest practical benefit of stateful tools (in my opinion) is that the &lt;strong&gt;properties can also be set deterministically&lt;/strong&gt;. We can hardcode properties in the tool when instantiating a new agent, so tool settings are pre-defined for the agent. This makes it very easy to scope an agent's access.&lt;/p&gt;
&lt;p&gt;For example, let's say you had an agent to query a patient's medical history, you could create a tool which takes in the patient ID as a runtime parameter and trust that the agent will call the tool with the correct ID. But what happens if a malicious actor convinces the agent that it should bypass guardrails and give the medical information for a different patient ID?&lt;/p&gt;
&lt;p&gt;Instead we can set the PatientId for the individual Tool instance, meaning the agent can use the tool, but never choose, or potentially even know, which patient it is using it for.&lt;/p&gt;
&lt;p&gt;To do this, we can create a tool class with a &lt;code&gt;PatientId&lt;/code&gt; property, and one or more methods which use the property:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class Sample.PatientQueryTool Extends %AI.Tool&lt;br&gt;&lt;br&gt;
{&lt;br&gt;&lt;br&gt;
Property PatientId;&amp;nbsp;

&lt;p&gt;Method QueryPatientHistory() As %DynamicArray&lt;br&gt;
{&lt;/p&gt;

&lt;p&gt;set sql = "SELECT TOP 20 RecordedAt, EncounterType, Condition, Treatment, Clinician "&lt;br&gt;
            _ "FROM Sample.PatientHistory "&lt;br&gt;
            _ "WHERE PatientId = ? "&lt;br&gt;
            _ "ORDER BY RecordedAt DESC"&lt;/p&gt;

&lt;p&gt;set stmt = ##class(%SQL.Statement).%New()&lt;br&gt;
   set sc = stmt.%Prepare(sql)&lt;br&gt;
   set rs = stmt.%Execute(..PatientId)&lt;/p&gt;

&lt;p&gt;set results = []&lt;br&gt;
   while rs.%Next() {&lt;br&gt;
       do results.%Push({&lt;br&gt;
           "RecordedAt":     (rs.%Get("RecordedAt")),&lt;br&gt;
           "EncounterType":  (rs.%Get("EncounterType")),&lt;br&gt;
           "Condition":      (rs.%Get("Condition")),&lt;br&gt;
           "Treatment":      (rs.%Get("Treatment")),&lt;br&gt;
           "Clinician":      (rs.%Get("Clinician"))&lt;br&gt;
       })&lt;br&gt;
   }&lt;/p&gt;

&lt;/code&gt;&lt;p&gt;&lt;code&gt;quit results&lt;br&gt;&lt;br&gt;
}&lt;br&gt;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;Now all we need to do is set the &lt;code&gt;PatientId&lt;/code&gt; when the Agent class is instantiated. We can do this as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;set Provider = ...&amp;nbsp;&lt;br&gt;&lt;br&gt;
set agent = ##class(%AI.Agent).%New(Provider)&lt;br&gt;&lt;br&gt;
set tool = ##class(Sample.PatientQueryTool).%New()&lt;br&gt;&lt;br&gt;
set tool.PatientId = 42

&lt;/code&gt;&lt;p&gt;&lt;code&gt;agent.ToolManager.AddTool(tool)&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;And now, this instance of an agent can only access the patient record of the patient in question. No non-deterministic guardrails about the AI only accessing the patient-in-question's record are needed, because the agent's tool &lt;strong&gt;can only access the data for the relevant patient&lt;/strong&gt;. The agent doesn't have setter or getter tools built-in for tool properties, so it cannot see or edit this &lt;code&gt;PatientId&lt;/code&gt; itself.&lt;/p&gt;
&lt;p&gt;One additional thing to be aware of, is that if you wish to use stateful tools like this, you are best to add them as instance objects. That is to say, you can't create an agent class with &lt;code&gt;PARAMETER TOOLS = "Sample.PatientQueryTool";&lt;/code&gt;, you instead need to add the tool after instantiation and property setting. You can do this with something like the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Class Sample.PatientAgent Extends %AI.Agent{

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Method %OnInit() As %Status
{&amp;nbsp;
// Set provider with API key from environment variable&amp;nbsp;
Set key = $System.Util.GetEnviron("OPENAI_API_KEY")&amp;nbsp;// or whatever  
Set ..Provider = ##class(%AI.Provider).Create("openai", {"api_key": (key)})
return $$$OK
}

Method AddPatientTools(pPatientId As %Integer) As %Status
{
    // Check the patientID has been set to a positive integer
    if 'pPatientId || pPatientId'&amp;amp;gt;0 {
        quit $$$ERROR($$$GeneralError, "PatientId must be set to a positive integer.")
    }
    // Create a new instance of our tool class
    Set tool = ##class(Sample.PatientQueryTool).%New()

    // Set the Patient ID on the tools
    set tool.PatientId = pPatientId

    // Add the tools to the agent instance
    do ..ToolManager.AddTool(tool)

    quit $$$OK
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/code&gt;&lt;p&gt;&lt;code&gt;}&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;
&lt;p&gt;Then you can instantiate this with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;set agent = ##class(Sample.PatientAgent).%New()&lt;br&gt;&lt;br&gt;
do agent.%Init()&lt;br&gt;&lt;br&gt;
do agent.AddPatientTools(42)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And chat with it as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;set session = agent.CreateSession()&lt;br&gt;&lt;br&gt;
set question = "Tell me about my recent history"&lt;br&gt;&lt;br&gt;
set response  = agent.Chat(session, question)&lt;br&gt;&lt;br&gt;
write response.Content&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;&amp;nbsp;&lt;/h2&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;In this article, I've shown how you can use stateful tools to create memory, or to add deterministic scope for your AI Agent Tools.&lt;/p&gt;
&lt;p&gt;There are so many other uses for these kinds of stateful tools, like caching outputs from one tool (method) to be used by another, providing they are defined in the same class. I'd love to see other cool, innovative uses for stateful tools from anyone who is interested in participating in the next round of the &lt;a href="https://community.intersystems.com/post/community-bounty-program-idea-application-%E2%80%94-round-2-live" rel="noopener nofollow noreferrer"&gt;Community Bounty Program&lt;/a&gt;!&lt;/p&gt;&amp;nbsp;&lt;p&gt;Frequently Asked Questions&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What is a stateful tool in InterSystems IRIS AI Hub?&lt;/li&gt;
&lt;li&gt;A stateful tool is a %AI.Tool or %AI.ToolSet instance that retains property values between executions. The tool instance remains available for the lifetime of the agent instance, so stored information can be reused by later tool calls.&lt;/li&gt;
&lt;li&gt;Can stateful tools provide memory across AI agent sessions?&lt;/li&gt;
&lt;li&gt;Yes. Because the state belongs to the tool instance associated with the agent, information stored in a property can remain available when one session ends and another session is created with the same agent instance. It does not automatically persist across separate agent instances.&lt;/li&gt;
&lt;li&gt;How do stateful tools store and access information?&lt;/li&gt;
&lt;li&gt;Information can be stored in properties of a %AI.Tool or %AI.ToolSet class. Instance methods can read or update those properties, allowing later tool calls to use values saved earlier.&lt;/li&gt;
&lt;li&gt;How can stateful tools restrict an AI agent's access to data?&lt;/li&gt;
&lt;li&gt;A property can be set deterministically when the tool is instantiated. For example, a patient-query tool can be assigned a specific PatientId before it is added to an agent. The tool then queries only that patient's data without requiring the AI agent to select or provide the identifier itself.&lt;/li&gt;
&lt;li&gt;Do stateful tools have uses beyond memory and access scoping?&lt;/li&gt;
&lt;li&gt;Yes. Stateful tools can be used to cache information or outputs from one tool method so they can be reused by another method defined in the same class.&lt;/li&gt;
&lt;/ul&gt;


</description>
      <category>ai</category>
      <category>programming</category>
      <category>tooling</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>DTL Deep Dive: Conditionals on Length, ReplaceStr, Special Character Cleaning, and Timestamp Formatting</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Tue, 27 Oct 2026 16:36:33 +0000</pubDate>
      <link>https://dev.to/intersystems/dtl-deep-dive-conditionals-on-length-replacestr-special-character-cleaning-and-timestamp-1mbd</link>
      <guid>https://dev.to/intersystems/dtl-deep-dive-conditionals-on-length-replacestr-special-character-cleaning-and-timestamp-1mbd</guid>
      <description>&lt;p&gt;Hi Community,&lt;/p&gt;

&lt;p&gt;Data Transformation Language (DTL) is one of those tools that appears deceptively simple at first—drag a source field, drop it on a target, and you are done. However, once you start working on real-world integration projects, you quickly realize that raw field mapping only gets you so far. The true challenge begins when you need to validate field lengths, clean up incoming strings, strip unwanted characters from IDs, or produce timestamps in a specific format required by a downstream system.&lt;/p&gt;

&lt;p&gt;In this article, we will move beyond the basics and explore four practical DTL scenarios that occur regularly in real-world integrations. Each section is built around a single sample HL7 message, allowing you to follow along in your own environment and see the results for yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What We Will Cover:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating a DTL from scratch in the Management Portal.&lt;/li&gt;
&lt;li&gt;Conditional logic based on field length (&lt;code&gt;$Length&lt;/code&gt;, &lt;code&gt;$Extract&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Stripping and replacing text using &lt;code&gt;ReplaceStr&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Stripping special characters from a Patient ID with chained &lt;code&gt;ReplaceStr&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Reformatting HL7 timestamps into a custom display format.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;InterSystems IRIS or HealthShare with an Interoperability-enabled namespace.&lt;/li&gt;
&lt;li&gt;Access to the Management Portal.&lt;/li&gt;
&lt;li&gt;Basic familiarity with HL7 v2 message structure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: While all examples use HL7 v2 ADT messages, the same DTL functions apply equally to XML, JSON, or custom message classes.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is a DTL?
&lt;/h2&gt;

&lt;p&gt;A DTL (Data Transformation Language) in InterSystems IRIS is a class that defines how to map and transform message fields — either between different message formats or within the same message type. You build it visually in the Management Portal, and IRIS generates the underlying ObjectScript code.&lt;/p&gt;

&lt;p&gt;Each transformation consists of actions. The most common ones are the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Assign:&lt;/strong&gt; Maps or sets a field value.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If: &lt;/strong&gt;Handles conditional branching.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code: &lt;/strong&gt;Allows you to write ObjectScript directly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Foreach: &lt;/strong&gt;Iterates over repeating segments.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Sample HL7 Message
&lt;/h2&gt;

&lt;p&gt;All four scenarios in this article use the same incoming ADT A01 message. Keeping this consistent is vital, since you rarely get to transform only one field at a time in production.&lt;/p&gt;

&lt;p&gt;Here is our sample message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MSH|^~\&amp;amp;|SENDING_APP|SENDING_FAC|RECEIVING_APP|RECEIVING_FAC|20250315143022||ADT^A01|MSG00001|P|2.5
EVN|A01|20250315143022
PID|1||MRN#001/2025^^^HOSP||VanDerBerghMontgomeryXYZABC^John^M||19850101|M|||123 Main Street^^Lahore^Punjab^54000^PK||+92-03001234567|||M||ACC001|
PV1|1|I|WARD-A^Room101^Bed1|E|||DOC001^Smith^James|||SUR|||||||V01|ACC001||||||||||||||||||||||||||20250315143022
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Items each field carries that matters for our examples:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PID-5.1&lt;/strong&gt; (Family Name): &lt;code&gt;VanDerBerghMontgomeryXYZABC&lt;/code&gt; (27 characters; intentionally exceeds the 25-character limit).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PID-3.1&lt;/strong&gt; (Patient ID): &lt;code&gt;MRN#001/2025&lt;/code&gt; contains &lt;code&gt;#&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt; characters that the target system cannot accept&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PID-13&lt;/strong&gt; (Phone Number): &lt;code&gt;+92-03001234567&lt;/code&gt; (Includes an unwanted country code prefix ).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PV1-44&lt;/strong&gt; (Admit Date/Time): &lt;code&gt;20250315143022&lt;/code&gt; (Standard HL7 DTM format; requires conversion to 15/03/2025 14:30).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: Keep this message open in a text editor as you work through each section.&lt;/p&gt;




&lt;h2&gt;
  
  
  Creating a DTL from Scratch
&lt;/h2&gt;

&lt;p&gt;Before jumping into transformations, let us set up the DTL in which all four examples will live.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Navigate to the DTL editor:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to &lt;strong&gt;Management Portal → Interoperability → Build → Data Transformations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8co9eucdl2tu0nkchvca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8co9eucdl2tu0nkchvca.png" alt=" " width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;New&lt;/strong&gt; to create a new transformation.&lt;/p&gt;

&lt;p&gt;Fill in the dialog:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Package&lt;/strong&gt;: &lt;code&gt;Demo&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt;: &lt;code&gt;ADTTransform&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description&lt;/strong&gt;: DTL deep dive demo&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source&lt;/strong&gt;: &lt;code&gt;EnsLib.HL7.Message&lt;/code&gt; set &lt;strong&gt;DocType&lt;/strong&gt; to &lt;code&gt;2.5:ADT_A01&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Target&lt;/strong&gt;: &lt;code&gt;EnsLib.HL7.Message&lt;/code&gt; set &lt;strong&gt;DocType&lt;/strong&gt; to &lt;code&gt;2.5:ADT_A01&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxz06gv5ldgpq6x7cmko9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxz06gv5ldgpq6x7cmko9.png" alt=" " width="800" height="667"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;OK&lt;/strong&gt;. The visual DTL editor will open with an empty canvas, showing the source on the left and the target on the right.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbu8ke925ht0y7b57yu99.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbu8ke925ht0y7b57yu99.png" alt=" " width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the top of the canvas you will see a toolbar with action buttons: &lt;strong&gt;Assign&lt;/strong&gt;, &lt;strong&gt;If&lt;/strong&gt;, &lt;strong&gt;Code&lt;/strong&gt;, &lt;strong&gt;Foreach&lt;/strong&gt;, and others. This is where we add each transformation. Click &lt;strong&gt;Save&lt;/strong&gt; once before adding any actions. This compiles the class and avoids losing work.&lt;/p&gt;

&lt;p&gt;Now we are ready to build.&lt;/p&gt;




&lt;h2&gt;
  
  
  Scenario 1: Conditional Logic Based on Field Length
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;The target system only accepts a patient's family name up to 25 characters. Anything longer than that triggers a silent rejection. Our sample message sends &lt;code&gt;VanDerBerghMontgomeryXYZABC&lt;/code&gt; to PID-5.1, which is 27 characters.&lt;/p&gt;

&lt;p&gt;The rule: if the family name exceeds 25 characters, truncate it to 25 and append &lt;code&gt;*&lt;/code&gt; so the receiving team can flag and review it. If it is within the limit, pass it through unchanged.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding the If Action
&lt;/h3&gt;

&lt;p&gt;First, set target = source so that the source data is assigned to the target message.&lt;br&gt;
In the DTL canvas, click the &lt;strong&gt;+&lt;/strong&gt; button to add an action and choose &lt;strong&gt;If&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Set the &lt;strong&gt;condition&lt;/strong&gt; to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$Length(source.{PID:PatientName(1).FamilyName}) &amp;gt; 25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$Length&lt;/code&gt; returns the character count of a string. You can use it directly in DTL conditions without any special wrapper.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmijrwq9mgipzm5xbilnk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmijrwq9mgipzm5xbilnk.png" alt=" " width="799" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside the &lt;strong&gt;true&lt;/strong&gt; branch (the &lt;code&gt;If&lt;/code&gt; side), add an &lt;strong&gt;Assign&lt;/strong&gt; action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Property&lt;/strong&gt;: &lt;code&gt;target.{PID:PatientName(1).FamilyName}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value&lt;/strong&gt;: $Extract(source.{PID:PatientName(1).FamilyName},1,25) _ "*"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;$Extract(string, start, end)&lt;/code&gt; pulls characters by position, meaning that &lt;code&gt;$Extract(value,1,25)&lt;/code&gt; takes the first 25 characters. The &lt;code&gt;_ "*"&lt;/code&gt; appends the asterisk using ObjectScript's string concatenation operator.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frdqbmyxh1djjsy9xlc8c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frdqbmyxh1djjsy9xlc8c.png" alt=" " width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;Else&lt;/strong&gt; branch, add another &lt;strong&gt;Assign&lt;/strong&gt; as a passthrough:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Property&lt;/strong&gt;: &lt;code&gt;target.{PID:PatientName(1).FamilyName}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value&lt;/strong&gt;: &lt;code&gt;source.{PID:PatientName(1).FamilyName}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdhalcw0rwupsp8a0bprp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdhalcw0rwupsp8a0bprp.png" alt=" " width="799" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing It
&lt;/h3&gt;

&lt;p&gt;Save and compile the DTL.&lt;br&gt;
Paste the sample message and click the &lt;strong&gt;Test&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;In the output message, PID-5.1 should show &lt;code&gt;VanDerBerghMontgomeryXYZAB*&lt;/code&gt; , which is exactly 25 characters plus the asterisk.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpanz1j5fi828009135j9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fpanz1j5fi828009135j9.png" alt=" " width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Scenario 2: Using ReplaceStr to Clean Field Values
&lt;/h2&gt;
&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;PID-13 (Phone Number) in our sample comes through as &lt;code&gt;+92-03001234567&lt;/code&gt;. The target system only wants the local number, no country code, no dash. We need to strip &lt;code&gt;+92-&lt;/code&gt; from every phone number before passing it on.&lt;/p&gt;
&lt;h3&gt;
  
  
  The ReplaceStr Function
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ReplaceStr&lt;/code&gt; is a static method on the &lt;code&gt;Ens.Util.FunctionSet&lt;/code&gt; class. It takes three arguments: the original string, what to find, and what to replace it with. Passing an empty string as the third argument deletes the matching text.&lt;/p&gt;

&lt;p&gt;You can call it directly inside an Assign value field in the DTL.&lt;/p&gt;
&lt;h3&gt;
  
  
  Adding the Assign Action
&lt;/h3&gt;

&lt;p&gt;Click &lt;strong&gt;+&lt;/strong&gt; and add an &lt;strong&gt;Assign&lt;/strong&gt; action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Property&lt;/strong&gt;: &lt;code&gt;target.{PID:PhoneNumberHome(1).TelephoneNumber}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value&lt;/strong&gt;: ##class(Ens.Util.FunctionSet).ReplaceStr(source.{PID:PhoneNumberHome(1).TelephoneNumber},"+92-","")&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1qiab5u15qty3gz4nkmr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1qiab5u15qty3gz4nkmr.png" alt=" " width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Testing It
&lt;/h3&gt;

&lt;p&gt;Save and compile the DTL.&lt;/p&gt;

&lt;p&gt;Paste the sample message and click the &lt;strong&gt;Test&lt;/strong&gt; button. In the output, PID-13 should show &lt;code&gt;03001234567&lt;/code&gt;; the prefix should be gone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzm22qashufyc692jpqvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzm22qashufyc692jpqvi.png" alt=" " width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Another Practical Use
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ReplaceStr&lt;/code&gt; is used not only for removing prefixes. If you need to replace a code value, say your source sends &lt;code&gt;M&lt;/code&gt; or &lt;code&gt;F&lt;/code&gt; for gender, but the target expects &lt;code&gt;Male&lt;/code&gt; or &lt;code&gt;Female&lt;/code&gt;, a Code action with explicit If/ElseIf logic is the cleanest approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Set sex = source.{PID:AdministrativeSex}
If sex = "M" { Set target.{PID:AdministrativeSex} = "Male" }
ElseIf sex = "F" { Set target.{PID:AdministrativeSex} = "Female" }
Else { Set target.{PID:AdministrativeSex} = sex }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nested &lt;code&gt;ReplaceStr&lt;/code&gt; calls can work for simple substitutions, but be careful, &lt;code&gt;ReplaceStr(value,"M","Male")&lt;/code&gt; would also match the &lt;code&gt;M&lt;/code&gt; inside &lt;code&gt;Female&lt;/code&gt; on a second pass if you are not careful with ordering.&lt;/p&gt;




&lt;h2&gt;
  
  
  Scenario 3: Stripping Special Characters from Patient ID
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;Look at PID-3.1 in our sample message. The Patient ID comes through as &lt;code&gt;MRN#001/2025&lt;/code&gt;. The &lt;code&gt;#&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt; characters were likely generated by a legacy system that used them internally as separators. The target system expects a clean alphanumeric ID and will reject or misroute the message if these characters are present.&lt;/p&gt;

&lt;p&gt;We need to strip both characters so that &lt;code&gt;MRN#001/2025&lt;/code&gt; can become &lt;code&gt;MRN0012025&lt;/code&gt;. We should use two chained &lt;strong&gt;Assign&lt;/strong&gt; actions here — one for each character to remove.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First Assign — strip the #:&lt;/strong&gt;&lt;br&gt;
Click + and add an Assign action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Property&lt;/strong&gt;: target.{PID:PatientIdentifierList(1).IDNumber}&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value:&lt;/strong&gt; ##class(Ens.Util.FunctionSet).ReplaceStr(source.{PID:PatientIdentifierList(1).IDNumber},"#","")&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Second Assign — strip the / from what the first Assign already wrote:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Click + and add an Assign action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Property: target.{PID:PatientIdentifierList(1).IDNumber}&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value:&lt;/strong&gt; ##class(Ens.Util.FunctionSet).ReplaceStr(target.{PID:PatientIdentifierList(1).IDNumber},"/","")&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: The second Assign reads from the target, not the source, since the first Assign already wrote the #-cleaned value there; now we clean it further.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxolg5d6vor0vzozdjcgo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxolg5d6vor0vzozdjcgo.png" alt=" " width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing It
&lt;/h3&gt;

&lt;p&gt;Save and compile the DTL.&lt;/p&gt;

&lt;p&gt;Paste the sample message and click the &lt;strong&gt;Test&lt;/strong&gt; button. In the output, PID-3.1 should show &lt;code&gt;MRN0012025&lt;/code&gt; with both the &lt;code&gt;#&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt; removed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnivpzn1njpxv2mh221wz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnivpzn1njpxv2mh221wz.png" alt=" " width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Scenario 4: Reformatting HL7 Timestamps
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;PV1-44 (Admit Date/Time) in our sample comes in as &lt;code&gt;20250315143022&lt;/code&gt;, which is a standard HL7 DTM format (YYYYMMDDHHMMSS). The target system wants a human-readable format: &lt;code&gt;15/03/2025 14:30&lt;/code&gt; (DD/MM/YYYY HH:MM).&lt;/p&gt;

&lt;h3&gt;
  
  
  Why $Extract Works Well Here
&lt;/h3&gt;

&lt;p&gt;HL7 DTM timestamps are fixed-position strings, which makes them ideal for &lt;code&gt;$Extract&lt;/code&gt;. The positions are always the same:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;&amp;nbsp; &amp;nbsp; Characters&lt;/th&gt;
&lt;th&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;How to Extract&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Year&lt;/td&gt;
&lt;td&gt;&amp;nbsp; &amp;nbsp; 1 – 4&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$Extract(dt,1,4)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Month&lt;/td&gt;
&lt;td&gt;&amp;nbsp; &amp;nbsp; 5 – 6&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$Extract(dt,5,6)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Day&lt;/td&gt;
&lt;td&gt;&amp;nbsp; &amp;nbsp; 7 – 8&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$Extract(dt,7,8)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hour&lt;/td&gt;
&lt;td&gt;&amp;nbsp; &amp;nbsp; 9 – 10&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$Extract(dt,9,10)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Minute &amp;nbsp;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&amp;nbsp; &amp;nbsp; 11 – 12&lt;/td&gt;
&lt;td&gt;&lt;code&gt;$Extract(dt,11,12)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Adding the Assign Action
&lt;/h4&gt;

&lt;p&gt;Click &lt;strong&gt;+&lt;/strong&gt; at the root level and add an &lt;strong&gt;Assign&lt;/strong&gt; action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Property&lt;/strong&gt;: &lt;code&gt;target.{PV1:AdmitDateTime.Time}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value: &amp;nbsp;&lt;/strong&gt;$Extract(source.{PV1:AdmitDateTime},7,8)_"/"_$Extract(source.{PV1:AdmitDateTime},5,6)_"/"_$Extract(source.{PV1:AdmitDateTime},1,4)_" "_$Extract(source.{PV1:AdmitDateTime},9,10)_":"_$Extract(source.{PV1:AdmitDateTime},11,12)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3r74skk55y5qvdhy3btl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3r74skk55y5qvdhy3btl.png" alt=" " width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing It
&lt;/h3&gt;

&lt;p&gt;Save and compile the DTL.&lt;/p&gt;

&lt;p&gt;Paste the sample message and click the &lt;strong&gt;Test&lt;/strong&gt; button. PV1-44 in the output should read &lt;code&gt;15/03/2025 14:30&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdyunmtil2i3ka4afo541.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdyunmtil2i3ka4afo541.png" alt=" " width="800" height="423"&gt;&lt;/a&gt;&lt;/p&gt;







&lt;h2&gt;
  
  
  Putting It All Together
&lt;/h2&gt;

&lt;p&gt;Our final DTL has four action blocks, each targeting a different field in the same ADT A01 message:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;If&lt;/strong&gt; checks &lt;code&gt;$Length&lt;/code&gt; of PID-5.1 and either truncates with &lt;code&gt;*&lt;/code&gt; or passes it through.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assign&lt;/strong&gt; uses &lt;code&gt;ReplaceStr&lt;/code&gt; to strip &lt;code&gt;+92-&lt;/code&gt; from PID-13.&lt;/li&gt;
&lt;li&gt;First&lt;strong&gt; Code&lt;/strong&gt; chains two &lt;code&gt;ReplaceStr&lt;/code&gt; calls to remove &lt;code&gt;#&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt; from PID-3.1.&lt;/li&gt;
&lt;li&gt;Second&lt;strong&gt; Code&lt;/strong&gt; reformats PV1-44 from HL7 DTM to &lt;code&gt;DD/MM/YYYY HH:MM&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Run the full sample message through the tester one final time and verify all four fields in the output at once.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcwglhwnaa7zmzalebn7e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcwglhwnaa7zmzalebn7e.png" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;DTL becomes genuinely powerful once you start combining it with such ObjectScript functions as &lt;code&gt;$Length&lt;/code&gt;, &lt;code&gt;$Extract&lt;/code&gt;, &lt;code&gt;$ZStrip&lt;/code&gt;, and utility methods like &lt;code&gt;ReplaceStr&lt;/code&gt;. The four patterns in this article are not edge cases; they show up on practically every real integration project.&lt;/p&gt;

&lt;p&gt;The habit of building is to test each transformation before it goes anywhere near a live production. The DTL tester handles most of it, and the terminal is always there for quick logic verification when needed.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;




</description>
      <category>dtl</category>
      <category>json</category>
      <category>programming</category>
      <category>tooling</category>
    </item>
    <item>
      <title>Advanced Programmatic FHIR Execution in InterSystems IRIS: A Deep Dive into ObjectScript Integration</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Fri, 23 Oct 2026 16:34:25 +0000</pubDate>
      <link>https://dev.to/intersystems/advanced-programmatic-fhir-execution-in-intersystems-iris-a-deep-dive-into-objectscript-integration-31gh</link>
      <guid>https://dev.to/intersystems/advanced-programmatic-fhir-execution-in-intersystems-iris-a-deep-dive-into-objectscript-integration-31gh</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; InterSystems IRIS for Health lets developers perform FHIR CRUD operations directly from backend ObjectScript routines without relying on an HTTP REST layer. Using&amp;nbsp;HS.FHIRServer.Service, developers can create service contexts, build dynamic queries, validate schemas, and retrieve FHIR resources efficiently.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Traditional FHIR implementations typically process requests through an HTTP/REST pipeline. This article explores what happens when that layer is bypassed, and FHIR operations are executed directly within the IRIS backend, focusing on the architecture, service context, query handling, validation, and resource access involved in this approach.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Who This Article Is For:&lt;/strong&gt; This guide is designed for InterSystems IRIS for Health, HealthShare, and Health Connect developers, and health informatics engineers who need to execute low-overhead FHIR operations directly inside backend ObjectScript routines without relying on external HTTP endpoints.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;Core Architecture: The Standard Flow vs. Programmatic Execution&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Standard FHIR implementations deployed on InterSystems IRIS for Health, HealthShare, and Health Connect rely on an incoming HTTP pipeline mapped to HS.FHIRServer.Service through the REST application layer. In this standard web architecture, client applications transmit requests over HTTP/HTTPS; the system evaluates security tokens, parses request payloads, and delegates operations down to the storage repository implementation to support Create, Read, Update, and Delete (CRUD) paradigms, along with specialized search capabilities.&lt;/p&gt;
&lt;p&gt;By bypassing the standard web server dispatch layer entirely, ObjectScript routines can instantiate backend service contexts and interact directly with the core engine room of the InterSystems IRIS FHIR repository. This approach lets developers build native query objects, manage sort parameters, validate schemas, and run storage-level searches or read records directly with maximum performance and precise control.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;GET&lt;/code&gt;: Used to read a single resource (&lt;code&gt;GET [base]/Patient/123&lt;/code&gt;) or search a collection using query filters (GET [base]/Patient?gender=male&amp;amp;birthdate=ge1980-01-01).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;POST&lt;/code&gt;: Utilized to create a brand-new resource (&lt;code&gt;POST [base]/Patient&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;PUT&lt;/code&gt;: Employed to update an existing resource or upsert it based on an identifier (&lt;code&gt;PUT [base]/Patient/123&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&amp;nbsp;&lt;code&gt;DELETE&lt;/code&gt;: Used to remove or archive a record (&lt;code&gt;DELETE [base]/Patient/123&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When you throw query parameters into a GET request, you are telling the server how to slice and dice the data. However, how does IRIS process those parameters programmatically when you step away from the browser or Postman? Instead of relying solely on the external HTTP REST layer, you want to execute FHIR operations directly inside your IRIS backend using&amp;nbsp;HS.FHIRServer.Service.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;Constructing Query Parameters Programmatically&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;When performing advanced searches internally, managing query parameters cleanly is essential to prevent malformed queries and ensure optimal performance through the&amp;nbsp;JsonAdvSQL execution engine. InterSystems provides&amp;nbsp;HS.FHIRServer.API.Data.QueryParameters for this exact purpose. Depending on where your data originates, you can construct and populate this object using two primary approaches:&lt;/p&gt;
&lt;p&gt;· &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Approach A: Manual Construction via&amp;nbsp;&lt;strong&gt;AddParameter()&lt;/strong&gt;: If you are dynamically building programmatic search criteria within your application logic (e.g., constructing a query based on internal business rules, user selections in a custom UI, or workflow states), you instantiate the&amp;nbsp;QueryParameters class directly and append filters one by one using the&amp;nbsp;AddParameter() method. This approach gives you absolute control over individual parameter names, modifiers, prefixes, and values before the query ever hits the IRIS storage layer.&lt;/p&gt;
&lt;p&gt;· &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Approach B: Parsing from a Query String via&amp;nbsp;&lt;strong&gt;CreateFromQueryString()&lt;/strong&gt;: When handling raw HTTP requests, you do not need to parse URL parameters manually. InterSystems IRIS provides a native utility method—CreateFromQueryString()—on the query parameter handler class to automate this transformation seamlessly.&lt;/p&gt;
&lt;h2&gt;Sorting and Linking Data Programmatically&lt;/h2&gt;
&lt;p&gt;Advanced searches require precise control over result ordering and related clinical records through explicit parameter configuration.&lt;/p&gt;
&lt;p&gt;· &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;The Automatic Way: When building standard FHIR applications, developers usually rely on incoming REST URLs. A client might request a list of patients sorted by their last update date in descending order:&amp;nbsp;GET [base]/Patient?gender=female&amp;amp;_sort=-_lastUpdated. When you pass this string into&amp;nbsp;HS.FHIRServer.API.Data.QueryParameters.CreateFromQueryString(), IRIS automatically parses out the&amp;nbsp;_sort parameter.&lt;/p&gt;
&lt;p&gt;· &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;The Manual Way: If you are not using a URL query string, or if you want to intercept a request in your custom interactions class and force a specific sort order regardless of what the user asked for, you can construct&amp;nbsp;.tSortKeys manually. Instead of relying on a string parser, you can build the sort array explicitly in ObjectScript.&lt;/p&gt;
&lt;p&gt;· &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Forward Links (_include)&amp;nbsp;: They follow references outward from the matching resource to pull related entities (e.g., searching for MedicationRequest resources and including the referenced Practitioner or Patient [MedicationRequest:patient]).&lt;/p&gt;
&lt;p&gt;· &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Reverse Links (_revinclude): They follow references backward from other resources that point to your match (e.g., searching for a Patient and pulling all Observation or Encounter records that reference that specific patient ID [Observation:patient]).&lt;/p&gt;
&lt;h2&gt;Technical Reference &amp;amp; Implementation Code Examples&lt;/h2&gt;
&lt;p&gt;The following ObjectScript code blocks illustrate how to execute these programmatic workflows directly inside InterSystems IRIS:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Manual Parameter Construction:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ClassMethod CreateParamsManually() As HS.FHIRServer.API.Data.QueryParameters
{
    Set params = ##class(HS.FHIRServer.API.Data.QueryParameters).%New()
    // Equivalent to filtering by ?gender=male
    Do params.AddParameter("gender", "male")
    // Equivalent to filtering by ?birthdate=ge1980-01-01
    Do params.AddParameter("birthdate", "ge1980-01-01")
    Quit params
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Parsing from a Query String:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ClassMethod CreateParamsFromString() As HS.FHIRServer.API.Data.QueryParameters
{
    Set queryString = "gender=male&amp;amp;name=Smith"
 &amp;nbsp;&amp;nbsp; // Set tQueryString = "patient=123&amp;amp;date=ge2026-01-01&amp;amp;_include=Observation:patient&amp;amp;_count=50"
 &amp;nbsp;&amp;nbsp;&amp;nbsp;// Automatically handles keys, values, prefixes (like 'ge'), and modifiers
    Set params = ##class(HS.FHIRServer.API.Data.QueryParameters).CreateFromQueryString(queryString)
    Return params
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Schema Metadata Validation via&amp;nbsp;FindSearchParam: To prevent runtime errors caused by invalid query criteria or resource-attribute mismatches, the active schema metadata should be inspected before execution.&amp;nbsp;tStrategy.Schema.FindSearchParam(pResourceType, pParamName) acts as a safety check.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ClassMethod ValidateSearchParameter(pStrategy As HS.FHIRServer.Storage.JsonStrategy, pResourceType As %String, pParamName As %String) As %Boolean
{
// Evaluates if the parameter is valid for the specified resource in the active FHIR version schema
    Set searchParam = pStrategy.Schema.FindSearchParam(pResourceType, pParamName)

 &amp;nbsp;&amp;nbsp;&amp;nbsp;If $IsObject(searchParam) {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     Write "Parameter '", pParamName, "' is valid for resource '", pResourceType, "'.", !
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     Quit 1
    }

 &amp;nbsp;&amp;nbsp;&amp;nbsp;Write "Invalid search parameter for this resource schema.", !
    Quit 0
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Direct Search Execution against the Interactions Engine:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ClassMethod ExecuteDirectSearch(pAppKey As %String) As %Status
{
    Set tSC = $$$OK
    Try {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     // Instantiate the FHIR Service, which contains the strategy and interactions objects
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     Set fhirService = ##class(HS.FHIRServer.Service).EnsureInstance(pAppKey)
 &amp;nbsp;&amp;nbsp;   
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Access the underlying interactions engine through the strategy
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     Set tInteractions = fhirService.Strategy.GetInteractions()
 &amp;nbsp;&amp;nbsp;   
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Reusing our query parameter builder
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     Set tParams = ##class(HS.FHIRServer.API.Data.QueryParameters).CreateFromQueryString("gender=male")
 &amp;nbsp;&amp;nbsp;   
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Execute the Search method directly against the Interactions class
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     // Parameters: (ResourceType, Compartment, CompartmentId, QueryParameters, .SortKeys)
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     Set tSearchResult = tInteractions.Search("Patient", "", "", tParams, .tSortKeys)
 &amp;nbsp;&amp;nbsp;   
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Iterate through the search results object
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     Write "Total matches found: ", tSearchResult.Total, !
 &amp;nbsp;&amp;nbsp;   
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Loop through matching resource IDs or entries
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     While tSearchResult.Next(.tId, .tResourceJson, .tStatusCode) {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;     Write "Patient ID: ", tId, " | Details: ", tResourceJson.%ToJSON(), !
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     }
 &amp;nbsp;&amp;nbsp;   
 &amp;nbsp;&amp;nbsp;&amp;nbsp; } Catch tException {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     Set tSC = tException.AsStatus()
 &amp;nbsp;&amp;nbsp;&amp;nbsp;     Write "Error during search: ", $System.Status.GetErrorText(tSC), !
    }
    Quit tSC
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Direct Resource Retrieval via&amp;nbsp;.Read(): The&amp;nbsp;Read() method on&amp;nbsp;HS.FHIRServer.Storage.JsonAdvSQL.Interactions is the core programmatic function responsible for fetching a specific, individual FHIR resource's JSON data directly from the repository storage layer without running search indexes.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Set pResourceType = "Patient"
Set resourceId = "1"
// Retrieve the resource as a %DynamicObject directly using interactions.Read()
Set tInteractions = fhirService.Strategy.GetInteractions()
Set resourceString = tInteractions.Read(pResourceType, resourceId)
Write "Patient ID: ", resourceId, " | Resource Data retrieved successfully.", !&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Common Mistakes to Avoid&lt;/p&gt;
&lt;p&gt;· &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Bypassing Schema Validation: Skipping calls to&amp;nbsp;FindSearchParam() before executing dynamic queries, which can lead to unhandled runtime exceptions when an attribute does not match the active FHIR resource schema version.&lt;/p&gt;
&lt;p&gt;· &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Hardcoding REST Dependency: Forcing internal microservices or batch engines to route through local loopback HTTP requests instead of calling&amp;nbsp;HS.FHIRServer.Service and&amp;nbsp;GetInteractions() directly in ObjectScript.&lt;/p&gt;
&lt;p&gt;· &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Improper Result Traversal: Failing to evaluate result status codes properly or using incorrect property lookups when iterating through&amp;nbsp;HS.FHIRServer.Util.SearchResult object loops.&lt;/p&gt;&amp;nbsp;&lt;p&gt;Frequently Asked Questions (FAQ)&lt;/p&gt;
&lt;h3&gt;Q: Can you execute FHIR queries without an HTTP server request?&lt;/h3&gt;
&lt;p&gt;A: Yes. By instantiating&amp;nbsp;HS.FHIRServer.Service and extracting the interactions engine, ObjectScript code can execute searches and read records entirely in-memory.&lt;/p&gt;
&lt;h3&gt;Q: How do you programmatically add&amp;nbsp;_include parameters?&lt;/h3&gt;
&lt;p&gt;A: You use the&amp;nbsp;AddParameter() method on your&amp;nbsp;QueryParameters instance, passing&amp;nbsp;_include as the key and the target reference path (e.g.,&amp;nbsp;Observation:subject) as the value.&lt;/p&gt;
&lt;h3&gt;Q: What is the purpose of&amp;nbsp;HS.FHIRServer.API.Data.QueryParameters?&lt;/h3&gt;
&lt;p&gt;A: It provides a structured mechanism to cleanly build, parse, and encapsulate query criteria, modifiers, and prefixes before execution through the&amp;nbsp;JsonAdvSQL storage layer.&lt;/p&gt;
&lt;h3&gt;Q: How does&amp;nbsp;.Read() differ from&amp;nbsp;.Search()?&lt;/h3&gt;
&lt;p&gt;A: Read() takes an explicit Resource Type and logical ID to fetch a single record instantly as a&amp;nbsp;%DynamicObject, whereas&amp;nbsp;Search() evaluates multi-parameter filters across a collection of resources.&lt;/p&gt;
&lt;h3&gt;Q: How do you handle custom sorting without a URL string?&lt;/h3&gt;
&lt;p&gt;A: You can manually define sort arrays using&amp;nbsp;.tSortKeys alongside schema definitions retrieved via&amp;nbsp;tStrategy.Schema.FindSearchParam().&lt;/p&gt;
&lt;h3&gt;Q: Why is schema validation necessary during programmatic execution?&lt;/h3&gt;
&lt;p&gt;A: It ensures that search keys, attributes, and modifier mappings conform to the active FHIR profile definitions, preventing execution errors.&lt;/p&gt;
&lt;h2&gt;Practical Recommendations&amp;nbsp;&lt;/h2&gt;
&lt;p&gt;Always initialize your runtime context using&amp;nbsp;HS.FHIRServer.Service.EnsureInstance(pAppKey) before extracting the interactions engine. Utilize&amp;nbsp;CreateFromQueryString() when processing incoming text maps, and implement schema validation checks via&amp;nbsp;FindSearchParam to guarantee robust, error-free backend integrations.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;Conclusion&amp;nbsp;&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;By bypassing standard REST routing and programmatically invoking the InterSystems IRIS FHIR interactions engine, developers gain direct, low-overhead access to the core repository. Utilizing manual query parameters for searches and the&amp;nbsp;Read() method for targeted resource retrieval provides the maximum speed, precision, and architectural flexibility required for high-performance backend integrations and custom business logic.&lt;br&gt;&amp;nbsp;&lt;/p&gt;

</description>
      <category>json</category>
      <category>ai</category>
      <category>performance</category>
      <category>programming</category>
    </item>
    <item>
      <title>Connect Microsoft Excel to InterSystems IRIS via ODBC (Windows)</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Tue, 13 Oct 2026 16:15:17 +0000</pubDate>
      <link>https://dev.to/intersystems/connect-microsoft-excel-to-intersystems-iris-via-odbc-windows-p1l</link>
      <guid>https://dev.to/intersystems/connect-microsoft-excel-to-intersystems-iris-via-odbc-windows-p1l</guid>
      <description>&lt;p&gt;&lt;span&gt;&lt;span&gt;How to create an ODBC connection on your native Windows laptop to IRIS running on a Windows VM on the same computer, test the connection, and pull data from IRIS into Excel.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Recently I learned that Excel can connect to external databases via ODBC. This includes basically any ODBC data source. Since IRIS speaks ODBC via the ODBC API, we can take advantage of the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a href="https://docs.intersystems.com/iris20233/csp/docbook/DocBook.UI.Page.cls?KEY=BNETODBC_intro" rel="noopener noreferrer"&gt;&lt;span&gt;&lt;span&gt;InterSystems ODBC Driver&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span&gt;&lt;span&gt; to establish an ODBC connection to IRIS on Windows that Excel can utilize.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;strong&gt;Before getting started,&lt;/strong&gt; make sure you have installed the latest InterSystems ODBC driver on your native Windows, which can either be found on WRC or on &lt;/span&gt;&lt;a href="https://github.com/intersystems-community/iris-driver-distribution/tree/main/ODBC" rel="noopener noreferrer"&gt;&lt;span&gt;&lt;span&gt;GitHub&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span&gt;&lt;span&gt;. I assume that you are running IRIS on a Windows VM using VMWare hosted on your Windows machine. I also assume that you have Microsoft Excel installed on your native Windows as well. You’ll also need some data pre-loaded into your namespace to access. For this post, I am using data from the &lt;/span&gt;&lt;/span&gt;&lt;a href="https://learning.intersystems.com/course/view.php?name=Python%20QS" rel="noopener noreferrer"&gt;&lt;span&gt;&lt;span&gt;Python Quickstart&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span&gt;&lt;span&gt;. The data can be found on &lt;/span&gt;&lt;/span&gt;&lt;a href="https://github.com/intersystems/Samples-Stock-Data" rel="noopener noreferrer"&gt;&lt;span&gt;&lt;span&gt;GitHub&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span&gt;&lt;span&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;strong&gt;First you need to find the IP address for the VM. &lt;/strong&gt;(Keep in mind that you may need to repeat this step if you restart the VM, connect to a different network or connect/disconnect a VPN connection.)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;To find your IP address in the Windows VM, go to the Windows Command Prompt (cmd):&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt;In the VM, hold the Windows key and the R key. This opens the Run dialog (as seen below). Type in “cmd” and click &amp;lt;OK&amp;gt;:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;

![ ](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/10jbj2wcemvvgoroidag.png)
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ol start="2"&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt;On the Command Prompt, type in “ipconfig -all” to find your IP address. You want to locate the line that says “IPv4 Address….” And make note of the numeric IP address given on that line:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;

![ ](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/m95oqonho5gccomss5ch.png)
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ol start="3"&gt;&lt;li&gt;
&lt;span&gt;&lt;span&gt;Also &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;strong&gt;make note of the Web Server Port &lt;/strong&gt;of your VM IRIS, because you’ll need that later.&lt;/span&gt;
&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Now, r&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;strong&gt;eturn to the Windows host system &lt;/strong&gt;and open the ODBC Data Source Administrator (ODBC DSA) and configure the connection:&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt;In the ODBC DSA, open the “System DSN” tab and click “Add”:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;

![ ](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/f3y8d546u2ehd5ovacof.png)
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ol start="2"&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt;You will be prompted to select a driver for the data source. If you installed the InterSystems ODBC driver on your native Windows machine, you should select “InterSystems IRIS ODBC…” as I have done below and click “Finish”:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4cf8avvft80fbvg1z9at.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4cf8avvft80fbvg1z9at.png" alt=" " width="696" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ol start="3"&gt;&lt;li&gt;&lt;span&gt;&lt;span&gt;This will open a new dialog where you need to name the data source, provide a description, input the IP address you copied previously and the Web Server Port. Input the namespace you want to connect to, the User Name and Password that you use for the Management Portal as well. Then click &amp;lt;Test Connection&amp;gt; as shown below:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqcqecxw8qyz7bic6eygr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqcqecxw8qyz7bic6eygr.png" alt=" " width="781" height="688"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;ol start="4"&gt;&lt;li&gt;
&lt;span&gt;&lt;span&gt;If all went well, you should see that the &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;strong&gt;test completed successfully&lt;/strong&gt; as shown below. This means that we now have a connection via our native Windows to IRIS on the VM:&lt;/span&gt;
&lt;/li&gt;&lt;/ol&gt;

![ ](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/wcjyxbt067h201gxjza4.png)
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Now we can &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;strong&gt;open Microsoft Excel&lt;/strong&gt; and access data via the ODBC data source. We do this by selecting the “Data” tab (1), then clicking “Get Data” (2). Click “From Other Sources” (3), and then “From ODBC” (4).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F36jxflfzr1vgqwnenj9t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F36jxflfzr1vgqwnenj9t.png" alt=" " width="800" height="860"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;From the drop down, select the data source you created previously and click OK:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwwjg9p6m9tf2domj70bo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwwjg9p6m9tf2domj70bo.png" alt=" " width="749" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;In the Navigator, select the table you want to connect to and click “Load”:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsn6z0phc60aezygllg2k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsn6z0phc60aezygllg2k.png" alt=" " width="800" height="623"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;From here, we can see that we successfully connected to the data on IRIS on a VM and are able to access it in Microsoft Excel running on native Windows:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1w83fgzd90u3z350j92z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1w83fgzd90u3z350j92z.png" alt=" " width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Wrapping up, we might wonder why we would want to access IRIS data in Excel. Many people have years of Excel expertise. They can use Excel to explore data, create pivot tables, visualizations, and dashboards.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>microsoft</category>
      <category>odbc</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Building Branded, Scheduled Reports on InterSystems IRIS with InterSystems Reports: An End-to-End Field Report</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Tue, 13 Oct 2026 16:07:23 +0000</pubDate>
      <link>https://dev.to/intersystems/building-branded-scheduled-reports-on-intersystems-iris-with-intersystems-reports-an-end-to-end-371n</link>
      <guid>https://dev.to/intersystems/building-branded-scheduled-reports-on-intersystems-iris-with-intersystems-reports-an-end-to-end-371n</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;TL;DR&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We connected InterSystems Reports, powered by Logi Report from insightsoftware (Designer + Server), to a production InterSystems IRIS instance to deliver branded, scheduled PDF and Excel reports built on IRIS SQL views. This article is the walkthrough we would have liked to have on day one: least-privilege IRIS setup, a reliable JDBC configuration, SQL views as the contract between IRIS and the reporting layer, and branding centralized in CSS plus a template report. Our main takeaway on the tooling itself is that although report files can be edited as code, the Designer UI should be your default — reserve direct file editing for features you already understand deeply. Each step includes the tips that made the setup repeatable for us.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Who This Article Is For&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This guide is for IRIS developers and integration engineers who need to expose IRIS data — in our case,, healthcare remittance data — through a third-party reporting tool, and who want the connectivity, modeling, and templating decisions laid out before they start.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;A Note on Our Approach: Code Editing vs. the Designer&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;InterSystems Reports store their reports, catalogs, and stylesheets as editable files, so everything you can do in the Designer, you can also do in a text editor. So, we deliberately pushed on that to find the limits.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For a team that prefers version-controlled, scriptable workflows, this is genuinely appealing, so we explored it: editing report XML directly and maintaining our styling as a hand-written CSS file.&lt;/p&gt;

&lt;p&gt;The conclusion we came to is worth stating up front, because it shapes every recommendation that follows:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Opt for the Designer UI by default.&lt;/strong&gt; Outside of it, behavior is harder to predict: the Designer maintains internal invariants and relationships between attributes that are not obvious from reading a file. Also, a hand-edited file can be structurally valid yet behave differently from one the Designer produced. Keep direct file editing for the pieces you already understand deeply.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;What We Were Building&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The goal was scheduled: brand-consistent client reports generated directly from IRIS production data, with no intermediate data warehouse.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our source data was EDI remittance content (835 / Electronic Remittance Advice) already persisted in IRIS. Our clients needed periodic operational reports — a payer routing summary with a claim-level detail tab and a remittance register — delivered on a schedule rather than run ad hoc from a portal.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;What we used&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Data platform&lt;/td&gt;
&lt;td&gt;InterSystems IRIS&lt;/td&gt;
&lt;td&gt;Source of truth; SQL views as the reporting contract,&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Connectivity&lt;/td&gt;
&lt;td&gt;InterSystems JDBC driver&lt;/td&gt;
&lt;td&gt;Single connection point for the report server,&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Report authoring&lt;/td&gt;
&lt;td&gt;InterSystems Report Designer&lt;/td&gt;
&lt;td&gt;Layout, parameters, grouping, summaries,&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delivery&lt;/td&gt;
&lt;td&gt;InterSystems Report Server (Windows VM)&lt;/td&gt;
&lt;td&gt;Scheduling, PDF/Excel export, distribution,&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The architecture is deliberately thin: IRIS does the querying, while the reporting tool handles presentation and delivery. Every design decision below originates from the need to keep that separation clean.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Why InterSystems Report and Not Power BI or Tableau&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;We evaluated Power BI and Tableau alongside InterSystems Report, and chose InterSystems Report mainly because it added the least infrastructure to an environment that IRIS already had.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Four points that influenced our choice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;First-class IRIS support:&lt;/strong&gt; InterSystems Reports is powered by Logi Report (formerly JReport from insightsoftware) and officially supported by InterSystems IRIS and IRIS for Health. Because of this, the connection path is fully documented and supported, saving us from having to prove it out ourselves.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No second database engine:&lt;/strong&gt; Since every tool requires space to store its configuration, catalog, and scheduling state, the InterSystems Reports Server keeps track of its configuration in a system database maintained by an InterSystems IRIS instance. This means that the same instance can act as both the data source and the system database. The alternatives need their own separate engine, which means additional licensing and extra things to back up and patch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delivery was simple to stand up:&lt;/strong&gt; Scheduled generation and distribution shipped with the report server, and could run on the same VM as everything else. Alternatively, getting comparable unattended delivery working on the other options involved noticeably more moving parts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lowest total cost for our footprint&lt;/strong&gt; (once the extra database and hosting for the alternatives were calculated).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Power BI and Tableau are stronger for interactive, self-service exploration. Our requirement, however, was the opposite — pixel-controlled, branded documents produced on a schedule — which is exactly where a banded, page-oriented report tool fits best.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 1: Granting the Reporting User Least-Privilege Access in IRIS&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Since the reports read from a production instance, we needed to grant the smallest set of privileges that would still let a report run — nothing more.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This turned out to be a short list, which was worth setting up deliberately rather than starting extensive trimming later. The minimum that worked for us included the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A dedicated user&lt;/strong&gt; exploited only by the report server'sconnection pool without interactive or Management Portal usage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One role&lt;/strong&gt; holding read access to the &lt;code&gt;%DB_&amp;lt;resource&amp;gt;&lt;/code&gt; of the database behind the namespace.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SELECT&lt;/code&gt;&lt;strong&gt; on the specific views the reports consume&lt;/strong&gt;, rather than on the whole schema, so new tables added later are not automatically exposed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;/strong&gt;&lt;code&gt;%Service_SQL&lt;/code&gt;&lt;strong&gt; service that is enabled&lt;/strong&gt; for that user, which is the SuperServer/JDBC path the report server uses.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That is all a report needs: no &lt;code&gt;%All&lt;/code&gt;, no &lt;code&gt;%Development&lt;/code&gt;, no write privileges anywhere.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; the database resource name is not necessarily derived from the namespace name — a namespace called &lt;code&gt;REPORTING&lt;/code&gt; can sit on a database whose resource has an entirely different name. Look up the actual resource in the Management Portal (System Administration → Configuration → Namespaces, then check the database behind it) and grant permissions on that exact &lt;code&gt;%DB_*&lt;/code&gt; name. Confirming it up front is the difference between a five-minute setup and a puzzling &lt;code&gt;Access Denied Error&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The JDBC detail worth writing on a sticky note:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Use the loopback &lt;strong&gt;IP address&lt;/strong&gt;, not the hostname:&lt;/p&gt;

&lt;p&gt;# Reliable&lt;br&gt;
jdbc:IRIS://127.0.0.1:1972/MYNAMESPACE&lt;/p&gt;

&lt;p&gt;# Can fail depending on host resolution order&lt;br&gt;
jdbc:IRIS://localhost:1972/MYNAMESPACE&lt;/p&gt;

&lt;p&gt;Driver class: &lt;code&gt;com.intersystems.jdbc.IRISDriver&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The reason matters: On a dual-stack Windows host, &lt;code&gt;localhost&lt;/code&gt; can resolve to the IPv6 loopback (&lt;code&gt;::1&lt;/code&gt;) while the SuperServer is listening on IPv4, so the connection attempt never reaches the listener. The symptom looks like a plain refused connection, with nothing pointing at the address family issues. Specifying &lt;code&gt;127.0.0.1&lt;/code&gt; removes the ambiguity entirely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Checklist of things to verify if the connection is hard to troubleshoot:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SuperServer port reachable (&lt;code&gt;1972&lt;/code&gt; by default)&lt;/li&gt;
&lt;li&gt;Driver JAR on the report server's classpath, matching the Java version in use&lt;/li&gt;
&lt;li&gt;Loopback specified as an IP&lt;/li&gt;
&lt;li&gt;Reporting role holds the correct &lt;code&gt;%DB_*&lt;/code&gt; resource&lt;/li&gt;
&lt;li&gt;Namespace name spelled exactly as IRIS reports it&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 2: Let SQL Views Be the Contract&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pointing a reporting tool at views instead of tables or persistent classes was the single most highest-leverage decision we made.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We defined views in IRIS that shape the remittance data into report-ready rows, then had Logi import only those. A simplified version of the pattern is as follows:&lt;/p&gt;

&lt;p&gt;Class Remit.View.Documents Extends %Persistent [ ClassType = view,&lt;br&gt;
SqlTableName = Documents, ViewQuery = { ... } ]&lt;br&gt;
{&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Why this helped:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Report layouts stop depending on physical structure.&lt;/strong&gt; Storage or class changes stay inside the view.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Business logic lives in IRIS&lt;/strong&gt;, where it can be easily tested with plain SQL, instead of remaining inside report expressions that are harder to inspect.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Column names become presentation-friendly&lt;/strong&gt; only once, rather than being aliased in every report.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complex navigation stays server-side.&lt;/strong&gt; Correlated subqueries and &lt;code&gt;-&amp;gt;&lt;/code&gt; implicit-join syntax are far easier to reason about in a view than in a report designer's query builder.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 3: Running the Report Server as a Windows Service&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Install the report server as a Windows service so that scheduled runs survive reboots and logoffs, and if it behaves inconsistently under the service wrapper, reinstall it in interactive mode.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The report server will ship a service utility, and the install command will accept an &lt;code&gt;-interactive&lt;/code&gt; option:&lt;/p&gt;

&lt;p&gt;JRService -install -interactive&lt;/p&gt;

&lt;p&gt;What the option does: Installing with &lt;code&gt;-interactive&lt;/code&gt; alongside &lt;code&gt;-install&lt;/code&gt; registers the service in interactive mode, so a Command Prompt window appears when the service starts. Without it, the server runs silently, and its console output is not shown anywhere conveniently. That visibility is the practical value — startup messages, classpath problems, and licensing or port complaints appear as the server emits them, rather than having to be inferred from a service that simply did not come up. If a service-hosted server starts behaving differently than the same server launched from a console, reinstalling this way is a quick, reversible thing to try.&lt;/p&gt;

&lt;p&gt;The lesson generalizes beyond this product: when a Java-based server behaves differently as a service than it does interactively, look at the registration flags, the service account, and the JVM the service actually resolves before changing anything in the application configuration.&lt;/p&gt;

&lt;p&gt;Two more environment notes worth setting up deliberately:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;If &lt;/strong&gt;&lt;code&gt;JAVA_HOME&lt;/code&gt;&lt;strong&gt; inheritance gives you trouble, pin the JDK path explicitly.&lt;/strong&gt; The service reads its JVM path and Java command line from &lt;code&gt;NTService.ini&lt;/code&gt; in the install &lt;code&gt;bin&lt;/code&gt; folder. Set the &lt;code&gt;JavaVM&lt;/code&gt; parameter to the exact JDK you intend to use, rather than depending on what the service account inherits. The same file is stored where heap size lives, so it is worth knowing regardless.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the IRIS JDBC JAR in the server's own library folder&lt;/strong&gt; so upgrades do not silently orphan it.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; A service-hosted server cannot reach mapped network drives because of a JVM limitation. If reports read from or write to a network location, use a UNC path rather than a mapped drive letter.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 4: Binding Data Inside the Report&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Most "cannot find dataset" errors come from binding the dataset to a nested component instead of the report body container.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Reading the report XML makes this requirement visible: the dataset element must be present on the &lt;code&gt;ReportBody&lt;/code&gt; container itself.&lt;/p&gt;

&lt;p&gt;&amp;lt;ReportBody name="Body"&amp;gt;&lt;br&gt;
&amp;lt;dataSet name="DS_Documents"/&amp;gt;&lt;br&gt;
&amp;lt;!-- tables, banded panels, charts --&amp;gt;&lt;br&gt;
&amp;lt;/ReportBody&amp;gt;&lt;/p&gt;

&lt;p&gt;If it appears only on the inner table, the report can fail at pre-initialization before anything renders — an error that reads like a missing resource rather than a placement issue.&lt;/p&gt;

&lt;p&gt;Two more binding behaviours worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;additionalMappingNames&lt;/code&gt;&lt;strong&gt; uses a counted, delimited format&lt;/strong&gt; (a count followed by each name in sequence). It is precise and unforgiving: if the count drifts out of step with the list, the failure tends to surface later and less obviously. This is a good example of an attribute to set in the Designer rather than by hand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A summary's reset level controls aggregation scope, not the location where the value appears.&lt;/strong&gt; A sum placed in a group footer will still total the whole report unless its reset level is set to the grouping field. Wrong-looking totals in the right-looking place almost always mean reset level issues.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;When you change a view, refresh the metadata:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Adding a column to an IRIS view does not automatically propagate to the report catalog. The column metadata has to be re-imported, and in our environment, a server or connection-pool restart was needed before the new column appeared in running reports. Building "refresh catalog metadata" into our schema-change routine removed a recurring source of confusion where the database and the report clearly disagreed.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 5: Brand Consistency Without Copy-Paste&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Reusable branding came from two artifacts — a CSS file for tokens and a template report for structure — not from styling each report manually.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A brand CSS file&lt;/strong&gt; defining classes for our palette and type scale, appended to the default stylesheet the report server serves. We can change colors and fonts in one place.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A template shell report&lt;/strong&gt; ccontaining the page header and footer with report title, date period, and run timestamp in the header (address found on the left, page number in the center, and company URL in the right part of the footer). New reports start as copies of the shell.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Registered custom fonts&lt;/strong&gt; referenced consistently by their registered names. Register your TrueType fonts in the report server's &lt;code&gt;font&lt;/code&gt; directory &lt;strong&gt;and&lt;/strong&gt; on every Designer machine. If a font is missing at render time, the output falls back to a substitute and the layout shifts, which is easy to miss until a client points at a PDF that looks slightly off.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We initially looked at XSD-based style groups for this, since they promise exactly this kind of centralized styling. However, since that mechanism is deprecated in current versions, we moved to CSS plus the template shell, which turned out to be simpler to review and version anyway. It is worth checking the deprecation status of any styling feature before building a system on it.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Step 6: Parameterize for Scheduling, Not for Clicking&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Reports designed for scheduling need parameters with sensible defaults and no reliance on user interaction.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every report shares the same parameter shape: client, date range, and entity identifier. Because schedules are interchangeable, adding a new client only requires a new schedule rather than a new report. Design implications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Give every parameter a valid default so an unattended run will never block on input.&lt;/li&gt;
&lt;li&gt;Echo the parameter values into the header so a delivered PDF is self-describing.&lt;/li&gt;
&lt;li&gt;Prefer date ranges computed relative to run time over hard-coded windows.&lt;/li&gt;
&lt;li&gt;Test the scheduled path early since it exercises a different code path than the Designer preview.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Common Mistakes&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pitfalls worth avoiding:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Granting namespace access without the underlying &lt;code&gt;%DB_*&lt;/code&gt; database resource.&lt;/li&gt;
&lt;li&gt;Editing counted-and-delimited XML attributes by hand.&lt;/li&gt;
&lt;li&gt;Assuming a group footer position implies group-level aggregation.&lt;/li&gt;
&lt;li&gt;Expecting IRIS schema changes to appear in the report catalog automatically.&lt;/li&gt;
&lt;li&gt;Building on a deprecated styling mechanism.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Frequently Asked Questions&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Q: Do I need a separate reporting database or read replica?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A: Not necessarily. We report directly from production through read-only views and scheduled off-peak runs. If report queries grow heavy, an IRIS mirror or shard is the natural next step. Starting simple, however, avoids creating infrastructure we do not need yet.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Q: Why do I get "Access Denied" when my credentials are correct?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A: Most often because the role lacks the &lt;code&gt;%DB_*&lt;/code&gt; resource for the database behind the namespace. Namespace and resource names are independent. Confirm the resource name in the Management Portal.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Q: Why does &lt;/strong&gt;&lt;code&gt;localhost&lt;/code&gt;&lt;strong&gt; fail in my JDBC URL when the instance is running?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A: Because it may resolve to the IPv6 loopback while the listener is bound to IPv4. Use &lt;code&gt;127.0.0.1&lt;/code&gt; explicitly.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Q: Should I edit report files as XML or use the Designer?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A: Use the Designer by default. The files are editable, and reading them is genuinely useful for understanding how a report is wired. However, behavior outside the Designer is less predictable. It maintains invariants between attributes that are not visible in the file. Reserve direct editing for things you already understand deeply.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Q: My report shows the wrong totals. Where do I look first?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A: At the summary's reset level. Panel placement affects where a value prints; reset level determines what it aggregates.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Q: I added a column to my view, and the report cannot see it. Why?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A: The report catalog caches column metadata. Re-import the view's metadata and, if needed, restart the server or connection pool so running reports pick up the change.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Q: How do we keep dozens of reports visually consistent?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A: A CSS file for color and type tokens, plus a template report carrying the page header and footer. Since new reports are copies of the template, structure and branding are inherited rather than rebuilt.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Practical Recommendations&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you are starting a similar project, this is the order we recommend you adopt:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Prove connectivity first&lt;/strong&gt; with a trivial one-column view before any layout work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Design the views before the reports.&lt;/strong&gt; The view list is your reporting API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build the branded template shell second&lt;/strong&gt;, so the first real report is already correct.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Externalize color and type into CSS&lt;/strong&gt; from day one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standardize the parameter signature&lt;/strong&gt; across reports.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test every export format and the scheduled path&lt;/strong&gt; before showing anything to a client.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write down the environment specifics&lt;/strong&gt;: driver path, JDK path, font directory, and resource names. In the future, you will need them at an inconvenient moment.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Connecting a third-party reporting tool to InterSystems IRIS is mostly a modeling and configuration exercise, not a rendering one. Once the security resources, JDBC details, and view layer are right, the reporting tool does what it is good at, and IRIS keeps doing what it does best. The details that matter are specific and learnable — resource names, host resolution, dataset placement, metadata caching — and each one becomes a checklist item rather than a recurring problem. We recommend spending the first day on the views and the branded template since, with those two in place, every report after the first one is mostly layout.&lt;/p&gt;

&lt;p&gt;Having tried a few other solutions, what stands out about InterSystems Report is how approachable it makes complex queries in a low-code way. It assumes a baseline understanding of SQL, but beyond that, the deeper concepts (grouping, nested groups, aggregation, and reset scopes) are unusually easy to reason about once you see how they are expressed in the Designer. That combination is what made it a good fit for reports that are structurally rich but need to be maintained by more than one person.&lt;/p&gt;

&lt;p&gt;A practical tip for getting started: &lt;strong&gt;build a plain table first.&lt;/strong&gt; A table shows you exactly what the query returned, so you can confirm that the data is what you expect before any presentation decisions are made. Once the table is right, base everything else (charts, summaries, grouped layouts) on that same verified dataset. It is a much shorter path than debugging a chart that is beautifully drawing the wrong numbers.&lt;/p&gt;

&lt;p&gt;The one area where we would love to see the product evolve is styling: &lt;strong&gt;a little consolidation there would go a long way.&lt;/strong&gt; Today, it is spread across several models: some styling is standard CSS, some uses Logi-specific class and property naming, and some deprecated mechanisms still appear in the UI. This makes it hard to tell which approach is current. There is also no first-class way to save a report's look as a reusable template; the practical workaround is to copy an existing report and build the new one on top of it, which works but means visual standards live in a file rather than in something explicitly designed to be shared. A single, clearly documented styling path plus a native template object would make brand consistency across a report suite considerably easier to achieve and to hand over. Everything we needed was reachable — it just took some exploration to find the right combination, and that is exactly the kind of thing better defaults could solve.&lt;/p&gt;

&lt;p&gt;The setup has been stable in production, and we are glad to compare notes with anyone building something similar.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>css</category>
      <category>debugging</category>
      <category>security</category>
    </item>
    <item>
      <title>Complementing IRIS with MLflow for a Continuous Training (CT) pipeline</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Wed, 30 Sep 2026 15:23:05 +0000</pubDate>
      <link>https://dev.to/intersystems/complementing-iris-with-mlflow-for-a-continuous-training-ct-pipeline-3h0e</link>
      <guid>https://dev.to/intersystems/complementing-iris-with-mlflow-for-a-continuous-training-ct-pipeline-3h0e</guid>
      <description>&lt;p&gt;A Continuous Training (CT) pipeline formalises a Machine Learning (ML) model developed through data science experimentation, using the data available at a given point in time. It prepares the model for deployment while enabling autonomous updates as new data becomes available, along with robust performance monitoring, logging, and model registry capabilities for auditing purposes.&lt;/p&gt;

&lt;p&gt;InterSystems IRIS already provides nearly all the components required to support such a pipeline. However, one key element is missing: a standardised tool for model registry. In this article, I present &amp;nbsp;&lt;a href="https://github.com/JorgeIvanJH/IRIS_and_MLflow-Continuous-Training-Pipeline/tree/v0.1.0" rel="noopener noreferrer"&gt;this approach (v0.1.0)&lt;/a&gt;, which combines the strengths of IRIS with the open-source AI engineering platform &lt;a href="https://mlflow.org/docs/latest/ml/" rel="noopener noreferrer"&gt;MLflow&lt;/a&gt;. Together, they act as complementary tools for building an effective Continuous Training (CT) pipeline.&lt;/p&gt;

&lt;p&gt;The implementation in this repo leverages MLflow's built-in configuration to store &lt;a href="https://shap.readthedocs.io/en/latest/" rel="noopener noreferrer"&gt;SHAP&lt;/a&gt; explainers to provide explanations behind the predictions made by the corresponding model made at the time, including "black-box" complex ones such as Random Forest, XGBoost, Neural Networks, etc.&lt;/p&gt;

&lt;p&gt;Demo: &lt;a href="https://youtu.be/qLdc4jhn83c" rel="noopener noreferrer"&gt;https://youtu.be/qLdc4jhn83c&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CT Pipeline Components
&lt;/h2&gt;

&lt;p&gt;The theory behind the modules of this CT pipeline is based on the industry standard for MLOps level 1 defined by Google in &lt;a href="https://docs.cloud.google.com/architecture/mlops-continuous-delivery-and-automation-pipelines-in-machine-learning?hl=en" rel="noopener noreferrer"&gt;this article&lt;/a&gt;, and the implementation of each of its components leverages the best features of both IRIS and MLflow, highlighted in red as seen in the image below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1vffylve1klg4luvyvid.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1vffylve1klg4luvyvid.png" alt=" " width="799" height="589"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For those new to CT pipelines, the image above describes how a traditional experimentation phase of a Data Science project (upper section "experimentation/development/test"), usually done in Jupyter notebooks, is transformed into a production-grade deployment of the developed model that allows continuous monitoring of performance over time, and automatic retraining whenever model performance degrades. All this with proper model versioning and logging for auditing purposes.&lt;/p&gt;

&lt;p&gt;We delve into the details on the &lt;a href="https://github.com/JorgeIvanJH/IRIS_and_MLflow-Continuous-Training-Pipeline/blob/main/README.md" rel="noopener noreferrer"&gt;README&lt;/a&gt; of the repo, but for early understanding of each component, we briefly define below what each one does, and how that relates to the IRIS/MLflow tool chosen for that purpose.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Feature Store: Is the single source of truth for sourcing the data, and where every constant parameter or definition related to the data itself is defined, which might vary across clients and use cases (e.g. each client might define readmission after 15, 30, or any other number of days. Late arrival to an appointment might be considered arriving after 5, 10, or any other number of minutes). IRIS SQL Tables' multidimensional globals allow high-speed storage, and stored computed properties ease the definition of custom properties along with the raw data itself.&lt;/li&gt;
&lt;li&gt;Automated Pipeline: Is the formalized and clearly modularized version of the "orchestrated experiment" that's usually done in a jupyter notebook, prepared to be executed every time the model has to be retrained if required. It contains every data and model-training process needed to get the model with the best overall performance. In this section, every constant related to the model itself chosen during the experimentation phase (previously done by data scientists in jupyter notebooks) is defined (e.g. seed, test size, K-folds for validation, etc). In our implementation, we leverage embedded python to easily access IRIS classes directly, along with all required standard Machine Learning python libraries (Pandas, scikit-learn, MLflow, etc).&lt;/li&gt;
&lt;li&gt;Model Registry: During Training, each model that is trained is logged into the MLflow's backend registry, automatically configured when building the project. We can at any moment re-download models from there and query performance of previous models.&lt;/li&gt;
&lt;li&gt;Trained Model: Though the MLflow backend has an Artifact Store where the weights of all trained models are stored, this project additionally saves the artifacts directly into a persistent location (Docker volume) for quick loading when needed. In case these are deleted, they are downloaded and re-saved in the same location from the MLflow Artifact Store.&lt;/li&gt;
&lt;li&gt;Model Serving: This block is in charge of managing the model that is served to production. We store the path to the model's artifacts to be used in production in an IRIS global, which is what gets updated whenever necessary. In this repo we directly promote the new model if it performs better than the previous one, but in a real scenario this might require human approval. We decided to store the path to the model in a global and not the model itself because doing that would imply additional processing time for serialization and deserialization of the python object, whereas text is faster and straightforward to read from a global regardless of classes in the whole repository, making it easy and fast to read anywhere.&lt;/li&gt;
&lt;li&gt;Prediction Service: Is the actual service that a client would use to request inferences on the current model set in production. At the moment this repo uses an embedded python method for this, but this block can potentially be improved by transforming the model into PMML format to make the production service executable using Integrated ML for any sklearn models, or any python model like LightGBM using the upcoming IntegratedML custom models in IRIS 2026.1.&lt;/li&gt;
&lt;li&gt;Performance Monitoring: Is any sort of monitoring that can be made implemented to keep track of the performance of the current model in production, along with previous ones if necessary. For this we leverage MLflow's UI, where we can make custom plots with any of the variables logged, datetime, performance metrics, both for each model and for all models historically trained.&lt;/li&gt;
&lt;li&gt;Trigger: Is whatever activates the execution of the Automated Pipeline. It can be data drift, model degradation beyond a certain threshold, availability of a certain amount of new data with enough ground truth, or a simple periodic schedule. In this project we directly compare against a defined threshold of the R² metric, so every time performance falls below the value in MLpipeline.PerformanceMonitoring.R2THRESHOLD, we execute the automated pipeline. For this task, another valid approach would be to use the task manager to schedule a method that looks at the performance registered during performance monitoring in MLflow tracking, and decide whether to retrain a new model.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The addition of MLflow enables straightforward historical performance monitoring of models over time through a single, locally hosted UI in a Docker container. It allows you to store and access artifacts from all previously trained models, including those deployed to production. These artefacts can be downloaded whenever needed, along with standard and custom performance metrics and custom visualisations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2cm6bfm7o7kfjhwtvoi5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2cm6bfm7o7kfjhwtvoi5.png" alt=" " width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F04k94cymyebnayxwlzac.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F04k94cymyebnayxwlzac.png" alt=" " width="799" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For each run associated with a model, it is also possible to log additional artifacts such as SHAP explainers, custom plots, and user-defined metrics.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F86h6b8f8lyz0r9qge21h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F86h6b8f8lyz0r9qge21h.png" alt=" " width="800" height="793"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo81a8qlguquhkpr1vydn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo81a8qlguquhkpr1vydn.png" alt=" " width="800" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;The implementation of this CT pipeline leverages &lt;a href="https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=GCM_structuredlog" rel="noopener noreferrer"&gt;Structured Logging&lt;/a&gt; to separate the logs from this pipeline from the rest of the system's, into a persistent path inside the volume of the container hosting IRIS.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;h2&gt;
  
  
  Future Work
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In the future, this pipeline can leverage the newly released feature in IRIS 2026.1: IntegratedML Custom Models, to make the prediction service easier through SQL commands, regardless of the model (added support for LightGBM, NNs, XGBoost, etc).&lt;/li&gt;
&lt;li&gt;Right now, the model is only updated automatically by retraining on new data, but the hyperparameters remain static. By following the instructions in &lt;a href="https://mlflow.org/docs/latest/ml/getting-started/hyperparameter-tuning/" rel="noopener noreferrer"&gt;this guide&lt;/a&gt; this pipeline could be improved by introducing hyperparameter flexibility and allowing the model to be re-optimised using the open-source hyperparameter optimisation framework &lt;a href="https://optuna.org/" rel="noopener noreferrer"&gt;Optuna&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;In this project, when prediction performance falls below a predefined threshold, the model is retrained and automatically updated. However, in some cases, human approval should be required before making changes in production, which is something that should be considered in a real-life scenario.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>docker</category>
      <category>machinelearning</category>
      <category>integratedml</category>
    </item>
    <item>
      <title>Understanding InterSystems IRIS Architecture</title>
      <dc:creator>InterSystems Developer</dc:creator>
      <pubDate>Mon, 28 Sep 2026 15:09:22 +0000</pubDate>
      <link>https://dev.to/intersystems/understanding-intersystems-iris-architecture-1b6c</link>
      <guid>https://dev.to/intersystems/understanding-intersystems-iris-architecture-1b6c</guid>
      <description>&lt;p&gt;When people first hear about InterSystems IRIS, they often get overwhelmed by the sheer amount of information surrounding this technology. It is described simultaneously as a data platform, a database, an interoperability engine, an analytics platform, and even an application development platform. Of course, it is easy to get lost in all of this. Unlike many technology stacks where you must assemble multiple products — a database, an integration engine, an API server, a machine learning platform, and reporting tools — InterSystems IRIS actually brings these capabilities together into a single runtime. Rather than learning half a dozen separate products, you are simply learning the different capabilities of one unified platform.&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fquqqqf9a9rj366zz0fus.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fquqqqf9a9rj366zz0fus.png" alt=" " width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is precisely why IRIS (or rather Caché at that point) was chosen as a good example for my subject - to show students different things without the&amp;nbsp;need to learn different software. Besides, instead of moving information between separate products, all components work directly with the same underlying data.&lt;br&gt;In this article, I will try to explain the architecture of InterSystems IRIS from a developer's perspective. Rather than diving into&amp;nbsp;low-level implementation details, we will look at the major building blocks, how they fit together, and the kinds of applications they are designed to support.&lt;/p&gt;
&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;h3&gt;Multi-Model Data Engine&lt;/h3&gt;
&lt;p&gt;Every application starts with data. At the core of InterSystems IRIS is an extremely high-performance multi-model database engine supporting the following data models:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hierarchical&lt;/li&gt;
&lt;li&gt;Key-value&lt;/li&gt;
&lt;li&gt;Object&lt;/li&gt;
&lt;li&gt;Document (JSON)&lt;/li&gt;
&lt;li&gt;Relational&lt;/li&gt;
&lt;li&gt;Columnar&lt;/li&gt;
&lt;li&gt;Vector&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Internally, all of these models are simply different ways of viewing the same stored data. You can read more about the data models in my &lt;a href="https://community.intersystems.com/post/intersystems-iris-data-models-explained-hierarchical-key-value-object-document-relational-and" rel="noopener noreferrer"&gt;previous article&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This data engine forms the foundation for every other subsystem in IRIS.&lt;/p&gt;
&lt;h3&gt;Interoperability&lt;/h3&gt;
&lt;p&gt;One of the best-known parts of InterSystems technology is its interoperability engine.&lt;/p&gt;
&lt;p&gt;Real-world systems rarely exist in isolation. Applications must constantly exchange data using the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;REST&lt;/li&gt;
&lt;li&gt;SOAP&lt;/li&gt;
&lt;li&gt;HTTP&lt;/li&gt;
&lt;li&gt;TCP&lt;/li&gt;
&lt;li&gt;Files&lt;/li&gt;
&lt;li&gt;Message queues&lt;/li&gt;
&lt;li&gt;Healthcare standards&lt;/li&gt;
&lt;li&gt;Custom protocols&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The interoperability engine provides the infrastructure to receive, transform, route, and deliver these messages. Instead of writing networking code repeatedly, developers configure productions composed of services, processes, and operations.&lt;/p&gt;
&lt;p&gt;A typical flow might look like the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffrnvt5tc4h9reylyxxv3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffrnvt5tc4h9reylyxxv3.png" alt=" " width="800" height="1200"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inbound Adapter&lt;/strong&gt;: Connects to an external system or data source and receives incoming messages, files, or requests into the inte&lt;a href="https://dev.tourl"&gt;&lt;/a&gt;roperability production.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Business Service&lt;/strong&gt;: Accepts data from the inbound adapter, validates or preprocesses it, and converts it into an internal message for further processing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Transformation&lt;/strong&gt;: Maps and converts data from one format or schema into another so the next component or target system can understand it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Business Process&lt;/strong&gt;: Implements the workflow or business logic, determining how messages should be processed, routed, or orchestrated.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Business Operation&lt;/strong&gt;: Sends the processed message to its destination, such as another application, a database, a web service, or a messaging system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Outbound Adapter&lt;/strong&gt;: Handles the low-level communication with the target system using the appropriate protocol (e.g., HTTP, TCP, FTP, JDBC, or HL7).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;IRIS includes numerous built-in adapters for common communication protocols together with graphical tools for building integration pipelines. For developers building enterprise software, this means a massive portion of the coding is already done!&lt;/p&gt;
&lt;h3&gt;Analytics&lt;/h3&gt;
&lt;p&gt;Modern applications need to do more than just store data - they need to extract insights from it. While many technology stacks rely on separate analytics platforms, InterSystems IRIS integrates analytics directly into the core platform. This allows developers to query, analyze, and visualize operational data without moving it into another system. Depending on the edition, this includes the following capabilities:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;IRIS BI&lt;/strong&gt; (Business Intelligence): Enables developers and business users to build interactive dashboards, perform multidimensional analysis, and explore data from different perspectives to identify trends and support decision making.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;InterSystems Reports&lt;/strong&gt;: Provides a flexible reporting environment for designing, generating, and distributing professional reports in various formats, making it easy to present business data to end users.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Columnar Storage&lt;/strong&gt;: Complements the transactional row-based storage by organizing analytical data in a column-oriented format. This significantly improves the performance of large-scale aggregations and reporting queries without impacting day-to-day transactional workloads.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector Search&lt;/strong&gt;: Enables semantic search by storing and querying vector embeddings alongside your operational data. Instead of searching for exact keywords, it finds information based on meaning, enabling retrieval of conceptually similar documents even when they do not share the same wording.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These components work together to support everything from traditional business reporting to modern AI-powered applications. Rather than exporting information into a separate analytics database, applications can analyze operational data directly. This architecture reduces latency and avoids the need to maintain duplicate datasets. Also, IRIS integrates seamlessly with existing data and application technologies, including popular third-party BI tools, such as Tableau, Looker, Qlik, Microsoft Power BI, and Excel.&lt;/p&gt;
&lt;h3&gt;AI and ML&lt;/h3&gt;
&lt;p&gt;Rather than requiring a collection of specialized databases and AI services, InterSystems IRIS provides built-in capabilities to develop AI-powered solutions that work directly with operational data. Depending on the edition, this includes the following capabilities:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;IntegratedML&lt;/strong&gt;: Allows developers and SQL users to build, train, and deploy machine learning models using simple SQL statements, eliminating the need for specialized machine learning expertise or complex data science pipelines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vector Search&lt;/strong&gt;: Stores and indexes vector embeddings directly within InterSystems IRIS, enabling semantic search and similarity matching across enterprise data without requiring a separate vector database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GenAI Frameworks&lt;/strong&gt;: Offer libraries and development tools for building AI-powered applications, including Retrieval-Augmented Generation (RAG) systems, intelligent assistants, semantic search, and document question-answering solutions.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Together, these capabilities enable developers to integrate structured enterprise data with modern AI techniques on a single platform. By keeping operational data, vector embeddings, and AI workflows within the same environment, InterSystems IRIS simplifies application architecture, reduces data movement, and accelerates the development of intelligent applications.&lt;/p&gt;
&lt;h3&gt;Application Services&lt;/h3&gt;
&lt;p&gt;Beyond data storage and processing, IRIS is also an application platform. Applications can be written in several languages, including the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ObjectScript&lt;/li&gt;
&lt;li&gt;Python&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;REST and GraphQL endpoints can also be exposed directly from the platform, making it straightforward to build APIs without introducing additional middleware.&lt;/p&gt;
&lt;h3&gt;Final Thoughts&lt;/h3&gt;
&lt;p&gt;At first glance, InterSystems IRIS can seem difficult to categorize because it refuses to fit into a single box. Is it a database? An integration engine? An analytics platform? An application server? The answer is yes to all of the above. Its architecture is built around a single high-performance multi-model data engine, with interoperability, analytics, APIs, application development, and operational capabilities layered on top. Rather than stitching together separate products, developers work within one cohesive environment where every component shares the same underlying data.&lt;/p&gt;


</description>
      <category>architecture</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
