MAGVAG02 ;WOIFO/NST - Utilities for RPC calls ; 11 Mar 2010 4:39 PM
;;3.0;IMAGING;**118**;Mar 19, 2002;Build 4525;May 01, 2013
;; Per VHA Directive 2004-038, this routine should not be modified.
;; +---------------------------------------------------------------+
;; | Property of the US Government. |
;; | No permission to copy or redistribute this software is given. |
;; | Use of unreleased versions of this software requires the user |
;; | to execute a written test agreement with the VistA Imaging |
;; | Development Office of the Department of Veterans Affairs, |
;; | telephone (301) 734-0100. |
;; | The Food and Drug Administration classifies this software as |
;; | a medical device. As such, it may not be changed in any way. |
;; | Modifications to this software may result in an adulterated |
;; | medical device under 21CFR820, the use of which is considered |
;; | to be a violation of US Federal Statutes. |
;; +---------------------------------------------------------------+
;;
Q
;
;***** Get artifact values with key list from ARTIFACT file (#2006.916)
; & ARTIFACT KEYLIST file (#2006.913) by artifact token
;
; RPC:MAGVA GET ARTIFACT W KL
;
; Input Parameters
; ================
; TOKEN = Artifact token
;
; Return Values
; =============
; if error MAGRY(0) = Failure status ^ Error message^
; if success MAGRY(0) = Success status
; MAGRY(1..n) XML based result in format
; <?xml version="1.0" encoding="utf-8"?>
; <artifacts>
; <artifact
; id=""
; token=""
; size=""
; keyListFK=""
; createdDateTime=""
; lastAccessDateTime=""
; crc="">
; <keys>
; <key kvalue="" klevel="" />
; ...
; <key kvalue="" klevel=""/>
; </keys>
; </artifact>
; </artifacts>
;
GAKLT(MAGRY,TOKEN) ; RPC [MAGVA GET ARTIFACT W KL]
K MAGRY
N RES,START
D GETAIENT^MAGVAG02(.RES,TOKEN,"") ; Get not deleted Artifact IEN by Token
I '$$ISOK^MAGVAF02(RES) S MAGRY(0)=RES Q
S IEN=$$GETVAL^MAGVAF02(RES)
S START=2 ; populate MAGRY starting with node 2
D GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"K") ; Get the artifact with KeyList;
D SETFTUCH^MAGVAF03(.MAGRY) ; set line 1 and two and the last one
Q
;
;***** Get artifact values with key list and artifact instance
; from ARTIFACT file (#2006.916)
; & ARTIFACT KEYLIST file (#2006.913) and ARTIFACT INSTANCE file (#2006.918)
; by artifact token
;
; RPC:MAGVA GET A W KL AND AIS
;
; Input Parameters
; ================
; TOKEN = Artifact token
;
; Return Values
; =============
; if error MAGRY(0) = Failure status ^ Error message^
; if success MAGRY(0) = Success status
; MAGRY(1..n) XML based result in format
; <?xml version="1.0" encoding="utf-8"?>
; <artifacts>
; <artifact
; id=""
; token=""
; size=""
; keyListFK=""
; createdDateTime=""
; lastAccessDateTime=""
; crc="">
; <keys>
; <key kvalue="" klevel="" />
; ...
; <key kvalue="" klevel="" />
; </keys>
; <artifact Instances>
; <artifact Instance>
; ....
; <artifact Instance>
; </artifact Instances>
; </artifact>
; </artifacts>
;
GAKLAIST(MAGRY,TOKEN) ; RPC [MAGVA GET A W KL AND AIS]
K MAGRY
N RES,START
D GETAIENT^MAGVAG02(.RES,TOKEN,"") ; Get not deleted Artifact IEN by Token
I '$$ISOK^MAGVAF02(RES) S MAGRY(0)=RES Q
S IEN=$$GETVAL^MAGVAF02(RES)
S START=2 ; populate MAGRY starting with node 2
D GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"KI") ; Get the artifact with KeyList & Artifact Instance
D SETFTUCH^MAGVAF03(.MAGRY) ; set line 1 and two and the last one
Q
;
;***** Get artifact values with key list and artifact instance
; from ARTIFACT file (#2006.916)
; & ARTIFACT KEYLIST file (#2006.913) and ARTIFACT INSTANCE file (#2006.918)
; by artifact PK (IEN)
;
; RPC:MAGVA GET A W KL AND AIS BY PK
;
; Input Parameters
; ================
; IEN = Artifact PK
;
; Return Values
; =============
; if error MAGRY(0) = Failure status ^ Error message^
; if success MAGRY(0) = Success status
; MAGRY(1..n) XML based result in format
; <?xml version="1.0" encoding="utf-8"?>
; <artifacts>
; <artifact
; id=""
; token=""
; size=""
; keyListFK=""
; createdDateTime=""
; lastAccessDateTime=""
; crc="">
; <keys>
; <key kvalue="" klevel="" />
; ...
; <key kvalue="" klevel="" />
; </keys>
; <artifact Instances>
; <artifact Instance>
; ....
; <artifact Instance>
; </artifact Instances>
; </artifact>
; </artifacts>
;
GAKLAISP(MAGRY,IEN) ; RPC [MAGVA GET A W KL AND AIS BY PK]
N START
K MAGRY
; Check whether artifact is deleted
I $$ISAFTDEL^MAGVAG02(IEN) S MAGRY(0)=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Artifact "_IEN_" is deleted" Q ; skip deleted artifact
S START=2 ; populate MAGRY starting with node 2
D GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"KI") ; Get the artifact with KeyList and Artifact Instance
D SETFTUCH^MAGVAF03(.MAGRY) ; set lines 0,1, and 2 and the last one
Q
;
;***** Get artifact values with keylist and artifact instance and
; artifact retention policy and fulfillment
; from ARTIFACT file (#2006.916)
; & ARTIFACT KEYLIST file (#2006.913), ARTIFACT INSTANCE file (#2006.918)
; ARTIFACT RETENTION POLICY file (#2006.921)
; and RETENTION POLICY FULFILLMENT file (#2006.922)
; by artifact token
;
; RPC:MAGVA GET A AIS ARPS AND RPFFS
;
; Input Parameters
; ================
; TOKEN = Artifact token
;
; Return Values
; =============
; if error MAGRY(0) = Failure status ^ Error message^
; if success MAGRY(0) = Success status
; MAGRY(1..n) XML based result in format
; <?xml version="1.0" encoding="utf-8"?>
; <artifacts>
; <artifact
; id=""
; token=""
; size=""
; keyListFK=""
; createdDateTime=""
; lastAccessDateTime=""
; crc="">
; <keys>
; <key kvalue="" klevel="" />
; ...
; <key kvalue="" klevel="" />
; </keys>
; <artifact Instances>
; <artifact Instance>
; ....
; <artifact Instance>
; </artifact Instances>
; <artifact Retention policy>
; <artifact Retention policy fulfillments>
; <artifact Retention policy fulfillment>
; ...
; <artifact Retention policy fulfillment>
; ...
; </artifact Retention policy fulfillments>
; </artifact Retention policy>
; </artifact>
; </artifacts>
;
GAKISRPT(MAGRY,TOKEN) ; RPC [MAGVA GET A AIS ARPS AND RPFFS]
K MAGRY
N RES,START,IEN
D GETAIENT^MAGVAG02(.RES,TOKEN,"") ; Get note deleted Artifact IEN by Token
I '$$ISOK^MAGVAF02(RES) S MAGRY(0)=RES Q
S IEN=$$GETVAL^MAGVAF02(RES)
S START=2 ; populate MAGRY starting with node 2
; Get the artifact with KeyList, Artifact Instance & Retention Policy and Fulfillment
D GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"KIR")
D SETFTUCH^MAGVAF03(.MAGRY) ; set line 1 and two and the last one
Q
;
; -- Get Artifact IEN by TOKEN
;
; Input parameters
; ================
; TOKEN = Artifact token
; FLAGS =
; [D] - Include deleted artifact
;
; Return Values
; =============
; if error MAGRY = Failure status ^ Error message^
; if success MAGRY = Success status^^IEN - IEN of the Artifact
;
GETAIENT(MAGRY,TOKEN,FLAGS) ;
I $G(TOKEN)="" S MAGRY=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Token is empty." Q
N FILE,IEN,DELAPP
S FILE=2006.916
; Get TOKEN IEN
S IEN=$O(^MAGV(FILE,"B",TOKEN,""))
I IEN="" S MAGRY=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Token not found." Q
I FLAGS["D" S MAGRY=$$OK^MAGVAF02()_$$RESDEL^MAGVAF02()_$$RESDEL^MAGVAF02()_IEN Q
;
; Check whether Artifact is deleted
S DELAPP=$$GET1^DIQ(FILE,IEN_",","DELETING APPLICATION","I")
I $$ISAFTDEL^MAGVAG02(IEN) S MAGRY=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"ARTIFACT TOKEN "_TOKEN_" is deleted" Q
S MAGRY=$$OK^MAGVAF02()_$$RESDEL^MAGVAF02()_$$RESDEL^MAGVAF02()_IEN Q
Q
; -- Is Artifact deleted
;
; Input parameters
; ================
; IEN = IEN in ARTIFACT file (#2006.916)
;
; Return Values
; =============
; 1 - artifact is deleted
; 0 - artifact is not deleted
;
ISAFTDEL(IEN) ; Is Artifact deleted
N DELAPP
; Check whether Artifact is deleted
S DELAPP=$$GET1^DIQ(2006.916,IEN_",","DELETING APPLICATION","I")
Q DELAPP'=""
;
;***** Get artifact values with key list and artifact instance
; from ARTIFACT file (#2006.916)
; & ARTIFACT KEYLIST file (#2006.913) and ARTIFACT INSTANCE file (#2006.918)
; by artifact KEYLIST
;
; RPC:MAGVA GET A W KL AND AIS BY KL
;
; Input Parameters
; ================
; KLIST(1) = First level Key
; KLIST(2) = Second level Key
; ...
; KLIST(N) = N-th level Key
;
; Any level is optional
;
; Return Values
; =============
; if error MAGRY(0) = Failure status ^ Error message^
; if success MAGRY(0) = Success status
; MAGRY(1..n) XML based result in format
; <?xml version="1.0" encoding="utf-8"?>
; <artifacts>
; <artifact
; id=""
; token=""
; size=""
; keyListFK=""
; createdDateTime=""
; lastAccessDateTime=""
; crc="">
; <keys>
; <key kvalue="" klevel="" />
; ...
; <key kvalue="" klevel="" />
; </keys>
; <artifact Instances>
; <artifact Instance>
; ....
; <artifact Instance>
; </artifact Instances>
; </artifact>
; ...
; </artifacts>
;
GAKLAISK(MAGRY,KLIST) ; RPC [MAGVA GET A W KL AND AIS BY KL]
K MAGRY
N KLIENS,ARTIFACT
N FILE,IEN,AIEN,J,CNT,START,OUT,ERR,ERR2,MAGRESA
S FILE=2006.916 ; ARTIFACT file
D FINDKEYS^MAGVAKL1(.KLIENS,.KLIST) ; Get a list with IENs that meets the KLIST values
I '$$ISOK^MAGVAF02(KLIENS(0)) S MAGRY(0)=KLIENS(0) Q ; Error found
K KLIENS(0) ; Delete result internal info
S START=2 ; populate MAGRY starting with node 2
S IEN=""
S ERR2=0
S CNT=0
S (MAGRY(1),MAGRY(2))="" ; place holders
F Q:ERR2 S IEN=$O(KLIENS(IEN)) Q:IEN="" D
. K OUT,ERR
. D FIND^DIC(FILE,"","@","QX",IEN,"","KL","","","OUT","ERR") ;
. I $D(ERR("DIERR")) D Q
. . D MSG^DIALOG("A",.MAGRESA,245,5,"ERR")
. . S MAGRY(0)=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Error getting token IEN: "_MAGRESA(1) Q ; Error getting the IEN
. . S ERR2=1
. . Q
. K ARTIFACT
. S J=""
. F S J=$O(OUT("DILIST","2",J)) Q:J="" D
. . S AIEN=OUT("DILIST","2",J)
. . Q:$$ISAFTDEL^MAGVAG02(AIEN) ; skip deleted artifact
. . D GAFTBYID^MAGVAG04(.ARTIFACT,AIEN,START,"KI") ; Get the artifact with KeyList & Artifact Instance
. . I '$$ISOK^MAGVAF02(ARTIFACT(0)) D Q ; error found - quit
. . . K MAGRY
. . . S MAGRY(0)=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Error getting artifact " Q ; Error getting the values
. . . S ERR2=1
. . . Q
. . K ARTIFACT(0) ; delete zero node record - it is for information only
. . S CNT=$$APP2ARR^MAGVAF04(.MAGRY,.ARTIFACT) ; Append ARTIFACT to result
. . Q
. Q
I 'CNT D Q ; No records found. Make an empty result and quit
. D EMPTYXML^MAGVAF03(.MAGRY,FILE)
. Q
;
S MAGRY(0)=$$OK^MAGVAF02()_$$RESDEL^MAGVAF02()_$$RESDEL^MAGVAF02()_CNT
D SETFTUCH^MAGVAF03(.MAGRY) ; set line 1 and two and the last one
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGVAG02 13027 printed Oct 16, 2024@18:10:03 Page 2
MAGVAG02 ;WOIFO/NST - Utilities for RPC calls ; 11 Mar 2010 4:39 PM
+1 ;;3.0;IMAGING;**118**;Mar 19, 2002;Build 4525;May 01, 2013
+2 ;; Per VHA Directive 2004-038, this routine should not be modified.
+3 ;; +---------------------------------------------------------------+
+4 ;; | Property of the US Government. |
+5 ;; | No permission to copy or redistribute this software is given. |
+6 ;; | Use of unreleased versions of this software requires the user |
+7 ;; | to execute a written test agreement with the VistA Imaging |
+8 ;; | Development Office of the Department of Veterans Affairs, |
+9 ;; | telephone (301) 734-0100. |
+10 ;; | The Food and Drug Administration classifies this software as |
+11 ;; | a medical device. As such, it may not be changed in any way. |
+12 ;; | Modifications to this software may result in an adulterated |
+13 ;; | medical device under 21CFR820, the use of which is considered |
+14 ;; | to be a violation of US Federal Statutes. |
+15 ;; +---------------------------------------------------------------+
+16 ;;
+17 QUIT
+18 ;
+19 ;***** Get artifact values with key list from ARTIFACT file (#2006.916)
+20 ; & ARTIFACT KEYLIST file (#2006.913) by artifact token
+21 ;
+22 ; RPC:MAGVA GET ARTIFACT W KL
+23 ;
+24 ; Input Parameters
+25 ; ================
+26 ; TOKEN = Artifact token
+27 ;
+28 ; Return Values
+29 ; =============
+30 ; if error MAGRY(0) = Failure status ^ Error message^
+31 ; if success MAGRY(0) = Success status
+32 ; MAGRY(1..n) XML based result in format
+33 ; <?xml version="1.0" encoding="utf-8"?>
+34 ; <artifacts>
+35 ; <artifact
+36 ; id=""
+37 ; token=""
+38 ; size=""
+39 ; keyListFK=""
+40 ; createdDateTime=""
+41 ; lastAccessDateTime=""
+42 ; crc="">
+43 ; <keys>
+44 ; <key kvalue="" klevel="" />
+45 ; ...
+46 ; <key kvalue="" klevel=""/>
+47 ; </keys>
+48 ; </artifact>
+49 ; </artifacts>
+50 ;
GAKLT(MAGRY,TOKEN) ; RPC [MAGVA GET ARTIFACT W KL]
+1 KILL MAGRY
+2 NEW RES,START
+3 ; Get not deleted Artifact IEN by Token
DO GETAIENT^MAGVAG02(.RES,TOKEN,"")
+4 IF '$$ISOK^MAGVAF02(RES)
SET MAGRY(0)=RES
QUIT
+5 SET IEN=$$GETVAL^MAGVAF02(RES)
+6 ; populate MAGRY starting with node 2
SET START=2
+7 ; Get the artifact with KeyList;
DO GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"K")
+8 ; set line 1 and two and the last one
DO SETFTUCH^MAGVAF03(.MAGRY)
+9 QUIT
+10 ;
+11 ;***** Get artifact values with key list and artifact instance
+12 ; from ARTIFACT file (#2006.916)
+13 ; & ARTIFACT KEYLIST file (#2006.913) and ARTIFACT INSTANCE file (#2006.918)
+14 ; by artifact token
+15 ;
+16 ; RPC:MAGVA GET A W KL AND AIS
+17 ;
+18 ; Input Parameters
+19 ; ================
+20 ; TOKEN = Artifact token
+21 ;
+22 ; Return Values
+23 ; =============
+24 ; if error MAGRY(0) = Failure status ^ Error message^
+25 ; if success MAGRY(0) = Success status
+26 ; MAGRY(1..n) XML based result in format
+27 ; <?xml version="1.0" encoding="utf-8"?>
+28 ; <artifacts>
+29 ; <artifact
+30 ; id=""
+31 ; token=""
+32 ; size=""
+33 ; keyListFK=""
+34 ; createdDateTime=""
+35 ; lastAccessDateTime=""
+36 ; crc="">
+37 ; <keys>
+38 ; <key kvalue="" klevel="" />
+39 ; ...
+40 ; <key kvalue="" klevel="" />
+41 ; </keys>
+42 ; <artifact Instances>
+43 ; <artifact Instance>
+44 ; ....
+45 ; <artifact Instance>
+46 ; </artifact Instances>
+47 ; </artifact>
+48 ; </artifacts>
+49 ;
GAKLAIST(MAGRY,TOKEN) ; RPC [MAGVA GET A W KL AND AIS]
+1 KILL MAGRY
+2 NEW RES,START
+3 ; Get not deleted Artifact IEN by Token
DO GETAIENT^MAGVAG02(.RES,TOKEN,"")
+4 IF '$$ISOK^MAGVAF02(RES)
SET MAGRY(0)=RES
QUIT
+5 SET IEN=$$GETVAL^MAGVAF02(RES)
+6 ; populate MAGRY starting with node 2
SET START=2
+7 ; Get the artifact with KeyList & Artifact Instance
DO GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"KI")
+8 ; set line 1 and two and the last one
DO SETFTUCH^MAGVAF03(.MAGRY)
+9 QUIT
+10 ;
+11 ;***** Get artifact values with key list and artifact instance
+12 ; from ARTIFACT file (#2006.916)
+13 ; & ARTIFACT KEYLIST file (#2006.913) and ARTIFACT INSTANCE file (#2006.918)
+14 ; by artifact PK (IEN)
+15 ;
+16 ; RPC:MAGVA GET A W KL AND AIS BY PK
+17 ;
+18 ; Input Parameters
+19 ; ================
+20 ; IEN = Artifact PK
+21 ;
+22 ; Return Values
+23 ; =============
+24 ; if error MAGRY(0) = Failure status ^ Error message^
+25 ; if success MAGRY(0) = Success status
+26 ; MAGRY(1..n) XML based result in format
+27 ; <?xml version="1.0" encoding="utf-8"?>
+28 ; <artifacts>
+29 ; <artifact
+30 ; id=""
+31 ; token=""
+32 ; size=""
+33 ; keyListFK=""
+34 ; createdDateTime=""
+35 ; lastAccessDateTime=""
+36 ; crc="">
+37 ; <keys>
+38 ; <key kvalue="" klevel="" />
+39 ; ...
+40 ; <key kvalue="" klevel="" />
+41 ; </keys>
+42 ; <artifact Instances>
+43 ; <artifact Instance>
+44 ; ....
+45 ; <artifact Instance>
+46 ; </artifact Instances>
+47 ; </artifact>
+48 ; </artifacts>
+49 ;
GAKLAISP(MAGRY,IEN) ; RPC [MAGVA GET A W KL AND AIS BY PK]
+1 NEW START
+2 KILL MAGRY
+3 ; Check whether artifact is deleted
+4 ; skip deleted artifact
IF $$ISAFTDEL^MAGVAG02(IEN)
SET MAGRY(0)=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Artifact "_IEN_" is deleted"
QUIT
+5 ; populate MAGRY starting with node 2
SET START=2
+6 ; Get the artifact with KeyList and Artifact Instance
DO GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"KI")
+7 ; set lines 0,1, and 2 and the last one
DO SETFTUCH^MAGVAF03(.MAGRY)
+8 QUIT
+9 ;
+10 ;***** Get artifact values with keylist and artifact instance and
+11 ; artifact retention policy and fulfillment
+12 ; from ARTIFACT file (#2006.916)
+13 ; & ARTIFACT KEYLIST file (#2006.913), ARTIFACT INSTANCE file (#2006.918)
+14 ; ARTIFACT RETENTION POLICY file (#2006.921)
+15 ; and RETENTION POLICY FULFILLMENT file (#2006.922)
+16 ; by artifact token
+17 ;
+18 ; RPC:MAGVA GET A AIS ARPS AND RPFFS
+19 ;
+20 ; Input Parameters
+21 ; ================
+22 ; TOKEN = Artifact token
+23 ;
+24 ; Return Values
+25 ; =============
+26 ; if error MAGRY(0) = Failure status ^ Error message^
+27 ; if success MAGRY(0) = Success status
+28 ; MAGRY(1..n) XML based result in format
+29 ; <?xml version="1.0" encoding="utf-8"?>
+30 ; <artifacts>
+31 ; <artifact
+32 ; id=""
+33 ; token=""
+34 ; size=""
+35 ; keyListFK=""
+36 ; createdDateTime=""
+37 ; lastAccessDateTime=""
+38 ; crc="">
+39 ; <keys>
+40 ; <key kvalue="" klevel="" />
+41 ; ...
+42 ; <key kvalue="" klevel="" />
+43 ; </keys>
+44 ; <artifact Instances>
+45 ; <artifact Instance>
+46 ; ....
+47 ; <artifact Instance>
+48 ; </artifact Instances>
+49 ; <artifact Retention policy>
+50 ; <artifact Retention policy fulfillments>
+51 ; <artifact Retention policy fulfillment>
+52 ; ...
+53 ; <artifact Retention policy fulfillment>
+54 ; ...
+55 ; </artifact Retention policy fulfillments>
+56 ; </artifact Retention policy>
+57 ; </artifact>
+58 ; </artifacts>
+59 ;
GAKISRPT(MAGRY,TOKEN) ; RPC [MAGVA GET A AIS ARPS AND RPFFS]
+1 KILL MAGRY
+2 NEW RES,START,IEN
+3 ; Get note deleted Artifact IEN by Token
DO GETAIENT^MAGVAG02(.RES,TOKEN,"")
+4 IF '$$ISOK^MAGVAF02(RES)
SET MAGRY(0)=RES
QUIT
+5 SET IEN=$$GETVAL^MAGVAF02(RES)
+6 ; populate MAGRY starting with node 2
SET START=2
+7 ; Get the artifact with KeyList, Artifact Instance & Retention Policy and Fulfillment
+8 DO GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"KIR")
+9 ; set line 1 and two and the last one
DO SETFTUCH^MAGVAF03(.MAGRY)
+10 QUIT
+11 ;
+12 ; -- Get Artifact IEN by TOKEN
+13 ;
+14 ; Input parameters
+15 ; ================
+16 ; TOKEN = Artifact token
+17 ; FLAGS =
+18 ; [D] - Include deleted artifact
+19 ;
+20 ; Return Values
+21 ; =============
+22 ; if error MAGRY = Failure status ^ Error message^
+23 ; if success MAGRY = Success status^^IEN - IEN of the Artifact
+24 ;
GETAIENT(MAGRY,TOKEN,FLAGS) ;
+1 IF $GET(TOKEN)=""
SET MAGRY=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Token is empty."
QUIT
+2 NEW FILE,IEN,DELAPP
+3 SET FILE=2006.916
+4 ; Get TOKEN IEN
+5 SET IEN=$ORDER(^MAGV(FILE,"B",TOKEN,""))
+6 IF IEN=""
SET MAGRY=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Token not found."
QUIT
+7 IF FLAGS["D"
SET MAGRY=$$OK^MAGVAF02()_$$RESDEL^MAGVAF02()_$$RESDEL^MAGVAF02()_IEN
QUIT
+8 ;
+9 ; Check whether Artifact is deleted
+10 SET DELAPP=$$GET1^DIQ(FILE,IEN_",","DELETING APPLICATION","I")
+11 IF $$ISAFTDEL^MAGVAG02(IEN)
SET MAGRY=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"ARTIFACT TOKEN "_TOKEN_" is deleted"
QUIT
+12 SET MAGRY=$$OK^MAGVAF02()_$$RESDEL^MAGVAF02()_$$RESDEL^MAGVAF02()_IEN
QUIT
+13 QUIT
+14 ; -- Is Artifact deleted
+15 ;
+16 ; Input parameters
+17 ; ================
+18 ; IEN = IEN in ARTIFACT file (#2006.916)
+19 ;
+20 ; Return Values
+21 ; =============
+22 ; 1 - artifact is deleted
+23 ; 0 - artifact is not deleted
+24 ;
ISAFTDEL(IEN) ; Is Artifact deleted
+1 NEW DELAPP
+2 ; Check whether Artifact is deleted
+3 SET DELAPP=$$GET1^DIQ(2006.916,IEN_",","DELETING APPLICATION","I")
+4 QUIT DELAPP'=""
+5 ;
+6 ;***** Get artifact values with key list and artifact instance
+7 ; from ARTIFACT file (#2006.916)
+8 ; & ARTIFACT KEYLIST file (#2006.913) and ARTIFACT INSTANCE file (#2006.918)
+9 ; by artifact KEYLIST
+10 ;
+11 ; RPC:MAGVA GET A W KL AND AIS BY KL
+12 ;
+13 ; Input Parameters
+14 ; ================
+15 ; KLIST(1) = First level Key
+16 ; KLIST(2) = Second level Key
+17 ; ...
+18 ; KLIST(N) = N-th level Key
+19 ;
+20 ; Any level is optional
+21 ;
+22 ; Return Values
+23 ; =============
+24 ; if error MAGRY(0) = Failure status ^ Error message^
+25 ; if success MAGRY(0) = Success status
+26 ; MAGRY(1..n) XML based result in format
+27 ; <?xml version="1.0" encoding="utf-8"?>
+28 ; <artifacts>
+29 ; <artifact
+30 ; id=""
+31 ; token=""
+32 ; size=""
+33 ; keyListFK=""
+34 ; createdDateTime=""
+35 ; lastAccessDateTime=""
+36 ; crc="">
+37 ; <keys>
+38 ; <key kvalue="" klevel="" />
+39 ; ...
+40 ; <key kvalue="" klevel="" />
+41 ; </keys>
+42 ; <artifact Instances>
+43 ; <artifact Instance>
+44 ; ....
+45 ; <artifact Instance>
+46 ; </artifact Instances>
+47 ; </artifact>
+48 ; ...
+49 ; </artifacts>
+50 ;
GAKLAISK(MAGRY,KLIST) ; RPC [MAGVA GET A W KL AND AIS BY KL]
+1 KILL MAGRY
+2 NEW KLIENS,ARTIFACT
+3 NEW FILE,IEN,AIEN,J,CNT,START,OUT,ERR,ERR2,MAGRESA
+4 ; ARTIFACT file
SET FILE=2006.916
+5 ; Get a list with IENs that meets the KLIST values
DO FINDKEYS^MAGVAKL1(.KLIENS,.KLIST)
+6 ; Error found
IF '$$ISOK^MAGVAF02(KLIENS(0))
SET MAGRY(0)=KLIENS(0)
QUIT
+7 ; Delete result internal info
KILL KLIENS(0)
+8 ; populate MAGRY starting with node 2
SET START=2
+9 SET IEN=""
+10 SET ERR2=0
+11 SET CNT=0
+12 ; place holders
SET (MAGRY(1),MAGRY(2))=""
+13 FOR
if ERR2
QUIT
SET IEN=$ORDER(KLIENS(IEN))
if IEN=""
QUIT
Begin DoDot:1
+14 KILL OUT,ERR
+15 ;
DO FIND^DIC(FILE,"","@","QX",IEN,"","KL","","","OUT","ERR")
+16 IF $DATA(ERR("DIERR"))
Begin DoDot:2
+17 DO MSG^DIALOG("A",.MAGRESA,245,5,"ERR")
+18 ; Error getting the IEN
SET MAGRY(0)=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Error getting token IEN: "_MAGRESA(1)
QUIT
+19 SET ERR2=1
+20 QUIT
End DoDot:2
QUIT
+21 KILL ARTIFACT
+22 SET J=""
+23 FOR
SET J=$ORDER(OUT("DILIST","2",J))
if J=""
QUIT
Begin DoDot:2
+24 SET AIEN=OUT("DILIST","2",J)
+25 ; skip deleted artifact
if $$ISAFTDEL^MAGVAG02(AIEN)
QUIT
+26 ; Get the artifact with KeyList & Artifact Instance
DO GAFTBYID^MAGVAG04(.ARTIFACT,AIEN,START,"KI")
+27 ; error found - quit
IF '$$ISOK^MAGVAF02(ARTIFACT(0))
Begin DoDot:3
+28 KILL MAGRY
+29 ; Error getting the values
SET MAGRY(0)=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Error getting artifact "
QUIT
+30 SET ERR2=1
+31 QUIT
End DoDot:3
QUIT
+32 ; delete zero node record - it is for information only
KILL ARTIFACT(0)
+33 ; Append ARTIFACT to result
SET CNT=$$APP2ARR^MAGVAF04(.MAGRY,.ARTIFACT)
+34 QUIT
End DoDot:2
+35 QUIT
End DoDot:1
+36 ; No records found. Make an empty result and quit
IF 'CNT
Begin DoDot:1
+37 DO EMPTYXML^MAGVAF03(.MAGRY,FILE)
+38 QUIT
End DoDot:1
QUIT
+39 ;
+40 SET MAGRY(0)=$$OK^MAGVAF02()_$$RESDEL^MAGVAF02()_$$RESDEL^MAGVAF02()_CNT
+41 ; set line 1 and two and the last one
DO SETFTUCH^MAGVAF03(.MAGRY)
+42 QUIT