New post

Find

Question
· Feb 3

JSON Parsing Structure Code Update Request

Hello All,

I need help Integrating the vendor-provided code into the current code to check if the data is an array and if it is, iterate through each item using a for each loop. Also, I need to hit every error handler code mentioned at the bottom along with the transform in both instances.

My Current Code:

/// Given a patient number in a JSON string format, this includes required transformations and makes use of 
/// the MPI Query Handler to pull basic demographics from Epic. 
Class CUH.Proc.DCIQGetPatient Extends Ens.BusinessProcessBPL [ ClassType = persistent, ProcedureBlock ]
{

Storage Default
{
<Type>%Storage.Persistent</Type>
}

/// BPL Definition
XData BPL [ XMLNamespace = "http://www.intersystems.com/bpl" ]
{
<process language='objectscript' request='CUH.Mess.DCIQ.JsonIn' response='CUH.Mess.DCIQ.JsonOut' height='3400' width='2000' >
<context>
<property name='JsonObjectIn' type='CUH.Mess.DCIQ.JsonInObj' instantiate='1' />
<property name='HL7QRY' type='EnsLib.HL7.Message' instantiate='0' />
<property name='HL7ADR' type='EnsLib.HL7.Message' instantiate='0' />
<property name='JsonObjectOut' type='CUH.Mess.DCIQ.JsonOutObj' instantiate='1' />
<property name='RequestNumber' type='%String' initialexpression='""' instantiate='0' >
<parameters>
<parameter name='MAXLEN'  value='50' />
</parameters>
</property>
<property name='IsInteger' type='%Boolean' instantiate='0' />
<property name='ProcError' type='%String' initialexpression='""' instantiate='0' >
<annotation><![CDATA[Error message to be sent back in the Response.]]></annotation>
<parameters>
<parameter name='MAXLEN'  value='50' />
</parameters>
</property>
<property name='ValidOriginUrl' type='%String' instantiate='0' >
<parameters>
<parameter name='MAXLEN'  value='100' />
</parameters>
</property>
<property name='ValidContactType' type='%String' instantiate='0' >
<parameters>
<parameter name='MAXLEN'  value='50' />
</parameters>
</property>
<property name='ValidIDNumberType' type='%String' initialexpression='""' instantiate='0' >
<parameters>
<parameter name='MAXLEN'  value='50' />
</parameters>
</property>
<property name='ValidNHSCodeType' type='%String' initialexpression='""' instantiate='0' >
<parameters>
<parameter name='MAXLEN'  value='50' />
</parameters>
</property>
</context>
<sequence xend='200' yend='3150' >
<scope xpos='200' ypos='250' xend='200' yend='2500' >
<annotation><![CDATA[Handles all errors]]></annotation>
<code name='Initialize JSON request' xpos='200' ypos='350' >
<![CDATA[ set context.JsonObjectIn = ##class(CUH.Mess.DCIQ.JsonInObj).%New()
 do context.JsonObjectIn.%JSONImport(request.bodyJson)]]>
</code>
<assign name="Valid URL" property="context.ValidOriginUrl" value="##class(Ens.Util.FunctionSet).Lookup(&quot;CUH.DCIQToEpic.OriginUrl&quot;,$NAMESPACE,&quot;&quot;,3)" action="set" xpos='200' ypos='450' >
<annotation><![CDATA[Environment specific]]></annotation>
</assign>
<assign name="Valid ContactType" property="context.ValidContactType" value="##class(Ens.Util.FunctionSet).Lookup(&quot;CUH.DCIQToEpic.ContactType&quot;,$NAMESPACE,&quot;&quot;,3)" action="set" xpos='200' ypos='550' >
<annotation><![CDATA[Environment specific]]></annotation>
</assign>
<assign name="Valid IDNumberType" property="context.ValidIDNumberType" value="##class(Ens.Util.FunctionSet).Lookup(&quot;CUH.DCIQToEpic.IDNumberType&quot;,$NAMESPACE,&quot;&quot;,3)" action="set" xpos='200' ypos='650' >
<annotation><![CDATA[Environment specific]]></annotation>
</assign>
<assign name="Valid NHSCodeType" property="context.ValidNHSCodeType" value="##class(Ens.Util.FunctionSet).Lookup(&quot;CUH.DCIQToEpic.NHSCodeType&quot;,$NAMESPACE,&quot;&quot;,3)" action="set" xpos='200' ypos='750' >
<annotation><![CDATA[Environment specific]]></annotation>
</assign>
<if name='Check OriginUrl' condition='context.JsonObjectIn.meta."origin_url"=context.ValidOriginUrl' xpos='200' ypos='850' xend='200' yend='2250' >
<true>
<if name='Check Contact Type' condition='(context.JsonObjectIn.data."0"."con_type"=context.ValidContactType)||(context.JsonObjectIn.data."con_type"=context.ValidContactType)' xpos='470' ypos='1000' xend='470' yend='2150' >
<true>
<if name='Check idNumber Type' condition='(context.JsonObjectIn.data.idNumbers.GetAt(1).type)=context.ValidIDNumberType' xpos='740' ypos='1150' xend='740' yend='2050' >
<true>
<assign name="Get Request Number" property="context.RequestNumber" value="context.JsonObjectIn.data.idNumbers.GetAt(1).number" action="set" xpos='1010' ypos='1300' />
<code name='Integer pattern' xpos='1010' ypos='1400' >
<![CDATA[ set context.IsInteger = ((context.RequestNumber)?.N)]]>
</code>
<if name='Integer?' condition='context.IsInteger' xpos='1010' ypos='1500' xend='1010' yend='1950' >
<annotation><![CDATA[Checks if Requested Number sent is an Integer]]></annotation>
<true>
<transform name='Create HL7 query' class='CUH.Tran.GetDCIQJsonPatientToEpicQRYQ011' source='context.JsonObjectIn' target='context.HL7QRY' xpos='1280' ypos='1650' />
<call name='Send to MPIQueryHandler' target='MPI Query Handler' async='0' xpos='1280' ypos='1750' >
<request type='EnsLib.HL7.Message' >
<assign property="callrequest" value="context.HL7QRY" action="set" />
</request>
<response type='EnsLib.HL7.Message' >
<assign property="context.HL7ADR" value="callresponse" action="set" />
</response>
</call>
<transform name='Converts HL7 to JSON' class='CUH.Tran.EpicADRA19ToDCIQJsonPatient' source='context.HL7ADR' target='context.JsonObjectOut' xpos='1280' ypos='1850' />
</true>
<false>
<assign name="Error No Number" property="context.ProcError" value="&quot;MRN needs to be a positive numeric value&quot;" action="set" xpos='1010' ypos='1650' />
</false>
</if>
</true>
<false>
<assign name="Error idNumber Type" property="context.ProcError" value="&quot;Invalid idNumber Type&quot;" action="set" xpos='740' ypos='1300' />
</false>
</if>
</true>
<false>
<assign name="Error Contact Type" property="context.ProcError" value="&quot;Invalid Patient Contact Type&quot;" action="set" xpos='470' ypos='1150' />
</false>
</if>
</true>
<false>
<assign name="Error Origin Url" property="context.ProcError" value="&quot;Origin URL not authorized!&quot;" action="set" xpos='200' ypos='1000' />
</false>
</if>
<faulthandlers>
<catchall xpos='200' ypos='2350' xend='200' yend='350' >
<assign property="context.ProcError" value="&quot;Error in the Json/HL7 conversion/transformation block&quot;" action="set" xpos='200' ypos='250' />
</catchall>
</faulthandlers>
</scope>
<assign name="Assign Error to Response" property="context.JsonObjectOut.errors" value="context.ProcError" action="set" xpos='200' ypos='2600' />
<if condition='context.JsonObjectOut.errors&apos;=""' xpos='200' ypos='2700' xend='200' yend='3050' >
<annotation><![CDATA[Check if any errors]]></annotation>
<true>
<trace name='Log the Error' value='context.JsonObjectOut.errors' xpos='470' ypos='2850' />
<assign name="Returns {}" property="response.bodyJson" value="&quot;{}&quot;" action="set" xpos='470' ypos='2950' />
</true>
<false>
<code name='Returns Valid Response' xpos='200' ypos='2850' >
<![CDATA[ set temp = ##class(CUH.Mess.DCIQ.JsonOut).%New()
 do context.JsonObjectOut.%JSONExportToString(.temp)
 set response.bodyJson = temp]]>
</code>
</false>
</if>
</sequence>
</process>
}

}

