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

IBCEFG.m

Go to the documentation of this file.
  1. IBCEFG ;ALB/TMP - OUTPUT FORMATTER EXTRACT ;17-JAN-96
  1. ;;2.0;INTEGRATED BILLING;**52,51,718**;21-MAR-94;Build 73
  1. ;
  1. ;EXTRACT(IBXFORM,IBXIEN,IBXREC,IBXPARM) ; Extract entry into global by rec #/pg/ln/col ; WCJ;IB718v22
  1. EXTRACT(IBXFORM,IBXIEN,IBXREC,IBXPARM,IBXPOSTWA) ; Extract entry into global by rec #/pg/ln/col; WCJ;IB718v22
  1. ; IBXFORM (required) Form id pointer to file #353
  1. ; IBXIEN (required) entry # in form's base file to output
  1. ; IBXREC (optional) record # in extract file - if not defined - 1 used
  1. ; IBXPARM (optional) array used to pass in specific search variables
  1. ; that can be used to customize the determination
  1. ; of the form field definition to use for each
  1. ; form field to be extracted
  1. ; IBXPARM(1) should contain a code to identify the
  1. ; type of form being processed (see $$ELE^IBCEFG0 function)
  1. ; IBXPOSTWA (optional) = 1 if the post processing of workarounds should be executed ; WCJ;IB718v22
  1. ; Returns total # of bytes of data extracted if extract successful
  1. ; or 0 if extract not successful
  1. ;
  1. N IBXPG,IBXLN,IBXCOL,IBXERR,IBXF,IBXFILE,IBX2,IBXSIZE
  1. S IBXERR="" S:$G(IBXREC)="" IBXREC=1
  1. I $G(IBXFORM)=""!($G(IBXIEN)="") S IBXERR="Missing Parameters" G EXTQ
  1. K ^TMP("IBXDATA",$J,IBXREC),^TMP("DIERR",$J,1),^TMP("IBXEDIT",$J)
  1. ;
  1. S IBX2=$G(^IBE(353,IBXFORM,2)),IBXFILE=+IBX2
  1. I 'IBXFILE S IBXERR="No base file found for form "_IBXFORM G EXTQ
  1. S IBXF=$S($P(IBX2,U,5):$P(IBX2,U,5),1:IBXFORM)
  1. ;
  1. I $G(^IBE(353,IBXFORM,"PRE"))'="" X ^("PRE") ;Entry pre-proc
  1. I $G(^IBE(353,IBXFORM,"PRE"))="",$G(^IBE(353,IBXF,"PRE"))'="" X ^("PRE") ;Entry pre-proc - parent
  1. G:$G(IBXERR)'="" EXTQ
  1. ;
  1. S IBXPG=""
  1. F S IBXPG=$O(^IBA(364.6,"ASEQ",IBXF,IBXPG)) Q:IBXPG="" S IBXLN="" F S IBXLN=$O(^IBA(364.6,"ASEQ",IBXF,IBXPG,IBXLN)) Q:IBXLN="" S IBXCOL="" D G:$G(IBXERR)'="" EXTQ
  1. .F S IBXCOL=$O(^IBA(364.6,"ASEQ",IBXF,IBXPG,IBXLN,IBXCOL)) Q:IBXCOL="" D Q:$G(IBXERR)'=""
  1. ..S IBXDA=$O(^IBA(364.6,"ASEQ",IBXF,IBXPG,IBXLN,IBXCOL,""))
  1. ..Q:'IBXDA
  1. ..D DATA(IBXPG,IBXLN,IBXCOL,IBXIEN,IBXFORM,IBXDA,.IBXPARM,.IBXERR)
  1. .. I $G(IBXERR)'="" S IBXERR=IBXERR_" Field: "_$P($G(^IBA(364.6,IBXDA,0)),U,10)
  1. ;
  1. EXTQ ;
  1. I $G(^IBE(353,IBXFORM,"POST"))'="" X ^("POST") ;Entry post-proc - assoc form or parent if not associated
  1. I $G(^IBE(353,IBXFORM,"POST"))="",$G(^IBE(353,IBXF,"POST"))'="" X ^("POST") ;Entry post-proc - parent of associated form
  1. ;
  1. K IBXMAX,IBX0,IBX00,IBXARRAY,IBXDA,IBXDATA,IBXFF,IBZ,IBZ0,IBZ1
  1. S:$G(IBXERR)'="" IBXSIZE=0
  1. Q +$G(IBXSIZE)
  1. ;
  1. DATA(IBXPG,IBXLN,IBXCOL,IBXIEN,IBXFORM,IBXDA,IBXPARM,IBXERR) ; Extract/Format Data Element
  1. ;IBXPG,IBXLN,IBXCOL = page,line,column to extract
  1. ;IBXIEN = internal entry # of entity to extract
  1. ;IBXFORM = internal entry # of FORM (file 353) to use to extract data
  1. ;IBXDA = ien of IB FORM SKELETON file entry to use (file 364.6)
  1. ; to use to extract the data
  1. ;IBXPARM = passed by reference. Array that optionally contains the
  1. ; parameters to use to screen
  1. ;IBXERR = passed by reference. Returned = error message if error
  1. ; condition found
  1. ;
  1. ; If associated form fld - get 'local' fld override
  1. S:'$D(IBXREC) IBXREC=1
  1. S:'$D(IBXFILE) IBXFILE=+$G(^IBE(353,IBXFORM,2))
  1. N IBXFF,IBX0,IBXELE,IBXARRAY,IBXZ,IBXMAX,IBXLEN,IBZ,IBZ0,IBZ1,IBX00,IBXDA0
  1. S IBXFF=$$ELE^IBCEFG0(IBXDA,.IBXPARM,IBXFORM) ;Form field entry to use
  1. Q:'IBXFF ;no form field definition found
  1. S IBX0=$G(^IBA(364.7,IBXFF,0)) ;Form field 0-node
  1. ;
  1. S IBXELE=$P(IBX0,U,3) ;data element def entry to use
  1. Q:'$D(^IBA(364.5,+IBXELE,0)) S IBX00=$G(^(0))
  1. ;
  1. S IBXARRAY=$S($G(^IBA(364.5,IBXELE,2))="":"IBXDATA",1:^(2))
  1. K:IBXARRAY?1A.E!(IBXARRAY?1"^"1A.E) @IBXARRAY
  1. S @IBXARRAY=$$DATA^IBCEFG0(IBXELE,IBX00,IBXFILE,IBXIEN,IBXARRAY,.IBXERR)
  1. Q:$G(IBXERR)'=""
  1. ;
  1. I $G(^IBA(364.7,IBXFF,1))'="" S IBXZ=^(1) D Q:$G(IBXERR)'=""
  1. . N IBXFF,IBXLOOP,Z
  1. . F Z="IBXDA","IBXPG","IBXLN","IBXCOL","IBX0" S IBXLOOP(Z)=@Z ;Protect loop variables
  1. . X IBXZ
  1. . F Z="IBXDA","IBXPG","IBXLN","IBXCOL","IBX0" K @Z S @Z=IBXLOOP(Z)
  1. S IBXDA0=$G(^IBA(364.6,IBXDA,0))
  1. ; Check for required field
  1. I $P(IBXDA0,U,13),'$G(IBXNOREQ) D Q:$G(IBXERR)'=""
  1. . I $G(@IBXARRAY)="" N Z S Z=0 F S Z=$O(@IBXARRAY@(Z)) S:'Z IBXERR="No data found for required field " Q:$S('Z:1,1:$G(@IBXARRAY@(Z))'="")
  1. D:'$G(IBXNOREQ) NULLCHEK
  1. K IBXNOREQ
  1. Q:$P(IBXDA0,U,11)!($P(IBXDA0,U,8)[".")!('$D(@IBXARRAY)) ;data no longer exists or fld not an output fld
  1. ;
  1. S IBXMAX=$O(@IBXARRAY@(""),-1),IBXLEN=$P(IBXDA0,U,9)
  1. I IBXMAX,$P(IBXDA0,U,6),IBXMAX>$P(IBXDA0,U,6) S IBXERR="Max # lines or occurrences exceeded ("_IBXMAX_" > "_$P(IBXDA0,U,6)_") - "_$P(IBXDA0,U,10) Q:$G(IBXERR)'=""
  1. I 'IBXMAX D Q
  1. . D SETGBL(IBXPG,IBXLN,IBXCOL,$$FORMAT($G(@IBXARRAY),IBXLEN,$P(^IBA(364.7,IBXFF,0),U,7),IBX0),.IBXSIZE)
  1. . D:$P($G(^IBE(353,IBXFORM,2)),U,2)="S" SETEDIT(IBXFORM,IBX0)
  1. ;
  1. S IBZ=IBXARRAY,IBZ0=$E(IBZ,1,$L(IBZ)-$S($E(IBZ,$L(IBZ))=")":1,1:0))
  1. S:IBZ0["("&($P(IBZ0,"(",2)'="") IBZ0=IBZ0_"," S:IBZ0'["(" IBZ0=IBZ0_"("
  1. F S IBZ=$Q(@IBZ) Q:IBZ'[IBZ0 I $QS(IBZ,$QL(IBZ)) D
  1. . S IBZ1=IBXLN+$P(IBZ,IBZ0,2)-1
  1. . D SETGBL(IBXPG,IBZ1,IBXCOL,$$FORMAT(@IBZ,IBXLEN,$P(^IBA(364.7,IBXFF,0),U,7),IBX0,+$P(IBZ,"(",2)),.IBXSIZE)
  1. . D:$P($G(^IBE(353,IBXFORM,2)),U,2)="S" SETEDIT(IBXFORM,IBX0)
  1. Q
  1. ;
  1. FORMAT(DATA,IBXLEN,IBXPAD,IBX0,MULTI) ; Adjust length on data for field def,add prompt
  1. ; DATA = the data to be output
  1. ; IBXLEN = the max length of the data
  1. ; IBXPAD = code for pad character
  1. ; IBX0 = the 0-node of the entry in file 364.7 being formatted
  1. ; MULTI = (optional)
  1. ; 0 or null if a single occurrence of the data
  1. ; > 0 if multiple ocurrences of the data being processed (group data)
  1. ;
  1. N Z
  1. S Z="",$P(Z,$S($E(IBXPAD)="Z":"0",1:" "),IBXLEN+1)=""
  1. S Z=$S($E(IBXPAD)="N":$E(DATA,1,IBXLEN),$E(IBXPAD,2)="L":$E(Z,1,IBXLEN-$L(DATA))_DATA,1:$E(DATA_Z,1,IBXLEN))
  1. I $P(IBX0,U,4)'="" D
  1. .I $S('$G(MULTI):1,1:MULTI=1) S Z=$P(IBX0,U,4)_Z Q ;Add prompt to data
  1. .S Z=$J("",$L($P(IBX0,U,4)))_Z
  1. I $P(IBX0,U,10),$P(IBX0,U,9)="E" S Z="["_$P(IBX0,U,10)_"] "_Z
  1. Q Z
  1. ;
  1. SETGBL(IBXPG,IBXLN,IBXCOL,VAL,IBXSIZE) ; Sets the output global
  1. ;IBXPG = Form page IBXLN = Form line IBXCOL = form column
  1. ;VAL = value to place at PG/LINE/COL IBXSIZE = size counter (optional)
  1. ;
  1. S ^TMP("IBXDATA",$J,IBXREC,IBXPG,IBXLN,IBXCOL)=VAL,IBXSIZE=$G(IBXSIZE)+$L(VAL)
  1. Q
  1. ;
  1. SETEDIT(IBFORM,IBX0) ;
  1. N Z,Z0
  1. Q:$P(IBX0,U,9)="D"!'$P(IBX0,U,10)
  1. S Z0=$P($G(^IBA(364.5,+$P(IBX0,U,3),0)),U,6)
  1. Q:Z0="" S Z0=$O(^DD(+$G(^IBE(353,IBXFORM,2)),"B",Z0,""))
  1. Q:Z0=""
  1. S Z=$O(^TMP("IBXEDIT",$J,$P(IBX0,U,10),""),-1)+1
  1. S ^TMP("IBXEDIT",$J,$P(IBX0,U,10),Z)=Z0
  1. Q
  1. ;
  1. NULLCHEK ; Checks for no output if null, deletes variable if appropriate
  1. ; Check for no output if transmit and null
  1. I $P($G(^IBA(364.6,+IBXDA,0)),U,12),$P($G(^IBE(353,IBXFORM,2)),U,2)="T" D
  1. . I $D(@IBXARRAY)=1 K:$G(@IBXARRAY)="" @IBXARRAY Q
  1. . I $D(@IBXARRAY)>9 D
  1. .. N Z
  1. .. S Z=0 F S Z=$O(@IBXARRAY@(Z)) Q:'Z I $G(@IBXARRAY@(Z))="" K @IBXARRAY@(Z)
  1. Q
  1. ;