发布新帖

查找

文章
· 七月 21, 2020 阅读大约需 2 分钟

Un-Typical persistence

During my search for a snapshot of a persistent object,
I met a feature that I would like to share as it could be useful in some special situations.
My trigger was to have a before- and an after-image during unit testing. A typical persistent class may have a storge definition like this

Storage Default
{
 <Data name="kDefaultData">
 +<Value name="1">
 </Value>
 </Data>
 <DataLocation>^rcc.kD</DataLocation>
 <DefaultData>kDefaultData</DefaultData>
 <IdLocation>^rcc.kD</IdLocation>
 <IndexLocation>^rcc.kI</IndexLocation>
 <StreamLocation>^rcc.kS</StreamLocation>
 <Type>%Storage.Persistent</Type>
}

Now I applied this change: 

  Parameter MANAGEDEXTENT = 0; ;extent manager dislikes this change

Storage Default
{
 <Data name="kDefaultData">
 +<Value name="1">
  </Value>
 </Data>
 <DataLocation>@(%storage_"D")</DataLocation>
 <DefaultData>kDefaultData</DefaultData>
 <IdLocation>@(%storage_"D")</IdLocation>
 <IndexLocation>@(%storage_"I")</IndexLocation>
 <StreamLocation>@(%storage_"S")</StreamLocation>
 <Type>%Storage.Persistent</Type>
}

All you have to do now to use it:

set %storage="^myGlobal"         ;; normal use with ROLLBACK
or 
set %storage="%myLocalVariable"  ;; no ROLLBACK
or
set %storage="^||myPPG"          ;; no ROLLBACK

and it works as you are used to it.
Except for ROLLBACK as there is, of course,  no Journal behind PPG or local variables 

A typical use sequence to prepare a check for changes could look similar:

set %storage="^rcc.k" 
set obj=##class(rcc.k).%OpenId(id)       ;; get original
do obj.%SetModified(1)                    ;; prepare for %Save
set %storage="^||rcc"                    ;; location of copy
set sc=obj.%Save()                        ;; write copy to temp storage
//// carry on with testing and changes and find what happened

 

 I think it's worth to share it.

4 Comments
讨论 (4)5
登录或注册以继续
文章
· 七月 21, 2020 阅读大约需 1 分钟

Snapshot to JSON

This is a sample to use %JSON.Adaptor class available in IRIS to produce a snapshot of your object.

The sample consists of 2 classes that are variations of what was known in Caché/SAMPLES as Sample.Person.
Be aware that the possibilities are limited by %JSON.Adapter and how you make use of it.

Once in place, you create some test data by Populate().
You select an object and take a snapshot.
You apply changes to your object and take another snapshot.
And see the difference.

BINGO!

GitHub

讨论 (0)1
登录或注册以继续
文章
· 七月 21, 2020 阅读大约需 1 分钟

Function to Check if string is JSON object

It's also an example of a customized SystemFunction extension (ZZISJSON) in Caché & IRIS
This time it is to be included in %ZLANGF00.mac

A JSON string is mostly imported from a file or over REST
You rely on a clean and compatible structure. This is the check.

required: ZPretty.mac

demo

USER>ZWRITE jsn  
jsn="{"Name":"Li,Robert K.","SSN":"672-92-9664","DOB":"1975-01-12","Home":{"Street":"986 Washington Blvd","City":"Boston","State":"PA","Zip":"95802"},"Office":{"Street":"6012 First Place","City":"Reston","State":"MT","Zip":"77739"},"Spouse":{"Name":"Avery,Zelda H.","SSN":"323-13-7437","DOB":"1943-03-27","Home":{"Street":"196 Main Drive","City":"Youngstown","State":"WY","Zip":"53229"},"Office":{"Street":"4056 Franklin Court","City":"Bensonhurst","State":"IA","Zip":"27688"},"FavoriteColors":["Black"],"Age":77},"Age":45,"Title":"Associate Marketing Manager","Salary":10421}" 

USER>if $ZZISJSON(jsn) write "OK"
OK

USER>set is(1)=$ZZISJSON(jsn),is(2)=$ZZISJSON(jsn_",home:") zwrite is
is(1)=1
is(2)=0

GitHub

讨论 (0)1
登录或注册以继续
文章
· 七月 21, 2020 阅读大约需 2 分钟

fast JSON formatting (Caché / Ensemble)

t's also an example for a customized command extension (ZZJSN) in Caché & IRIS

This is the Caché version for fast JSON formatting but it also works in IRIS.
Requires package ZPretty
To allow parallel existence in IRIS this is named ZZJSN

see:

USER>ZWRITE jsn  
jsn="{"Name":"Li,Robert K.","SSN":"672-92-9664","DOB":"1975-01-12","Home":{"Street":"986 Washington Blvd","City":"Boston","State":"PA","Zip":"95802"},"Office":{"Street":"6012 First Place","City":"Reston","State":"MT","Zip":"77739"},"Spouse":{"Name":"Avery,Zelda H.","SSN":"323-13-7437","DOB":"1943-03-27","Home":{"Street":"196 Main Drive","City":"Youngstown","State":"WY","Zip":"53229"},"Office":{"Street":"4056 Franklin Court","City":"Bensonhurst","State":"IA","Zip":"27688"},"FavoriteColors":["Black"],"Age":77},"Age":45,"Title":"Associate Marketing Manager","Salary":10421}" 

This doesn't look so easy to follow.
So this is a shorthand to save time and reduce mistyping.

The attached ZZJSN.inc is to be included into your %ZLANGC00.mac

USER>ZZJSN jsn        ; does the Output to Terminal / Device  
{
  "Name":"Li,Robert K.",
  "SSN":"672-92-9664",
  "DOB":"1975-01-12",
  "Home":{
    "Street":"986 Washington Blvd",
    "City":"Boston",
    "State":"PA",
    "Zip":"95802"
  },
  "Office":{
    "Street":"6012 First Place",
    "City":"Reston",
    "State":"MT",
    "Zip":"77739"
  },
  "Spouse":{
    "Name":"Avery,Zelda H.",
    "SSN":"323-13-7437",
    "DOB":"1943-03-27",
    "Home":{
      "Street":"196 Main Drive",
      "City":"Youngstown",
      "State":"WY",
      "Zip":"53229"
    },
    "Office":{
      "Street":"4056 Franklin Court",
      "City":"Bensonhurst",
      "State":"IA",
      "Zip":"27688"
    },
    "FavoriteColors":[
      "Black"
    ],
    "Age":77
  },
  "Age":45,
  "Title":"Associate Marketing Manager",
  "Salary":10421
}

output to stream

set st=##class(%Stream.GlobalCharacter).%New()
ZZJSN jsn:st      ; write result to Stream

output to string

ZZJSN jsn:"BOBBY"  ; writes it to local variable BOBBY

GitHub

讨论 (0)1
登录或注册以继续
问题
· 七月 20, 2020

Corner Secure FHIR Sandbox access from production

Hi

Has anyone been able to successfully connect IRIS for Health to Cerner's Secure FHIR Sandbox?

Anyone have any easy instructions for getting this working?

1 Comment
讨论 (1)2
登录或注册以继续