#Coding Guidelines

6 Followers · 56 Posts

Recommendations and best practices for writing code.

New
Article David Hockenbroch · Feb 18 7m read

In the previous article, we examined how we can use the %CSP.Request and %CSP.Response classes to test a REST API without having the API fully set up and accessible across a network with an authentication mechanism. In this article, we will build on that foundation to perform some simple unit testing of one of our REST API methods.

The unit testing framework requires a couple of setup steps before we can use it.First, we have to ensure that the unit testing portion of the management portal is enabled so we can review the results of our tests.

0
1 93
Article Keren Skubach · May 5, 2025 4m read

An extension “extends” or enhances a FHIR resource or a data element in a custom way. The extension can be added to the root of a resource, such as “Patient.ethnicity” in US Core profile, and they can be added to individual elements such as HumanName, Address or Identifier.

Did you know that you can also add an extension to a primitive data type?

Primitives usually store a single item and are the most basic element in FHIR. For example: "Keren", false, 1234, 12/08/2024 etc.

For example, the patient resources might look like this:

The gender, birthDateor family elements are primitive elements,

2
2 364
Article Andrew Sklyarov · Nov 8, 2025 4m read

When I started my journey with InterSystems IRIS, especially in Interoperability, one of the initial and common questions I had was: how can I run something on an interval or schedule? In this topic, I want to share two simple classes that address this issue. I'm surprised that some similar classes are not located somewhere in EnsLib. Or maybe I didn't search well? Anyway, this topic is not meant to be complex work, just a couple of snippets for beginners.

0
0 117
Article Andrew Sklyarov · Nov 2, 2025 7m read

Over time, while I was working with Interoperability on the IRIS Data Platform, I developed rules for organizing a project code into packages and classes. That is what is called a Naming Convention, usually. In this topic, I want to organize and share these rules. I hope it can be helpful for somebody.

 

Disclaimer: This guide is a good fit for Interoperability projects.When you have integrations, data flows, when you use IRIS for ETL processes, etc.Overall, when your code is combined with Productions.

4
4 162
Question Justin Millette · Jun 23, 2025

I have a class with a projection that creates some persistent classes (chunks) and a non-persistent "Daemon" class that I want to have running in the background, doing some processing. The daemon needs to look at the "chunk" classes, and I want it to be simple to start the daemon -- I am currently calling the daemon's start method at the end of the CreateProjection method. When I do this, I get a <CLASS DOES NOT EXIST> error from the daemon when it tries to query against one of the chunk tables. But, if I add a "HANG 5" at the beginning of the daemon start method, this runs fine.

8
0 121
Article Sergei Sarkisian · Jul 1, 2022 8m read

Before we start with some intermediate and advanced topics, I would like to sum up some more general points. They are subjective, of course, so I will be happy to discuss them if you have other opinion or better arguments for any of them.

The list is not comprehensive and this is intended, cause I will cover some topics in future articles.

Tip 1. Follow official styleguide

Angular is quite strict in terms of limiting the possible architecture of an application, but there are still many places in it that allow you to do things your own way.

2
4 591
Article David Hockenbroch · Apr 22, 2025 7m read

The Good Old Days

The %Library.DynamicObject class has been in IRIS since before it became IRIS. If you have been using it since the Cache days, you may want to brush up on some of its changes.

In Cache 2018, the %Get method only had one argument. It was the key to retrieving from the JSON, meaning that if your JSON object called myObj, it would look like the following:

3
3 387
Article David Hockenbroch · Nov 5, 2024 7m read

As we keep updating our software, we often realize that we require more and more modern solutions. So far, only one major piece of our software relies on reading barcodes in documents and images. Since Cache did not have a means of reading barcodes in the past, we have always achieved our goals by using a Visual Basic 6 application. However, it is no longer an ideal solution because it is currently complicated to maintain it. IRIS also lacks this capability, but it has recently got an option that makes up for it: embedded Python!

