查找

Pergunta
· 3 hr atrás

Are class queries only for SELECT?

Hi developers!

There is a neat feature of ObjectScript classes - Query element, which allows you to write in a clear SQL (without any & or ()), pass parameters to it and call it from ObjectScript as do QueryNameFunc() or via Call SQLProcedureName via SQL, .e.g.

Query MyQuery(p as %String) as %SQLQuery [SQLProc]

{ 

SELECT * FROM MyTable 

WHERE Name=:p

}

All works fine, but when I tried to use the same for a DELETE statement see the following error:

SELECT expected, DELETE found ^ DECLARE Q1 CURSOR FOR DELETE

Is the Query element for SELECT only? What am I doing wrong? )

2 novos comentários
Discussão (2)1
Entre ou crie uma conta para continuar
Artigo
· 3 hr atrás 1min de leitura

#DIM vs SET - Objectscript

SET assigns value to the variable at RUNTIME.

#DIM declare the variable and it's Data Type at COMPILE TIME.


SET #DIM
Makes the variables Dynamic. Improves Readability.
No Data Type Declaration. Enables IDE auto-completion.
Runtime Useful for Object references.

#DIM name As %String
Set name = "Micheal Scott"
#DIM age As %Numeric
Set age = 36
#DIM employer As App.Employer               ; compile time
Set employer = ##class(App.Employer).%New() ; runtime 

 

SET or #DIM? Your design, your rules.

1 novo comentário
Discussão (1)2
Entre ou crie uma conta para continuar
Artigo
· 4 hr atrás 3min de leitura

embeddedpy-bridge: A Toolkit for Embedded Python

Embeddedpy-bridge: A Toolkit for Embedded Python

Overview

Embedded Python is a game-changer for InterSystems IRIS, offering access to the vast Python ecosystem directly within the database. However, bridging the gap between ObjectScript and Python can sometimes feel like translating between two different worlds.

To make this transition seamless using embeddedpy-bridge.

This package is a developer-centric utility kit designed to provide high-level ObjectScript wrappers, familiar syntax, and robust error handling for Embedded Python. It allows developers to interact with Python data structures using the native IRIS patterns they are already comfortable with.

The Challenge

While the %SYS.Python library is powerful, developers often face a few hurdles:

  1. Handling Proxies: Navigating Python lists and dictionaries using raw proxies doesn't feel "native" to ObjectScript.
  2. Iteration: Standard ObjectScript While loops don't natively "talk" to Python iterators.
  3. Namespace Management: Ensuring Python utilities are available system-wide.

The Solution: embeddedpy-bridge

My goal was to create a "Bridge" that makes Python feel like a first-class citizen in ObjectScript.

Key Features:

  • The py Prefix Convention: All methods in the %ZPython.Utils class use a py prefix (e.g., pyDict(), pyList(), pyJSON()) to clearly distinguish Python-related logic from native IRIS code.
  • OO Wrappers: High-level classes for List and Dict that support familiar methods like GetAt(), SetAt(), and Count().
  • Smart Iterators: Integrated ListIterator and DictIterator allow you to traverse Python data using standard ObjectScript While loops.
  • Macro Support: A %ZPython.inc file provides shortcuts like $$$pyDict and $$$pyJSON for cleaner, faster development.

Usage Examples

1. Simple Syntax (Macros)

No more typing ##class(...) every time. Use short shortcuts:

  • $$$pyDict — Create a Python Dictionary.
  • $$$pyList — Create a Python List.
  • $$$pyJSON(dynObj) — Turn a JSON object into Python instantly.

2. Unified Dictionary Handling

Instead of managing raw Python proxies, use the wrapped dictionary:

Code snippet:

Include %ZPython
Set pyDict = $$$pyDict
Do pyDict.SetAt("Status", "Active")
Do pyDict.SetAt("Version", 1.0)

