MAGNAN01 ;WOIFO/NST - IMAGING ANNOTATION UTILITY RPCS ; 07 May 2018 11:43 AM
;;3.0;IMAGING;**185,201**;Mar 19, 2002;Build 92;Aug 02, 2012
;; 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
;
;***** STORES THE DETAIL OF STUDY ANNOTATION
;
; RPC: MAGN ANNOT STORE STUDY
;
; .MAGOUT Reference to a local variable where the results are returned to
; .MAGPARAM
; MAGPARAM("STUDY UID")
; MAGPARAM("PSTATE UID")
; MAGPARAM("NAME")
; MAGPARAM("SOURCE")
; MAGPARAM("TOOL VERSION")
; MAGPARAM(1..n) Annotation Data (XML/JSON)
;
; Return Values
; =============
; MAGOUT(0) is defined and its 1st '^'-piece is 0, then an error
; occurred during execution of the procedure.
; MAGOUT(0) = Success status - success
; Failure status - error
STORE(MAGOUT,MAGPARAM) ;RPC [MAGN ANNOT STORE STUDY]
N MAGNFDA,MAGNXE,IENS,STUDYIEN,STUDYID,PSTATIEN,PSTATUID,EXIT
;
; Set input variables
S STUDYID=$G(MAGPARAM("STUDY UID"))
S PSTATUID=$G(MAGPARAM("PSTATE UID"))
;
K MAGOUT
S MAGOUT(0)=$$SETERROR^MAGNU002("")
I '$G(DUZ) S MAGOUT(0)=$$SETERROR^MAGNU002("No DUZ defined") Q
I STUDYID="" S MAGOUT(0)=$$SETERROR^MAGNU002("No STUDYID") Q
I PSTATUID="" S MAGOUT(0)=$$SETERROR^MAGNU002("No PSTATEUID") Q
S STUDYIEN=$$FIND1^DIC(2005.003,"","X",STUDYID,"","","MAGNXE")
I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) Q ; Set MAGOUT and quit if error exists
I 'STUDYIEN D ; Create Study record
. S IENS="+1,"
. S MAGNFDA(2005.003,IENS,.01)=STUDYID
. D UPDATE^DIE("","MAGNFDA","MAGNIEN","MAGNXE")
. I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) Q
. ; What is the Image IEN D ENTRY^MAGLOG("MAG ANNOT",$G(DUZ),IEN,"MAG IMAGE ANNOTATION","","1",$G(SOURCE,"CLINIC")) ;log annotation
. S STUDYIEN=MAGNIEN(1)
. Q
;
I $D(MAGNXE) Q ; MAGOUT is aleady set with the error
;
S PSTATIEN=$$FIND1^DIC(2005.0031,","_STUDYIEN_",","X",PSTATUID,"","","MAGNXE")
I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) Q ; Set MAGOUT and quit if error exists
;
I 'PSTATIEN D Q ; Create a new annotation record for the study and quit
. S PSTATIEN=$$UPDATE(.MAGOUT,STUDYIEN,"+2",.MAGPARAM)
. Q
;
I $G(MAGPARAM("DELETED")) D Q
. S EXIT=$$DELANNOT(.MAGOUT,STUDYIEN,PSTATIEN)
. Q
;
S EXIT=$$UPDATE(.MAGOUT,STUDYIEN,PSTATIEN,.MAGPARAM)
; MAGOUT is set at this point
Q
;
UPDATE(MAGOUT,IEN0,IEN1,MAGPARAM) ; Add new annotation data node w/ DUZ, version, data ...
N ANNOT,ANSITE,ANSERV,STUDYID,PSTATUID,NAME,SOURCE,VER
N I,MAGNFDA,MAGNIEN,MAGNXE
;
; Set input variables
S PSTATUID=$G(MAGPARAM("PSTATE UID"))
S NAME=$G(MAGPARAM("NAME"))
S SOURCE=$G(MAGPARAM("SOURCE"))
S VER=$G(MAGPARAM("TOOL VERSION"))
S I=0
F S I=$O(MAGPARAM(I)) Q:'I D
. S ANNOT(I)=MAGPARAM(I)
. Q
;
S ANSITE=$G(DUZ(2)) ; Annotation Site
S ANSERV=$$GET1^DIQ(200,DUZ,29,"I") ; Annotation service
;
S IENS=IEN1_","_IEN0_","
S:$E(IEN0)'="+" MAGNIEN(1)=IEN0
S:$E(IEN1)'="+" MAGNIEN(2)=IEN1
K MAGNFDA
S MAGNFDA(2005.0031,IENS,.01)=$G(MAGPARAM("PSTATE UID"))
S MAGNFDA(2005.0031,IENS,1)=DUZ ;ANNOTATOR
S:$D(ANNOT) MAGNFDA(2005.0031,IENS,2)=$$NOW^XLFDT() ;SAVE D/T
S:VER'="" MAGNFDA(2005.0031,IENS,3)=VER ;VERSION
S MAGNFDA(2005.0031,IENS,4)=$G(SOURCE,"CLINIC")
S MAGNFDA(2005.0031,IENS,7)=ANSERV ;SERVICE/SECTION
S MAGNFDA(2005.0031,IENS,8)=ANSITE ;SITE
S:NAME'="" MAGNFDA(2005.0031,IENS,9)=NAME ;Annotation name
D UPDATE^DIE("","MAGNFDA","MAGNIEN","MAGNXE")
I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) Q 0
;
I '$D(ANNOT) Q MAGNIEN(2)
S IENS=MAGNIEN(2)_","_IEN0_","
; Annotation data 2005.003 field #6
D WP^DIE(2005.0031,IENS,6,"","ANNOT","MAGNXE")
I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) D Q 0
. N DA,DIK
. ; clean up data
. S DIK="^MAG(2005.003,"_IEN0_",1,",DA=IEN1,DA(1)=IEN0
. D ^DIK
. Q
;
Q MAGNIEN(2)
;
DELANNOT(MAGOUT,IEN0,IEN1) ; Set Deleted flag
N IENS,MAGNFDA,MAGNIEN,MAGNXE
;
S IENS=IEN1_","_IEN0_","
K MAGNFDA
S MAGNFDA(2005.0031,IENS,5)=1
D UPDATE^DIE("","MAGNFDA","MAGNIEN","MAGNXE")
I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) Q 0
;
Q 1
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGNAN01 5078 printed Nov 22, 2024@17:17:16 Page 2
MAGNAN01 ;WOIFO/NST - IMAGING ANNOTATION UTILITY RPCS ; 07 May 2018 11:43 AM
+1 ;;3.0;IMAGING;**185,201**;Mar 19, 2002;Build 92;Aug 02, 2012
+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 ;***** STORES THE DETAIL OF STUDY ANNOTATION
+20 ;
+21 ; RPC: MAGN ANNOT STORE STUDY
+22 ;
+23 ; .MAGOUT Reference to a local variable where the results are returned to
+24 ; .MAGPARAM
+25 ; MAGPARAM("STUDY UID")
+26 ; MAGPARAM("PSTATE UID")
+27 ; MAGPARAM("NAME")
+28 ; MAGPARAM("SOURCE")
+29 ; MAGPARAM("TOOL VERSION")
+30 ; MAGPARAM(1..n) Annotation Data (XML/JSON)
+31 ;
+32 ; Return Values
+33 ; =============
+34 ; MAGOUT(0) is defined and its 1st '^'-piece is 0, then an error
+35 ; occurred during execution of the procedure.
+36 ; MAGOUT(0) = Success status - success
+37 ; Failure status - error
STORE(MAGOUT,MAGPARAM) ;RPC [MAGN ANNOT STORE STUDY]
+1 NEW MAGNFDA,MAGNXE,IENS,STUDYIEN,STUDYID,PSTATIEN,PSTATUID,EXIT
+2 ;
+3 ; Set input variables
+4 SET STUDYID=$GET(MAGPARAM("STUDY UID"))
+5 SET PSTATUID=$GET(MAGPARAM("PSTATE UID"))
+6 ;
+7 KILL MAGOUT
+8 SET MAGOUT(0)=$$SETERROR^MAGNU002("")
+9 IF '$GET(DUZ)
SET MAGOUT(0)=$$SETERROR^MAGNU002("No DUZ defined")
QUIT
+10 IF STUDYID=""
SET MAGOUT(0)=$$SETERROR^MAGNU002("No STUDYID")
QUIT
+11 IF PSTATUID=""
SET MAGOUT(0)=$$SETERROR^MAGNU002("No PSTATEUID")
QUIT
+12 SET STUDYIEN=$$FIND1^DIC(2005.003,"","X",STUDYID,"","","MAGNXE")
+13 ; Set MAGOUT and quit if error exists
IF $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE)
QUIT
+14 ; Create Study record
IF 'STUDYIEN
Begin DoDot:1
+15 SET IENS="+1,"
+16 SET MAGNFDA(2005.003,IENS,.01)=STUDYID
+17 DO UPDATE^DIE("","MAGNFDA","MAGNIEN","MAGNXE")
+18 IF $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE)
QUIT
+19 ; What is the Image IEN D ENTRY^MAGLOG("MAG ANNOT",$G(DUZ),IEN,"MAG IMAGE ANNOTATION","","1",$G(SOURCE,"CLINIC")) ;log annotation
+20 SET STUDYIEN=MAGNIEN(1)
+21 QUIT
End DoDot:1
+22 ;
+23 ; MAGOUT is aleady set with the error
IF $DATA(MAGNXE)
QUIT
+24 ;
+25 SET PSTATIEN=$$FIND1^DIC(2005.0031,","_STUDYIEN_",","X",PSTATUID,"","","MAGNXE")
+26 ; Set MAGOUT and quit if error exists
IF $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE)
QUIT
+27 ;
+28 ; Create a new annotation record for the study and quit
IF 'PSTATIEN
Begin DoDot:1
+29 SET PSTATIEN=$$UPDATE(.MAGOUT,STUDYIEN,"+2",.MAGPARAM)
+30 QUIT
End DoDot:1
QUIT
+31 ;
+32 IF $GET(MAGPARAM("DELETED"))
Begin DoDot:1
+33 SET EXIT=$$DELANNOT(.MAGOUT,STUDYIEN,PSTATIEN)
+34 QUIT
End DoDot:1
QUIT
+35 ;
+36 SET EXIT=$$UPDATE(.MAGOUT,STUDYIEN,PSTATIEN,.MAGPARAM)
+37 ; MAGOUT is set at this point
+38 QUIT
+39 ;
UPDATE(MAGOUT,IEN0,IEN1,MAGPARAM) ; Add new annotation data node w/ DUZ, version, data ...
+1 NEW ANNOT,ANSITE,ANSERV,STUDYID,PSTATUID,NAME,SOURCE,VER
+2 NEW I,MAGNFDA,MAGNIEN,MAGNXE
+3 ;
+4 ; Set input variables
+5 SET PSTATUID=$GET(MAGPARAM("PSTATE UID"))
+6 SET NAME=$GET(MAGPARAM("NAME"))
+7 SET SOURCE=$GET(MAGPARAM("SOURCE"))
+8 SET VER=$GET(MAGPARAM("TOOL VERSION"))
+9 SET I=0
+10 FOR
SET I=$ORDER(MAGPARAM(I))
if 'I
QUIT
Begin DoDot:1
+11 SET ANNOT(I)=MAGPARAM(I)
+12 QUIT
End DoDot:1
+13 ;
+14 ; Annotation Site
SET ANSITE=$GET(DUZ(2))
+15 ; Annotation service
SET ANSERV=$$GET1^DIQ(200,DUZ,29,"I")
+16 ;
+17 SET IENS=IEN1_","_IEN0_","
+18 if $EXTRACT(IEN0)'="+"
SET MAGNIEN(1)=IEN0
+19 if $EXTRACT(IEN1)'="+"
SET MAGNIEN(2)=IEN1
+20 KILL MAGNFDA
+21 SET MAGNFDA(2005.0031,IENS,.01)=$GET(MAGPARAM("PSTATE UID"))
+22 ;ANNOTATOR
SET MAGNFDA(2005.0031,IENS,1)=DUZ
+23 ;SAVE D/T
if $DATA(ANNOT)
SET MAGNFDA(2005.0031,IENS,2)=$$NOW^XLFDT()
+24 ;VERSION
if VER'=""
SET MAGNFDA(2005.0031,IENS,3)=VER
+25 SET MAGNFDA(2005.0031,IENS,4)=$GET(SOURCE,"CLINIC")
+26 ;SERVICE/SECTION
SET MAGNFDA(2005.0031,IENS,7)=ANSERV
+27 ;SITE
SET MAGNFDA(2005.0031,IENS,8)=ANSITE
+28 ;Annotation name
if NAME'=""
SET MAGNFDA(2005.0031,IENS,9)=NAME
+29 DO UPDATE^DIE("","MAGNFDA","MAGNIEN","MAGNXE")
+30 IF $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE)
QUIT 0
+31 ;
+32 IF '$DATA(ANNOT)
QUIT MAGNIEN(2)
+33 SET IENS=MAGNIEN(2)_","_IEN0_","
+34 ; Annotation data 2005.003 field #6
+35 DO WP^DIE(2005.0031,IENS,6,"","ANNOT","MAGNXE")
+36 IF $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE)
Begin DoDot:1
+37 NEW DA,DIK
+38 ; clean up data
+39 SET DIK="^MAG(2005.003,"_IEN0_",1,"
SET DA=IEN1
SET DA(1)=IEN0
+40 DO ^DIK
+41 QUIT
End DoDot:1
QUIT 0
+42 ;
+43 QUIT MAGNIEN(2)
+44 ;
DELANNOT(MAGOUT,IEN0,IEN1) ; Set Deleted flag
+1 NEW IENS,MAGNFDA,MAGNIEN,MAGNXE
+2 ;
+3 SET IENS=IEN1_","_IEN0_","
+4 KILL MAGNFDA
+5 SET MAGNFDA(2005.0031,IENS,5)=1
+6 DO UPDATE^DIE("","MAGNFDA","MAGNIEN","MAGNXE")
+7 IF $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE)
QUIT 0
+8 ;
+9 QUIT 1