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

BMXRPC2.m

Go to the documentation of this file.
  1. BMXRPC2 ; IHS/OIT/HMW - FIELD LIST ;
  1. ;;4.0;BMX;;JUN 28, 2010
  1. ;
  1. FLDLIST(BMXGBL,BMXFL,BMXATTR,BMXSCR) ;EP
  1. ;TODO: Change all this to be a hard-coded $O thru ^DD
  1. ;Returns info in BMXATTR for all fields in file number BMXFL
  1. ;BMXSCR is executable code to set $T
  1. ; When BMXSCR is executed, the field number is in BMXFLD
  1. ;See FileMan documentation for FIELD^DD for description
  1. ;of Attributes
  1. ;
  1. ;---> Set variables, kill temp globals.
  1. ;S ^HW("F",BMXFL)=""
  1. ;S ^HW("F",BMXATTR)=""
  1. N BMX31,BMXERR,BMXG,BMXFLD,BMX,BMXC,BMXT
  1. S BMX31=$C(31)_$C(31)
  1. S BMXGBL="BMXTMP("_$J_")",BMXERR="",U="^"
  1. K BMXTMP($J)
  1. ;
  1. ;---> If file number not provided, return error.
  1. ;I '+BMXFL D ERROUT^BMXRPC("File number not provided.",1) Q
  1. ;---> If file number not provided check for file name.
  1. I +BMXFL'=BMXFL D
  1. . S BMXFL=$TR(BMXFL,"_"," ")
  1. . I '$D(^DIC("B",BMXFL)) S BMXFL="" Q
  1. . S BMXFL=$O(^DIC("B",BMXFL,0))
  1. I '$G(BMXFL) D ERROUT^BMXRPC("File number not provided.",1) Q
  1. ;
  1. ;---> If no such file, return error.
  1. I '$D(^DD(BMXFL,0)) D ERROUT^BMXRPC("File does not exist.",1) Q
  1. ;
  1. ;---> Validate screen code
  1. I $G(BMXSCR)="" S BMXSCR="I 1"
  1. S X=$G(BMXSCR)
  1. I X]"" D ^DIM
  1. I '$D(X) S BMXSCR="I 1" ;Default to no screen
  1. ;
  1. ;---> Set Target Global for output and errors.
  1. S BMXG="BMXTMP($J,""DID"")"
  1. ;
  1. ;---> Loop through ^DD(FileNumber,FieldNumber,0) to get field names
  1. K BMXTMP($J)
  1. I $G(BMXATTR)="" S BMXATTR="LABEL" ;Changed from NAME to LABEL
  1. ;---> Attribute Names
  1. F I=1:1:$L(BMXATTR,";") S BMXT($P(BMXATTR,";",I))=""
  1. S (BMX,BMXC)=0 F S BMX=$O(BMXT(BMX)) Q:BMX="" D
  1. . S BMXC=BMXC+1
  1. . S $P(BMXT,U,BMXC)="T00030"_BMX
  1. S BMXTMP($J,1)="T00030NUMBER"_U_BMXT_$C(30)
  1. ;
  1. ;S BMXFLD=0 F I=2:1 S BMXFLD=$O(^DD(BMXFL,BMXFLD)) Q:'+BMXFLD D
  1. S BMXTMP($J,2)=".001^BMXIEN"_$C(30)
  1. S BMXFLDN=0 F I=3:1 S BMXFLDN=$O(^DD(BMXFL,"B",BMXFLDN)) Q:BMXFLDN="" D
  1. . S BMXFLD=$O(^DD(BMXFL,"B",BMXFLDN,0)) Q:'+BMXFLD
  1. . X BMXSCR Q:'$T
  1. . D FIELD^DID(BMXFL,BMXFLD,,BMXATTR,BMXG,BMXG)
  1. . K BMXT S (BMXC,BMX)=0
  1. . F S BMX=$O(BMXTMP($J,"DID",BMX)) Q:BMX="" D
  1. . . S BMXC=BMXC+1
  1. . . S $P(BMXT,U,BMXC)=BMXTMP($J,"DID",BMX)
  1. . S BMXTMP($J,I)=BMXFLD_U_$TR(BMXT," ","_")_$C(30)
  1. ;S I=I+1,BMXTMP($J,I)=".001^BMXIEN"_$C(30)
  1. S I=I+1
  1. K BMXTMP($J,"DID")
  1. ;---> Tack on Error Delimiter and any error.
  1. S BMXTMP($J,I)=BMX31_BMXERR
  1. Q
  1. ;
  1. MLTLIST(BMXGBL,BMXFL,BMXONEOK) ;EP
  1. ;Returns list of multiple fields in file BMXFL, returns only one field
  1. ;if BMXONEOK is TRUE
  1. ;S ^HW($H,"MLTLIST","FL")=BMXFL
  1. ;S ^HW($H,"MLTLIST","ONE")=BMXONEOK
  1. N BMX31,BMXERR,BMXG,BMXFLD,BMX,BMXC,BMXT,I
  1. S BMX31=$C(31)_$C(31)
  1. S BMXGBL="BMXTMP("_$J_")",BMXERR="",U="^"
  1. K BMXTMP($J)
  1. ;
  1. ;---> If file number not provided check for file name.
  1. I +BMXFL'=BMXFL D
  1. . S BMXFL=$TR(BMXFL,"_"," ")
  1. . I '$D(^DIC("B",BMXFL)) S BMXFL="" Q
  1. . S BMXFL=$O(^DIC("B",BMXFL,0))
  1. I '$G(BMXFL) D ERROUT^BMXRPC("File number not provided.",1) Q
  1. ;
  1. ;---> If no such file, return error.
  1. I '$D(^DD(BMXFL,0)) D ERROUT^BMXRPC("File does not exist.",1) Q
  1. ;
  1. ;---> Column Headers
  1. S BMXTMP($J,1)="T00030NUMBER"_U_"T00030NAME"_$C(30)
  1. ;
  1. ;---> $O thru ^DD(BMXFL,"SB" to get subfile numbers and names
  1. S I=2
  1. N BMXSB,BMXSBN,BMXSBF,BMXFOUND
  1. S BMXFOUND=0
  1. I $D(^DD(BMXFL,"SB")) D
  1. . S BMXSB=0
  1. . F S BMXSB=$O(^DD(BMXFL,"SB",BMXSB)) Q:'+BMXSB D I BMXFOUND Q:BMXONEOK=1
  1. . . S BMXSBF=$O(^DD(BMXFL,"SB",BMXSB,0))
  1. . . Q:'+BMXSBF
  1. . . S BMXSBN=$G(^DD(BMXFL,BMXSBF,0))
  1. . . Q:BMXSBN=""
  1. . . S BMXZ=$G(^DD(BMXSB,.01,0))
  1. . . Q:$P(BMXZ,U,2)["W"
  1. . . S BMXFOUND=1
  1. . . S BMXSBN=$P(BMXSBN,U)
  1. . . S BMXTMP($J,I)=BMXSB_U_BMXSBN_$C(30)
  1. . . S I=I+1
  1. ;
  1. ;---> Tack on Error Delimiter and any error.
  1. S BMXTMP($J,I)=BMX31_BMXERR
  1. Q