MAGUFFLL ;WOIFO/MLH - Imaging FileMan utility - return list of fields in a file; 24 Sep 2011 11:52 AM
;;3.0;IMAGING;**118**;Mar 19, 2002;Build 4525;May 01, 2013
;; 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
;
FIELDLST(OUT,FILENO,ORDER) ; rpc MAG FILEMAN FIELD LIST
; input: FILENO The number of a Fileman file or subfile
; ORDER Desired order of field list return:
; A alpha
; N numeric (default)
;
; output: OUT() Array of return values formatted as follows:
; If no input or processing error:
; OUT(1) = 0``n where n = number of entries on the OUT() array
; OUT(m) where 1 < m <= n
; = field_number`field_name
; If an input or processing error:
; OUT(1) = n`error_message
;
; All ^DD references permitted under ICR #5551
;
K OUT
I FILENO=+FILENO,$D(^DD(FILENO)) ; valid input
E S OUT(1)="-1`'"_FILENO_"' not a valid Fileman file or subfile number" Q
S ORDER=$G(ORDER,"N")
I ".A.N."'[("."_ORDER_".") S OUT(1)="-2`invalid order (must be A or N)" Q
N FIELDNAME,FIELDNO,FIELDINFO,FIELDLIST,FIELDIX,OUTIX
S FIELDNAME=""
F S FIELDNAME=$O(^DD(FILENO,"B",FIELDNAME)) Q:FIELDNAME="" D
. S FIELDNO=0
. F S FIELDNO=$O(^DD(FILENO,"B",FIELDNAME,FIELDNO)) Q:'FIELDNO D
. . S FIELDLIST($S(ORDER="N":FIELDNO,1:$O(FIELDLIST(""),-1)+1))=FIELDNO_"`"_FIELDNAME
. . Q
. Q
S FIELDIX=0,OUTIX=1
F S FIELDIX=$O(FIELDLIST(FIELDIX)) Q:'FIELDIX D
. S OUTIX=OUTIX+1,OUT(OUTIX)=FIELDLIST(FIELDIX)
. Q
S OUT(1)="0``"_(OUTIX-1) ; count
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGUFFLL 2555 printed Dec 13, 2024@02:08:58 Page 2
MAGUFFLL ;WOIFO/MLH - Imaging FileMan utility - return list of fields in a file; 24 Sep 2011 11:52 AM
+1 ;;3.0;IMAGING;**118**;Mar 19, 2002;Build 4525;May 01, 2013
+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 ;
FIELDLST(OUT,FILENO,ORDER) ; rpc MAG FILEMAN FIELD LIST
+1 ; input: FILENO The number of a Fileman file or subfile
+2 ; ORDER Desired order of field list return:
+3 ; A alpha
+4 ; N numeric (default)
+5 ;
+6 ; output: OUT() Array of return values formatted as follows:
+7 ; If no input or processing error:
+8 ; OUT(1) = 0``n where n = number of entries on the OUT() array
+9 ; OUT(m) where 1 < m <= n
+10 ; = field_number`field_name
+11 ; If an input or processing error:
+12 ; OUT(1) = n`error_message
+13 ;
+14 ; All ^DD references permitted under ICR #5551
+15 ;
+16 KILL OUT
+17 ; valid input
IF FILENO=+FILENO
IF $DATA(^DD(FILENO))
+18 IF '$TEST
SET OUT(1)="-1`'"_FILENO_"' not a valid Fileman file or subfile number"
QUIT
+19 SET ORDER=$GET(ORDER,"N")
+20 IF ".A.N."'[("."_ORDER_".")
SET OUT(1)="-2`invalid order (must be A or N)"
QUIT
+21 NEW FIELDNAME,FIELDNO,FIELDINFO,FIELDLIST,FIELDIX,OUTIX
+22 SET FIELDNAME=""
+23 FOR
SET FIELDNAME=$ORDER(^DD(FILENO,"B",FIELDNAME))
if FIELDNAME=""
QUIT
Begin DoDot:1
+24 SET FIELDNO=0
+25 FOR
SET FIELDNO=$ORDER(^DD(FILENO,"B",FIELDNAME,FIELDNO))
if 'FIELDNO
QUIT
Begin DoDot:2
+26 SET FIELDLIST($SELECT(ORDER="N":FIELDNO,1:$ORDER(FIELDLIST(""),-1)+1))=FIELDNO_"`"_FIELDNAME
+27 QUIT
End DoDot:2
+28 QUIT
End DoDot:1
+29 SET FIELDIX=0
SET OUTIX=1
+30 FOR
SET FIELDIX=$ORDER(FIELDLIST(FIELDIX))
if 'FIELDIX
QUIT
Begin DoDot:1
+31 SET OUTIX=OUTIX+1
SET OUT(OUTIX)=FIELDLIST(FIELDIX)
+32 QUIT
End DoDot:1
+33 ; count
SET OUT(1)="0``"_(OUTIX-1)
+34 QUIT