0 Followers · 433 Posts

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write.

Article Muhammad Waseem · Sep 21, 2023 7m read

image

Hi Community,
In this article, I will demonstrate below steps to create your own chatbot by using spaCy (spaCy is an open-source software library for advanced natural language processing, written in the programming languages Python and Cython):

  • Step1: Install required libraries

  • Step2: Create patterns and responses file

  • Step3: Train the Model

  • Step4: Create ChatBot Application based on the trained model

So Let us start.

1
1 3648
Question Victor Castanon · Jul 9, 2024

I'm running into an intermittent issue with some of our Custom Operations/Processes as a result of some large FHIR R4 Binaries. Essentially we get a response from an AthenaHealth FHIR endpoint that appears to be too large to be processed using the IRIS Built In Functions for FHIR:
I've replicated it on the command line here using a file (binary.json) that has the response from the FHIR Endpoint. Not sharing full contents due to PHI concerns.

1
0 151
Announcement Timothy Leavitt · Jun 27, 2022

Hello community,

I'd like to briefly announce three new packages, available on the Open Exchange / through ZPM, that can really help accelerate modern full-stack application development on IRIS. I announced all of these in a Global Summit session last week, but you may have missed it - and I hear there's a full-stack application development contest coming up!

1
1 442
Question Scott Roth · Jul 9, 2024

Using the FHIR DEMO, I have pieced together how to make a FHIR Request using OAuth against an External FHIR Repository. When I execute the Patient search (HS.FHIRServer.Interop.Request), I get a HS.FHIRServer.Interop.Response that has a Quick Stream ID, which I then use to convert the Quick Stream to a JSON Dynamic Object. if I do a trace on the Raw JSON Object, I am able to pull out single elements, however I want to pull the raw JSON into a defined Class Structure. 

I tried using fromDao(dao As %DynamicAbstractObject) As <HS.FHIRModel.R4 subclass> outlined within Working with FHIR Data

2
0 267
Article Guillaume Rongier · Jul 8, 2024 8m read

django_logo

Description

This is a template for an Django application that can be deployed in IRIS as an native Web Application.

Installation

  1. Clone the repository
  2. Create a virtual environment
  3. Install the requirements
  4. Run the docker-compose file
git clone
cd iris-django-template
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
docker-compose up

Usage

The base URL is http://localhost:53795/django/.

Endpoints

  • /iris - Returns a JSON object with the top 10 classes present in the IRISAPP namespace.
  • /interop - A ping endpoint to test the interoperability framework of IRIS.
  • /api/posts - A simple CRUD endpoint for a Post object.
  • /api/comments - A simple CRUD endpoint for a Comment object.

How to develop from this template

See WSGI introduction article: wsgi-introduction.

TL;DR : You can toggle the DEBUG flag in the Security portal to make changes to be reflected in the application as you develop.

Code presentation

The Django application is structured as follows:

  • app - Django project folder
    • app - Django app folder for configuration
      • settings.py - Django settings file
      • urls.py - Django URL configuration file to connect the views to the URLs
      • wsgi.py - Django WSGI file
      • asgi.py - Django ASGI file
    • community - Django app folder for the community app, crud on Post and Comment objects
      • models.py - Django models file for the Post and Comment objects
      • views.py - Django views file to access the Post and Comment objects
      • serializers.py - Django serializers file for the Post and Comment objects
      • admin.py - Django admin file add crud to the admin interface
      • migrations - Django migrations folder to build the database
      • fixtures - Django fixtures folder demo data
    • sqloniris - Django app folder for the SQL on IRIS app
      • views.py - Django views file to query the IRISAPP namespace
      • apps.py - Django app configuration file
    • interop - Django app folder for the interoperability app
      • views.py - Django views file to test the interoperability framework
      • apps.py - Django app configuration file
    • manage.py - Django management file

app/settings.py

This file contains the Django settings for the application.

...

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'community',
    'sqloniris',
    'interop',
    'rest_framework'
]

...

REST_FRAMEWORK = {
    # Use Django's standard `django.contrib.auth` permissions,
    # or allow read-only access for unauthenticated users.
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
    ],
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
    'PAGE_SIZE': 20
}

...

DATABASES = {
    "default": {
        "ENGINE": "django_iris",
        "EMBEDDED": True,
        "NAMESPACE": "IRISAPP",
        "USER":"SuperUser",
        "PASSWORD":"SYS",
    }
}

