HMPUTIL1 ;SLC/AGP,ASMR/RRB,CPC - HMP utilities routine ;May 15, 2016 14:15
;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**1,6**;May 15, 2016;Build 3
;Per VA Directive 6402, this routine should not be modified.
;
Q
;
; ADHOC subroutine refactored for DE1788
ADHOC(HMPDMINP,HMPFCNT,DFN) ; Add syncStart metastamp and syncStatus to unsolicited updates
Q:($G(HMPDMINP)="")!($G(DFN)="") ; domain and DFN required
; HMPFCNT = count of objects, passed by ref.
; expects HMPFSTR (set in HMPDJFSG) is ^XTMP freshness stream subscript
; the heading from APIHDR^HMPDJFSG is in ^TMP("HMPF",$J) already
; the JSON built here is placed inside a JSON array, with a '[' after the heading
;
N HMPA4JSN,HMPDAT,HMPDMTOT,HMPDOM,HMPID,HMPJSERR,HMPJSON,HMPSUB,I,J,LSTLN,QTE,SUB,X,Y,DELJSON
N HMPJSNSY
; HMPA4JSN, HMPJSON, HMPJSERR - used for JSON encoder
; HMPA4JSN - array to encode
; HMPJSON - JSON result
; HMPJSERR - error text from encoder
; QTE - " character
; HMPJSNSY - The system id value for the JSON Encoder, If fully numeric it needs a " prepended
S HMPDAT("DELDATE")="",QTE=$C(34)
S HMPDMTOT=0 ; domain total
; Save delete date/time for later use.
I $G(ACT)="@" D
. D ;DE4307 get from freshness save if available
.. I +$G(FILTER("freshnessDateTime")) S HMPDAT("DELDATE")=$$JSONDT^HMPUTILS(FILTER("freshnessDateTime")) Q
.. S Y=$$FMTH^XLFDT($P(HMPFSTRM,"~",3)) ; Get the date from fresh stream (HMPFS~<server>~<date>)
.. S Y=$$HTFM^XLFDT($P(Y,",")_","_$G(ARGS("hmp-fst"),0)) ; Add delete time stored in ARGS("hmp-fst")
.. S HMPDAT("DELDATE")=$$JSONDT^HMPUTILS(Y) ; delete date/time into JSON format
. S DELJSON="{""pid"":"""_$$PID^HMPDJFS(DFN)_""",""removed"":""true"",""stampTime"":"_HMPDAT("DELDATE")_",""uid"":"""_$G(HMP97)_"""}"
;
S HMPA4JSN=$NA(^TMP($J,"ARRAY4JSON")) K @HMPA4JSN ; data array for JSON
S HMPJSON=$NA(^TMP($J,"JSONRESULT")) K @HMPJSON ; JSON result
;
S HMPDAT("STAMPTIME")=$$EN^HMPSTMP("NOW"),HMPID=$$SYS^HMPUTILS,HMPJSNSY=$S(+HMPID=HMPID:""""_HMPID,1:HMPID)
;
D:DFN'="OPD" ; get PID data for patient
.N ITM,VAL ; $$PIDS returns: ,"pid":"9E4B;3","systemId":"9E4B","localId":"3","icn":"10207V420718"
.S Y=$$PIDS^HMPDJFS(DFN) ; parse Y, remove quotes save values in HMPID('item')
.F J=2:1:$L(Y,",") S X=$P(Y,",",J),ITM=$TR($P(X,":"),QTE),VAL=$TR($P(X,":",2),QTE) S:ITM]"" HMPID(ITM)=VAL
;
; transform domain name for quick orders to match the uid
S HMPDOM=HMPDMINP I HMPDOM="quick" S HMPDOM="qo"
;
; stamp time put into HMPDAT("STAMPTIME")
S HMPSUB=""
S HMPDAT("STAMPTIME")=""
F S HMPSUB=$O(^TMP("HMP",$J,HMPSUB)) Q:'HMPSUB D
.N DONE,HMPN,NEXT,SRCH,HMPDATP ;cpc 2015/10/21
.S SRCH="""uid"""_":"_""""_"urn:va:"_HMPDOM_":"
.; Search back from last record - but include start of next to cover crossovers
.S HMPDAT="" ;cpc 2015/10/21
.S HMPN="",HMPDAT("UID")="",DONE=""
.F S HMPN=$O(^TMP("HMP",$J,HMPSUB,HMPN),-1) Q:'HMPN D Q:DONE
..S HMPDATP=$E(HMPDAT,1,100) ;cpc 2015/10/21
..S HMPDAT=$G(^TMP("HMP",$J,HMPSUB,HMPN)) Q:HMPDAT="null"!'$L(HMPDAT)
..S HMPDAT=HMPDAT_HMPDATP ;cpc 2015/10/21 - look for crossover data
..;Search for last occurrence of uid in record (this will be parent)
..I $G(HMPDAT(HMPSUB,"UID"))="",$F(HMPDAT,SRCH) F I=2:1 S NEXT=$P($P(HMPDAT,SRCH,I),QTE) Q:NEXT="" S HMPDAT(HMPSUB,"UID")=NEXT ;cpc 2016/09/16
..;BL;CPC Extract stamptime if present (patient data ONLY)
..;cpc 2015/10/09 - conditionalize tests
..I '$G(HMPDAT(HMPSUB,"STAMPTIME")),$F(HMPDAT,"stampTime") D ;cpc 2015/10/21
...S HMPDAT(HMPSUB,"STAMPTIME")=$P($P(HMPDAT,"""stampTime"":",2),",")
...;Keep the latest stamptime so that we can use it for the overall metastamp
...I HMPDAT(HMPSUB,"STAMPTIME")>HMPDAT("STAMPTIME") S HMPDAT("STAMPTIME")=HMPDAT(HMPSUB,"STAMPTIME")
..;Patient data requires both UID and stampTime to be complete
..S:$G(HMPDAT(HMPSUB,"UID"))&$G(HMPDAT(HMPSUB,"STAMPTIME")) DONE=1
..;cpc 2015/10/09 - end
;
; HMP97 is uid, SET in FRESHITM^HMPDJFSG
I $G(ACT)="@" S HMPDAT("UID")=$P($G(HMP97),":",4,99)
;
S @HMPA4JSN@("collection")=$S(DFN="OPD":"OPDsyncStart",1:"syncStart")
I DFN="OPD" S @HMPA4JSN@("systemId")=$P(HMPID,";") ; set systemId for OPD
S X="" F S X=$O(HMPID(X)) Q:X="" S @HMPA4JSN@(X)=HMPID(X) ; add pid, systemId, localId, icn
;
;DE4307 - if stamptime still doesn't exist then get from freshness
I '+HMPDAT("STAMPTIME"),+$G(FILTER("freshnessDateTime")) S HMPDAT("STAMPTIME")=$$JSONDT^HMPUTILS(FILTER("freshnessDateTime"))
; build metastamp components
S SUB="metaStamp"
S X="" F S X=$O(HMPID(X)) Q:X="" S @HMPA4JSN@(SUB,X)=HMPID(X) ; add pid, systemId, localId, icn
S @HMPA4JSN@(SUB,"stampTime")=HMPDAT("STAMPTIME")
;
S SUB(1)="sourceMetaStamp",X=""
F S X=$O(HMPID(X)) Q:X="" S @HMPA4JSN@(SUB,SUB(1),HMPJSNSY,X)=HMPID(X) ; add pid, systemId, localId, icn ;de4757 use stringed version of system
S @HMPA4JSN@(SUB,SUB(1),HMPJSNSY,"stampTime")=HMPDAT("STAMPTIME")
;
S SUB(2)="domainMetaStamp"
S @HMPA4JSN@(SUB,SUB(1),HMPJSNSY,SUB(2),HMPDOM,"domain")=HMPDOM
S @HMPA4JSN@(SUB,SUB(1),HMPJSNSY,SUB(2),HMPDOM,"stampTime")=$S($L($G(HMPDAT("DELDATE"))):HMPDAT("DELDATE"),1:HMPDAT("STAMPTIME"))
;
; Loop through HMPSUB to generate the eventMetastamp
S SUB(3)=$S(DFN="OPD":"itemMetaStamp",1:"eventMetaStamp"),HMPSUB="" ;cpc 2015/10/22
F S HMPSUB=$O(HMPDAT(HMPSUB)) Q:'HMPSUB D
.S SUB(4)="urn:va:"_HMPDOM_":"_$S($G(ACT)="@":HMPDAT("UID"),1:HMPDAT(HMPSUB,"UID")) ;CPC won't exist for deletion
.S @HMPA4JSN@(SUB,SUB(1),HMPJSNSY,SUB(2),HMPDOM,SUB(3),SUB(4),"stampTime")=$S($L($G(HMPDAT("DELDATE"))):HMPDAT("DELDATE"),1:HMPDAT(HMPSUB,"STAMPTIME"))
;
D ENCODE^HMPJSON(HMPA4JSN,HMPJSON,"HMPJSERR")
I $D(HMPJSERR) S $EC=",JSON encode error in unsolicited update," Q
; find last line of JSON
S LSTLN=0 F J=1:1 Q:'$D(@HMPJSON@(J)) S LSTLN=J
; Merge in data section from FRESHITM^HMPDJFSG
; Add a comma after the syncStart Message for the actual data
S @HMPJSON@(LSTLN,.3)=","
S HMPSUB=""
;
; do the merge
F S HMPSUB=$O(^TMP("HMP",$J,HMPSUB)) Q:'HMPSUB D
.N HMPX,HMPDATA
.S LSTLN=LSTLN+1
.; If it is patient data add the wrapper with pid
.I DFN'="OPD" S @HMPJSON@(LSTLN,.4)="{""collection"":"""_HMPDOM_""""_$$PIDS^HMPDJFS(DFN)_",""seq"":1,""total"":1,""object"":"_$S($G(ACT)="@":DELJSON,1:"")
.; If it is operational data add the wrapper without pid
.I DFN="OPD",$G(ACT)="@" S @HMPJSON@(LSTLN,.4)="{""collection"":"""_HMPDOM_""",""seq"":1,""total"":1,""object"":"_DELJSON ;;US5647
.; If it is operational data and to be deleted
.I DFN="OPD",$G(ACT)'="@" D ;US5859
..S @HMPJSON@(LSTLN,.4)="{""collection"":"""_HMPDOM_""",""seq"":1,""total"":1,""object"":"
..S HMPX="""stampTime"":"_QTE_$S($L($G(HMPDAT("DELDATE"))):HMPDAT("DELDATE"),1:HMPDAT("STAMPTIME"))_QTE_","
..S HMPDATA=^TMP("HMP",$J,HMPSUB,1)
..S ^TMP("HMP",$J,HMPSUB,1)="{"_HMPX_$P(HMPDATA,"{",2,999)
.M @HMPJSON@(LSTLN)=^TMP("HMP",$J,HMPSUB)
.; Close the wrapper
.S HMPCLFLG=1
.; Add the closing brace for the wrapper
.S @HMPJSON@(LSTLN+1,.1)="}"
.; Increment the domain total
.S HMPDMTOT=HMPDMTOT+1
;
S HMPFCNT=$G(HMPFCNT)+1
M ^TMP("HMPF",$J,HMPFCNT)=@HMPJSON
; need a comma if more than one item
I HMPFCNT>1 S ^TMP("HMPF",$J,HMPFCNT,.3)=$S(HMPLITEM="SYNC":"},",1:",") S HMPLITEM="FRESH" ; DE3502
;
; clean up residual data in ^TMP($J), may be quite a lot
K @HMPA4JSN,@HMPJSON
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHMPUTIL1 7445 printed Nov 22, 2024@17:04:49 Page 2
HMPUTIL1 ;SLC/AGP,ASMR/RRB,CPC - HMP utilities routine ;May 15, 2016 14:15
+1 ;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**1,6**;May 15, 2016;Build 3
+2 ;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 QUIT
+5 ;
+6 ; ADHOC subroutine refactored for DE1788
ADHOC(HMPDMINP,HMPFCNT,DFN) ; Add syncStart metastamp and syncStatus to unsolicited updates
+1 ; domain and DFN required
if ($GET(HMPDMINP)="")!($GET(DFN)="")
QUIT
+2 ; HMPFCNT = count of objects, passed by ref.
+3 ; expects HMPFSTR (set in HMPDJFSG) is ^XTMP freshness stream subscript
+4 ; the heading from APIHDR^HMPDJFSG is in ^TMP("HMPF",$J) already
+5 ; the JSON built here is placed inside a JSON array, with a '[' after the heading
+6 ;
+7 NEW HMPA4JSN,HMPDAT,HMPDMTOT,HMPDOM,HMPID,HMPJSERR,HMPJSON,HMPSUB,I,J,LSTLN,QTE,SUB,X,Y,DELJSON
+8 NEW HMPJSNSY
+9 ; HMPA4JSN, HMPJSON, HMPJSERR - used for JSON encoder
+10 ; HMPA4JSN - array to encode
+11 ; HMPJSON - JSON result
+12 ; HMPJSERR - error text from encoder
+13 ; QTE - " character
+14 ; HMPJSNSY - The system id value for the JSON Encoder, If fully numeric it needs a " prepended
+15 SET HMPDAT("DELDATE")=""
SET QTE=$CHAR(34)
+16 ; domain total
SET HMPDMTOT=0
+17 ; Save delete date/time for later use.
+18 IF $GET(ACT)="@"
Begin DoDot:1
+19 ;DE4307 get from freshness save if available
Begin DoDot:2
+20 IF +$GET(FILTER("freshnessDateTime"))
SET HMPDAT("DELDATE")=$$JSONDT^HMPUTILS(FILTER("freshnessDateTime"))
QUIT
+21 ; Get the date from fresh stream (HMPFS~<server>~<date>)
SET Y=$$FMTH^XLFDT($PIECE(HMPFSTRM,"~",3))
+22 ; Add delete time stored in ARGS("hmp-fst")
SET Y=$$HTFM^XLFDT($PIECE(Y,",")_","_$GET(ARGS("hmp-fst"),0))
+23 ; delete date/time into JSON format
SET HMPDAT("DELDATE")=$$JSONDT^HMPUTILS(Y)
End DoDot:2
+24 SET DELJSON="{""pid"":"""_$$PID^HMPDJFS(DFN)_""",""removed"":""true"",""stampTime"":"_HMPDAT("DELDATE")_",""uid"":"""_$GET(HMP97)_"""}"
End DoDot:1
+25 ;
+26 ; data array for JSON
SET HMPA4JSN=$NAME(^TMP($JOB,"ARRAY4JSON"))
KILL @HMPA4JSN
+27 ; JSON result
SET HMPJSON=$NAME(^TMP($JOB,"JSONRESULT"))
KILL @HMPJSON
+28 ;
+29 SET HMPDAT("STAMPTIME")=$$EN^HMPSTMP("NOW")
SET HMPID=$$SYS^HMPUTILS
SET HMPJSNSY=$SELECT(+HMPID=HMPID:""""_HMPID,1:HMPID)
+30 ;
+31 ; get PID data for patient
if DFN'="OPD"
Begin DoDot:1
+32 ; $$PIDS returns: ,"pid":"9E4B;3","systemId":"9E4B","localId":"3","icn":"10207V420718"
NEW ITM,VAL
+33 ; parse Y, remove quotes save values in HMPID('item')
SET Y=$$PIDS^HMPDJFS(DFN)
+34 FOR J=2:1:$LENGTH(Y,",")
SET X=$PIECE(Y,",",J)
SET ITM=$TRANSLATE($PIECE(X,":"),QTE)
SET VAL=$TRANSLATE($PIECE(X,":",2),QTE)
if ITM]""
SET HMPID(ITM)=VAL
End DoDot:1
+35 ;
+36 ; transform domain name for quick orders to match the uid
+37 SET HMPDOM=HMPDMINP
IF HMPDOM="quick"
SET HMPDOM="qo"
+38 ;
+39 ; stamp time put into HMPDAT("STAMPTIME")
+40 SET HMPSUB=""
+41 SET HMPDAT("STAMPTIME")=""
+42 FOR
SET HMPSUB=$ORDER(^TMP("HMP",$JOB,HMPSUB))
if 'HMPSUB
QUIT
Begin DoDot:1
+43 ;cpc 2015/10/21
NEW DONE,HMPN,NEXT,SRCH,HMPDATP
+44 SET SRCH="""uid"""_":"_""""_"urn:va:"_HMPDOM_":"
+45 ; Search back from last record - but include start of next to cover crossovers
+46 ;cpc 2015/10/21
SET HMPDAT=""
+47 SET HMPN=""
SET HMPDAT("UID")=""
SET DONE=""
+48 FOR
SET HMPN=$ORDER(^TMP("HMP",$JOB,HMPSUB,HMPN),-1)
if 'HMPN
QUIT
Begin DoDot:2
+49 ;cpc 2015/10/21
SET HMPDATP=$EXTRACT(HMPDAT,1,100)
+50 SET HMPDAT=$GET(^TMP("HMP",$JOB,HMPSUB,HMPN))
if HMPDAT="null"!'$LENGTH(HMPDAT)
QUIT
+51 ;cpc 2015/10/21 - look for crossover data
SET HMPDAT=HMPDAT_HMPDATP
+52 ;Search for last occurrence of uid in record (this will be parent)
+53 ;cpc 2016/09/16
IF $GET(HMPDAT(HMPSUB,"UID"))=""
IF $FIND(HMPDAT,SRCH)
FOR I=2:1
SET NEXT=$PIECE($PIECE(HMPDAT,SRCH,I),QTE)
if NEXT=""
QUIT
SET HMPDAT(HMPSUB,"UID")=NEXT
+54 ;BL;CPC Extract stamptime if present (patient data ONLY)
+55 ;cpc 2015/10/09 - conditionalize tests
+56 ;cpc 2015/10/21
IF '$GET(HMPDAT(HMPSUB,"STAMPTIME"))
IF $FIND(HMPDAT,"stampTime")
Begin DoDot:3
+57 SET HMPDAT(HMPSUB,"STAMPTIME")=$PIECE($PIECE(HMPDAT,"""stampTime"":",2),",")
+58 ;Keep the latest stamptime so that we can use it for the overall metastamp
+59 IF HMPDAT(HMPSUB,"STAMPTIME")>HMPDAT("STAMPTIME")
SET HMPDAT("STAMPTIME")=HMPDAT(HMPSUB,"STAMPTIME")
End DoDot:3
+60 ;Patient data requires both UID and stampTime to be complete
+61 if $GET(HMPDAT(HMPSUB,"UID"))&$GET(HMPDAT(HMPSUB,"STAMPTIME"))
SET DONE=1
+62 ;cpc 2015/10/09 - end
End DoDot:2
if DONE
QUIT
End DoDot:1
+63 ;
+64 ; HMP97 is uid, SET in FRESHITM^HMPDJFSG
+65 IF $GET(ACT)="@"
SET HMPDAT("UID")=$PIECE($GET(HMP97),":",4,99)
+66 ;
+67 SET @HMPA4JSN@("collection")=$SELECT(DFN="OPD":"OPDsyncStart",1:"syncStart")
+68 ; set systemId for OPD
IF DFN="OPD"
SET @HMPA4JSN@("systemId")=$PIECE(HMPID,";")
+69 ; add pid, systemId, localId, icn
SET X=""
FOR
SET X=$ORDER(HMPID(X))
if X=""
QUIT
SET @HMPA4JSN@(X)=HMPID(X)
+70 ;
+71 ;DE4307 - if stamptime still doesn't exist then get from freshness
+72 IF '+HMPDAT("STAMPTIME")
IF +$GET(FILTER("freshnessDateTime"))
SET HMPDAT("STAMPTIME")=$$JSONDT^HMPUTILS(FILTER("freshnessDateTime"))
+73 ; build metastamp components
+74 SET SUB="metaStamp"
+75 ; add pid, systemId, localId, icn
SET X=""
FOR
SET X=$ORDER(HMPID(X))
if X=""
QUIT
SET @HMPA4JSN@(SUB,X)=HMPID(X)
+76 SET @HMPA4JSN@(SUB,"stampTime")=HMPDAT("STAMPTIME")
+77 ;
+78 SET SUB(1)="sourceMetaStamp"
SET X=""
+79 ; add pid, systemId, localId, icn ;de4757 use stringed version of system
FOR
SET X=$ORDER(HMPID(X))
if X=""
QUIT
SET @HMPA4JSN@(SUB,SUB(1),HMPJSNSY,X)=HMPID(X)
+80 SET @HMPA4JSN@(SUB,SUB(1),HMPJSNSY,"stampTime")=HMPDAT("STAMPTIME")
+81 ;
+82 SET SUB(2)="domainMetaStamp"
+83 SET @HMPA4JSN@(SUB,SUB(1),HMPJSNSY,SUB(2),HMPDOM,"domain")=HMPDOM
+84 SET @HMPA4JSN@(SUB,SUB(1),HMPJSNSY,SUB(2),HMPDOM,"stampTime")=$SELECT($LENGTH($GET(HMPDAT("DELDATE"))):HMPDAT("DELDATE"),1:HMPDAT("STAMPTIME"))
+85 ;
+86 ; Loop through HMPSUB to generate the eventMetastamp
+87 ;cpc 2015/10/22
SET SUB(3)=$SELECT(DFN="OPD":"itemMetaStamp",1:"eventMetaStamp")
SET HMPSUB=""
+88 FOR
SET HMPSUB=$ORDER(HMPDAT(HMPSUB))
if 'HMPSUB
QUIT
Begin DoDot:1
+89 ;CPC won't exist for deletion
SET SUB(4)="urn:va:"_HMPDOM_":"_$SELECT($GET(ACT)="@":HMPDAT("UID"),1:HMPDAT(HMPSUB,"UID"))
+90 SET @HMPA4JSN@(SUB,SUB(1),HMPJSNSY,SUB(2),HMPDOM,SUB(3),SUB(4),"stampTime")=$SELECT($LENGTH($GET(HMPDAT("DELDATE"))):HMPDAT("DELDATE"),1:HMPDAT(HMPSUB,"STAMPTIME"))
End DoDot:1
+91 ;
+92 DO ENCODE^HMPJSON(HMPA4JSN,HMPJSON,"HMPJSERR")
+93 IF $DATA(HMPJSERR)
SET $ECODE=",JSON encode error in unsolicited update,"
QUIT
+94 ; find last line of JSON
+95 SET LSTLN=0
FOR J=1:1
if '$DATA(@HMPJSON@(J))
QUIT
SET LSTLN=J
+96 ; Merge in data section from FRESHITM^HMPDJFSG
+97 ; Add a comma after the syncStart Message for the actual data
+98 SET @HMPJSON@(LSTLN,.3)=","
+99 SET HMPSUB=""
+100 ;
+101 ; do the merge
+102 FOR
SET HMPSUB=$ORDER(^TMP("HMP",$JOB,HMPSUB))
if 'HMPSUB
QUIT
Begin DoDot:1
+103 NEW HMPX,HMPDATA
+104 SET LSTLN=LSTLN+1
+105 ; If it is patient data add the wrapper with pid
+106 IF DFN'="OPD"
SET @HMPJSON@(LSTLN,.4)="{""collection"":"""_HMPDOM_""""_$$PIDS^HMPDJFS(DFN)_",""seq"":1,""total"":1,""object"":"_$SELECT($GET(ACT)="@":DELJSON,1:"")
+107 ; If it is operational data add the wrapper without pid
+108 ;;US5647
IF DFN="OPD"
IF $GET(ACT)="@"
SET @HMPJSON@(LSTLN,.4)="{""collection"":"""_HMPDOM_""",""seq"":1,""total"":1,""object"":"_DELJSON
+109 ; If it is operational data and to be deleted
+110 ;US5859
IF DFN="OPD"
IF $GET(ACT)'="@"
Begin DoDot:2
+111 SET @HMPJSON@(LSTLN,.4)="{""collection"":"""_HMPDOM_""",""seq"":1,""total"":1,""object"":"
+112 SET HMPX="""stampTime"":"_QTE_$SELECT($LENGTH($GET(HMPDAT("DELDATE"))):HMPDAT("DELDATE"),1:HMPDAT("STAMPTIME"))_QTE_","
+113 SET HMPDATA=^TMP("HMP",$JOB,HMPSUB,1)
+114 SET ^TMP("HMP",$JOB,HMPSUB,1)="{"_HMPX_$PIECE(HMPDATA,"{",2,999)
End DoDot:2
+115 MERGE @HMPJSON@(LSTLN)=^TMP("HMP",$JOB,HMPSUB)
+116 ; Close the wrapper
+117 SET HMPCLFLG=1
+118 ; Add the closing brace for the wrapper
+119 SET @HMPJSON@(LSTLN+1,.1)="}"
+120 ; Increment the domain total
+121 SET HMPDMTOT=HMPDMTOT+1
End DoDot:1
+122 ;
+123 SET HMPFCNT=$GET(HMPFCNT)+1
+124 MERGE ^TMP("HMPF",$JOB,HMPFCNT)=@HMPJSON
+125 ; need a comma if more than one item
+126 ; DE3502
IF HMPFCNT>1
SET ^TMP("HMPF",$JOB,HMPFCNT,.3)=$SELECT(HMPLITEM="SYNC":"},",1:",")
SET HMPLITEM="FRESH"
+127 ;
+128 ; clean up residual data in ^TMP($J), may be quite a lot
+129 KILL @HMPA4JSN,@HMPJSON
+130 QUIT
+131 ;