// Standard IRIS iteration
Set iter = pyDict.%GetIterator()
While iter.%GetNext(.key, .val) {
    Write "Key: ", key, " Val: ", val, !
}

 

Set pyList = $$$zpyList()

Do pyList.Append("First Item")
Do pyList.Append("Second Item")

Write "Total items: ", pyList.Count(), !

// Access by index
Write "Item 1: ", pyList.GetAt(0), !

2. Seamless Data Conversion

Convert IRIS Dynamic Objects to Python objects and back with one line:

Code snippet

Set dynObj = {"name": "John", "roles": ["Admin", "User"]}
Set pyObj = $$$pyJSON(dynObj)

// Verify Python type
Write ##class(%ZPython.Utils).IsType(pyObj, "dict") // 1

The goal of this project is to bridge the gap between two powerful worlds. While InterSystems IRIS provides the engine for Embedded Python, embeddedpy-bridge provides the steering wheel. 

Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· 6 hr atrás 6min de leitura

2025.1 FHIR Search Highlight - Lists-related Search Support (_List, $find, Functional/"Current" Lists)

Sometimes it is more convenient, more efficient, and more secure, to limit FHIR Searches per pre-defined "Lists" of Resources.

Since v2025.1 we support several List-related features in our FHIR Server.

I will highlight these here, and provide some samples.

In general you can see details about the List Resource from the official FHIR documentation.

But here is a short description based on the above:

The FHIR List Resource represents a flat (optionally ordered) collection of records used for clinical lists (e.g., allergies, meds, alerts, histories) and workflow management (e.g., tracking patients, teaching cases).
Lists may be homogeneous (single resource type) or heterogeneous (mixed types, e.g., a problem list spanning Conditions, AllergyIntolerances, Procedures).
Use List when you need a curated/filtered set that cannot be obtained via a simple query (e.g., “current” allergies vs all recorded allergies).
Querying a List yields a human-curated point-in-time snapshot, whereas querying the resource endpoint usually returns a broader, non-curated, “as of now” dataset.

In our latest versions (2025.1+) you can find new support for working with Lists:

  • The _list Search Parameter 

See the related FHIR docs for a full description. See our related Docs for details about the support available (specifically around Type-level vs. System-level searches).

Using this feature you can define for example a List of certain Resources, for example Encounters or Patients, etc. which you might want to Search according to them, without having to detail all of them as multiple Search Parameters.

For example I could define a List of Patients:

 
PUT /List cURL snippet

And then Search for them like this:

 
GET /Patient?_list cURL snippet

And get back a curated list of the Patients I wanted, instead of having to "mention" all of them in some multiple Search Parameters.

And of course there are many other use-cases.

  • Functional Lists (including the Custom Operation $update-functional)

A special kind of lists are Functional Lists (or "Current Resource" Lists).

See the related FHIR docs for a full description.

For your convenience here is a short description based on the above:

Many clinical systems maintain “current” patient lists (for example, a current problem list and a current medication list), but FHIR cannot reliably infer “current-ness” by inspecting a single resource instance.
Using Condition as an example, the same resource type may be posted for multiple legitimate purposes (curated problem list entry, encounter complaint/diagnosis, diagnostic workflow context, or inbound referral data), and Condition has no element that cleanly distinguishes these usages.
Because distinguishing current vs. past would require retrospective alteration (creating integrity and digital-signature concerns), a normal search on Condition for a patient will return more than just the curated “current problems,” and limiting it to “current only” would hide other important Condition records.
Therefore, whether a Condition (or similar record) is on a patient’s “current list” could determined by whether it is referenced from the appropriate List.
Via the REST API, this is expressed via the list search mechanism using _list with standard functional list names (e.g., GET [base]/AllergyIntolerance?patient=42&_list=$current-allergies), and the server may support this without necessarily exposing a standalone List instance.
There are several "common" functional list names such as $current-problems, $current-medications, $current-allergies, and $current-drug-allergies (a subset of allergies).

