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

MAGNAN02.m

Go to the documentation of this file.
  1. 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
  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. ;***** RETURNS THE LIST OF STUDY ANNOTATIONS
  1. ;
  1. ; RPC: MAGN ANNOT GET STUDY
  1. ;
  1. ; .MAGOUT Reference to a local variable where the results
  1. ; are returned to.
  1. ; .MAGPARAM List of studies to being annotated
  1. ; [MAGFLAGS]
  1. ; D - include deleted annotations
  1. ; U - include all user's annotations
  1. ; W - include word processing fields
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; if error found during execution
  1. ; MAGOUT(0) = Failure status^Error getting values
  1. ; if success
  1. ; MAGOUT(0) = Success status^^Total lines
  1. ; MAGOUT(1) = header with name of the fields
  1. ; MAGOUT(3) = "^" delimited pairs with internal and external values of the fields listed in MAGOUT(1)
  1. ; MAGOUT(n) = "WordProcesingFieldxxx^line value"
  1. ; MAGOUT(m) = "MultipleField000^fields header"
  1. ; MAGOUT(m..m+1) = "MultipleField001^fields values listed in MAGOUT(m)"
  1. ;
  1. GET(MAGOUT,MAGPARAM,MAGFLAGS) ;RPC [MAGN ANNOT GET STUDY]
  1. N CNT,ERR,MAGI,MAGNXE,CNT
  1. N FILE,FIELDS,STUDYID,STUDYIEN
  1. S MAGFLAGS=$G(MAGFLAGS)
  1. S MAGOUT(0)=$$SETERROR^MAGNU002("")
  1. S FILE=2005.003
  1. S FIELDS="**"
  1. S MAGI=""
  1. S CNT=0
  1. S ERR=0
  1. F S MAGI=$O(MAGPARAM(MAGI)) Q:'MAGI D Q:ERR
  1. . S STUDYID=MAGPARAM(MAGI)
  1. . S STUDYIEN=$$FIND1^DIC(FILE,"","X",STUDYID,"","","MAGNXE")
  1. . I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) S ERR=1 Q
  1. . I 'STUDYIEN S MAGOUT(0)=$$SETERROR^MAGNU002("Study "_STUDYID_" not found") S ERR=1 Q
  1. . D GRECBYPK^MAGNAU03(.MAGOUT,2005.003,STUDYIEN,MAGFLAGS,.CNT)
  1. . Q
  1. Q
  1. ;
  1. ;***** RETURNS THE LIST OF PSTATE ANNOTATIONS
  1. ;
  1. ; RPC: MAGN ANNOT GET PSTATE
  1. ;
  1. ; .MAGOUT Reference to a local variable where the results
  1. ; are returned to.
  1. ; .MAGPARAM List of presentation state UID
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; if error found during execution
  1. ; MAGRY(0) = Failure status^Error getting values
  1. ; if success
  1. ; MAGRY(0) = Success status^^Total lines
  1. ; MAGRY(1) = header with name of the fields
  1. ; MAGRY(3) = "^" delimited pairs with internal and external values of the fields listed in MAGRY(1)
  1. ; MAGRY(n) = "WordProcesingFieldxxx^line value"
  1. ; MAGRY(m) = "MultipleField000^fields header"
  1. ; MAGRY(m..m+1) = "MultipleField001^fields values listed in MAGRY(m)"
  1. ;
  1. GETPSTAT(MAGOUT,MAGPARAM) ;RPC [MAGN ANNOT GET PSTATE]
  1. N CNT,CNTG,ERR,MAGI,MAGTMP,FILE,FIELDS
  1. N PSTATEID,PSTATIEN,STUDYIEN
  1. K MAGOUT
  1. S MAGOUT(0)=$$SETERROR^MAGNU002("")
  1. S FILE=2005.0031
  1. S FIELDS="**"
  1. S MAGI=""
  1. S ERR=0
  1. S CNT=0
  1. S CNTG=0
  1. F S MAGI=$O(MAGPARAM(MAGI)) Q:'MAGI D Q:ERR
  1. . S PSTATEID=MAGPARAM(MAGI)
  1. . S STUDYIEN=$O(^MAG(2005.003,"C",PSTATEID,0))
  1. . I 'STUDYIEN K MAGOUT S MAGOUT(0)=$$SETERROR^MAGNU002("Study not found for presentation ID: "_PSTATEID),ERR=1 Q
  1. . S PSTATIEN=$O(^MAG(2005.003,"C",PSTATEID,STUDYIEN,0))
  1. . K MAGTMP
  1. . D GRECBYPK^MAGNAU03(.MAGTMP,2005.0031,PSTATIEN_","_STUDYIEN,"DUW",.CNT)
  1. . I '$$ISOK^MAGNU002(MAGTMP(0)) K MAGOUT M MAGOUT=MAGTMP S ERR=1 Q
  1. . S CNTG=CNTG+1
  1. . D MERGE(.MAGOUT,.MAGTMP,.CNT,CNTG)
  1. . Q
  1. S:'ERR MAGOUT(0)=$$SETOKVAL^MAGNU002(CNT)
  1. Q
  1. ;
  1. MERGE(MAGOUT,MAGTMP,CNT,CNTG) ; Merge one result set to final result list
  1. N J
  1. S MAGTMP(1)="ANNOTATION GROUP000"_"^"_MAGTMP(1)
  1. S MAGTMP(2)="ANNOTATION GROUP"_$TR($J(CNTG,3)," ",0)_"^"_MAGTMP(2)
  1. S J=$S($D(MAGOUT(1)):1,1:0) ; Start from line 1
  1. F S J=$O(MAGTMP(J)) Q:'J D
  1. . S CNT=CNT+1
  1. . S MAGOUT(CNT)=MAGTMP(J)
  1. . Q
  1. Q