- MAGNAN02 ;WOIFO/NST - IMAGING ANNOTATION UTILITY RPCS ; 20 Oct 2017 11:43 AM
- ;;3.0;IMAGING;**185**;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 STUDY ANNOTATIONS
- ;
- ; RPC: MAGN ANNOT GET STUDY
- ;
- ; .MAGOUT Reference to a local variable where the results
- ; are returned to.
- ; .MAGPARAM List of studies to being annotated
- ; [MAGFLAGS]
- ; D - include deleted annotations
- ; U - include all user's annotations
- ; W - include word processing fields
- ;
- ; Return Values
- ; =============
- ; if error found during execution
- ; MAGOUT(0) = Failure status^Error getting values
- ; if success
- ; MAGOUT(0) = Success status^^Total lines
- ; MAGOUT(1) = header with name of the fields
- ; MAGOUT(3) = "^" delimited pairs with internal and external values of the fields listed in MAGOUT(1)
- ; MAGOUT(n) = "WordProcesingFieldxxx^line value"
- ; MAGOUT(m) = "MultipleField000^fields header"
- ; MAGOUT(m..m+1) = "MultipleField001^fields values listed in MAGOUT(m)"
- ;
- GET(MAGOUT,MAGPARAM,MAGFLAGS) ;RPC [MAGN ANNOT GET STUDY]
- N CNT,ERR,MAGI,MAGNXE,CNT
- N FILE,FIELDS,STUDYID,STUDYIEN
- S MAGFLAGS=$G(MAGFLAGS)
- S MAGOUT(0)=$$SETERROR^MAGNU002("")
- S FILE=2005.003
- S FIELDS="**"
- S MAGI=""
- S CNT=0
- S ERR=0
- F S MAGI=$O(MAGPARAM(MAGI)) Q:'MAGI D Q:ERR
- . S STUDYID=MAGPARAM(MAGI)
- . S STUDYIEN=$$FIND1^DIC(FILE,"","X",STUDYID,"","","MAGNXE")
- . I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) S ERR=1 Q
- . I 'STUDYIEN S MAGOUT(0)=$$SETERROR^MAGNU002("Study "_STUDYID_" not found") S ERR=1 Q
- . D GRECBYPK^MAGNAU03(.MAGOUT,2005.003,STUDYIEN,MAGFLAGS,.CNT)
- . Q
- Q
- ;
- ;***** RETURNS THE LIST OF PSTATE ANNOTATIONS
- ;
- ; RPC: MAGN ANNOT GET PSTATE
- ;
- ; .MAGOUT Reference to a local variable where the results
- ; are returned to.
- ; .MAGPARAM List of presentation state UID
- ;
- ; Return Values
- ; =============
- ; if error found during execution
- ; MAGRY(0) = Failure status^Error getting values
- ; if success
- ; MAGRY(0) = Success status^^Total lines
- ; MAGRY(1) = header with name of the fields
- ; MAGRY(3) = "^" delimited pairs with internal and external values of the fields listed in MAGRY(1)
- ; MAGRY(n) = "WordProcesingFieldxxx^line value"
- ; MAGRY(m) = "MultipleField000^fields header"
- ; MAGRY(m..m+1) = "MultipleField001^fields values listed in MAGRY(m)"
- ;
- GETPSTAT(MAGOUT,MAGPARAM) ;RPC [MAGN ANNOT GET PSTATE]
- N CNT,CNTG,ERR,MAGI,MAGTMP,FILE,FIELDS
- N PSTATEID,PSTATIEN,STUDYIEN
- K MAGOUT
- S MAGOUT(0)=$$SETERROR^MAGNU002("")
- S FILE=2005.0031
- S FIELDS="**"
- S MAGI=""
- S ERR=0
- S CNT=0
- S CNTG=0
- F S MAGI=$O(MAGPARAM(MAGI)) Q:'MAGI D Q:ERR
- . S PSTATEID=MAGPARAM(MAGI)
- . S STUDYIEN=$O(^MAG(2005.003,"C",PSTATEID,0))
- . I 'STUDYIEN K MAGOUT S MAGOUT(0)=$$SETERROR^MAGNU002("Study not found for presentation ID: "_PSTATEID),ERR=1 Q
- . S PSTATIEN=$O(^MAG(2005.003,"C",PSTATEID,STUDYIEN,0))
- . K MAGTMP
- . D GRECBYPK^MAGNAU03(.MAGTMP,2005.0031,PSTATIEN_","_STUDYIEN,"DUW",.CNT)
- . I '$$ISOK^MAGNU002(MAGTMP(0)) K MAGOUT M MAGOUT=MAGTMP S ERR=1 Q
- . S CNTG=CNTG+1
- . D MERGE(.MAGOUT,.MAGTMP,.CNT,CNTG)
- . Q
- S:'ERR MAGOUT(0)=$$SETOKVAL^MAGNU002(CNT)
- Q
- ;
- MERGE(MAGOUT,MAGTMP,CNT,CNTG) ; Merge one result set to final result list
- N J
- S MAGTMP(1)="ANNOTATION GROUP000"_"^"_MAGTMP(1)
- S MAGTMP(2)="ANNOTATION GROUP"_$TR($J(CNTG,3)," ",0)_"^"_MAGTMP(2)
- S J=$S($D(MAGOUT(1)):1,1:0) ; Start from line 1
- F S J=$O(MAGTMP(J)) Q:'J D
- . S CNT=CNT+1
- . S MAGOUT(CNT)=MAGTMP(J)
- . Q
- Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGNAN02 4594 printed Jan 18, 2025@03:08:22 Page 2
- MAGNAN02 ;WOIFO/NST - IMAGING ANNOTATION UTILITY RPCS ; 20 Oct 2017 11:43 AM
- +1 ;;3.0;IMAGING;**185**;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 STUDY ANNOTATIONS
- +20 ;
- +21 ; RPC: MAGN ANNOT GET STUDY
- +22 ;
- +23 ; .MAGOUT Reference to a local variable where the results
- +24 ; are returned to.
- +25 ; .MAGPARAM List of studies to being annotated
- +26 ; [MAGFLAGS]
- +27 ; D - include deleted annotations
- +28 ; U - include all user's annotations
- +29 ; W - include word processing fields
- +30 ;
- +31 ; Return Values
- +32 ; =============
- +33 ; if error found during execution
- +34 ; MAGOUT(0) = Failure status^Error getting values
- +35 ; if success
- +36 ; MAGOUT(0) = Success status^^Total lines
- +37 ; MAGOUT(1) = header with name of the fields
- +38 ; MAGOUT(3) = "^" delimited pairs with internal and external values of the fields listed in MAGOUT(1)
- +39 ; MAGOUT(n) = "WordProcesingFieldxxx^line value"
- +40 ; MAGOUT(m) = "MultipleField000^fields header"
- +41 ; MAGOUT(m..m+1) = "MultipleField001^fields values listed in MAGOUT(m)"
- +42 ;
- GET(MAGOUT,MAGPARAM,MAGFLAGS) ;RPC [MAGN ANNOT GET STUDY]
- +1 NEW CNT,ERR,MAGI,MAGNXE,CNT
- +2 NEW FILE,FIELDS,STUDYID,STUDYIEN
- +3 SET MAGFLAGS=$GET(MAGFLAGS)
- +4 SET MAGOUT(0)=$$SETERROR^MAGNU002("")
- +5 SET FILE=2005.003
- +6 SET FIELDS="**"
- +7 SET MAGI=""
- +8 SET CNT=0
- +9 SET ERR=0
- +10 FOR
- SET MAGI=$ORDER(MAGPARAM(MAGI))
- if 'MAGI
- QUIT
- Begin DoDot:1
- +11 SET STUDYID=MAGPARAM(MAGI)
- +12 SET STUDYIEN=$$FIND1^DIC(FILE,"","X",STUDYID,"","","MAGNXE")
- +13 IF $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE)
- SET ERR=1
- QUIT
- +14 IF 'STUDYIEN
- SET MAGOUT(0)=$$SETERROR^MAGNU002("Study "_STUDYID_" not found")
- SET ERR=1
- QUIT
- +15 DO GRECBYPK^MAGNAU03(.MAGOUT,2005.003,STUDYIEN,MAGFLAGS,.CNT)
- +16 QUIT
- End DoDot:1
- if ERR
- QUIT
- +17 QUIT
- +18 ;
- +19 ;***** RETURNS THE LIST OF PSTATE ANNOTATIONS
- +20 ;
- +21 ; RPC: MAGN ANNOT GET PSTATE
- +22 ;
- +23 ; .MAGOUT Reference to a local variable where the results
- +24 ; are returned to.
- +25 ; .MAGPARAM List of presentation state UID
- +26 ;
- +27 ; Return Values
- +28 ; =============
- +29 ; if error found during execution
- +30 ; MAGRY(0) = Failure status^Error getting values
- +31 ; if success
- +32 ; MAGRY(0) = Success status^^Total lines
- +33 ; MAGRY(1) = header with name of the fields
- +34 ; MAGRY(3) = "^" delimited pairs with internal and external values of the fields listed in MAGRY(1)
- +35 ; MAGRY(n) = "WordProcesingFieldxxx^line value"
- +36 ; MAGRY(m) = "MultipleField000^fields header"
- +37 ; MAGRY(m..m+1) = "MultipleField001^fields values listed in MAGRY(m)"
- +38 ;
- GETPSTAT(MAGOUT,MAGPARAM) ;RPC [MAGN ANNOT GET PSTATE]
- +1 NEW CNT,CNTG,ERR,MAGI,MAGTMP,FILE,FIELDS
- +2 NEW PSTATEID,PSTATIEN,STUDYIEN
- +3 KILL MAGOUT
- +4 SET MAGOUT(0)=$$SETERROR^MAGNU002("")
- +5 SET FILE=2005.0031
- +6 SET FIELDS="**"
- +7 SET MAGI=""
- +8 SET ERR=0
- +9 SET CNT=0
- +10 SET CNTG=0
- +11 FOR
- SET MAGI=$ORDER(MAGPARAM(MAGI))
- if 'MAGI
- QUIT
- Begin DoDot:1
- +12 SET PSTATEID=MAGPARAM(MAGI)
- +13 SET STUDYIEN=$ORDER(^MAG(2005.003,"C",PSTATEID,0))
- +14 IF 'STUDYIEN
- KILL MAGOUT
- SET MAGOUT(0)=$$SETERROR^MAGNU002("Study not found for presentation ID: "_PSTATEID)
- SET ERR=1
- QUIT
- +15 SET PSTATIEN=$ORDER(^MAG(2005.003,"C",PSTATEID,STUDYIEN,0))
- +16 KILL MAGTMP
- +17 DO GRECBYPK^MAGNAU03(.MAGTMP,2005.0031,PSTATIEN_","_STUDYIEN,"DUW",.CNT)
- +18 IF '$$ISOK^MAGNU002(MAGTMP(0))
- KILL MAGOUT
- MERGE MAGOUT=MAGTMP
- SET ERR=1
- QUIT
- +19 SET CNTG=CNTG+1
- +20 DO MERGE(.MAGOUT,.MAGTMP,.CNT,CNTG)
- +21 QUIT
- End DoDot:1
- if ERR
- QUIT
- +22 if 'ERR
- SET MAGOUT(0)=$$SETOKVAL^MAGNU002(CNT)
- +23 QUIT
- +24 ;
- MERGE(MAGOUT,MAGTMP,CNT,CNTG) ; Merge one result set to final result list
- +1 NEW J
- +2 SET MAGTMP(1)="ANNOTATION GROUP000"_"^"_MAGTMP(1)
- +3 SET MAGTMP(2)="ANNOTATION GROUP"_$TRANSLATE($JUSTIFY(CNTG,3)," ",0)_"^"_MAGTMP(2)
- +4 ; Start from line 1
- SET J=$SELECT($DATA(MAGOUT(1)):1,1:0)
- +5 FOR
- SET J=$ORDER(MAGTMP(J))
- if 'J
- QUIT
- Begin DoDot:1
- +6 SET CNT=CNT+1
- +7 SET MAGOUT(CNT)=MAGTMP(J)
- +8 QUIT
- End DoDot:1
- +9 QUIT