検索

記事
· 2025年2月23日 4m read

Creating FHIR responses with IRIS Interoperability production

When we create a FHIR repository in IRIS, we have an endpoint to access information, create new resources, etc. But there are some resources in FHIR that probably we wont have in our repository, for example, Binary resource (this resource returns a document, like PDF for example).

I have created an example that when a Binary resource is requested, FHIR endpoint returns a response, like it exists in the repository. 

First of all, we need a Namespace and a FHIR endpoint. After this, we need to configure an Interoperability production that will be connected to the FHIR endpoint. This production must have this items:

  • Business Operations:
    • HS.Util.Trace.Operations (in fact this is optional, but can be very useful)
    • HS.FHIRServer.Interop.Operation, with TraceOperations property set to *FULL*
  • Business Service:
    • HS.FHIRServer.Interop.Service, with TraceOperations property set to *FULL* and Target Config Name set to HS.FHIRServer.Interop.Operation name

This is how production looks like:

After creating this production, we need to connect it with the FHIR endpoint. So edit FHIR endpoint and set the parameter Service Config Name with the name of the Business Service:

Now, if we start to send requests to FHIR repository, we will see all the traces in Message Viewer:

Now we can have a Business Process to control what to do with specific paths.

In this example we have a Business Process that receives every request (now the Business Service it's connected to this Business Process, instead of the Business Operation) and 2 new Business Operation that makes another actions that will be explained later:

Let's take a look to the Business Process called FHIRRouter:

If we take a look, we will see that, if RequestPath contains "Binary/", then we will do something with this request: generate our custom Binary response. Otherwise, we will send the request to FHIR Repository directly.

Let't take a look at the sequence called "Generate Binary":

First of all, we create a new instance of HS.FHIRServer.Interop.Response. And we get the document ID from the Request Path. How? Every time someone want's a Binary resource, it must be requested with the ID of the document in the URL path, something like this: ..../fhir/r4/Binary/XXXXX. So we extract the document ID from the Request Path with this expression:

$Replace(request.Request.RequestPath,"Binary/","")

(It's not very elegant, but it works).

If we have a document ID, then we make a call to a Business Operation called Find to find the filename associated to that document ID:

In fact, this Business Operation Find always returns the same filename:

It's an example of what we can do.

If we have a filename, then, we call another Business Operation called File to get this file content, encoded in base64:

And finally, we can return 2 kind of responses:

  • If we don't have file content (because we don't have a document ID or we don't find it's associated filename or content), we return a 404 response, with this custom response:
 set json = {
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "error",
            "code": "not-found",
            "diagnostics": "<HSFHIRErr>ResourceNotFound",
            "details": {
                "text": "No resource with type 'Binary'"
            }
        }
    ]
 }
 set json.issue.%Get(0).details.text = json.issue.%Get(0).details.text_" and id '"_context.docId_"'"
 set qs = ##class(HS.SDA3.QuickStream).%New()
 do qs.Write(json.%ToJSON())
 set response.QuickStreamId = qs.%Id()
 set response.ContentType = "application/fhir+json"
 set response.CharSet = "UTF-8"
  • If we have file content, then we return a 200 response with this custom response:
 set json = {
  "resourceType": "Binary",
  "id": "",
  "contentType": "application/pdf",
  "securityContext": {
    "reference": "DocumentReference/"
  },
  "data": ""
 }
 set json.id = context.docId
 set json.securityContext.reference = json.securityContext.reference_json.id
 set json.data = context.content.Read(context.content.Size)
 
 set qs = ##class(HS.SDA3.QuickStream).%New()
 do qs.Write(json.%ToJSON())
 set response.QuickStreamId = qs.%Id()
 set response.ContentType = "application/fhir+json"
 set response.CharSet = "UTF-8"

The key here is to create a HS.SDA3.QuickStream, that contains the JSON object. And add this QuickStream to the response.

And now, if we test our endpoint, if we request of a Binary document, we will see the response:

And if we request a Binary document that doesn't exist (you can test it passing no document ID), we will see 404 response:

In summary, connecting our FHIR endpoint with interoperability we can do whatever we want, with all the capabilities of InterSystems IRIS.

5 Comments
ディスカッション (5)2
続けるにはログインするか新規登録を行ってください
質問
· 2025年2月21日

SQL Table - Data Cleanup

Hi Community,

I've created a method in my File Service to do a cleanup for every file load. Currently, I've set it to delete data when LastUpdated date is greater than maxdate. However, I want to do a cleanup for every new file load. Any suggestions or advice on how to do this? Thanks!

 

Method Cleanup()
{

   Set tMaxDate = ""
   &SQL(SELECT Max(LastUpdated) into :tMaxDate
   FROM MC_Table_Data.Patient) 
 

   &SQL(DELETE MC_Table_Data.Patient WHERE LastUpdated<:tMaxDate)
}

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
記事
· 2025年2月21日 4m read

