MAGSANNO ;WOIFO/JSL/GEK - IMAGING ANNOTATION UTILITY RPCS ; 9 Jun 2011 11:43 AM
;;3.0;IMAGING;**122**;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
;-------------------------------------------------------------------
;***** RETURNS THE LIST OF IMAGE ANNOTATIONS
; RPC: MAG ANNOT GET IMAGE
;
; .MAGOUT Reference to a local variable where the results
; are returned to.
; .MAGIEN Internal Entry Number of IMAGE file being annotated
;
; Return Values
; =============
; If MAGOUT(0) is defined and its 1st '^'-piece is 0, then an error
; occurred during execution of the procedure. 0^0^ ERROR explanation
; MAGOUT(0) = 1 ^ COUNTER ^ MESSAGE/1childIEN ;OK + the counter of saved annotations
; MAGOUT(n) = LAYER ID ^ ANNOTATOR ^ SAVED DATE/TIME ^ ANNOTATION VERSION
; ^ SOURCE ^ DELETION ^ TIU COMPLETION
; ^ SERVICE/SECTION ^ SITE# ^ DUZ
;
; Definition of each piece of MAGOUT(n)
;[1] = layer ID (unique to the image, not globally unique)
;[2] = name of user who saved layer
;[3] = date layer stored
;[4] = annotation version
;[5] = application that created layer
;[6] = 0/1 to indicate if layer deleted
;[7] = indicates if the layer was saved after the TIU Note COMPLETE (if there is a note)
;[8] = Service Section of user who saved layer
;[9] = user site name
;[10] = DUZ of user who saved layer
GET(MAGOUT,MAGIEN) ;RPC [MAG ANNOT GET IMAGE]
N N,CNT,X,Y,IEN,DATA,ERR,RET
S MAGOUT(0)=0
S IEN=MAGIEN
I '$$ISVALID^MAGGI11(IEN,.RET) S MAGOUT(0)="0^0^"_$P(RET,"^",2) Q
I $$ISDEL^MAGGI11(IEN,.RET) S MAGOUT(0)="0^0^Image IEN: "_IEN_" is Deleted." Q
;if group, find child IEN
I $$ISGRP^MAGGI11(MAGIEN,.ERR) S IEN=$$GRPCH1^MAGGI14(MAGIEN,"E")
; If invalid Group child. Quit.
I (IEN<1) S MAGOUT(0)="0^0^Invalid Group Image: "_MAGIEN Q
S CNT=0
;
;P122 takes only one type of annotation (Clinic or VistARAD), but not both
I $D(^MAG(2005,IEN,210,0)) D
. F S CNT=$O(^MAG(2005,IEN,210,CNT)) Q:'CNT S X=$G(^(CNT,0)) I $L(X) D
. . S MAGOUT(CNT)=$$DATA210(IEN,CNT)
. Q
I $D(^MAG(2005.002,IEN,0)) D
. F S CNT=$O(^MAG(2005.002,IEN,1,CNT)) Q:'CNT S X=$G(^(CNT,0)) I $L(X) D
. . S MAGOUT(CNT)=$$DATA002(IEN,CNT)
. Q
I '$O(MAGOUT(0)) S MAGOUT(0)="1^0^No annotation for image IEN#"_MAGIEN Q
S MAGOUT(0)=1_U_+$O(MAGOUT(" "),-1)_U_$S(IEN=MAGIEN:"",1:IEN) ;1:success^layer counter^optional childIEN
Q
;-------------------------------------------------------------------
;***** RETURNS THE DETAIL OF IMAGE ANNOTATIONS
; RPC: MAG ANNOT GET IMAGE DETAIL
;
; .MAGOUT Reference to a local variable where the results are returned to.
; .MAGIEN Internal entry number of IMAGE file been annotated
; .LAYIEN Internal entry number of ANNOTATION IMAGE LAYER in #2005.002
;
; Return Values
; =============
; If MAGOUT(0) is defined and its 1st '^'-piece is 0, then an error
; occurred during execution of the procedure. 0 ^ 0 ^ error message
; MAGOUT(0) = 1 ^ total count ; lines counter of the returned array
; MAGOUT(1) = LAYER ID ^ ANNOTATOR ^ SAVED DATE/TIME ^ ANNOTATION VERSION ^ SOURCE ^ DELETION ^ TIU COMPLETION
; ^ SERVICE/SECTION ^ SITE# ^ DUZ
; MAGOUT(n+1) = XML data line(s)
;
GETD(MAGOUT,MAGIEN,LAYIEN) ;RPC [MAG ANNOT GET IMAGE DETAIL]
N N,CNT,LN,X,Y,IEN,ERR,LASTN,WP
S MAGOUT(0)=0
S IEN=MAGIEN
I '$$ISVALID^MAGGI11(IEN,.RET) S MAGOUT(0)="0^0^"_$P(RET,"^",2) Q
I $$ISDEL^MAGGI11(IEN,.RET) S MAGOUT(0)="0^0^Image IEN: "_IEN_" is Deleted." Q
;if group, find child IEN
I $$ISGRP^MAGGI11(MAGIEN,.ERR) S IEN=$$GRPCH1^MAGGI14(MAGIEN,"E")
; If invalid Group child. Quit.
I (IEN<1) S MAGOUT(0)="0^0^Invalid Group Image: "_MAGIEN Q
;
;P122 handles only one type of annotation (Clinic or VistARAD), but not on both
I $D(^MAG(2005,IEN,210,0)) D
. S CNT=+$G(LAYIEN,1),X=$G(^MAG(2005,IEN,210,CNT,0)) I $L(X) D
. . S MAGOUT(1)=$$DATA210(IEN,CNT) ; P122 GEK
. . S LN=$P($G(^MAG(2005,IEN,210,CNT,1,0)),U,3) Q:'LN
. . F N=1:1:LN S MAGOUT(N+1)=$G(^MAG(2005,IEN,210,CNT,1,N,0)) ;XML raw data
. Q
I $D(^MAG(2005.002,IEN,0)) D
. S LASTN=+$P($G(^MAG(2005.002,IEN,1,0)),U,3) ;last annotation, if no LAYIEN
. S CNT=$G(LAYIEN,LASTN),X=$G(^MAG(2005.002,IEN,1,CNT,0)) I $L(X) D
. . S MAGOUT(1)=$$DATA002(IEN,CNT) ; P122 GEK
. . S X=$$GET1^DIQ(2005.0021,CNT_","_IEN,5,"","WP")
. . S LN="" F N=2:1 S LN=$O(WP(LN)) Q:'LN S MAGOUT(N)=WP(LN) ;XML raw data
. Q
;
I '$O(MAGOUT(0)) S MAGOUT(0)="1^0^No annotation for image IEN#"_MAGIEN_" ("_$G(LAYIEN)_")" Q
S CNT=+$O(MAGOUT(" "),-1),MAGOUT(0)=1_U_CNT_U_$S(IEN=MAGIEN:"",1:IEN) ;success + total count + optional childIEN
Q
;
; --- DATA210
; Get data from Image file for VistaRAD Annotations.
; Function returns "^" delimited string of annotation properties.
; Other functions call here to get data from Image file.
;
DATA210(IEN,CNT) ;Get VistaRAD Annotation data
N X,DATA
N ANDUZ,ANDTM,ANVRN,ANSRC,ANDEL,ANTIUST,ANSERV,ANSITE
S X=$G(^MAG(2005,IEN,210,CNT,0))
S ANDUZ=$P(X,"^",3),ANDTM=$P(X,"^",4),ANVRN="",ANSRC="VISTARAD",ANDEL=0,ANTIUST=0
S ANSERV="RADIOLOGY"
S ANSITE=$P($G(^MAG(2005,IEN,100)),"^",3)
;
S $P(DATA,"^",1)=CNT ;
S $P(DATA,"^",2)=$$GET1^DIQ(200,ANDUZ,.01,"E") ;
S $P(DATA,"^",3)=$$FMTE^XLFDT(ANDTM) ;
S $P(DATA,"^",4)=ANVRN ;ANVRN ("" for VistaRAD);
S $P(DATA,"^",5)=ANSRC ;ANSRC (Defalut to VistaRAD);
S $P(DATA,"^",6)=ANDEL ;ANDEL (0 for VistaRAD);
S $P(DATA,"^",7)=ANTIUST ;ANTIUST (0 for VistaRAD).
S $P(DATA,"^",8)=ANSERV ;ANSERV (default to RADIOLOGY)
S $P(DATA,"^",9)=$S(ANSITE:$$GET1^DIQ(4,ANSITE,.01,"E"),1:ANSITE) ;
S $P(DATA,"^",10)=ANDUZ ;
Q DATA
;
; --- DATA002
; Get data from Imaging Annotation file entry
; Function returns "^" delimited string of annotation properties.
; Other functions call here to get data from Imaging Annotation file.
;
DATA002(IEN,CNT) ;Get Image Annotation data.
N X,DATA
N ANDUZ,ANDTM,ANVRN,ANSRC,ANDEL,ANTIUST,ANSERV,ANSITE
S X=$G(^MAG(2005.002,IEN,1,CNT,0))
S ANDUZ=$P(X,U,1),ANDTM=$P(X,U,2),ANVRN=$P(X,U,3),ANSRC=$P(X,U,4),ANDEL=$P(X,U,5),ANTIUST=$P(X,U,6)
S ANSERV=+$P(X,U,7) S:ANSERV ANSERV=$$GET1^DIQ(49,ANSERV,.01,"E")
S ANSITE=+$P(X,U,8) S:ANSITE ANSITE=$$GET1^DIQ(4,ANSITE,.01,"E")
;
S $P(DATA,"^",1)=CNT ;
S $P(DATA,"^",2)=$$GET1^DIQ(200,ANDUZ,.01,"E") ;
S $P(DATA,"^",3)=$$FMTE^XLFDT(ANDTM) ;
S $P(DATA,"^",4)=ANVRN ;
S $P(DATA,"^",5)=ANSRC ;
S $P(DATA,"^",6)=ANDEL ;
S $P(DATA,"^",7)=ANTIUST ;
S $P(DATA,"^",8)=$S(ANSERV:$$GET1^DIQ(49,ANSERV,.01,"E"),1:ANSERV) ;
S $P(DATA,"^",9)=$S(ANSITE:$$GET1^DIQ(4,ANSITE,.01,"E"),1:ANSITE) ;
S $P(DATA,"^",10)=ANDUZ ; ANDUZ Not DUZ
Q DATA
;
CAP(X) ;
Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
;-------------------------------------------------------------------
;***** STORES THE DETAIL OF IMAGE ANNOTATIONS
; RPC: MAG ANNOT STORE IMAGE DETAIL
;
; .MAGOUT Reference to a local variable where the results are returned to
; .MAGIEN Internal Entry Number(IEN) of IMAGE file been annotated
; .SOURCE Reference to the application XML been created by ('CLINIC' or 'VISTARAD'...etc)
; .VER Reference to the annotation tool version (e.g.: IG16.2)
; .XML[] Annotation raw data array
;
; Return Values
; =============
; MAGOUT(0) is defined and its 1st '^'-piece is 0, then an error
; occurred during execution of the procedure.
; MAGOUT(0) = 1 - success ^ total data lines ^ child IEN(optional)
; 0 - error
; MAGOUT(1) = Saved layer info:::LAYER ID ^ANNOTATOR ^ SAVED DATE/TIME ^ ANNOTATION VERSION ^ SOURCE ^ DELETION ^ TIU COMPLETION
; ^ SERVICE/SECTION ^ SITE# ^ DUZ
STORE(MAGOUT,MAGIEN,SOURCE,VER,XML,DEL) ;RPC [MAG ANNOT STORE IMAGE DETAIL]
N MAGFDA,MAGERR,IEN,LN,I,X,Y,Y0,Y2,FREF,NOW,D1,D2,CONCMP,ANSITE,ANSERV,LAYERID,GRPIEN,GRPY2
S MAGOUT(0)=0 I '$G(MAGIEN) S MAGOUT(0)="0^0^No IEN" Q
S LN=+$G(XML(0)) S:'LN LN=+$O(XML(" "),-1) I 'LN S MAGOUT(0)="0^0^No XML data found" Q
I '$G(DUZ) S MAGOUT(0)="0^0^No DUZ defined" Q
S IEN=MAGIEN S:'$D(U) U="^"
I $$ISGRP^MAGGI11(MAGIEN,.ERR) S IEN=$$GRPCH1^MAGGI14(MAGIEN,"E") Q:'IEN ;if group, find child IEN .
S Y0=$G(^MAG(2005,IEN,0)),GRPIEN=$P(Y0,U,10),GRPIEN=$S(+GRPIEN:GRPIEN,1:IEN),Y2=$G(^MAG(2005,GRPIEN,2))
I Y0="" S MAGOUT(0)="0^0^No IMAGE data found for IEN# "_IEN Q
S FREF=$P(Y0,U,2) I FREF="" S MAGOUT(0)="0^0^IMAGE file("_MAGIEN_") is missing FILEREF" Q
S D1=$P(Y2,U,6),D2=$P(Y2,U,7),ANSITE=$G(DUZ(2)),ANSERV=$$GET1^DIQ(200,DUZ,29,"E")
;;I $G(SOURCE)["RAD"!(D1=74) S MAGOUT(0)="0^No annotation for RAD image" Q ;p122 no RAD
I (D1["8925") D DATA^MAGGNTI(.X,D2) I $P(X,U,6)["COMPLETED" S CONCMP=1 ;check status of TIU note for completion
S VER=$G(VER),VER=$$CAP(VER) ;IMAGE GEAR VERSION
I $L(ANSERV) N X,DIC S DIC=49,DIC(0)="B",X=ANSERV D ^DIC S ANSERV=$S(+Y:+Y,1:"") ;SERVICE/SECTION
I '$D(^MAG(2005.002,IEN)) D ;Add new 2005.002 entry
. S IEN(1)=IEN
. S MAGFDA(2005.002,"+1,",.01)=IEN ;P122 - WPR
. D UPDATE^DIE("","MAGFDA","IEN","MAGERR")
. D ENTRY^MAGLOG("MAG ANNOT",$G(DUZ),IEN,"MAG IMAGE ANNOTATION","","1",$G(SOURCE,"CLINIC")) ;log annotation
I $D(MAGERR) S MAGOUT(0)="0^Error adding annotation: "_MAGERR("DIERR",1,"TEXT",1) Q
; Add new annotation data node w/ DUZ, version, XML ...
N MAGFDA,MAGERR K IEN(2)
S NOW=$$NOW^XLFDT()
S MAGFDA(2005.0021,"+2,"_IEN_",",.01)=DUZ ;ANNOTATOR
S MAGFDA(2005.0021,"+2,"_IEN_",",1)=NOW ;SAVE D/T
S MAGFDA(2005.0021,"+2,"_IEN_",",2)=VER ;VERSION
S MAGFDA(2005.0021,"+2,"_IEN_",",3)=$G(SOURCE,"CLINIC")
S MAGFDA(2005.0021,"+2,"_IEN_",",4)=$G(DEL) ;ANNOTATION LAYER DELETION
S MAGFDA(2005.0021,"+2,"_IEN_",",6)=$G(CONCMP) ;TIU completed status #8925 (.05)
S MAGFDA(2005.0021,"+2,"_IEN_",",7)=$G(ANSERV) ;SERVICE/SECTION
S MAGFDA(2005.0021,"+2,"_IEN_",",8)=$G(ANSITE) ;SITE
D UPDATE^DIE("","MAGFDA","IEN","MAGERR")
I $D(MAGERR) S MAGOUT(0)="0^Error adding annotations: "_MAGERR("DIERR",1,"TEXT",1) Q
; XML 2005.002 field #5
S (LAYERID,D1)=IEN(2)
D WP^DIE(2005.0021,D1_","_IEN_",",5,"A","XML","MAGERR")
I $D(MAGERR("DIERR","E")) D Q
. N DA,DIK
. S MAGOUT(0)="0^Error adding annotation XML: "_MAGERR("DIERR",1,"TEXT",1)
. ; clean up data
. S DIK="^MAG(2005.002,"_IEN_",1,",DA=D1,DA(1)=IEN
. D ^DIK
. Q
S D2=$O(XML(""),-1)
I $G(MAGERR)="" S $P(^MAG(2005.002,IEN,1,D1,1,0),U,2)="2005.215A" DO ;SUCCESS
. ; [1] Stored layer info::: Layer ^NAME ^DATE/TIME ^VERSION^ SOURCE ^DELETION^ TIU COMPLETED ^ ANNOATOR SERVICE ^ SITE id# ^ DUZ
. S MAGOUT(0)=1_U_D2_U_$S(IEN=MAGIEN:"",1:IEN)
. S MAGOUT(1)=LAYERID_U_$$GET1^DIQ(200,DUZ,.01,"E")_U_$$FMTE^XLFDT(NOW)_U_$G(VER)_U_$G(SOURCE,"CLINIC")_U_$G(DEL)_U_$G(CONCMP)_U_$G(ANSERV)_U_$G(ANSITE)_U_DUZ
Q
;
;***** Check for ANNOTATION feature is allowed settings
; RPC: MAG ANNOT IMAGE ALLOW
;
; Return Values
; =============
; if error MAGRY = first "^" piece is zero when error occurs
; if success MAGRY = "1^0" or "1^1" 2nd piece 0 - not allowed; 1 - allowed ; 1@ - super user
ANOALLOW(MAGRY) ; RPC [MAG ANNOT IMAGE ALLOW]
; USR^SRV^DIV^SYS
N SRV,DIV,RESULT,PARM,I
N $ETRAP,$ESTACK S $ETRAP="D ERR^MAGGTERR"
S MAGRY=0,RESULT=0,PARM="MAG IMAGE ALLOW ANNOTATE"
I $G(DUZ) D
. I $D(^XUSEC("MAG ANNOTATE MGR",DUZ)) S RESULT="1@" Q ; ANNOTATION super key
. S SRV=$$GET1^DIQ(200,DUZ,29,"I") ; DUZ's service/section
. S RESULT=$$GET^XPAR("USR^SRV.`"_SRV_"^DIV^SYS",PARM,,"I") ; IA# 2263
. S RESULT=$S(RESULT="":1,1:+RESULT) ; 1 by default
. Q
S MAGRY=1_"^"_RESULT
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGSANNO 12739 printed Nov 22, 2024@17:18:16 Page 2
MAGSANNO ;WOIFO/JSL/GEK - IMAGING ANNOTATION UTILITY RPCS ; 9 Jun 2011 11:43 AM
+1 ;;3.0;IMAGING;**122**;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 ;***** RETURNS THE LIST OF IMAGE ANNOTATIONS
+20 ; RPC: MAG ANNOT GET IMAGE
+21 ;
+22 ; .MAGOUT Reference to a local variable where the results
+23 ; are returned to.
+24 ; .MAGIEN Internal Entry Number of IMAGE file being annotated
+25 ;
+26 ; Return Values
+27 ; =============
+28 ; If MAGOUT(0) is defined and its 1st '^'-piece is 0, then an error
+29 ; occurred during execution of the procedure. 0^0^ ERROR explanation
+30 ; MAGOUT(0) = 1 ^ COUNTER ^ MESSAGE/1childIEN ;OK + the counter of saved annotations
+31 ; MAGOUT(n) = LAYER ID ^ ANNOTATOR ^ SAVED DATE/TIME ^ ANNOTATION VERSION
+32 ; ^ SOURCE ^ DELETION ^ TIU COMPLETION
+33 ; ^ SERVICE/SECTION ^ SITE# ^ DUZ
+34 ;
+35 ; Definition of each piece of MAGOUT(n)
+36 ;[1] = layer ID (unique to the image, not globally unique)
+37 ;[2] = name of user who saved layer
+38 ;[3] = date layer stored
+39 ;[4] = annotation version
+40 ;[5] = application that created layer
+41 ;[6] = 0/1 to indicate if layer deleted
+42 ;[7] = indicates if the layer was saved after the TIU Note COMPLETE (if there is a note)
+43 ;[8] = Service Section of user who saved layer
+44 ;[9] = user site name
+45 ;[10] = DUZ of user who saved layer
GET(MAGOUT,MAGIEN) ;RPC [MAG ANNOT GET IMAGE]
+1 NEW N,CNT,X,Y,IEN,DATA,ERR,RET
+2 SET MAGOUT(0)=0
+3 SET IEN=MAGIEN
+4 IF '$$ISVALID^MAGGI11(IEN,.RET)
SET MAGOUT(0)="0^0^"_$PIECE(RET,"^",2)
QUIT
+5 IF $$ISDEL^MAGGI11(IEN,.RET)
SET MAGOUT(0)="0^0^Image IEN: "_IEN_" is Deleted."
QUIT
+6 ;if group, find child IEN
+7 IF $$ISGRP^MAGGI11(MAGIEN,.ERR)
SET IEN=$$GRPCH1^MAGGI14(MAGIEN,"E")
+8 ; If invalid Group child. Quit.
+9 IF (IEN<1)
SET MAGOUT(0)="0^0^Invalid Group Image: "_MAGIEN
QUIT
+10 SET CNT=0
+11 ;
+12 ;P122 takes only one type of annotation (Clinic or VistARAD), but not both
+13 IF $DATA(^MAG(2005,IEN,210,0))
Begin DoDot:1
+14 FOR
SET CNT=$ORDER(^MAG(2005,IEN,210,CNT))
if 'CNT
QUIT
SET X=$GET(^(CNT,0))
IF $LENGTH(X)
Begin DoDot:2
+15 SET MAGOUT(CNT)=$$DATA210(IEN,CNT)
End DoDot:2
+16 QUIT
End DoDot:1
+17 IF $DATA(^MAG(2005.002,IEN,0))
Begin DoDot:1
+18 FOR
SET CNT=$ORDER(^MAG(2005.002,IEN,1,CNT))
if 'CNT
QUIT
SET X=$GET(^(CNT,0))
IF $LENGTH(X)
Begin DoDot:2
+19 SET MAGOUT(CNT)=$$DATA002(IEN,CNT)
End DoDot:2
+20 QUIT
End DoDot:1
+21 IF '$ORDER(MAGOUT(0))
SET MAGOUT(0)="1^0^No annotation for image IEN#"_MAGIEN
QUIT
+22 ;1:success^layer counter^optional childIEN
SET MAGOUT(0)=1_U_+$ORDER(MAGOUT(" "),-1)_U_$SELECT(IEN=MAGIEN:"",1:IEN)
+23 QUIT
+24 ;-------------------------------------------------------------------
+25 ;***** RETURNS THE DETAIL OF IMAGE ANNOTATIONS
+26 ; RPC: MAG ANNOT GET IMAGE DETAIL
+27 ;
+28 ; .MAGOUT Reference to a local variable where the results are returned to.
+29 ; .MAGIEN Internal entry number of IMAGE file been annotated
+30 ; .LAYIEN Internal entry number of ANNOTATION IMAGE LAYER in #2005.002
+31 ;
+32 ; Return Values
+33 ; =============
+34 ; If MAGOUT(0) is defined and its 1st '^'-piece is 0, then an error
+35 ; occurred during execution of the procedure. 0 ^ 0 ^ error message
+36 ; MAGOUT(0) = 1 ^ total count ; lines counter of the returned array
+37 ; MAGOUT(1) = LAYER ID ^ ANNOTATOR ^ SAVED DATE/TIME ^ ANNOTATION VERSION ^ SOURCE ^ DELETION ^ TIU COMPLETION
+38 ; ^ SERVICE/SECTION ^ SITE# ^ DUZ
+39 ; MAGOUT(n+1) = XML data line(s)
+40 ;
GETD(MAGOUT,MAGIEN,LAYIEN) ;RPC [MAG ANNOT GET IMAGE DETAIL]
+1 NEW N,CNT,LN,X,Y,IEN,ERR,LASTN,WP
+2 SET MAGOUT(0)=0
+3 SET IEN=MAGIEN
+4 IF '$$ISVALID^MAGGI11(IEN,.RET)
SET MAGOUT(0)="0^0^"_$PIECE(RET,"^",2)
QUIT
+5 IF $$ISDEL^MAGGI11(IEN,.RET)
SET MAGOUT(0)="0^0^Image IEN: "_IEN_" is Deleted."
QUIT
+6 ;if group, find child IEN
+7 IF $$ISGRP^MAGGI11(MAGIEN,.ERR)
SET IEN=$$GRPCH1^MAGGI14(MAGIEN,"E")
+8 ; If invalid Group child. Quit.
+9 IF (IEN<1)
SET MAGOUT(0)="0^0^Invalid Group Image: "_MAGIEN
QUIT
+10 ;
+11 ;P122 handles only one type of annotation (Clinic or VistARAD), but not on both
+12 IF $DATA(^MAG(2005,IEN,210,0))
Begin DoDot:1
+13 SET CNT=+$GET(LAYIEN,1)
SET X=$GET(^MAG(2005,IEN,210,CNT,0))
IF $LENGTH(X)
Begin DoDot:2
+14 ; P122 GEK
SET MAGOUT(1)=$$DATA210(IEN,CNT)
+15 SET LN=$PIECE($GET(^MAG(2005,IEN,210,CNT,1,0)),U,3)
if 'LN
QUIT
+16 ;XML raw data
FOR N=1:1:LN
SET MAGOUT(N+1)=$GET(^MAG(2005,IEN,210,CNT,1,N,0))
End DoDot:2
+17 QUIT
End DoDot:1
+18 IF $DATA(^MAG(2005.002,IEN,0))
Begin DoDot:1
+19 ;last annotation, if no LAYIEN
SET LASTN=+$PIECE($GET(^MAG(2005.002,IEN,1,0)),U,3)
+20 SET CNT=$GET(LAYIEN,LASTN)
SET X=$GET(^MAG(2005.002,IEN,1,CNT,0))
IF $LENGTH(X)
Begin DoDot:2
+21 ; P122 GEK
SET MAGOUT(1)=$$DATA002(IEN,CNT)
+22 SET X=$$GET1^DIQ(2005.0021,CNT_","_IEN,5,"","WP")
+23 ;XML raw data
SET LN=""
FOR N=2:1
SET LN=$ORDER(WP(LN))
if 'LN
QUIT
SET MAGOUT(N)=WP(LN)
End DoDot:2
+24 QUIT
End DoDot:1
+25 ;
+26 IF '$ORDER(MAGOUT(0))
SET MAGOUT(0)="1^0^No annotation for image IEN#"_MAGIEN_" ("_$GET(LAYIEN)_")"
QUIT
+27 ;success + total count + optional childIEN
SET CNT=+$ORDER(MAGOUT(" "),-1)
SET MAGOUT(0)=1_U_CNT_U_$SELECT(IEN=MAGIEN:"",1:IEN)
+28 QUIT
+29 ;
+30 ; --- DATA210
+31 ; Get data from Image file for VistaRAD Annotations.
+32 ; Function returns "^" delimited string of annotation properties.
+33 ; Other functions call here to get data from Image file.
+34 ;
DATA210(IEN,CNT) ;Get VistaRAD Annotation data
+1 NEW X,DATA
+2 NEW ANDUZ,ANDTM,ANVRN,ANSRC,ANDEL,ANTIUST,ANSERV,ANSITE
+3 SET X=$GET(^MAG(2005,IEN,210,CNT,0))
+4 SET ANDUZ=$PIECE(X,"^",3)
SET ANDTM=$PIECE(X,"^",4)
SET ANVRN=""
SET ANSRC="VISTARAD"
SET ANDEL=0
SET ANTIUST=0
+5 SET ANSERV="RADIOLOGY"
+6 SET ANSITE=$PIECE($GET(^MAG(2005,IEN,100)),"^",3)
+7 ;
+8 ;
SET $PIECE(DATA,"^",1)=CNT
+9 ;
SET $PIECE(DATA,"^",2)=$$GET1^DIQ(200,ANDUZ,.01,"E")
+10 ;
SET $PIECE(DATA,"^",3)=$$FMTE^XLFDT(ANDTM)
+11 ;ANVRN ("" for VistaRAD);
SET $PIECE(DATA,"^",4)=ANVRN
+12 ;ANSRC (Defalut to VistaRAD);
SET $PIECE(DATA,"^",5)=ANSRC
+13 ;ANDEL (0 for VistaRAD);
SET $PIECE(DATA,"^",6)=ANDEL
+14 ;ANTIUST (0 for VistaRAD).
SET $PIECE(DATA,"^",7)=ANTIUST
+15 ;ANSERV (default to RADIOLOGY)
SET $PIECE(DATA,"^",8)=ANSERV
+16 ;
SET $PIECE(DATA,"^",9)=$SELECT(ANSITE:$$GET1^DIQ(4,ANSITE,.01,"E"),1:ANSITE)
+17 ;
SET $PIECE(DATA,"^",10)=ANDUZ
+18 QUIT DATA
+19 ;
+20 ; --- DATA002
+21 ; Get data from Imaging Annotation file entry
+22 ; Function returns "^" delimited string of annotation properties.
+23 ; Other functions call here to get data from Imaging Annotation file.
+24 ;
DATA002(IEN,CNT) ;Get Image Annotation data.
+1 NEW X,DATA
+2 NEW ANDUZ,ANDTM,ANVRN,ANSRC,ANDEL,ANTIUST,ANSERV,ANSITE
+3 SET X=$GET(^MAG(2005.002,IEN,1,CNT,0))
+4 SET ANDUZ=$PIECE(X,U,1)
SET ANDTM=$PIECE(X,U,2)
SET ANVRN=$PIECE(X,U,3)
SET ANSRC=$PIECE(X,U,4)
SET ANDEL=$PIECE(X,U,5)
SET ANTIUST=$PIECE(X,U,6)
+5 SET ANSERV=+$PIECE(X,U,7)
if ANSERV
SET ANSERV=$$GET1^DIQ(49,ANSERV,.01,"E")
+6 SET ANSITE=+$PIECE(X,U,8)
if ANSITE
SET ANSITE=$$GET1^DIQ(4,ANSITE,.01,"E")
+7 ;
+8 ;
SET $PIECE(DATA,"^",1)=CNT
+9 ;
SET $PIECE(DATA,"^",2)=$$GET1^DIQ(200,ANDUZ,.01,"E")
+10 ;
SET $PIECE(DATA,"^",3)=$$FMTE^XLFDT(ANDTM)
+11 ;
SET $PIECE(DATA,"^",4)=ANVRN
+12 ;
SET $PIECE(DATA,"^",5)=ANSRC
+13 ;
SET $PIECE(DATA,"^",6)=ANDEL
+14 ;
SET $PIECE(DATA,"^",7)=ANTIUST
+15 ;
SET $PIECE(DATA,"^",8)=$SELECT(ANSERV:$$GET1^DIQ(49,ANSERV,.01,"E"),1:ANSERV)
+16 ;
SET $PIECE(DATA,"^",9)=$SELECT(ANSITE:$$GET1^DIQ(4,ANSITE,.01,"E"),1:ANSITE)
+17 ; ANDUZ Not DUZ
SET $PIECE(DATA,"^",10)=ANDUZ
+18 QUIT DATA
+19 ;
CAP(X) ;
+1 QUIT $TRANSLATE(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+2 ;-------------------------------------------------------------------
+3 ;***** STORES THE DETAIL OF IMAGE ANNOTATIONS
+4 ; RPC: MAG ANNOT STORE IMAGE DETAIL
+5 ;
+6 ; .MAGOUT Reference to a local variable where the results are returned to
+7 ; .MAGIEN Internal Entry Number(IEN) of IMAGE file been annotated
+8 ; .SOURCE Reference to the application XML been created by ('CLINIC' or 'VISTARAD'...etc)
+9 ; .VER Reference to the annotation tool version (e.g.: IG16.2)
+10 ; .XML[] Annotation raw data array
+11 ;
+12 ; Return Values
+13 ; =============
+14 ; MAGOUT(0) is defined and its 1st '^'-piece is 0, then an error
+15 ; occurred during execution of the procedure.
+16 ; MAGOUT(0) = 1 - success ^ total data lines ^ child IEN(optional)
+17 ; 0 - error
+18 ; MAGOUT(1) = Saved layer info:::LAYER ID ^ANNOTATOR ^ SAVED DATE/TIME ^ ANNOTATION VERSION ^ SOURCE ^ DELETION ^ TIU COMPLETION
+19 ; ^ SERVICE/SECTION ^ SITE# ^ DUZ
STORE(MAGOUT,MAGIEN,SOURCE,VER,XML,DEL) ;RPC [MAG ANNOT STORE IMAGE DETAIL]
+1 NEW MAGFDA,MAGERR,IEN,LN,I,X,Y,Y0,Y2,FREF,NOW,D1,D2,CONCMP,ANSITE,ANSERV,LAYERID,GRPIEN,GRPY2
+2 SET MAGOUT(0)=0
IF '$GET(MAGIEN)
SET MAGOUT(0)="0^0^No IEN"
QUIT
+3 SET LN=+$GET(XML(0))
if 'LN
SET LN=+$ORDER(XML(" "),-1)
IF 'LN
SET MAGOUT(0)="0^0^No XML data found"
QUIT
+4 IF '$GET(DUZ)
SET MAGOUT(0)="0^0^No DUZ defined"
QUIT
+5 SET IEN=MAGIEN
if '$DATA(U)
SET U="^"
+6 ;if group, find child IEN .
IF $$ISGRP^MAGGI11(MAGIEN,.ERR)
SET IEN=$$GRPCH1^MAGGI14(MAGIEN,"E")
if 'IEN
QUIT
+7 SET Y0=$GET(^MAG(2005,IEN,0))
SET GRPIEN=$PIECE(Y0,U,10)
SET GRPIEN=$SELECT(+GRPIEN:GRPIEN,1:IEN)
SET Y2=$GET(^MAG(2005,GRPIEN,2))
+8 IF Y0=""
SET MAGOUT(0)="0^0^No IMAGE data found for IEN# "_IEN
QUIT
+9 SET FREF=$PIECE(Y0,U,2)
IF FREF=""
SET MAGOUT(0)="0^0^IMAGE file("_MAGIEN_") is missing FILEREF"
QUIT
+10 SET D1=$PIECE(Y2,U,6)
SET D2=$PIECE(Y2,U,7)
SET ANSITE=$GET(DUZ(2))
SET ANSERV=$$GET1^DIQ(200,DUZ,29,"E")
+11 ;;I $G(SOURCE)["RAD"!(D1=74) S MAGOUT(0)="0^No annotation for RAD image" Q ;p122 no RAD
+12 ;check status of TIU note for completion
IF (D1["8925")
DO DATA^MAGGNTI(.X,D2)
IF $PIECE(X,U,6)["COMPLETED"
SET CONCMP=1
+13 ;IMAGE GEAR VERSION
SET VER=$GET(VER)
SET VER=$$CAP(VER)
+14 ;SERVICE/SECTION
IF $LENGTH(ANSERV)
NEW X,DIC
SET DIC=49
SET DIC(0)="B"
SET X=ANSERV
DO ^DIC
SET ANSERV=$SELECT(+Y:+Y,1:"")
+15 ;Add new 2005.002 entry
IF '$DATA(^MAG(2005.002,IEN))
Begin DoDot:1
+16 SET IEN(1)=IEN
+17 ;P122 - WPR
SET MAGFDA(2005.002,"+1,",.01)=IEN
+18 DO UPDATE^DIE("","MAGFDA","IEN","MAGERR")
+19 ;log annotation
DO ENTRY^MAGLOG("MAG ANNOT",$GET(DUZ),IEN,"MAG IMAGE ANNOTATION","","1",$GET(SOURCE,"CLINIC"))
End DoDot:1
+20 IF $DATA(MAGERR)
SET MAGOUT(0)="0^Error adding annotation: "_MAGERR("DIERR",1,"TEXT",1)
QUIT
+21 ; Add new annotation data node w/ DUZ, version, XML ...
+22 NEW MAGFDA,MAGERR
KILL IEN(2)
+23 SET NOW=$$NOW^XLFDT()
+24 ;ANNOTATOR
SET MAGFDA(2005.0021,"+2,"_IEN_",",.01)=DUZ
+25 ;SAVE D/T
SET MAGFDA(2005.0021,"+2,"_IEN_",",1)=NOW
+26 ;VERSION
SET MAGFDA(2005.0021,"+2,"_IEN_",",2)=VER
+27 SET MAGFDA(2005.0021,"+2,"_IEN_",",3)=$GET(SOURCE,"CLINIC")
+28 ;ANNOTATION LAYER DELETION
SET MAGFDA(2005.0021,"+2,"_IEN_",",4)=$GET(DEL)
+29 ;TIU completed status #8925 (.05)
SET MAGFDA(2005.0021,"+2,"_IEN_",",6)=$GET(CONCMP)
+30 ;SERVICE/SECTION
SET MAGFDA(2005.0021,"+2,"_IEN_",",7)=$GET(ANSERV)
+31 ;SITE
SET MAGFDA(2005.0021,"+2,"_IEN_",",8)=$GET(ANSITE)
+32 DO UPDATE^DIE("","MAGFDA","IEN","MAGERR")
+33 IF $DATA(MAGERR)
SET MAGOUT(0)="0^Error adding annotations: "_MAGERR("DIERR",1,"TEXT",1)
QUIT
+34 ; XML 2005.002 field #5
+35 SET (LAYERID,D1)=IEN(2)
+36 DO WP^DIE(2005.0021,D1_","_IEN_",",5,"A","XML","MAGERR")
+37 IF $DATA(MAGERR("DIERR","E"))
Begin DoDot:1
+38 NEW DA,DIK
+39 SET MAGOUT(0)="0^Error adding annotation XML: "_MAGERR("DIERR",1,"TEXT",1)
+40 ; clean up data
+41 SET DIK="^MAG(2005.002,"_IEN_",1,"
SET DA=D1
SET DA(1)=IEN
+42 DO ^DIK
+43 QUIT
End DoDot:1
QUIT
+44 SET D2=$ORDER(XML(""),-1)
+45 ;SUCCESS
IF $GET(MAGERR)=""
SET $PIECE(^MAG(2005.002,IEN,1,D1,1,0),U,2)="2005.215A"
Begin DoDot:1
+46 ; [1] Stored layer info::: Layer ^NAME ^DATE/TIME ^VERSION^ SOURCE ^DELETION^ TIU COMPLETED ^ ANNOATOR SERVICE ^ SITE id# ^ DUZ
+47 SET MAGOUT(0)=1_U_D2_U_$SELECT(IEN=MAGIEN:"",1:IEN)
+48 SET MAGOUT(1)=LAYERID_U_$$GET1^DIQ(200,DUZ,.01,"E")_U_$$FMTE^XLFDT(NOW)_U_$GET(VER)_U_$GET(SOURCE,"CLINIC")_U_$GET(DEL)_U_$GET(CONCMP)_U_$GET(ANSERV)_U_$GET(ANSITE)_U_DUZ
End DoDot:1
+49 QUIT
+50 ;
+51 ;***** Check for ANNOTATION feature is allowed settings
+52 ; RPC: MAG ANNOT IMAGE ALLOW
+53 ;
+54 ; Return Values
+55 ; =============
+56 ; if error MAGRY = first "^" piece is zero when error occurs
+57 ; if success MAGRY = "1^0" or "1^1" 2nd piece 0 - not allowed; 1 - allowed ; 1@ - super user
ANOALLOW(MAGRY) ; RPC [MAG ANNOT IMAGE ALLOW]
+1 ; USR^SRV^DIV^SYS
+2 NEW SRV,DIV,RESULT,PARM,I
+3 NEW $ETRAP,$ESTACK
SET $ETRAP="D ERR^MAGGTERR"
+4 SET MAGRY=0
SET RESULT=0
SET PARM="MAG IMAGE ALLOW ANNOTATE"
+5 IF $GET(DUZ)
Begin DoDot:1
+6 ; ANNOTATION super key
IF $DATA(^XUSEC("MAG ANNOTATE MGR",DUZ))
SET RESULT="1@"
QUIT
+7 ; DUZ's service/section
SET SRV=$$GET1^DIQ(200,DUZ,29,"I")
+8 ; IA# 2263
SET RESULT=$$GET^XPAR("USR^SRV.`"_SRV_"^DIV^SYS",PARM,,"I")
+9 ; 1 by default
SET RESULT=$SELECT(RESULT="":1,1:+RESULT)
+10 QUIT
End DoDot:1
+11 SET MAGRY=1_"^"_RESULT
+12 QUIT