Few important settings to note:

  • INSTALLED_APPS - Contains the list of installed apps in the Django project.
    • community - The Django app for the CRUD operations on the Post and Comment objects.
    • sqloniris - The Django app for the SQL on IRIS operations.
    • interop - The Django app for the interoperability operations.
    • rest_framework - The Django REST framework for the REST API.
  • REST_FRAMEWORK - Contains the settings for the Django REST framework.
    • DEFAULT_PERMISSION_CLASSES - Only authenticated users can perform CRUD operations.
    • DEFAULT_PAGINATION_CLASS - The pagination class for the REST API.
  • DATABASES - Contains the settings for the IRIS database connection.
    • Here we are using the django_iris engine to connect to the IRIS database.

app/urls.py

This file contains the URL configuration for the Django application.

from django.contrib import admin
from django.urls import path,include
from rest_framework import routers
from community.views import PostViewSet, CommentViewSet
from sqloniris.views import index
from interop.views import index as interop_index

router = routers.DefaultRouter()
router.register(r'posts', PostViewSet)
router.register(r'comments', CommentViewSet)


urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include(router.urls)),
    path('iris/', index),
    path('interop/', interop_index)
]
  • router - Contains the default router for the REST API.
  • routeer.register - Registers the Post and Comment viewsets to the router.
  • urlpatterns - Contains the URL patterns for the Django application.
    • /admin/ - The Django admin interface.
    • /api/ - The REST API for the Post and Comment objects.
    • /iris/ - The SQL on IRIS endpoint.
    • /interop/ - The interoperability endpoint.

app/wsgi.py

This file contains the WSGI configuration for the Django application.

This is the file that we have to provide to IRIS to run the Django application.

In the Security->Applications->Web Applications section, we have to provide the path to this file.

  • Application Name
    • app.wsgi
  • Callable Name
    • application
  • WSGI App directory
    • /irisdev/app/app

community/models.py

This file contains the Django models for the Post and Comment objects.

from django.db import models

# Create your models here.
class Post(models.Model):
    title = models.CharField(max_length=100)
    content = models.TextField()

class Comment(models.Model):
    content = models.TextField()
    post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='comments')
  • Post - The model for the Post object.
    • title - The title of the post.
    • content - The content of the post.
  • Comment - The model for the Comment object.
    • content - The content of the comment.
    • post - The foreign key to the Post object.
    • related_name - The related name for the comments.

community/seializers.py

This file contains the Django serializers for the Post and Comment objects.

Using the Django REST framework, we can serialize the Django models to JSON objects.

from rest_framework import serializers
from community.models import Post, Comment

class PostSerializer(serializers.ModelSerializer):
    class Meta:
        model = Post
        fields = ('id', 'title', 'content', 'comments')

class CommentSerializer(serializers.ModelSerializer):
    class Meta:
        model = Comment
        fields = ('id', 'content', 'post')
  • PostSerializer - The serializer for the Post object.
  • CommentSerializer - The serializer for the Comment object.
  • fields - The fields to be serialized.

community/views.py

This file contains the Django views for the Post and Comment objects.

Using the Django REST framework, we can create CRUD operations for the Django models.

from django.shortcuts import render
from rest_framework import viewsets

# Import the Post and Comment models
from community.models import Post, Comment

# Import the Post and Comment serializers
from community.serializers import PostSerializer, CommentSerializer

# Create your views here.
class PostViewSet(viewsets.ModelViewSet):
    queryset = Post.objects.all()
    serializer_class = PostSerializer

class CommentViewSet(viewsets.ModelViewSet):
    queryset = Comment.objects.all()
    serializer_class = CommentSerializer
  • PostViewSet - The viewset for the Post object.
  • CommentViewSet - The viewset for the Comment object.
  • queryset - The queryset for the viewset.
  • serializer_class - The serializer class for the viewset.

sqloniris/views.py

This file contains the Django views for the SQL on IRIS operations.

from django.http import JsonResponse

import iris

def index(request):
    query = "SELECT top 10 * FROM %Dictionary.ClassDefinition"
    rs = iris.sql.exec(query)
    # Convert the result to a list of dictionaries
    result = []
    for row in rs:
        result.append(row)
    return JsonResponse(result, safe=False)
  • index - The view for the SQL on IRIS operation.
  • query - The SQL query to be executed on the IRIS database.
  • rs - The result set from the query.
  • result - The list of list from the result set.
  • JsonResponse - The JSON response for the view, safe is set to False to allow list of list.

