#Code Snippet

6 Followers · 302 Posts

Code snippet is a programming term for a small region of re-usable source code, machine code, or text.

Question Yone Moreno · May 12, 2023

Good morning,

I was wondering:

Given the following scenario where we have a string where each two items are being splitted by "|" as follows: "squadName|initialLetter"

"Alfa|A|Bravo|B|Charlie|C|Delta|D|Echo|E|Foxtrot|F|Golf|G|Hotel|H|India|I|Juliett|J|Kilo|K|Lima|L|Mike|M|November|N|Oscar|O|Papa|P|Quebec|Q|Romeo|R|Sierra|S|Tango|T|Uniform|U|Victor|V|Whiskey|W|X-ray|X|Yankee|Y|Zulu|Z"

And we would need to generate a String structure like:
 

[
    {
        "number": "number 1",
        "squad": "Alfa",
        "answer": [
            {
                "initialLetter": "A"
            }
4
0 395
Question Yone Moreno · May 24, 2023

Hello,

We currently have the following scenario: We have a bussiness SOAP Operation, where we get a SAML String and we convert it into a %SAML.Assertion object correctly.

👩‍💻👨‍💻 We would need to send the SAML Assertion inside the SOAP Header to the Target System.

First of all thanks for reading, and thanks for answering.

We currently have opened Log Soap and we do not observe it being added to the SOAP Header, as you would observe in the following Log Soap:

05/24/2023 08:53:37 *********************
Output from Web client with SOAP action = urn:ihe:iti:2007:CrossGatewayQuery
<?xml version="1.0" en
1
0 294
Question Yone Moreno · May 22, 2023

Good afternoon,

first thank you from heart and mind, mind and heart; for reading, thinking, reflecting, responding, and above all explaining a possible solution and/or documentation to address this doubt.

We would need a way to get inside a SOAP Web Service the SAML Assertion, and then, send it directly to the endpoint throught a SOAP Operation.

Currently we have researched and developed how to get the SAML Assertion with the following code:

Class Servicios.RESNS.ConsultaRecetas Extends EnsLib.SOAP.Service [ ProcedureBlock ]
{

/// This is the namespace used by the ServiceParameter NAMESPACE
1
0 442
Question Punit · Apr 24, 2023

I have a %GlobalBinaryStream object that I'm trying to save as a local file after being received through a SOAP Web Service.

To do this, I created a %Stream.FileBinary object and wanted to set where the stream copied to this object would be saved by using either the DefaultStreamDir() ClassMethod or the NewFileName() ClassMethod. However, the documentation isn't very helpful on how to use these ClassMethods.

Right now, I have the below code:

set localStream = ##class(%Stream.FileBinary).%New()
set st = localStream.CopyFromAndSave(file) /// file is the %GlobalBinaryStreamObject
4
0 335
Article Benjamin Thorne · Jul 17, 2018 1m read

The following code snippet uses GZIP to compress/decompress a file. Choose a file by specifying a file path in the "filename" variable.


Class objectscript.GZIP Extends %RegisteredObject
{
	classmethod test() {
		//Export Global(s) uncompressed
		set filename="C:\Temp\myglobal.xml"
		do $System.OBJ.Export("^oddEXTR.gbl",filename)
		//Open exported Globals
		set uncompressed = ##class(%FileBinaryStream).%New()
		set uncompressed.Filename=filename
		Set compressed = "C:\temp\mycomglobal.xml"
		//Open File Device over Gzip and Copy Uncompressed information to it
		Open
6
1 2391
Article Jeff Morgan · Oct 21, 2016 3m read

This article will describe and include an example of how to embed an external PDF file into an HL7 segment, specifically ADT_A01:2.3.1 OBX().  This can be useful when attempting to insert pictures or other external data into an HL7 message.  In this example, the name of the PDF file to be embedded is provided in the incoming HL7 message in OBX(1):ObservationValue field.


The basic stipulations for this example are as follows:

  1. Accept a PDF file
  2. Accept an HL7 message
  3. Using the name of the PDF file, embed the PDF data into the HL7 message
  4. Output the message to file

  

Using

4
6 15868
Article Kyle Baxter · Jul 19, 2016 2m read

Date range queries going too slow for you?  SQL Performance got you down?  I have one weird trick that might just help you out! (SQL Developers hate this!)*

If you have a class that records timestamps when the data is added, then that data will be in sequence with your IDKEY values - that is, TimeStamp< TimeStampif and only if ID1 < IDfor all IDs and TimeStamp values in table - then you can use this knowledge to increase performance for queries against TimeStamp ranges.  Consider the following table:

Class User.TSOrder extends %Persistent 
{ 

Property TS as %TimeStamp;

Property
9
1 30732
Question Yone Moreno · Dec 1, 2022

Hello, first of all thanks for your time and help.

We do send from a REST POST request using SoapUI software, an "Authorization Bearer".

POST http://[IP]:[Port]/aplicaciones/scs/informescctest/Servicios.SOAP.InformesCConcertadosv01r00.cls HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/xml
Authorization: Bearer eyJ0e[...]
SOAPAction: http://SCS.Servicios/InformesCConcertadosv01r00/ResultadosER7
Content-Length: 1871
Host: AAA
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

Our mission is to get it inside a SOAP Service.

The Service's ADAPTER is:

Parameter ADAPTER = "

1
0 392
Question Yone Moreno · Nov 25, 2022

Good morning,

We have been investigating how to activate a Server to Generate Tokens and an associated Resource Server to Validate the Token. This step, actually we have found out with the invaluable support of @Alberto Fuentes from Intersystems.

Then the need is as follows: To centralize in 1 single Environment ( PREPRODUCTION ) and in 1 single Namespace the Resource Server ( for example in a dedicated NAMESPACE called AUTHSERVER ) ; we would need somehow to "call", "invoke", "communicate" from the other environments ( for example INTEGRATION ) with the PREPRODUCTION Resource Server in order

1
0 396
Discussion Eduard Lebedyuk · Nov 9, 2022

We're back with a code golf!

You will receive a string. Each word in the string will contain a number. This number is the position that word should have in the sentence. If the input string is empty, return an empty string. The output can only be in words, without the given numbers.

##Input "i2s T1his Te4st a3"

##Output This is a Test

13
0 697
Article Timothy Leavitt · May 12, 2016 6m read

The topic of for/while loop performance in Caché ObjectScript came up in discussion recently, and I'd like to share some thoughts/best practices with the rest of the community. While this is a basic topic in itself, it's easy to overlook the performance implications of otherwise-reasonable approaches. In short, loops iterating over $ListBuild lists with $ListNext or over a local array with $Order are the fastest options.

As a motivating example, we will consider looping over the pieces of a comma-delimited string.

A natural way to write such a loop, in minimal code, is:

For
21
5 10120
Discussion Yone Moreno · Sep 13, 2022

To celebrate programming day, could we create solutions for a little challenge?

We have the following statement:

Given a string of words, return the length of the shortest word(s).

String will never be empty and you do not need to account for different data types.

Some test made in Java would be:

 * Created by Javatlacati on 01/03/2017.
21
0 573
Question Bransen Smith · Oct 7, 2022

We have a handful of cases where we get reflex orders in an interface that contain multiple OBR segments. These are rare but when we get them, they are causing errors in down stream systems because we are unintentionally excluding OBR segments.

Questions:

At the DTL level - is it possible to iterate over this segment WITHOUT altering the underlying schema? If so what would that look like?

Ideally we would not like to alter the schema unless we have to. No matter what logic we attempt to write on the DTL level we are unable to read anything past the first OBR (because of our schema config). 

  

1
0 329
Article Timothy Leavitt · Oct 12, 2022 1m read

I just wrote up a quick sample to help a colleague load data into IRIS from R using RJDBC, and figured it's worth sharing here for future reference.

Ultimately it was pretty simple, aside from IRIS not liking "." in column names; the workaround is to just rename the columns. Someone better at R than me could probably provide some generic approach. smiley

# Need a valid value for JAVA_HOME prior to calling library(RJDBC)
Sys.setenv(JAVA_HOME="C:\\Java\\jdk-8.0.322.6-hotspot\\jre")
library(RJDBC)
library(dplyr)
# Connect to IRIS – needs path to InterSystems JDBC JAR in your installation
drv <-
2
2 351
Discussion Yone Moreno · Sep 19, 2022

Hello community,

Yesterday was celebrated the "World Medical Ethics Day" https://www.ama.com.au/media/wma-medical-ethics-day

We could celebrate it with a programming quiz or challenge:

DESCRIPTION:

Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms.

If you want to know more: http://en.wikipedia.org/wiki/DNA

In DNA strings, symbols "A" and "T" are complements of each other, as "C" and "G".

5
0 818
Discussion Yone Moreno · Sep 19, 2022

Hello, community

To celebrate that this week is "International Week of Deaf People 2022" , https://wfdeaf.org/iwdeaf2022/

Could we do a small challenge?

The statement is:

Task

Give you two strings: s1 and s2. If they are opposite, return true; otherwise, return false. Note: The result should be a boolean value, instead of a string.

The opposite means: All letters of the two strings are the same, but the case is opposite. you can assume that the string only contains letters or it's a empty string. Also take note of the edge case - if both strings are empty then you should return false/False.

E

3
0 305
Discussion Yone Moreno · Sep 13, 2022

Hello,

I was wondering if there is a way, or what is your recommended way to generate, or develop some kind of deep interest or even some joy, love, or excitement towards coding, programming, software developing. Specifically for people aged between 20 and 30 years old.

I am aware of some programming games like the following ones:

https://wintrmut3.itch.io/maelstromexe

https://theov.itch.io/automaton

https://importantlittlegames.itch.io/codemancer-ch-1

Also, there are some coding platforms with online exercises and/or challenges:

https://www.codewars.com/dashboard

https://codecombat.com/

https://www.

5
0 272
Discussion Yone Moreno · Sep 18, 2022

Hello community,

Because of recently the "Green Game Jam" has been celebrated as a part of a mission to improve environmental awareness, as the following quote explains: https://playing4theplanet.org/about

"UNEP has been working with the gaming industry to explore how, through their massive reach, they can inspire young people to learn and act in support of the environment. The gaming industry reaches 1 in 3 people on the planet and has a platform with unprecedented influence. How can this rapidly expanding media platform be harnessed to deliver on the Sustainable Development Goals?"

"The

1
0 362
Discussion Eduard Lebedyuk · Jul 1, 2022

Leet (or "1337"), also known as eleet or leetspeak, is a system of modified spellings used primarily on the Internet. It often uses character replacements in ways that play on the similarity of their glyphs via reflection or other resemblance. Additionally, it modifies certain words based on a system of suffixes and alternate meanings. There are many dialects or linguistic varieties in different online communities. Wikipedia

You'll have to translate a string into a LeetSpeak. As usual shortest solution wins.

##Input "Listen"

##Output 1|573n

##Note

  • You must not repeat the same letter
8
0 671
Article Timothy Leavitt · Mar 17, 2021 3m read

I ran into an interesting ObjectScript use case today with a general solution that I wanted to share.

Use case:

I have a JSON array (specifically, in my case, an array of issues from Jira) that I want to aggregate over a few fields - say, category, priority, and issue type. I then want to flatten the aggregates into a simple list with the total for each of the groups. Of course, for the aggregation, it makes sense to use a local array in the form:

agg(category, priority, type) = total

Such that for each record in the input array I can just:

Do $increment(agg(category, priority, type))

But once I've

10
4 1213
Question Yone Moreno · Apr 25, 2022

Hello, good morning

First thank you for your time in reading and answering our question.

We have been reading, inquiring, researching about how to make multiple dispatches from 1 Process of type "DICOM.BP.QueryProcess" to several target Operations.

We need some help to further develop this use case, and some advice 🧭, examples or recommendations

Currently we are using the basic example, the one that includes Ensemble, and this has DICOM Process which has a property by which from Web Production we write to which Operation it sends our FIND/QUERY/RETRIEVE messages:

The circuit is shown graphically:

Be

1
0 323
Article Eduard Lebedyuk · Jun 19, 2020 2m read

Recently I needed to generate a Swagger spec from persistent and serial classes, so I'm publishing my code (it's not complete - you still need to hash out the application specifics, but it's a start). It's available here.

Let's say you have these classes:

 

Classes

14
3 1974
Question Yone Moreno · Mar 28, 2022

Good morning,

We would appreciate your support:

Developing an integration to perform a "Query / Retrieve" circuit with DICOM medical imaging studies, we would need the following:

Options of invocation of the DICOM TCP service that has been published for this integration, alternatives to the command line option.

Specifically we have read: Receive DICOM document with an embedded PDF and metadata.

Adapting the example, we use the line:

./storescu -b VNAPRE -c ESBPRE@10.136.4.XYZ:19ABC ./embeddedpdf.dcm

By which we simulate the sending of a DICOM document with a PDF.

However, this is not fruitful,

3
0 351
Question Yone Moreno · Apr 1, 2022

Good morning,

Thank you for taking the time to read and answer this question.

We need to find out how to display an EnsLib.DICOM.Document using LOGINFO, in the traces.

We have tried to use:

set writer=##class(%XML.Writer).%New()

set status=writer.OutputToString()

set status=writer.RootObject(..DocumentFromService)

set xml= writer.GetXMLString()

$$$LOGINFO("..DocumentFromService en xml: "_xml)

 

In the trace it informs us that the "RootObject" method for DICOM documents, the EnsLib.DICOM.Document, does not exist:

Please, could you indicate, recommend, suggest or send us supporting

0
0 225
Question Yone Moreno · Mar 31, 2022

Good morning,

First of all, thank you very much in advance for reading and responding.

Also, thank you for any support, because it is a relief, support, contribution, help to have people with more understanding, knowledge and practice, reading, and thinking this doubt.

There is the following need:

Two 2 circuits are available:

1st DICOM Circuit of "Studio" ( Classic Service ).

Service: class: DICOM.BS.QueryService

Process: class: DICOM.BP.QueryProcess

Operation: class: EnsLib.DICOM.Operation.TCP

We test from the "Console" of the "Studio" by means of:

do ##class(DICOM.BS.QueryService).TestFind("102030")
0
0 287
Question Yone Moreno · Mar 28, 2022

Hello,

First of all thanks for your help

How would you recommend us to filter in the message viewer to find inside a property called "mensaje" of type "%XML.GlobalCharacterStream" which is inside a class called"Mensajes.Request.Laboratorio.peticionER7Request", the text "24642"?

We have tried:

It shows:

ERROR #5540: SQLCODE: Message -37: Unary function %EXTERNAL does not support sequence fields.

ORIGIN ELEMENT: %ZEN.Component.tablePane (resultsTable)

 

In addition we have tried to output the %XML.GlobalCharacterStream as a %String, using Read() function, and then trying to filter with

2
0 669