2
1 571
Article David Hockenbroch · Oct 14, 2024 9m read

Many programming languages use the try-and-catch construct to handle runtime errors gracefully. If the code within the try block encounters an error, it will throw an exception to the catch block, where the error handling occurs. Today we will dive into the ObjectScript implementation of this construct and discuss some ways to clean things up.

ObjectScript Implementation Basics

To get started, we will first look at the basic structure of the try/catch block:

try{
    //some code here
}
catch ex{
    //some error handling here
}

In this case, ex is a variable name for the exception object

1
3 421
Question Stefan Cronje · Jul 18, 2024

Hi folks,

We are in the process of migrating from Ensemble to IRIS.

After the migration I would like to find all usages of deprecated classes and methods in all of our code. This is to align with the changes in package like %SYSTEM.SQL for example.

Is there an easy way to do this, or maybe a tool that can assist?

Thanks.

7
1 374
Article Hiroshi Sato · Apr 25, 2024 1m read

InterSystems FAQ rubric

For naming conventions, please check the respective document pages below.

About table name (class name): Identifier rules and guidelines - classes

About column names (property names): Identifier rules and guidelines - class members

As stated here, only alphanumeric characters and characters with Unicode code points larger than ASCII 128 can be used in column names (property names).

  • The name must begin with a letter, a Unicode code point greater than ASCII 128, or a percent sign (%).
  • The remaining characters must be alphabetic, letters or numbers with a Unicode code point
0
1 311
Article David Hockenbroch · Sep 14, 2023 9m read

Have you ever thought of creating your own systems for editing users or, perhaps, even an API that you can call? Today, you’re going to join me in the %SYS namespace and get to know Security.Users! 

This class has forty properties, many of which you’ve seen before in the System Management Portal.There are class methods for manipulating most of those properties.Every method in this class is a class method, and in most of them, the username is passed as an argument.These methods can be used when you do not want to open and directly manipulate the user’s objects, which is a bad idea anyway!

1
3 614
Article Ward De Backer · Apr 21, 2023 5m read

When you install an IRIS or Caché instance on Windows Server, you'll usually need to install it under a specific user account that has network access permissions. This is very handy when you needs to access network resources for creating files or directly accessing printers.

TL;DR: see key takeaways at the bottom!

When you need to change the Windows user account the IRIS/Caché service is running as, you can configure (after installation):

  • for IRIS (also see the docs): 
    <install-dir>\bin\IRISinstall.exe setserviceusername <instance-name> <username> <password>
  • for Caché (also see the docs and
0
1 697
Article Timothy Leavitt · May 12, 2016 6m read

The topic of for/while loop performance in Caché ObjectScript came up in discussion recently, and I'd like to share some thoughts/best practices with the rest of the community. While this is a basic topic in itself, it's easy to overlook the performance implications of otherwise-reasonable approaches. In short, loops iterating over $ListBuild lists with $ListNext or over a local array with $Order are the fastest options.

As a motivating example, we will consider looping over the pieces of a comma-delimited string.

A natural way to write such a loop, in minimal code, is:

For
21
5 10115
Article Danny Wijnschenk · Jul 19, 2022 4m read

Mixing Object syntax with SQL is one of the nice features in Object Script. But in one case, it gave strange results, so I decided to isolate the case and describe it here.

Let's say you need to write a classmethod that updates a single property on disk. Usually, i would write that using SQL like this :

ClassMethod ActivateSQL(customerId) as %Status
{
   &sql(Update Test.Customer Set Active=1 Where ID=:customerId)
   If SQLCODE'=0 {
      Set exception = ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, $Get(%msg))
      Quit exception.AsStatus()
   } Else {
      Quit $$$OK
   }
}
 

and call this

5
0 424
Article Sergei Sarkisian · Jul 18, 2022 12m read

Hi! Today I would like to talk about one of the most important architectural patterns in Angular.