Vendor Provided Code Snippet:

<code name='Initialize JSON request' xpos='200' ypos='350' >
<![CDATA[
set context.JsonObjectIn = ##class(CUH.Mess.DCIQ.JsonInObj).%New()
do context.JsonObjectIn.%JSONImport(request.bodyJson)
]]>
</code>

<code name='Determine Data Structure' xpos='200' ypos='450' >
<![CDATA[
set context.IsArrayData = $isobject(context.JsonObjectIn.data) && context.JsonObjectIn.data.%IsArray()
]]>
</code>

<if name='Check OriginUrl' condition='context.JsonObjectIn.meta."origin_url"=context.ValidOriginUrl' xpos='200' ypos='850' xend='200' yend='2250' >
<true>
<if name='Check Data Structure' condition='context.IsArrayData' xpos='470' ypos='950' xend='470' yend='2050' >
<true>
<foreach name='Iterate Data Array' collection='context.JsonObjectIn.data' xpos='740' ypos='1050' >
    <if name='Check Contact Type in Array' condition='(item."con_type"=context.ValidContactType)' xpos='1010' ypos='1150' xend='1010' yend='1950' >
        <true>
        <foreach name='Iterate idNumbers Array' collection='item."idNumbers"' xpos='1280' ypos='1250' >
            <if name='Check idNumber Type' condition='(subitem."type"=context.ValidIDNumberType)' xpos='1550' ypos='1350' >
                <true>
                <assign name="Get Request Number" property="context.RequestNumber" value="subitem."number"" action="set" xpos='1820' ypos='1450' />
                <code name='Integer pattern' xpos='1820' ypos='1550' >
                <![CDATA[ set context.IsInteger = ((context.RequestNumber)?.N)]]>
                </code>
                </true>
            </if>
        </foreach>
        </true>
    </if>