In order to allow maintaining these Functional Lists, we defined a Custom Operation, called $update-functional, which allows for creating and updated these kinds of lists. See more details in our Docs.

You can define a list of current allergies for example like this:

 
POST /List/$update-functional?for=...&name=\$current-allergies cURL snippet

This will create/update the $current-allergies List, for a specific Patient (ID 34 in the example above).

Note I include the 'for=' in the URL pointing to the Patient ID, and in the List I have 'subject' referencing the Patient.

(Note also that for the dollar sign ($) I used a slash (\) before it, i.e.: \$)

And now, I can ask for AllergyIntolerance Resource of this Patient, and instead of getting all of them, I can ask for just the "current" ones, as defined in the List above.

This would look like this:

 
GET /AllergyIntolerance?patient=...&_list=\$current-allergies cURL snippet

And this would return a subset of this Patient's allergies, per the current allergies list.

Note we're using the same _list Search Parameter mentioned previously, just this time instead of with a "Custom List", with a "Functional List".

Note you can control the names of the functional list names (and for each list, it's subject Search Parameter, and subject Resource Type; for example in the sample above the subject Search parameter was patient and the subject Resource Type was Patient), via the FHIR Endpoint configuration, specifically the "Interactions Strategy Settings", see related Docs here. This looks like this:

  • $find Operation

In addition, if you simply want to get the Functional List itself (for a particular subject, and of a particular type), you can use the $find operation.

See the related FHIR docs for a full description. And see also our related Docs.

Here's an example, per the previous one:

 
/List/$find?patient=...&name=\$current-allergies cURL snippet

This will return the related $current-allergies list for this Patient, as defined above via the $update-functional function.

See the related Open Exchange app which includes a Postman Collection with the samples above (plus a little more) and instructions re running this against @Evgeny.Shvarov's FHIR server template docker container (indeed the sample above was created around this sample; with a slight change... see details in my app usage instructions).

A general note - all this functionality assumes you are using the, relatively newer, and current default, JsonAdvSQL Storage Strategy for your Endpoint. (If relevant see here regarding migrating from a legacy Strategy)
Discussão (0)1
Entre ou crie uma conta para continuar
Artigo
· 15 hr atrás 1min de leitura

关于导出映射Global

InterSystems 常见问题

使用 %Library.Global 类的 Export() 方法导出时,如果导出格式(第四个参数:OutputFormat)设置为 7,即 "块格式(Block format)/Caché 块格式 (%GOF)",则无法导出映射的Global项(只能导出命名空间默认Global数据库中的Global项)。要导出 "块格式/Caché 块格式 (%GOF) "的映射Global项,请在 %Library.Global.Export() 的第一个参数中指定要映射Global项的数据库目录。

执行示例如下。

set DB = "^^c:\InterSystems\Cache\Mgr\Test\" ; "^^\<path to database folder>\"
set sc = ##class(%Library.Global).Export(DB, "TESTGBL.gbl",FULLPATH,7,,")

如果将导出格式指定为 5(默认),即 "ISM/ObjectScript 格式(ISM/缓存格式)(*)",则也可以导出映射Global,但输出文件会比将导出格式(第四个参数:OutputFormat)设置为 7(即 "块格式/Caché 块格式(%GOF)")时大。

此外,如果在Global中记录了二进制数据,也无法正确输出。

更多信息,请参阅以下文档。
类参考:%Library.Global.Export() [IRIS]
类参考:%Library.Global.Export()

[注意]
默认导出格式为 5(ISM/ObjectScript 格式(ISM/Cache 格式)(*))时,包含 $LIST 格式或控制字符的Global文件无法正确导出。 在这种情况下,必须将导出格式(第四个参数:OutputFormat)设置为 7(块格式/Caché 块格式 (%GOF)),按数据库逐个导出。

* 顺序文件格式

Discussão (0)1
Entre ou crie uma conta para continuar