José Pereira · Jan 7, 2022 go to post

For those who are looking for unziping features, Embedded Python (for IRIS 2021.2+) allows you to use zipfile Python lib. For instance:

ClassMethod UnZip(pZipFileName As %String, pExtractToDir As %String) [ Language = python ]
{
    #; solution based on this one: https://stackoverflow.com/a/3451150/345422
    import zipfile
    with zipfile.ZipFile(pZipFileName, 'r') as zip_ref:
        zip_ref.extractall(pExtractToDir)
}

Or

ClassMethod UnZip2(pZipFileName As %String, pExtractToDir As %String)
{
    Set zipfile = $SYSTEM.Python.Import("zipfile")
    Do zipfile.ZipFile(pZipFileName, "r").extractall(pExtractToDir)
}

Tested on iris-ml-community:2021.2.0.617.0-zpm

José Pereira · Jan 14, 2022 go to post

Hi @Ben Spead!

Thank you for warning me! :)

Fixed! I usually double check my English writings in text editors like Google Docs, but I missed to check the title...

A little explanation here, I'm Brazilian, so a Portuguese native speaker. But it's OK, Portuguese is a kind of brother of Spanish! =)

José Pereira · Feb 28, 2022 go to post

Really nice apps in this contest, I'm learning a lot! Congrats to all participants!

José Pereira · Apr 7, 2022 go to post

Hi Vitaliy,

Thank you for that valuable information! I'll take it into account.

But let's assume that I do a partial rebuild. Is it OK to use this partially rebuilt index if I don't care about data that isn't indexed? Did you do this before?

Thanks

José Pereira · Nov 25, 2022 go to post

Hi Edmara!

Which IRIS version are you trying?

I did a test using the version "IRIS for UNIX (Ubuntu Server LTS for x86-64 Containers) 2022.2 (Build 368U) Fri Oct 21 2022 17:18:04 EDT" and all worked fine.

Please, checkout the example below on your IRIS version. It shows the index global value (^dado.TblTesteI) in order to get more visibility of what is going on.

dado.TblTeste:

 

Spoiler

dado.TblFieldOne:

 

Spoiler

dado.TblFieldTwo:

 

Spoiler

dado.TblFieldThree:

 

Spoiler

Output of OpenCompositeIndexTest() method:

IRISAPP>d ##class(dado.TblTeste).OpenCompositeIndexTest()
IRIS version: IRIS for UNIX (Ubuntu Server LTS for x86-64 Containers) 2022.2 (Build 368U) Fri Oct 21 2022 17:18:04 EDT

Cleaning up tables...
Populating tables...

---
Test with FieldThreeId using SQL DML:
Ok
Index global: 
^dado.TblTesteI("idxFieldOneFieldTwoFieldThree",1,2,3,1)=""

---
Test with no FieldThreeId using SQL DML:
Ok
Index global: 
^dado.TblTesteI("idxFieldOneFieldTwoFieldThree",1,2,-100000000000000,2)=""
^dado.TblTesteI("idxFieldOneFieldTwoFieldThree",1,2,3,1)=""

---
Test with no FieldThreeId using object:
Ok
Index global: 
^dado.TblTesteI("idxFieldOneFieldTwoFieldThree",1,2,-100000000000000,2)=""
^dado.TblTesteI("idxFieldOneFieldTwoFieldThree",1,2,3,1)=""
^dado.TblTesteI("idxFieldOneFieldTwoFieldThree",2,1,-100000000000000,3)=""

HTH,

José

José Pereira · Dec 1, 2022 go to post

Hi @Thomas Kotze 

Currently this is not possible.

But maybe some changes here may work for your needs. Try to replace the server address.

Let me know if it works.

Regards,

José

José Pereira · Dec 11, 2022 go to post

But the way that this IA understands and creates text is impressive, no doubts. I think this is something we'll learn how to deal with our daily tasks.

As the zdnet article says, Stack Overflow removes **temporarily**, so it may be a matter of time until we get handed by IA in our development tasks, with services like GitHub copilot.

So thank you for bringing this topic to discussion! smiley

José Pereira · Dec 14, 2022 go to post

Hi!

I grabbed some pieces of code from a previous project. In this project I could connect to Cache 2018.

PS: I didn't test this mashup.

import irisnative
import jaydebeapi
import pandas as pd