</foreach>
</true>
<false>
<if name='Check Contact Type in Object' condition='(context.JsonObjectIn.data."0"."con_type"=context.ValidContactType)||(context.JsonObjectIn.data."con_type"=context.ValidContactType)' xpos='470' ypos='1050' >
    <true>
    <if name='Check idNumber Type' condition='(context.JsonObjectIn.data.idNumbers.GetAt(1).type)=context.ValidIDNumberType' xpos='740' ypos='1150' >
        <true>
        <assign name="Get Request Number" property="context.RequestNumber" value="context.JsonObjectIn.data.idNumbers.GetAt(1).number" action="set" xpos='1010' ypos='1250' />
        <code name='Integer pattern' xpos='1010' ypos='1350' >
        <![CDATA[ set context.IsInteger = ((context.RequestNumber)?.N)]]>
        </code>
        </true>
    </if>
    </true>
</if>
</false>
</if>
</true>
</if>

Any help would be appreciated.

Thank you!

Discussion (0)1
Log in or sign up to continue
Article
· Feb 3 2m read

Test des fonctionnalités FOREIGN SERVER et FOREIGN TABLE

Bonjour ! J'ai étendu mon référentiel de démonstration, andreas5588/demo-dbs-iris, pour faciliter le test des fonctionnalités FOREIGN SERVER et FOREIGN TABLE dans IRIS.

Pour y parvenir, j'ai créé un espace de noms appelé FEDERATION. L'idée est la suivante :

  1. Configurez des connexions JDBC pour chaque espace de noms.
  2. Créez un FOREIGN SERVER dans l'espace de noms FEDERATION pour chaque connexion.
  3. Définissez une FOREIGN TABLE au moins pour une table basée sur chaque serveur étranger.

Le script :  demo-dbs-iris/src/sql/02_create_foreign_server.sql

IRIS ne prend pas en charge l'exécution d'instructions SQL qui combinent des tables de différents espaces de noms. Pour remédier à cette limitation, cet espace de noms fédéré exploite le concept de création de serveurs étrangers pour inclure d'autres espaces de noms. En définissant des tables étrangères, il devient possible de combiner de manière transparente des tables entre des espaces de noms, ce qui permet aux utilisateurs d'écrire des instructions SQL qui unifient les données en une seule requête. Cet espace de noms est utilisé pour explorer cette fonctionnalité, sert de démonstration pratique de cette capacité, montrant comment l'explorer et l'utiliser.

