· Jun 16

How do we map Globals (holds data which spreads across different DBs) to multiple Databases

We are trying to come up with huge DataStore which needs to store HIPAA transactions and Data getting partitioned with idkey - YYYYMM.  Current Live data get inserted into current Month DB -  HIPAA_202306. 10 years (Hipaa retention policy) old data is going to be sitting in to 120 DBs ( 201606_HIPAA, 201607... 202305) for historical audit legal compliance purposes.

Currently if we create Namespace we get 2 databases - CODEDB for routes/classes & DATADB for journals data.  

In our requirement, Global mapping should point to 120 DataDbs. How would we Map/design this using Globals. 

Really appreciate your help on this.

Product version: IRIS 2021.1
Discussion (7)2
Log in or sign up to continue

in your namespace you can map not just full Globals   
to a different Database but also parts of a Global.
This works over Global Subscript   Details

IF your structure is ^HISTORY(yyyymm, ....)    [yyyymm as first subscript ]
? eventually also your IDKEY ?
this is a possible way   to set   
^HISTORY(201606) >>  201606_HIPAA.dat 
^HISTORY(201607) >>  201607_HIPAA.dat

But if yyyymm is just somewhere in your data, you need to reorganize your global
I assume this is something  you have to do anyhow with your history 

ATTENTION: this is total static.
so for 120 DBs you need 120 mapping lines

If you are describing your globals in a class and they do not use default storage, but rather SQL Storage(%Storage.SQL) you can define your storage to include extended references.  This is a technique that I have used in the past.  How you loop thru the extended references is up to you.  In my case we took advantage of the ability to SetServerInitCode which is called once when the connection is made to the server, there is an equivalent capability in DeepSee/Analytics.  In our ServerInitCode we populated an array of the different extended references we needed to access and our storage map firstly looped thru this structure and then the actual global.

Adding some code collateral to help explore challenge:

Class definition top

Include (%occInclude, %syConfig)

Some code to listing maps in a database

set pNamespace="HSCUSTOM"
set cns="Map."_pNamespace
set map=""
set found=0
for {
  set map=$O(^CONFIG(cns,map),+1,db)
  set len=$L($P(map,"("),"_")
  set globalMap=$P(map,"_",len,999)
  write !,"global match:""",globalMap,""" to Database:",db}

Example output:

global match:"IRIS.MsgNames("EnsSearchTable")" to Database:ENSLIB
global match:"IRIS.MsgNames("EnsWf")" to Database:ENSLIB
global match:"IRIS.MsgNames("EnsXPATH")" to Database:ENSLIB
global match:"IRIS.MsgNames("EnsebXML")" to Database:ENSLIB
global match:"IRIS.MsgNames("Ensemble")" to Database:ENSLIB
global match:"IRIS.MsgNames("ITK")" to Database:ENSLIB
global match:"IRIS.MsgNames("RuleEditor")" to Database:ENSLIB

Delete a map

set tSC=##Class(Config.MapGlobals).Delete(pNamespace,globalMatch,,$$$CPFSave)

Create a map

set global="IRIS.MsgNames("EnsSearchTable")"  // example like variable "gm" above.

kill params
sset params("Database")="CUSTOMLIB"  // The database you want to use
set params("Collation")=""
set tSC = ##Class(Config.MapGlobals).Create(pNamespace,global,.params,,$$$CPFSave)

// Always apply any pending changes
// Always confirm in testing that the configuration "sticks" after a system restart

do ##class(Config.CPF).Activate()

Alternatives to programmatic approach

Extended global syntax can be useful to copy start / end data between previously mapped and currently mapped database.

Restating advice from above.

A mapping rule is required per database with data.

For example.

------------ Mapping one -----------------

Global Database Location = 201606_HIPAA

Global Name: HISTORY

Global Subscripts to be Mapped: (201606)

------------ Mapping Two -----------------

Global Database Location = 201607_HIPAA

Global Name: HISTORY

Global Subscripts to be Mapped: (201607)


Can see Global "History" is stated in question.

Suggest review is needed to double-check where indexes and rowID counters are stored.