Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: MAGVAG02

MAGVAG02.m

Go to the documentation of this file.
  1. 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
  1. ;; Per VHA Directive 2004-038, this routine should not be modified.
  1. ;; +---------------------------------------------------------------+
  1. ;; | Property of the US Government. |
  1. ;; | No permission to copy or redistribute this software is given. |
  1. ;; | Use of unreleased versions of this software requires the user |
  1. ;; | to execute a written test agreement with the VistA Imaging |
  1. ;; | Development Office of the Department of Veterans Affairs, |
  1. ;; | telephone (301) 734-0100. |
  1. ;; | The Food and Drug Administration classifies this software as |
  1. ;; | a medical device. As such, it may not be changed in any way. |
  1. ;; | Modifications to this software may result in an adulterated |
  1. ;; | medical device under 21CFR820, the use of which is considered |
  1. ;; | to be a violation of US Federal Statutes. |
  1. ;; +---------------------------------------------------------------+
  1. ;;
  1. Q
  1. ;
  1. ;***** Get artifact values with key list from ARTIFACT file (#2006.916)
  1. ; & ARTIFACT KEYLIST file (#2006.913) by artifact token
  1. ;
  1. ; RPC:MAGVA GET ARTIFACT W KL
  1. ;
  1. ; Input Parameters
  1. ; ================
  1. ; TOKEN = Artifact token
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; if error MAGRY(0) = Failure status ^ Error message^
  1. ; if success MAGRY(0) = Success status
  1. ; MAGRY(1..n) XML based result in format
  1. ; <?xml version="1.0" encoding="utf-8"?>
  1. ; <artifacts>
  1. ; <artifact
  1. ; id=""
  1. ; token=""
  1. ; size=""
  1. ; keyListFK=""
  1. ; createdDateTime=""
  1. ; lastAccessDateTime=""
  1. ; crc="">
  1. ; <keys>
  1. ; <key kvalue="" klevel="" />
  1. ; ...
  1. ; <key kvalue="" klevel=""/>
  1. ; </keys>
  1. ; </artifact>
  1. ; </artifacts>
  1. ;
  1. GAKLT(MAGRY,TOKEN) ; RPC [MAGVA GET ARTIFACT W KL]
  1. K MAGRY
  1. N RES,START
  1. D GETAIENT^MAGVAG02(.RES,TOKEN,"") ; Get not deleted Artifact IEN by Token
  1. I '$$ISOK^MAGVAF02(RES) S MAGRY(0)=RES Q
  1. S IEN=$$GETVAL^MAGVAF02(RES)
  1. S START=2 ; populate MAGRY starting with node 2
  1. D GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"K") ; Get the artifact with KeyList;
  1. D SETFTUCH^MAGVAF03(.MAGRY) ; set line 1 and two and the last one
  1. Q
  1. ;
  1. ;***** Get artifact values with key list and artifact instance
  1. ; from ARTIFACT file (#2006.916)
  1. ; & ARTIFACT KEYLIST file (#2006.913) and ARTIFACT INSTANCE file (#2006.918)
  1. ; by artifact token
  1. ;
  1. ; RPC:MAGVA GET A W KL AND AIS
  1. ;
  1. ; Input Parameters
  1. ; ================
  1. ; TOKEN = Artifact token
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; if error MAGRY(0) = Failure status ^ Error message^
  1. ; if success MAGRY(0) = Success status
  1. ; MAGRY(1..n) XML based result in format
  1. ; <?xml version="1.0" encoding="utf-8"?>
  1. ; <artifacts>
  1. ; <artifact
  1. ; id=""
  1. ; token=""
  1. ; size=""
  1. ; keyListFK=""
  1. ; createdDateTime=""
  1. ; lastAccessDateTime=""
  1. ; crc="">
  1. ; <keys>
  1. ; <key kvalue="" klevel="" />
  1. ; ...
  1. ; <key kvalue="" klevel="" />
  1. ; </keys>
  1. ; <artifact Instances>
  1. ; <artifact Instance>
  1. ; ....
  1. ; <artifact Instance>
  1. ; </artifact Instances>
  1. ; </artifact>
  1. ; </artifacts>
  1. ;
  1. GAKLAIST(MAGRY,TOKEN) ; RPC [MAGVA GET A W KL AND AIS]
  1. K MAGRY
  1. N RES,START
  1. D GETAIENT^MAGVAG02(.RES,TOKEN,"") ; Get not deleted Artifact IEN by Token
  1. I '$$ISOK^MAGVAF02(RES) S MAGRY(0)=RES Q
  1. S IEN=$$GETVAL^MAGVAF02(RES)
  1. S START=2 ; populate MAGRY starting with node 2
  1. D GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"KI") ; Get the artifact with KeyList & Artifact Instance
  1. D SETFTUCH^MAGVAF03(.MAGRY) ; set line 1 and two and the last one
  1. Q
  1. ;
  1. ;***** Get artifact values with key list and artifact instance
  1. ; from ARTIFACT file (#2006.916)
  1. ; & ARTIFACT KEYLIST file (#2006.913) and ARTIFACT INSTANCE file (#2006.918)
  1. ; by artifact PK (IEN)
  1. ;
  1. ; RPC:MAGVA GET A W KL AND AIS BY PK
  1. ;
  1. ; Input Parameters
  1. ; ================
  1. ; IEN = Artifact PK
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; if error MAGRY(0) = Failure status ^ Error message^
  1. ; if success MAGRY(0) = Success status
  1. ; MAGRY(1..n) XML based result in format
  1. ; <?xml version="1.0" encoding="utf-8"?>
  1. ; <artifacts>
  1. ; <artifact
  1. ; id=""
  1. ; token=""
  1. ; size=""
  1. ; keyListFK=""
  1. ; createdDateTime=""
  1. ; lastAccessDateTime=""
  1. ; crc="">
  1. ; <keys>
  1. ; <key kvalue="" klevel="" />
  1. ; ...
  1. ; <key kvalue="" klevel="" />
  1. ; </keys>
  1. ; <artifact Instances>
  1. ; <artifact Instance>
  1. ; ....
  1. ; <artifact Instance>
  1. ; </artifact Instances>
  1. ; </artifact>
  1. ; </artifacts>
  1. ;
  1. GAKLAISP(MAGRY,IEN) ; RPC [MAGVA GET A W KL AND AIS BY PK]
  1. N START
  1. K MAGRY
  1. ; Check whether artifact is deleted
  1. I $$ISAFTDEL^MAGVAG02(IEN) S MAGRY(0)=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Artifact "_IEN_" is deleted" Q ; skip deleted artifact
  1. S START=2 ; populate MAGRY starting with node 2
  1. D GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"KI") ; Get the artifact with KeyList and Artifact Instance
  1. D SETFTUCH^MAGVAF03(.MAGRY) ; set lines 0,1, and 2 and the last one
  1. Q
  1. ;
  1. ;***** Get artifact values with keylist and artifact instance and
  1. ; artifact retention policy and fulfillment
  1. ; from ARTIFACT file (#2006.916)
  1. ; & ARTIFACT KEYLIST file (#2006.913), ARTIFACT INSTANCE file (#2006.918)
  1. ; ARTIFACT RETENTION POLICY file (#2006.921)
  1. ; and RETENTION POLICY FULFILLMENT file (#2006.922)
  1. ; by artifact token
  1. ;
  1. ; RPC:MAGVA GET A AIS ARPS AND RPFFS
  1. ;
  1. ; Input Parameters
  1. ; ================
  1. ; TOKEN = Artifact token
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; if error MAGRY(0) = Failure status ^ Error message^
  1. ; if success MAGRY(0) = Success status
  1. ; MAGRY(1..n) XML based result in format
  1. ; <?xml version="1.0" encoding="utf-8"?>
  1. ; <artifacts>
  1. ; <artifact
  1. ; id=""
  1. ; token=""
  1. ; size=""
  1. ; keyListFK=""
  1. ; createdDateTime=""
  1. ; lastAccessDateTime=""
  1. ; crc="">
  1. ; <keys>
  1. ; <key kvalue="" klevel="" />
  1. ; ...
  1. ; <key kvalue="" klevel="" />
  1. ; </keys>
  1. ; <artifact Instances>
  1. ; <artifact Instance>
  1. ; ....
  1. ; <artifact Instance>
  1. ; </artifact Instances>
  1. ; <artifact Retention policy>
  1. ; <artifact Retention policy fulfillments>
  1. ; <artifact Retention policy fulfillment>
  1. ; ...
  1. ; <artifact Retention policy fulfillment>
  1. ; ...
  1. ; </artifact Retention policy fulfillments>
  1. ; </artifact Retention policy>
  1. ; </artifact>
  1. ; </artifacts>
  1. ;
  1. GAKISRPT(MAGRY,TOKEN) ; RPC [MAGVA GET A AIS ARPS AND RPFFS]
  1. K MAGRY
  1. N RES,START,IEN
  1. D GETAIENT^MAGVAG02(.RES,TOKEN,"") ; Get note deleted Artifact IEN by Token
  1. I '$$ISOK^MAGVAF02(RES) S MAGRY(0)=RES Q
  1. S IEN=$$GETVAL^MAGVAF02(RES)
  1. S START=2 ; populate MAGRY starting with node 2
  1. ; Get the artifact with KeyList, Artifact Instance & Retention Policy and Fulfillment
  1. D GAFTBYID^MAGVAG04(.MAGRY,IEN,START,"KIR")
  1. D SETFTUCH^MAGVAF03(.MAGRY) ; set line 1 and two and the last one
  1. Q
  1. ;
  1. ; -- Get Artifact IEN by TOKEN
  1. ;
  1. ; Input parameters
  1. ; ================
  1. ; TOKEN = Artifact token
  1. ; FLAGS =
  1. ; [D] - Include deleted artifact
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; if error MAGRY = Failure status ^ Error message^
  1. ; if success MAGRY = Success status^^IEN - IEN of the Artifact
  1. ;
  1. GETAIENT(MAGRY,TOKEN,FLAGS) ;
  1. I $G(TOKEN)="" S MAGRY=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Token is empty." Q
  1. N FILE,IEN,DELAPP
  1. S FILE=2006.916
  1. ; Get TOKEN IEN
  1. S IEN=$O(^MAGV(FILE,"B",TOKEN,""))
  1. I IEN="" S MAGRY=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Token not found." Q
  1. I FLAGS["D" S MAGRY=$$OK^MAGVAF02()_$$RESDEL^MAGVAF02()_$$RESDEL^MAGVAF02()_IEN Q
  1. ;
  1. ; Check whether Artifact is deleted
  1. S DELAPP=$$GET1^DIQ(FILE,IEN_",","DELETING APPLICATION","I")
  1. I $$ISAFTDEL^MAGVAG02(IEN) S MAGRY=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"ARTIFACT TOKEN "_TOKEN_" is deleted" Q
  1. S MAGRY=$$OK^MAGVAF02()_$$RESDEL^MAGVAF02()_$$RESDEL^MAGVAF02()_IEN Q
  1. Q
  1. ; -- Is Artifact deleted
  1. ;
  1. ; Input parameters
  1. ; ================
  1. ; IEN = IEN in ARTIFACT file (#2006.916)
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; 1 - artifact is deleted
  1. ; 0 - artifact is not deleted
  1. ;
  1. ISAFTDEL(IEN) ; Is Artifact deleted
  1. N DELAPP
  1. ; Check whether Artifact is deleted
  1. S DELAPP=$$GET1^DIQ(2006.916,IEN_",","DELETING APPLICATION","I")
  1. Q DELAPP'=""
  1. ;
  1. ;***** Get artifact values with key list and artifact instance
  1. ; from ARTIFACT file (#2006.916)
  1. ; & ARTIFACT KEYLIST file (#2006.913) and ARTIFACT INSTANCE file (#2006.918)
  1. ; by artifact KEYLIST
  1. ;
  1. ; RPC:MAGVA GET A W KL AND AIS BY KL
  1. ;
  1. ; Input Parameters
  1. ; ================
  1. ; KLIST(1) = First level Key
  1. ; KLIST(2) = Second level Key
  1. ; ...
  1. ; KLIST(N) = N-th level Key
  1. ;
  1. ; Any level is optional
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; if error MAGRY(0) = Failure status ^ Error message^
  1. ; if success MAGRY(0) = Success status
  1. ; MAGRY(1..n) XML based result in format
  1. ; <?xml version="1.0" encoding="utf-8"?>
  1. ; <artifacts>
  1. ; <artifact
  1. ; id=""
  1. ; token=""
  1. ; size=""
  1. ; keyListFK=""
  1. ; createdDateTime=""
  1. ; lastAccessDateTime=""
  1. ; crc="">
  1. ; <keys>
  1. ; <key kvalue="" klevel="" />
  1. ; ...
  1. ; <key kvalue="" klevel="" />
  1. ; </keys>
  1. ; <artifact Instances>
  1. ; <artifact Instance>
  1. ; ....
  1. ; <artifact Instance>
  1. ; </artifact Instances>
  1. ; </artifact>
  1. ; ...
  1. ; </artifacts>
  1. ;
  1. GAKLAISK(MAGRY,KLIST) ; RPC [MAGVA GET A W KL AND AIS BY KL]
  1. K MAGRY
  1. N KLIENS,ARTIFACT
  1. N FILE,IEN,AIEN,J,CNT,START,OUT,ERR,ERR2,MAGRESA
  1. S FILE=2006.916 ; ARTIFACT file
  1. D FINDKEYS^MAGVAKL1(.KLIENS,.KLIST) ; Get a list with IENs that meets the KLIST values
  1. I '$$ISOK^MAGVAF02(KLIENS(0)) S MAGRY(0)=KLIENS(0) Q ; Error found
  1. K KLIENS(0) ; Delete result internal info
  1. S START=2 ; populate MAGRY starting with node 2
  1. S IEN=""
  1. S ERR2=0
  1. S CNT=0
  1. S (MAGRY(1),MAGRY(2))="" ; place holders
  1. F Q:ERR2 S IEN=$O(KLIENS(IEN)) Q:IEN="" D
  1. . K OUT,ERR
  1. . D FIND^DIC(FILE,"","@","QX",IEN,"","KL","","","OUT","ERR") ;
  1. . I $D(ERR("DIERR")) D Q
  1. . . D MSG^DIALOG("A",.MAGRESA,245,5,"ERR")
  1. . . S MAGRY(0)=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Error getting token IEN: "_MAGRESA(1) Q ; Error getting the IEN
  1. . . S ERR2=1
  1. . . Q
  1. . K ARTIFACT
  1. . S J=""
  1. . F S J=$O(OUT("DILIST","2",J)) Q:J="" D
  1. . . S AIEN=OUT("DILIST","2",J)
  1. . . Q:$$ISAFTDEL^MAGVAG02(AIEN) ; skip deleted artifact
  1. . . D GAFTBYID^MAGVAG04(.ARTIFACT,AIEN,START,"KI") ; Get the artifact with KeyList & Artifact Instance
  1. . . I '$$ISOK^MAGVAF02(ARTIFACT(0)) D Q ; error found - quit
  1. . . . K MAGRY
  1. . . . S MAGRY(0)=$$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Error getting artifact " Q ; Error getting the values
  1. . . . S ERR2=1
  1. . . . Q
  1. . . K ARTIFACT(0) ; delete zero node record - it is for information only
  1. . . S CNT=$$APP2ARR^MAGVAF04(.MAGRY,.ARTIFACT) ; Append ARTIFACT to result
  1. . . Q
  1. . Q
  1. I 'CNT D Q ; No records found. Make an empty result and quit
  1. . D EMPTYXML^MAGVAF03(.MAGRY,FILE)
  1. . Q
  1. ;
  1. S MAGRY(0)=$$OK^MAGVAF02()_$$RESDEL^MAGVAF02()_$$RESDEL^MAGVAF02()_CNT
  1. D SETFTUCH^MAGVAF03(.MAGRY) ; set line 1 and two and the last one
  1. Q