The pattern itself is not related to Angular directly, but as Angular is component-driven framework, this pattern is one of the most essential for building modern Angular applications.

Container-Presentation pattern

It is believed that good components should be small, focused, independent, testable and most important - reusable.

If your component is making server calls, contains business logic, tightly coupled to other components, knows too much about other component’s or services’ internals, then it

0
0 1270
Question GUSTAVO MARQUES · Mar 3, 2022

Does any one could tell me how can I access the target properties from inside SQL in DTL Subtransform? For example, if I use the following statement:

SELECT ID INTO :target.SetIDPID  FROM firstlook.person WHERE  FirstName = 'Paul' - as said in documentation :

  SELECT Name INTO :target.Name FROM MainFrame.EmployeeRecord WHERE SSN = :source.SSN AND City = :source.Home.City

I get an Error: ERROR <Ens>ErrException: <PROPERTY DOES NOT EXIST>

But if I pass the value for a variable "SetIDPID" I can use it in a set action without any problem: 

SELECT ID INTO :SetIDPID  FROM firstlook.person WHERE

1
0 376
Question Joao Lazaroni · Feb 8, 2022

I have created a Class method to list employees that are subordinated to a certain boss. But I don´t know how to relate the data in the way it was given to me.

For Example:

  • ^Employee(IdEmployee) = Name

                  ^Employee(1) = "Jessica"

                    ^Funcionario(10) = "Rose"

  • ^HistEmployee(IdEmployee, Date) = Salary^Job^IdEmployeeBoss

                    ^HistEmployee(10, 64628) = "3500^Secretary^1"

So, based on this seetings, Jessica is Rose's boss. But I don't know how I can make a relation between that string and the subscript. Can someone help me?

2
0 290
Article Nigel Salm · Aug 18, 2021 15m read

Why I love ObjectScript and why I think I might love Python More

I was looking at the thread of messages on the topic of "Performance when constructing a comma-separated string", and I started writing a response but got distracted, the page refreshed, and I lost my text. I couldn't spend the time rewriting my response, so I started writing this document instead.

I started writing MUMPS at the beginning of my career.I wrote very tight and dense code blocks where exercises such as the string example were authentic challenges.

17
5 1745
Article Nigel Salm · Aug 21, 2021 106m read

How to develop an interoperability solution in one code base and then use it to generate many individual interfaces

Overview

In 2009 I wrote the first of several Interfaces for LabTrak.The Interfaces allowed existing National Health Laboratory Services (NHLS) clients to send Patient Demographics and Orders to LabTrak.LabTrak would, in turn, send the results of those tests back to the client.I wrote 3 or 4 at the time and an Interface that fed data from LabTrak into the NHLS Corporate Data Warehouse.

2
0 781
Question Warren Oyco · Jul 16, 2021

Hi! I am working on a project where I use record map to transform a flat file and split it into two output text file and in the future will need to split four output files.

I only want to use one  target business operations instead of multiple. Is there a way to set the output file and the target folder path in my business process class?

Any advice on how I can achieve this or is this possible? Thanks!

5
0 551
Question Jack Huser · Feb 10, 2021

Hello everyone,

I have an issue with using "Open" function.

My goal is to execute a shell script with parameters like as:

/trak/FRXX/config/shells/transportIDE.sh "login|password|NOMUSUEL|PRENOM|NOMDENAISSANCE|1234567891320|199999999999999999999999|09%2099%2099%2099%2099|31%2F12%2F1999|242%20IMPASSE%20DES%20MACHINCHOOOOOOOOSE%20||99999|SAINT%20BIDULETRUC%20DE%20MACHINCHOSE|isc%24jhu|123456|123456798"" 2>&1"

But when some parameters are too long, I have a <NAMEADD> error.

I would like to avoid to write the %String command line in a temporary file and execute this file using : Open strCmd:"QR"
Is

4
0 456