Exécutez ce conteneur de démonstration directement via :

docker pull andreasschneiderixdbde/demo-dbs-iris:latest

Après cela, vous pouvez faire des requêtes comme celle-ci :

Amusez-vous à tester et à améliorer la démo

Discussion (0)1
Log in or sign up to continue
Question
· Feb 3

To configure VSCode as Studio for Intersystems

Hello All,

 I'm new to InterSystems, just wanted to check if we can configure the Visual Studio code to use it as Studio for Intersystems development. I tried following the instructions in few posts but nothing worked. Please  guide me to setup this

3 Comments
Discussion (3)4
Log in or sign up to continue
Job
· Feb 3

Vacante: Especialista en Aplicaciones - Químico Farmacéutico

¡Hola Comunidad!

Os dejamos una oferta interesante para una vacante en InterSystems:

Como especialista en aplicaciones HIS con enfoque en gestión de medicamentos, desempeñará un rol estratégico en la implementación, configuración y soporte de los sistemas de información hospitalario (HIS). Su principal responsabilidad será garantizar la eficacia, seguridad y cumplimiento normativo en la gestión integral del ciclo de medicación optimizando el proceso desde la prescripción hasta la administración y asegurando el uso efectivo de la tecnología.

Ubicación: Santiago.

Enlace para aplicar con toda la información: https://www.intersystems.com/careers/careers-search/?gh_jid=6072943003

Discussion (0)1
Log in or sign up to continue
Digest
· Feb 3

Resumen de la Comunidad de Desarrolladores, enero 2025

¡Hola!

¿No habéis podido entrar en la Comunidad todo lo que queríais este mes? ¡No pasa nada! Os traemos un resumen de este mes de enero.

Estadísticas generales
✓ publicaciones nuevas:
 19 artículos
 12 anuncios
 2 nuevas preguntas
Publicaciones populares
Autores populares
Artículos
#InterSystems IRIS
Obtened vuestro código a través de ODBC/JDBC.
Por Jose-Tomas Salvador
¿Por qué son importantes Docker, IPM y ObjectScript Quality?
Por Luis Angel Pérez Ramos
Creando un cliente REST para obtener canciones de la API REST de Spotify - Parte 1: Comprobad el token
Por Ricardo Paiva
Eliminar clases borradas después de una importación
Por Alberto Fuentes
Carga de archivos Parquet en IRIS
Por Joel Espinoza
QuinielaML - Predicción de la 34ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
Encontrad valores desde texto y mostradlos
Por Jose-Tomas Salvador
Conectando IRIS a SQL Server mediante una conexión ODBC
Por Arsh Hasan
QuinielaML - Predicción de la 36ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
¿Qué versión tiene mi imagen?
Por Ricardo Paiva
Probando la función FOREIGN SERVER y FOREIGN TABLE
Por Luis Angel Pérez Ramos
Destacados de Interoperabilidad HTTP 2024.3 - Nuevos Ajustes de OAuth 2.0 para Salidas
Por Jose-Tomas Salvador
QuinielaML - Predicción de la 38ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
IoP: Soporte DTL para Mensajes y JsonSchema
Por Alberto Fuentes
Conexión de JDBC a MS Azure SQL a través de Microsoft Entra y autenticación con contraseña de Active Directory
Por Ricardo Paiva
QuinielaML - Predicción de la 40ª jornada de la Quiniela
Por Luis Angel Pérez Ramos
 
#Documentación
 
#HealthShare
 
#InterSystems IRIS for Health
 
Anuncios
#InterSystems IRIS
 
#Comunidad de Desarrolladores Oficial
 
#Portal de Formación
¿Qué aprenderéis en 2025?
Por Kristina Lauer
 
#Oferta de empleo
Vacante: Ingeniero/a de IRIS
Por Sergio Farago
 
#Portal de ideas de InterSystems
 
#IRIS contest
 
#Open Exchange
 
#Otro
 
Preguntas
#InterSystems IRIS for Health
¿Índice en campo TimeStamp, o mejor en Date?
Por Laura Blázquez García
Aprende FHIR como nunca antes
Por Jose-Tomas Salvador
 
enero, 2025Month at a GlanceInterSystems Developer Community