interop/views.py

This file contains the Django views for the interoperability operations.

from django.http import HttpResponse

from grongier.pex import Director

bs = Director.create_python_business_service('BS')

def index(request):
    result = bs.on_process_input(request)
    return HttpResponse(result, safe=False)
  • bs - The business service object created using the Director class.
  • index - The view for the interoperability operation.
  • result - The result from the business service.

NB : we don't use JsonResponse to simplify the code, we can use it if we want to return a JSON object.

Troubleshooting

How to run the Django application in a standalone mode

To run the Django application in a standalone mode, we can use the following command:

cd /irisdev/app/app
python3 manage.py runserver 8001

This will run the Django application on the default port 8001.

NB : You must be inside of the container to run this command.

docker exec -it iris-django-template-iris-1 bash

Restart the application in IRIS

Be in DEBUG mode make multiple calls to the application, and the changes will be reflected in the application.

How to access the IRIS Management Portal

You can access the IRIS Management Portal by going to http://localhost:53795/csp/sys/UtilHome.csp.

Run this template locally

For this you need to have IRIS installed on your machine.

Next you need to create a namespace named IRISAPP.

Install the requirements.

# Move to the app directory
cd /irisdev/app/app

# python manage.py flush --no-input
python3 manage.py migrate
# create superuser
export DJANGO_SUPERUSER_PASSWORD=SYS
python3 manage.py createsuperuser --no-input --username SuperUser --email admin@admin.fr

# load demo data
python3 manage.py loaddata community/fixtures/demo.json

# collect static files
python3 manage.py collectstatic --no-input --clear

# init iop
iop --init

# load production
iop -m /irisdev/app/app/interop/settings.py

# start production
iop --start Python.Production

How to serve static files

To serve the static files in the Django application, we can use the following command:

cd /irisdev/app
python3 manage.py collectstatic

This will collect the static files from the Django application and serve them in the /irisdev/app/static directory.

To publish the static files in IRIS, configure the Security->Applications->Web Applications section.

web_applications

1
0 325
Question Sylvie Greverend · Jul 2, 2024

I use a swagger file and ##class(%REST.API).CreateApplication to create the rest api.

There is an interesting post: https://community.intersystems.com/post/download-file-rest-api-operation, but it is code, not a swagger configuration. disp.cls returns always a header content : application/json that of course fails as I am not always returning a json

I can not figure out what to put in swagger. Some examples I tried:

produces:
- application/pdf
- image/png
responses:
   200:
      schema:
           type: file
responses:
   200:
       schema:
           type: string
           format: binary

Thank you

2
0 200
Question Aman · Jul 2, 2024

Hello Community,

I'm a beginner and currently working on a project to convert CCDA files to FHIR using InterSystems IRIS. I have developed a web form to upload CCDA files, and I'm attempting to convert the uploaded CCDA files to FHIR. However, I am encountering an issue where the conversion process results in an empty entry.
Here's the Output it displays on HTML page:

Size of CCDA Stream: 74152
vR4
{"resourceType":"Bundle","type":"transaction","entry":[]}

Here is my code: CCDtoFHIR.csp

9
0 189
Question Will · Jun 18, 2024

HI,

I'm migration an existing integration to InterSystems.  The upstream (external) system calls a JSON web service hosted in the interface engine, which converts the JSON data received to a HL-7 messages to send to the downstream system. I'm looking for direction and example of how to do the equivalent in InterSystems, so the the upstream system only has to modify the URL of the web service they call.

I suppose in IS we'll need to create a business service that is a RESTful JSON web service? How to access the JSON data (parameters in the web service call) in the Transformation?

Thank you!

W

2
0 342
Question Scott Roth · Jun 27, 2024

IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2024.1 (Build 267_2U) Tue Apr 30 2024 16:06:39 EDT [HealthConnect:7.2.0-1.r1]

I have a use case where Epic is sending an A60 Allergy transaction is set at the Patient level, but we have a system called VIBE which needs the ADT at an Encounter level instead. Currently we store ADT information in a MS SQL database for years, and we are querying it to get the latest Account Number to insert into the ADT^A60 for VIBE.

2
0 211
Question Oliver Wilms · Jun 23, 2024

I am working on JSON and want to be prepared to handle large Objects. I try this code:

ClassMethod MaxLen() As %Status

{

    set longStr=""

    for i=1:1:$SYSTEM.SYS.MaxLocalLength() { set longStr = longStr_"x" }

    write "Maximum string length = "_$LENGTH(longStr)

    ;

    set longObject = {"a":(longStr),"b":(longStr)}

    set file=##class(%File).%New("/tmp/longObjectFile.txt")

    do file.Open("WSN")

    do longObject.%ToJSON(file)

    do file.Close()

    ;

    do file.Open("RS")

    set newObject = {}.%FromJSONFile(file)

    write !,"Property newObject.a is "_$LENGTH(newObject.a)_" characters long."

5
0 325
Question Oliver Wilms · Jun 23, 2024

I have JSON object which contains file references. I need to replace the file reference with base64 encoded file which is up to 10MB.

I tried the following but it did not work as expected:

do dynObj.%Set("data",pStream.ReadLineIntoStream(.tSC))

9
0 188
Article Luis Angel Pérez Ramos · Feb 7, 2024 6m read

In this article we are going to see how we can use the WhatsApp instant messaging service from InterSystems IRIS to send messages to different recipients. To do this we must create and configure an account in Meta and configure a Business Operation to send the messages we want.

Let's look at each of these steps in more detail.

Setting up an account on Meta

This is possibly the most complicated point of the entire configuration, since we will have to configure a series of accounts until we can have the messaging functionality.

Here you can read the official Meta documentation.

1
4 703
Question Pietro Di Leo · Jun 13, 2024

Hello everyone,

Recently, I've been working on a Business Process that processes a large JSON FHIR message containing up to 50k requests in an array within the JSON.

Currently, the code imports the JSON as a dynamic object from the original message stream, obtains an iterator from it, and processes each request one at a time in a loop.

2
0 980
Question Michael Wood · Jun 6, 2024

I have an API that does not have all the data.  Like it is truncated. Magic number of characters seems to be 163,280

I do an <assign> 

context.RawBundle=##class(%DynamicObject).%FromJSON(context.FHIRResponse.Body)

The error does not happen when the response is < 163,280 chars.  And when < 163,280 chars, it is a complete FHIR Bundle.  Have anyone experienced this?  If so, what is the resolution?

2
0 220
Question Thembelani Mlalazi · Jun 3, 2024

I am trying to work with the FHIR Object Model where I convert an incoming  HL7v2 to SDA then FHIR. From here I would like to be able to process the FHIR Object by deserializing it to a Bundle object using the following code my problem is I keep on getting an error  which is not explaining much about what is wrong with what I am doing any help will be appreciated  thanks.

Property FHIRAdapter As HS.JSON.AdaptorFHIR;

Method OnRequest(pRequest As HS.Message.FHIR.Request, Output pResponse As HS.Message.FHIR.Response) As %Status
{

3
0 316
Question Yone Moreno · May 21, 2024

Good morning, 🙂

I would like to ask a question, which has to do with how to manage %GlobalCharacterStream representing JSONS.

Thank you for reading this question, thank you for your help, and thank you for your time and attention.

Specifically, in a certain Process, we were querying 2 Operations, whose response we were converting to a Property called "informesAutorizadosRangoFechas" (reportsAuthorizedInRangeDates) which is %GlobalCharacterStream whose content is a JSON with the same structure.

That is, at a visual level, a concrete example is the following:

5
0 234
Question Florian Hansmann · Feb 27, 2020

Hello Community,

My Intersystems Caché Version: 1.2014 (Can't update now.)

I have the following issue:

I have for example an articlenumber with 15049950, which is numeric. But sometimes it can also be an alphanumeric string like PK15049950.

How can i set numbers always to string in Json Stream with quotes like "15049950".

Code Example:

set object = ##class(%ZEN.proxyObject).%New()

set articlenumber = "15049950"

set object.articlenumber = articlenumber

set x = ##class(%ZEN.Auxiliary.jsonArrayProvider).%WriteJSONStreamFromObject(.json,object)

Will output:

{

 "articlenumber": 15049950

}

but I want always:

{

5
0 416
Question Evgeny Shvarov · Feb 28, 2023

Hi folks!

Researching FHIR bundle transactions.

The idea is that you can post a bundle to a FHIR server with a set of resources. And you can send it as a transaction, so only all the resources will be published or neither.

E.g. I send a bundle of two resources: patient and its observation.

The observation resource should reference an existing patient. But it probably doesn't exist yet on the server and goes within the same bundle. 

For this purpose there is a way to have a temporary id in the bundle, to let resources reference ids.

6
0 552
Question André-Claude Gendron · May 9, 2024

Is there a way to use the %JSON.Adaptor to project readable JSON when a property is defined as a %Integer but with a DISPLAYLIST ? 

Class User.CExampleJSON Extends (%RegisteredObject, %JSON.Adaptor, %XML.Adaptor)
{

Property something As%Integer(DISPLAYLIST = ",OK,Error,Warning", VALUELIST = ",0,1,2") [ InitialExpression = 0 ];ClassMethod RunMe()
{
      set obj = ..%New()
      set obj.something = 2do obj.%JSONExportToString(.string)
      write"JSON : " _ string,!!!

      write"Content  : " _ ..somethingLogicalToDisplay(obj.something),!
}

}
4
0 207
Article Keren Skubach · Jan 22, 2024 2m read

Did you know that you can get JSON data directly from your SQL tables?

Let me introduce you to 2 useful SQL functions that are used to retrieve JSON data from SQL queries - JSON_ARRAY and JSON_OBJECT
You can use those functions in the SELECT statement with other types of select items, and they can be specified in other locations where an SQL function can be used, such as in a WHERE clause

The JSON_ARRAY function takes a comma-separated list of expressions and returns a JSON array containing those values.

11
4 1064
Question Phil Burkhalter · May 1, 2024

I have the JSON message below. I am struggling with parsing the data in the OtherProcedures section. That section can be null, or have from one to many other procedures. Any help is greatly appreciated. I have tried using/setting an iterator to go thru the data but not having any success with that. 

5
0 240
Question Kurro Lopez · Apr 9, 2024

Hi community,

I'm calling to a API that it is retrieving the content of a file as Content of response. I'm catching the binary but I need to convert this Stream to a Base64 string.

I'm trying to convert a %Stream.GlobaBinary to a Base64 string using the following code, but it doesn't work.

do stream1.Rewind()
set response = ""while 'stream1.AtEnd {
    set temp=stream.Read(4000)
    set temp=$system.Encryption.Base64Encode(temp)
    set response = response_temp
}

The content is not correctly converted to Base64

Also, I've tried to convert it as dynamic JSon and get the stream as base64

6
0 602
Question Carl (booz Allen) Deitrich · Mar 5, 2024

We have JSON type data in a Dynamic Object.  Is there a simple way to export / dump that data to a delimited string or file?

e.g.

Results={"ClassA":{"ClassName":"ClassA","ACount":367191880,"BCount":367191880,"CurrentDiff":0,"PreviousDiff":0,"ReportDate":"2024-03-02 00:00:00"}
"ClassB":{"ClassName":"ClassB","ACount":5352149227,"BCount":5352149227,"CurrentDiff":0,"PreviousDiff":0,"ReportDate":"2024-03-02 00:00:00"}}

6
0 454
Question Joe Jones · Mar 17, 2023

Hi Community,

I am trying to read a JSON file and convert into HL7 message.Please find the example below

Set Jsonobj={"Doctype":"ADT^A01","PatientId":"123","PatientName":"Alex"}

Set Dynjsonobj=##class(%Library.DynamicObject).%FromJSON(Jsonobj)

Error :<THROW>%FromJSON+37^%Library.DynamicAbstractObject.1 *%Exception.General READ error while reading input stream 10 Line 1 Offset 0

I am getting this error while reading the file,Can you please tell me where i am doing wrong in converting the file?

Joe

9
0 1191
Announcement Rob Tweed · Mar 26, 2024

You may have heard about our mg-dbx-napi interface for IRIS which provides insanely fast access from Node.js.  If you've been following recent developments in the server-side JavaScript world, you'll be excited to know that mg-dbx-napi also works with Bun.js, the latter proving to be significantly faster than Node.js for many/most purposes.

Of course, if you're a Node.js user, you'll probably wonder how mg-dbx-napi compares with the Native API for Node.js that is included with IRIS.

With all that in mind, we've created a Github repository: mg-showcase

8
2 290