Controlando o IRISTEMP: Pare de Deixar Que Ele Ocupe Todo o Seu Armazenamento!

Introdução: Quando o IRISTEMP Armazena Dados Demais

Então, você verificou seu servidor e viu que o IRISTEMP está crescendo demais. Não precisa entrar em pânico. Vamos investigar o problema antes que seu armazenamento acabe.

Passo 1: Confirmar o Problema de Crescimento do IRISTEMP

Antes de assumir que o IRISTEMP é o problema, vamos verificar seu tamanho real.

Verificar o Espaço Livre

Execute o seguinte comando no terminal IRIS:

%SYS>do ^%FREECNT

Quando solicitado, digite:

Database directory to show free space for (*=All)? /<your_iris_directory>/mgr/iristemp/

Se a saída mostrar muito pouco espaço livre, o IRISTEMP está enchendo seu armazenamento como um armário superlotado. Mas se o espaço livre estiver bom, mas o arquivo de banco de dados IRISTEMP (IRIS.DAT) ainda for enorme (que é provavelmente por isso que você está aqui), significa que os dados temporários já foram limpos. Nesse caso, sua missão é ficar de olho nas coisas, seguir os passos abaixo para pegá-lo em flagrante na próxima vez e recuperar esse espaço precioso.

Passo 2: Identificar o que está usando o IRISTEMP

Execute ^%GSIZE para encontrar Globais Grandes

%SYS>do ^%GSIZE

Siga as instruções:

Directory name: /<your_iris_dir>/mgr/iristemp/

All Globals? No => yes

33 items selected from
33 available globals

1) Get exact packing details
2) Get block counts only
3) Use fast stochastic estimate

Please select an option:  3 => 3

Exemplo de saída:

        Global              Blocks          Bytes Used Packing
      ----------- ---------------- ------------------- -------
      IRIS.Temp.Ensemble
                                1                  60      1 %
      IRIS.Temp.MARIO
                               50             360,960     88 %
      IRIS.Temp.RecompileInfo
                                1                  84      1 %

Se você vir algo desconhecido, especialmente relacionado a ISC ou SQL, pode ser que consultas SQL estejam usando muito espaço. Verifique com os desenvolvedores do aplicativo para ver o que essas consultas estão fazendo e se elas podem ser otimizadas. Às vezes, adicionar um índice ou remover uma cláusula ORDER BY desnecessária pode fazer uma grande diferença.

Passo 3: Verificar Globais Privadas de Processo (PPGs)

Globais Privadas de Processo (PPGs) podem não ser liberadas corretamente por alguns processos. Execute:

%SYS>DO ^GETPPGINFO

Exemplo de saída:

