#Code Snippet

0 Followers · 298 Posts

Code snippet is a programming term for a small region of re-usable source code, machine code, or text.

Article Andrew Sklyarov · Nov 8 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 0
Article Pravin Barton · May 1, 2020 1m read

ObjectScript doesn't include any built-in method for appending one JSON dynamic array to another. Here's a code snippet I use that's equivalent to the JavaScript concat() method.

Call it with any number of arguments to concatenate them into a new array. If an argument is a dynamic array, its elements will be added. Otherwise the argument itself will be added.

6
4 942
Question Michael Akselrod · Nov 3

Only method/routine executed as "do Method..." is included into $ESTACK.How can I modify a method or routine that returns a value so it can be included in $ESTACK?Example upon executing via Studio Debug ($ESTACK is converted to string with ">" delimiter):    Expected: stackstr = %Debugger.System.DebugStub > LogGenerate > Entry > DirChain > Attributes >  LogNew > LogSize >  LogFormat > LogWrite        Processes DirChain, LogNew, LogSize, LogFormat are executed as "If Method..."        Process Attributes is executed as "set a = Attributes..."    Current: stackstr =  %Debugger.System.DebugStub >

0
0 0
Question Michael Akselrod · Oct 29

Environment:
    Targeted *.inc file (with hundreds of defined macros) is in use throughout the application and included into every class declaration.
    Statement "set a = $$$TestIf(3)" is included into a classmethod with no other code in. Expected output 5
Same macro options in *.inc:
    #define TestIf(%arr)    if %arr>0 QUIT 5
    #define TestIf(%arr)    if (%arr>0) {QUIT 5}
Issue:
    failure to compile class with the same error on all tried definition options as:

0
0 0
Article David Hockenbroch · Apr 2, 2024 9m read

One of the most common kinds of integration we are asked to do is emailing. One of the most typical email services our customers use is Microsoft’s Office 365. After setting up the right configuration on the Microsoft side, we can email from IRIS with two HTTP requests. By the end of this article, we will be able to send an email with an attachment through our Microsoft 365 service!

0
0 681
Article Robbie Luman · Aug 15 8m read

Dynamic Entities (objects and arrays) in IRIS are incredibly useful in situations where you are having to transform JSON data into an Object Model for storage to the database, such as in REST API endpoints hosted within IRIS. This is because these dynamic objects and arrays can easily serve as a point of conversion from one data structure to the other.

Dynamic Objects

Dynamic Objects are very similar to the standard ObjectScript object model you get when you create a new instance of a class object, but with some key differences:

0
0 0
Article David Hockenbroch · Jul 10 16m read

Dear community, I have a confession to make. I have not gotten over Zen yet. Alas, all good things must come to an EOF, so I am currently learning about Angular. I am working on proving to myself that with the right back end and Angular components, I can deliver to myself and my team a very Zen-like experience in this environment. Since this is my first attempt, here is a fair warning: I will be providing some rather large code samples before discussing them. Please warm up your mouse and hand for extensive upcoming scrolling! Also, a note on the code snippets: many of them are labeled

0
0 0
Article David Hockenbroch · Sep 11, 2024 9m read

Do not let the title of this article confuse you; we are not planning to take the InterSystems staff out to a fine Italian restaurant. Instead, this article will cover the principles of working with date and time data types in IRIS. When we use these data types, we should be aware of three different conversion issues:

  1. Converting between internal and ODBC formats.
  2. Converting between local time, UTC, and Posix time.
  3. Converting to and from various date display formats.
0
0 0
Question Yone Moreno Jiménez · Jun 23

Good morning,

We would need help, thanks in advance for your help. 🙂

We have been trying to debug the following error, when sending a DICOM from a "EnsLib.DICOM.Operation.TCP" to a PACs:

  ERROR <EnsDICOM>NoCompatibleTransferSyntaxFound: No negotiated transfer syntax for SOP class '1.2.840.10008.5.1.4.1.1.4' is compatible with document transfer syntax '1.2.840.10008.1.2.4.70'

We use the following AET titles at the Operation:

LocalAET: ESBSSCC-DCM

RemoteAET: HUNSCESBGWT

0
0 0
Question Yone Moreno Jiménez · Jun 23

Hello, good morning, thank you so much for reading this question. ☺️🙂👍

We are developing a code to get information about our Production's items: services, processes and operations.

We know we can get various configurations of a given item: Category, Port, Enabled...

But we wonder how we could get the date time of the last mesage (most recent) received in an item.

To give a code snippet a small section of the code we have developed (and tested), it looks like:

0
0 0
Article Keren Skubach · May 5 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:

0
0 0
Question Marc Mundt · Jun 21, 2016

A customer is using Caché online backups and needs to automatically purge the cbk files with a scheduled task.

This is a wheel has been reinvented uncountable times already and I know somebody out there has a well written, extremely robust version that has already stood the test of time.

Does anyone have a nice routine/class/task for purging old Caché backup files? 

11
1 1759
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!

0
0 0
Question Yone Moreno · Nov 4, 2024

Hello,
Please, we would need your help 🙂:

In a development environment, we have added quite a few presentation contexts to the DICOM configurations (the associations). We would need to find a way to export them from this environment to make it easier for us to import them in PRO (and avoid doing it by hand one by one).

0
0 0
Question Yone Moreno · Oct 18, 2024

Hello,

First of all: thanks for your help, and thank you for your time.

Thanks for your time.

We have the following situation:

We are in a BPL, and we have defined 4 <call> asynchronous as follows:

First one name: "Enviar a Proceso NEGRIN"

The second one, named as: "Enviar a Proceso HUNSC"

The third one, titled: "Enviar a Proceso CHUIMI 02"

And the fourth and last one names as: "Enviar a Proceso Fuertev"

Inmediately after the 4 calls, we have a <sync> instruction which should wait for all of them to finish.

0
0 0
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
}
0
0 0
Question Yone Moreno · Jun 25, 2024

Hello,

Thanks for reading this question.

We need to remove the line feeds and carriage returns from start and end, but not from the middle of a string

We have tested the following ways:

set output = $ZStrip("[line feed](carriage return) str [line feed](carriage return) ing [line feed](carriage return)","<>C")

But it removes also control characters which we need to preserve...

Also we have tested:

set output = $REPLACE("[line feed](carriage return) str [line feed](carriage return) ing [line feed](carriage return)",$C(13,10),"")
0
0 0
Article Eduard Lebedyuk · Mar 4, 2021 1m read

Recently I wanted to get a list of all cached queries and their texts. Here's how to do that.

First create an SQL Procedure returning Cache Query text from a Cached Query routine name:

Class test.CQ
{

/// SELECT test.CQ_GetText()
ClassMethod GetText(routine As %String) As %String [ CodeMode = expression, SqlProc ]
{
##class(%SQLCatalog).GetCachedQueryInfo(routine)
}

}

And after that you can execute this query:

SELECT Routine, test.CQ_GetText(Routine)
FROM %SQL_Manager.CachedQueryTree()

And get a list of Cached Queries:

4
0 722
Question Yone Moreno · Nov 22, 2023

Hello,

First of all thanks for your help.

We have the following scenario: some responses include special characters as ">" and "<" which are being put inside a property defined as:

Property PACPROBLEMAS As %String(MAXLEN = "", XMLNAME = "PAC_PROBLEMAS");

So then, when we observe the LOG SOAP it shows that the Target System replies to the ESB as follows:

➡️ <PAC_PROBLEMAS>46807#278.01#OBESIDAD INFANTIL GRAVE     ( Z-SCORE IMC &gt;2,70 ) #19/09/2019##N#</PAC_PROBLEMAS>

4
0 745
Article Alberto Fuentes · Jan 29, 2024 12m read

We have a yummy dataset with recipes written by multiple Reddit users, however most of the information is free text as the title or description of a post. Let's find out how we can very easily load the dataset, extract some features and analyze it using features from OpenAI large language model within Embedded Python and the Langchain framework.

Loading the dataset

First things first, we need to load the dataset or can we just connect to it?

2
2 381
Discussion Yone Moreno · May 15, 2024

Hello,

I would like you to propose this challenge.

It has been created by the CodeWars community here: https://www.codewars.com/kata/6523a71df7666800170a1954/python

I will copy and paste the description:

🔡🟢 DESCRIPTION:

A number is Esthetic if, in any base from base2 up to base10, the absolute difference between every pair of its adjacent digits is constantly equal to 1.

0
0 147
Discussion Yone Moreno · May 13, 2024

Hello,

I would like to propose you a challenge.

It has been created by a web user called "uttumuttu" and it is being explained here: https://www.codewars.com/kata/66314d6b7cb7030393dddf8a

Here is the proposed challenge copied and pasted:

DESCRIPTION:

This kata was created as a contender for the EPIC Challenge 2024.

Background

It's your dream to have a magical wedding day, and you're willing to spend every last penny on it — while simultaneously planning for a stable retirement income.

Task

0
0 200
Article Erin Spencer · Jan 24, 2024 9m read

The traditional use of an IRIS production is for an inbound adapter to receive input from an external source, send that input to an IRIS service, then have that service send that input through the production.

With a custom inbound adapter though, we can make an IRIS production do more. We can use an IRIS production to process data from our own database without any external trigger.

By using an IRIS production in this way your data processing tasks now get to leverage all the built in features of an IRIS production, including:

0
0 461
Article David Hockenbroch · Apr 25, 2024 3m read

I came up with a challenge for myself to come up with a way to make a variable watch itself for a certain value and do something when it hits that value without having to check it every time something touches it. Basically, a way to say "if at any point during the execution of this code, if x = 0 (or whatever the condition is) do this thing." The class I ended up with watches a %Status:

0
0 287