defcreate_conn(type, host, port, namespace, user, password):if type == "cache":
        url = f"jdbc:Cache://{host}:{port}/{namespace}"
        driver = "com.intersys.jdbc.CacheDriver"
        jarfile = "C:/InterSystems/Cache2018/dev/java/lib/JDK18/cache-jdbc-2.0.0.jar"
        conn = jaydebeapi.connect(driver, url, [user, password], jarfile)
    else:
        conn = irisnative.createConnection(host, port, namespace, user, password, sharedmemory = True)
    return conn

conn = create_conn("cache", "x.x.x.x", "56772", "namespace", "user", "password")
sql = "select ..."
df = pd.read_sql(sql, conn)
display(df)

HTH,

José

José Pereira · Jan 5, 2023 go to post

Hi @Ori Tsarfati!

Recently, I had a similar requirement in a personal project and found JSON2Persistent in OpenExchange from @Michael.Braam.

I don't know if this is exactly what you need, but using this tool you can transform an ordinary JSON into in a set of persistent IRIS classes which could be used in DTLs.

For instance, I took this FHIR resrouce example and save it to a file.

 

JSON input

Then I exctracted a set of persistent classes organized in a package called tmp.FHIRObservationSchema from that file using JSON2Persistent, like this:

$$$TOE(sc, ##class(ISC.SE.Tools.JSON).GenerateClasses("/tmp/file.json", "tmp", "FHIRObservationSchema", 0, 1, "crk", 1))

After that, I was able to create a DTLs using the schema created from the FHIR resource JSON:

 

DTL (Code)

 

DTL (UI)

So, I create a method to test it:

 

DTL test method

And got this output:

HTH,

José

José Pereira · Jan 9, 2023 go to post

Hi!

Don't know if it's your case, but if you are able to generate the global data, you could use the $INCREMENT() function, which automatically stores the array length into global's head:

Set^test($INCREMENT(^test)) = "aa"Set^test($INCREMENT(^test)) = "aa"Set^test($INCREMENT(^test)) = "aa"Set^test($INCREMENT(^test)) = "aa"ZWrite^test^test=4^test(1)="aa"^test(2)="aa"^test(3)="aa"^test(4)="aa"Write^test4

HTH,

José

José Pereira · Jan 13, 2023 go to post

Hi!

May be this example could help you:

ClassMethod ExecTestQuery(pParams)
{
	Set mdx = 
		"WITH "_
		"	%PARM pSelectedDim as 'value:Trimestre' "_
		"	%PARM pSelectedYear as 'value:NOW' "_
		"SELECT "_
		"	[Measures].[QtdAtendimento] ON 0, "_
		"	NON EMPTY [DataD].[H1].@pSelectedDim.Members ON 1 "_
		"FROM [ARQORDEMSERVICO] "_
		"%FILTER [DATAD].[H1].[ANO].&[@pSelectedYear]"Set rs = ##class(%DeepSee.ResultSet).%New()
	Try {
		$$$TOE(st, rs.%PrepareMDX(mdx))
		Write"Parameters: "Write:($D(pParams) = 0) "(default)"Write !
		ZW pParams
		$$$TOE(st, rs.%Execute(.pParams))
		Do rs.%Print()
	} Catch(e) {
		Write e.DisplaytString(),!
	}
}

ClassMethod TestDeepSeeResultSet()
{
	Write"Test 1", !
	Do..ExecTestQuery()
	
	Write"------",!
	Write"Test 2", !
	Set params("pSelectedDim") = "MesAno"Set params("pSelectedYear") = "2022"Do..ExecTestQuery(.params)
}
Do##class(teste.NewClass1).TestDeepSeeResultSet()
Test 1
Parameters: (default)
                           Qtd Atendimento
Q1 20234
------
Test 2
Parameters: 
pParams("pSelectedDim")="MesAno"
pParams("pSelectedYear")=2022
                           Qtd Atendimento
1 Ago-2022152Set-2022303 Out-2022254 Nov-202295 Dez-20225

Some resources that may be useful:

https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KE…

https://docs.intersystems.com/ens201815/csp/docbook/Doc.View.cls?KEY=D2…

HTH,

José

José Pereira · Jul 4, 2023 go to post

Hi! Which pic? I can see all the 2 pics within the article. Could you send me its link or any other reference, please?