%SYS> DO ^GETPPGINFO("*")
Process ID: 303 --> Total PPG Block count 10840
  ^||%t uses 10838 blocks (maxblock #1926355)
  ^||TempQuery uses 2 blocks (maxblock #115489)
  Highest block #: 1926355
Process ID: 33456 --> Total PPG Block count 45343
  ^||MARIOtest uses 45343 blocks (maxblock #1927313)
  Highest block #: 1927313

Se um processo estiver usando muito espaço de PPG, ele pode estar travado ou não funcionando como esperado. Você deve investigar com os desenvolvedores do aplicativo para verificar se os PPGs são conhecidos e se há algo quebrado no código. Da mesma forma, se o PPG não for conhecido e parecer código interno da InterSystems (por exemplo, ^||%t), é melhor você abrir um caso de suporte WRC pedindo ajuda.

Torne-se um especialista em GETPPGINFO lendo a documentação oficial.

Passo 4: Corrigir o Problema

Opção 1: Parar o Processo

Uma vez que você identificou o processo consumindo o IRISTEMP, se você sabe o que ele está fazendo e considera seguro, você pode usar o Portal de Gerenciamento do Sistema ou o terminal para pará-lo. Do terminal, você pode encontrar o trabalho e terminá-lo:

%SYS>do ^JOBEXAM

Encontre o número do trabalho e execute:

%SYS>DO ^RESJOB
 
Force a process to quit InterSystems IRIS
 
Process ID (? for status report): 7732

Process ID (? for status report):
 
%SYS>

⚠️ Pare um processo apenas se você o conhecer e tiver certeza de que é seguro fazê-lo!

Opção 2: Reiniciar o IRISTEMP e Definir Limites

Para limpar o IRISTEMP, pare o Iris, remova seu arquivo IRIS.DAT e reinicie:

iris stop <instance_name>
rm /<iris_directory>/mgr/iristemp/IRIS.DAT
iris start <instance_name>

Para impedir que ele cresça demais, defina um limite na sua configuração do IRIS:

[Startup]
MaxIRISTempSizeAtStart=5000

Consulte a documentação oficial sobre MaxIRISTempSizeAtStart para obter mais detalhes. Além disso, há outros artigos com mais detalhes na comunidade: Como Reduzir o IRISTEMP

Opção 3: Versão antiga? Atualize!

Se você estiver executando uma versão antiga do Iris, atualize! Por exemplo, lembro-me de termos corrigido um bug na versão 2021.1.1+ onde o IrisTemp podia crescer descontroladamente. Atualizar e estar nas versões de manutenção mais recentes é a melhor maneira de evitar bugs conhecidos.

Conclusão: Mantenha o IRISTEMP Sob Controle

Seguindo estes passos, você pode:
✅ Encontrar o que está usando o IRISTEMP com ^%GSIZE e ^GETPPGINFO
✅ arar processos conhecidos que ocupam muito espaço PPG
✅ ecuperar o espaço definindo limites ou recriando o banco de dados IrisTemp.

Atualizar! Isto é sempre recomendado!

Ao fazer isto, você pode manter o IRISTEMP sob controle e evitar problemas de armazenamento. 🚀

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
質問
· 2025年2月21日

Problem sending Mail via smtp-mail.outlook.com / OAUTH2 as SMTP or JSON

Hi,

I do have the problem to send mails to outlook after getting the new OAUTH2 token. 

 I have no problem getting the token, but after I got the token I try to send the mail thru smtp but authorization failed , please see my try to send the token thru the %Net.Authenticator mechanism %Net.SASL.XOAUTH2

Is this ok?

Or is there an other method to authenticate using the needed bearer method instead of user/pwd with the authenticator? 

 

 ....code to get the token is working..

...   set s=##class(%Net.SMTP).%New()
    
    set m=##class(%Net.MailMessage).%New()
    
    set auth=##class(%Net.Authenticator).%New() 
    set auth.UserName="user@..."
    
    set meth=##class(%Net.SASL.XOAUTH2).%New()
    set meth.MechanismName="XOAUTH2"
    set meth.AccessToken=".....the token i got from Microsoft....sadfsafasdfasdfasdfasdfsdfs...."
    
    set auth.Mechanism=meth

    set auth.ServiceName="smtp"
    
    set s.authenticator=auth
    set s.port=587
    set s.SSLConfiguration="ISC.FeatureTracker.SSL.Config"
    set s.UseSTARTTLS=1

           
    set m.Subject=SUBJECT                     
    set m.Charset="iso-8859-1"
    set m.IsHTML=1
    ...etc all other smtp properties....
    

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
記事
· 2025年2月21日 3m read

How to shoot a good video for the article contest bonus - Part 3 What to consider during editing

Hello Community:

Let's go with the last article on how to record yourselves for the Article Contest video bonus.

I'm not going to go into how to do very specific things in editing because it varies depending on the program you use. The keyboard shortcuts and menus are different, but the concept is the same. You are going to use a programme to organise the recorded material, remove the excess and give it structure. Many of these softwares are free (Capcut, Canva and if I'm not mistaken DaVinci had a free version). I've been editing with Adobe Premiere for almost ten years now (wow, I'm getting old), so if you have any questions about this software, feel free to write to me.

Here are some concrete tips:

ORGANISE YOURSELF AND GET ALL THE MATERIAL BEFORE YOU START

This is the advice of years of work. Once you open the programme it's non-stop editing (until dinner time, that is). I'm a fan of doing things one at a time, so the first thing to do is to collect all the material. Once you have everything organised in folders on your computer: music, video clips, screenshots? open the programme and get started.

THE SCRIPT IS YOUR FRIEND AGAIN

Let's remember the importance of structure. Doing a quick read through of the script again is worthwhile. Remember: an introduction with a hook, a step-by-step development and a closing that answers the question of the introduction. Now is the time to execute it.

REMOVE WITHOUT FEAR. ELIMINATES NOISE.

One thing you realise over time is that you think everything you've recorded is worthwhile. This is often not correct. Take away without fear. It has to be fluid, dynamic. Remove a 5-second pause if you're silent thinking about how to say something. If you can't be seen on camera while you're speaking, you can remove the noises and mumbling, i.e. cut the audio track so that everything is much cleaner.

A question that may help you: does this part really interest whoever is watching the video? If not, remove it. If it doesn't, remove it. I'm not talking about gags or jokes, I'm talking about redundancies, silences or loading times.

FREE IMAGE LIBRARIES

Have you thought about it? There are free image libraries where you can take images to make your video more attractive. Be careful because in the small print it usually says that you have to mention where the images have been taken from. Here are some of them:

BALANCED MUSIC AND AUDIO

This is an important point. Adding music will add a layer of depth and relax the viewer. It is important that it does not cover your voice. You can find free music in libraries, just like in the images.

CHECK IT BEFORE EXPORTING

Do not be overconfident. Before exporting, take a look at it. Give it a play. It will save you time. It has already happened to me many times that I have had to open the programme again and change things because I said ‘I'll export and I'll check it later’. It's not the most efficient thing to do.


This concludes the tips for the video bonus. I wish you all the best of luck in the English contest and I encourage you to keep the Spanish contest in mind in May.

See you soon :)

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください