Wow, what a useful thread! Thank you.
I especially like the fact that you offer solution in each IRIS language : SQL, Python, ObjectScript.
- Log in to post comments
Wow, what a useful thread! Thank you.
I especially like the fact that you offer solution in each IRIS language : SQL, Python, ObjectScript.
SELECT {fn WEEK('2004-02-25')} AS Week, {fn DAY('2004-02-25')} as Day,{fn DAYOFWEEK('2004-02-25')} as DayOfWeek,{fn Year('2004-02-25')} as Year,{fn Quarter('2004-02-25')} as Quarter,{fn DAYOFYEAR('2004-02-25')} as DayOfYearDoc : https://docs.intersystems.com/iris20223/csp/documatic/%25CSP.Documatic…
not all your requirements but it's a start
Another good way is to set the header :
Prefer: return=representationThe payload will be sent you back with the id.
Example :
POST http://localhost:33783/fhir/r4/Patient HTTP/1.1
Content-Type: application/json+fhir
Accept: application/json+fhir
Prefer: return=representation
{
"resourceType": "Patient",
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
]
}Response :
HTTP/1.1 201 Created
Date: Wed, 29 Mar 2023 12:13:40 GMT
Server: Apache
CACHE-CONTROL: no-cache
ETAG: W/"1"
EXPIRES: Thu, 29 Oct 1998 17:04:19 GMT
LAST-MODIFIED: Wed, 29 Mar 2023 12:13:40 GMT
LOCATION: http://localhost:33783/fhir/r4/Patient/2011/_history/1
PRAGMA: no-cache
CONTENT-LENGTH: 177
Connection: close
Content-Type: application/fhir+json; charset=UTF-8
{
"resourceType": "Patient",
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"id": "2011",
"meta": {
"lastUpdated": "2023-03-29T12:13:40Z",
"versionId": "1"
}
}Great article, if your are looking for an approach without objectscript and making use of "irispyhton", check this code :
python code :
import pandas as pd
from sqlalchemy import create_engine,types
engine = create_engine('iris+emb:///')
df = pd.read_csv("/irisdev/app/notebook/Notebooks/date_panda.csv")
# change type of FullDate to date
df['FullDate'] = pd.to_datetime(df['FullDate'])
df.head()
df.to_sql('DateFact', engine, schema="Demo" ,if_exists='replace', index=True,
dtype={'DayName': types.VARCHAR(50), 'FullDate': types.DATE, 'MonthName': types.VARCHAR(50),
'MonthYear': types.INTEGER, 'Year': types.INTEGER})
requirements.txt :
pandas
sqlalchemy==1.4.22
sqlalchemy-iris==0.5.0
irissqlcli
date_panda.csv
ID,DayName,FullDate,MonthName,MonthYear,Year
1,Monday,1900-01-01,January,190001,1900
2,Tuesday,1900-01-02,January,190001,1900
3,Wednesday,1900-01-03,January,190001,1900
4,Thursday,1900-01-04,January,190001,1900
5,Friday,1900-01-05,January,190001,1900
6,Saturday,1900-01-06,January,190001,1900
7,Sunday,1900-01-07,January,190001,1900
8,Monday,1900-01-08,January,190001,1900
9,Tuesday,1900-01-09,January,190001,1900
nc -z -v localhost 1972Use netcat, it will tell you if the port is open, if not then it's may be because superserver is not ready
Thank for the feedback.
I think I will continue to use my sunglasses to check the community at night for a while ![]()
Hi @Raj Singh , it does support float even is the readme is not up to date.
If you are looking for an objectscript / embedded python approach Alex Woodhead solution will fit you well.
If you are looking for an python only approach my module may help you.
You are welcome.
And I'm very happy that you find this trick useful. :)
have you tired this python module ?
pip3 install iris-dollar-list
it can convert $list to python list.
Sure you can, for example to retrieve all the patient with an observation based on the code : 8302-2
[FHIR EndPoint]/Patient?_has:Observation:patient:code=8302-2
More info here : https://www.hl7.org/fhir/search.html#has
For the python part have a look at this git :
https://github.com/LucasEnard/fhir-client-python
It's a simple example how to use python client to interact with a FHIR server.
For fhir-py to create the same query use raw search :
https://github.com/grongierisc/fhir-py#raw-parameters
Last but not least, check out our neat implementation of SQL On FHIR aka FHIR SQL Builder
Demo here : https://github.com/grongierisc/iris-fhirsqlbuilder
How to setup a secure connection :
openssl req -x509 -nodes -days 1 -newkey rsa:2048 -subj /CN=* -keyout /irisdev/app/server.key -out /irisdev/app/server.crt
https://docs.intersystems.com/iris20223/csp/docbook/Doc.View.cls?KEY=GTLS_superserver
python3 -m irissqlcli iris://SuperUser:SYS@localhost:33782/USER -c server.crt
If I understand correctly, the trick is to load the "src/gbl/SYS.xml" file that holds the configuration of git-source-control module.
If we create a new file like a BP or a DTL, we still have to add it to the source control module with the UI. Then, if we do so, we have to update the "src/gbl/SYS.xml" file with the new file.
Am I right ?
Great post thanks.
If you want to go further check this git :
I'm not tottaly agree with you.
Imagine you are new to iris, you just wish to play with our SQL engine.
With your proposal, you have to know how to connect to a terminal and know the magic command (zzq, BTW i was not aware of this one) to run a query.
Then, you can't do that remotely or with out SSH.
To finish, with your example, you don't show us how to do it from a Shell.
In my point of view, this app is a game changer.
Let me explain why.
Imagine you have an DDL statement that you want to execute on a database. Example:
File: misc/init.sql
CREATE TABLE test.formation (
name varchar(50) NULL,
room varchar(50) NULL
);
INSERT INTO test.formation
(name, room)
VALUES('formation1', 'salle1');
You can execute this statement in the irissqlcli app by using the following command:
irissqlcli iris://_SYSTEM@localhost:51776/USER -W < misc/init.sql
Before this app, you had to use the terminal to execute this command.
cat <<EOF | iris session iris
do \$SYSTEM.SQL.Schema.ImportDDL("/irisdev/app/misc/init.sql",.log)
if log'="" { write "Error: ",log }
h
EOF
Let's compare the two commands:
| tool | command | comment |
|---|---|---|
| irissqlcli | irissqlcli iris://_SYSTEM@localhost:51776/USER -W < misc/init.sql` | One line, easy to read, eeasy to maintaine |
| terminal | `cat < |
multiple line, arkward to read, hard to maintain, must understand the syntax of the terminal, had to be on the same machine |
One last thing, if I want to extract the data from a table, I can use the following command:
irissqlcli iris://_SYSTEM@localhost:51776/USER -W -e "SELECT * FROM test.formation" --csv
This command will return the following result:
"name","room"
"formation1","salle1"
Try to do the same thing with the terminal ;).
cat <<EOF | iris session iris
do ##class(%SQL.Statement).%ExecDirect(,"SELECT * FROM test.formation").%DisplayFormatted("CSV",,,.filesUsed)
do ##class(%Stream.FileCharacter).%OpenId(filesUsed(1)).OutputToDevice()
h
EOF
Cool, this can be really useful while waiting for OpenTelemetry and SAM.
The big advantage of this, is that you don't need other tool/server/docker.
Wow, easy to use (nice UI) and powerful in it's usage (spec first on OpenAPI 3.0) !
![]()
Hi Yuri,
I confirm this issue, I do encounter the same.
intersystemsdc/iris-community:preview, solve it.
Hi dear community,
If you lack inspiration for the contest, here are some ideas:
A tool to improve the load of DDL or SQL statements in IRIS.
A tool to automatically export objectscript classes to the local folder
Class codeGolf.Pyramid
{
ClassMethod BuildPython(f As %Integer) [ Language = python ]
{
for i in range(f):
print(' ' * (f - i - 1) + '#' * (2 * i + 1))
}
/// Description: Build a pyramid of height f
ClassMethod Build(f As %Integer) As %Status
{
Set sc = $$$OK
For i = 1:1:f {
set space = $tr($j("",f-i)," "," ")
set hash = $tr($j("",2*i-1)," ","#")
Write space_hash, !
}
Return sc
}
}Hi Joe,
The 2 dots syntax is used to access the properties and methods of the current object. You can also use $this to access the current object.
For example, if you have a class called "MyClass" and you have a property called "MyProperty" in that class, you can access the property value by using the following syntax:
User.MyClass Extends EnsLib.BusinessService
{
Property MyProperty;
Method MyMethod()
{
set ..MyProperty = 10;
set $this.MyProperty = 10;
}
}
In your case, you can use the following syntax to access the methods of the EnsLib.File.InboundAdapter class:
User.MyClass Extends EnsLib.BusinessService
{
Parameter ADAPTER = "EnsLib.File.InboundAdapter";
Property Adapter = "EnsLib.File.InboundAdapter";
Method MyMethod()
{
do ..Adapter.AdapterMethod()
do $this.Adapter.AdapterMethod()
}
}
Hope this helps.
My guess is that you try to use some outdated nativeapi drivers. https://github.com/intersystems/quickstarts-multimodel-python <- outdate more than 3 years old I encourage you to use this git for drivers : https://github.com/intersystems-community/iris-driver-distribution
If you are looking for python expérience on IRIS have a look at those git :
BTW : a more complete DB-API and SQL Alchemy support is under development
What do you mean by remove any dependencies whitout removing PWS ?
I don't know if removing PWS will be the definitive answer. If I understand correctly, you want to make it disable by default, and enable it only when you need it. For example with the iris.cpf file.
[Startup]
WebServer=1
WebServerPort=52773
I would like to add the presentation of IRIS and Python that I did at the last IRIS Community Day. Here is the link to the power point. PythonEtIRIS.pptx
I also would like to add that the motivations are for sure breaking down the monolith, but also to make the product more secure. The private web server can be security hole. And removing it is a good step to make the product more secure. Because one of the main entry point for a hacker is the web server.
Just to be clear, the remove of the private web server is just for IRIS and IRIS for Health. IRIS and IRIS for Health community edition still has the private web server.
Then, the question is, what is the cost of this decision for end-developers like most of here.
I would say not that much as you think. The main raison is that most of the developer use the community edition. And the community edition still has the private web server. Then if you have an preinstalled IRIS, you will keep the private server.
The main cost is for the new developer that don't have an preinstalled IRIS and that don't want to use the community edition. I agree that installing a web server is not that easy if you sick on windows. But it is not that hard if you are on Linux or Mac.
For windows developers, may be we can provide simple installer that install a web server and configure it for IRIS.
Now, if we take a step back on the ease of use. I think, this decision is a good one, because it's the first major step of breaking down the monolith. From this point, we can start to make the product more modular. And of course, there is a lot of work to do.
I agree with you that we must improve our client libraries and drivers. Put them in direct distribution, make them more easy to use and with modern features.
This post has been edited to make use of the IRIS Embedded Python Wrapper : https://github.com/grongierisc/iris-embedded-python-wrapper.
The old version :
alias irisvenv="/opt/intersystems/iris/bin/irispython -m venv .venv; rm .venv/bin/python3; ln -s /opt/intersystems/iris/bin/irispython .venv/bin/python3; source .venv/bin/activate;"
Was in fact not working, because of the irispython interpretor that doesn't support venv yet.
To make embedded python works with venv, please use :
alias irisvenv="python3 -m venv .venv; source .venv/bin/activate; pip install https://github.com/grongierisc/iris-embedded-python-wrapper/releases/download/v0.0.1/iris-0.0.1-py3-none-any.whl"
and make sure that the environment variable named IRISINSTALLDIR is pointing to the InterSystems IRIS installation directory.
export IRISINSTALLDIR=/opt/iris
Major update :
Now this module is available on Pypi:
pip3 install iris-pex-embedded-python
Import the ObjectScript classes, open an embedded python shell and run :
from grongier.pex import Utils
Utils.setup()
If the module is not updated, make sure to remove the old version :
pip3 uninstall iris-pex-embedded-python
or manually remove the grongier folder in
or force the installation with pip :
pip3 install --upgrade iris-pex-embedded-python --target <iris_installation>/lib/python/
Just to be clear: in future IRIS installations, the System Management Portal will be unavailable, unless you have a web server installed and configured?
Yes.
For now, the docker community edition will still have an PWS for preserving an out of the box experience.
The docker non community edition will not have an PWS or apache/nginx install. We will provide dockerfile, docker-compose, podman-compose and K8s yaml examples to help you setup an webgateway.