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

AGGWDEF.m

Go to the documentation of this file.
AGGWDEF ;VNGT/HS/ALA - Window definition ; 24 May 2010  11:47 AM
 ;;1.0;PATIENT REGISTRATION GUI;;Nov 15, 2010
 ;;
 Q
 ;
EN(DATA,VFILE,TYPE) ;EP -- AGG GET WINDOW DEFINITION
 ;
 ;Input
 ;  VFILE - The Window number or name
 ;
 NEW UID,II,IEN,VFIL,VALUE,ORD,VDATA,VDATA1,VDATA2,BJ,CLEAR,CLRFLD,CN,FLDNM
 NEW HELP,VDATA3,VFILN,VHELP,BN,AGGHELP,AGGHELPW,VFLD,VDATA9,SVFILN,SVFLD
 NEW DEF,HDR,NOSAVE,REQ,RGFN,RGN,VAL,VFIEN,CASE,BATCH
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGWDEF",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGWDEF D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S VFIEN=$G(VFILE,""),TYPE=$G(TYPE,"V")
 ;
 S HDR="T00030VFILE_NAME^T00015VFILE_NUMBER^T00030DISPLAY_RPC^T00045DISPLAY_RPC_PARAM^T00030EDIT_RPC^T00045EDIT_RPC_PARAM^T00030INIT_TRIGGER_RPC^"
 S HDR=HDR_"T00045INIT_TRIG_PARAM^T00030DELETE_RPC^T00045DELETE_RPC_PARAM^T00001FILTER^T00030VALID_RPC^"
 S HDR=HDR_"T00030DISPLAY_COLUMN^T00030INTERNAL_COLUMN^I00003SIZE^T00001COL_TYPE_PEND^T00001COL_TYPE_VIEW^T00008CODE^T00001GROUP^T00001CODE_TYPE^T00030UPPER^T00030LOWER^"
 S HDR=HDR_"T00030DEFAULT^T00001ACTION^T00001REQ_OPT^T00036EXCLUSION^T00001UNIQUE_VAL^T00003BATCH^T00045VALIDATION^T00030VALID_INPUT^T00020TABLE^T00001TABLE_LOOKUP^T00001PROV_SCREEN^T00150TABLE_SCREEN^"
 ;S HDR=HDR_"T00030DEFAULT^T00001ACTION^T00001REQ_OPT^T00036EXCLUSION^T00045VALIDATION^T00030VALID_INPUT^T00020TABLE^T00001TABLE_LOOKUP^T00001PROV_SCREEN^T00150TABLE_SCREEN^"
 S HDR=HDR_"T00001TRIGGER^T00030TRIG_RPC^T00045TRIG_CODES^T00001TABLE_PRELOAD^T00001TABLE_LOOKUP_TYPE^T00003DEC_PLACES^T00030ALT_DISPLAY^T00030MULT_REF^T00045GROUP_NAME^I00003GRID_ORDER^"
 S HDR=HDR_"T00030LINK_DATA_COL^T00045LINK_RPC^T00030LINK_PARAM^T00001NOSAVE^T00001CASE^T00250CLEAR_FIELDS^T01024HELP_TEXT"_$C(30)
 S @DATA@(II)=HDR
 ;
 I VFIEN="" D  G DONE
 . S VFIL=0
 . F  S VFIL=$O(^AGG(9009068.3,"D",TYPE,VFIL)) Q:'VFIL  D
 .. ; If it is a subdefinition for a multiple, it is retrieved from the
 .. ; Master definition so don't need to retrieve data fields
 .. I $$GET1^DIQ(9009068.3,VFIL_",",.07,"I") Q
 .. I $$GET1^DIQ(9009068.3,VFIL_",",.03,"I")=1 Q
 .. D VF(VFIL)
 ;
 ; If someone passes the name
 I VFIEN'?.N S VFIEN=$$FIND1^DIC(9009068.3,"","MX",VFILE,"","","ERROR")
 ; If someone passes the file number
 I $L(VFIEN)>6 S VFIEN=$$FIND1^DIC(9009068.3,"","MX",VFILE,"","","ERROR")
 ;
 I VFIEN=0 S BMXSEC="Passed in file "_VFILE_" is not correct" Q
 I $$GET1^DIQ(9009068.3,VFIEN_",",.03,"I")=1 S BMXSEC=VFILE_" is not active" Q
 ;
 D VF(VFIEN)
 ;
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
VF(VFIL) ;EP
 ; Parameters
 ;   VFILN - File Number
 ;   ORD   - Display Order number
 ;   
 NEW VFDATA,VFSDATA,MULTR,SFIL,VFSDATA2,FILTER,VALID,LINK,LRPC,LINP
 NEW BQN,BQP,BQPARM,VFDATA2,PRMND,PNAM,PTYP,PORD
 ;
 S VFDATA=^AGG(9009068.3,VFIL,0)
 S VFDATA2=$G(^AGG(9009068.3,VFIL,2))
 S FILTER=$S($D(^AGG(9009068.3,VFIL,7)):"Y",1:"N")
 S VALID=$P($G(^AGG(9009068.3,VFIL,8)),U,1)
 I $P(VFDATA,U,6)="D" Q
 ;
 D PRMS(VFIL)
 ;
 S VFILN=$P(VFDATA,U,2),SVFILN=$P(VFDATA,U,14)
 S VALUE=$P(VFDATA,U,1)_U_VFILN_U_$P(VFDATA,U,4)_U_BQPARM(3)_U_$P(VFDATA,U,12)_U_BQPARM(4)_U_$P(VFDATA,U,13)_U_BQPARM(5)_U_$P(VFDATA2,U)_U_BQPARM(6)_U_FILTER_U_VALID
 S ORD=""
 F  S ORD=$O(^AGG(9009068.3,VFIL,10,"C",ORD)) Q:ORD=""  D
 . S IEN=""
 . F  S IEN=$O(^AGG(9009068.3,VFIL,10,"C",ORD,IEN)) Q:IEN=""  D
 .. D RET(VFIL,IEN)
 ;
 ;Check for subdefinitions
 S SFIL=""
 F  S SFIL=$O(^AGG(9009068.3,"ASUB",VFIL,SFIL)) Q:SFIL=""  D
 . ;S VFILN=$$GET1^DIQ(9009068.3,SFIL_",",.02,"E")
 . ;S VALUE=$$GET1^DIQ(9009068.3,SFIL_",",.01,"E")_U_VFILN
 . S VFSDATA=^AGG(9009068.3,SFIL,0)
 . I $P(VFSDATA,U,3)=1 Q
 . S VFSDATA2=$G(^AGG(9009068.3,VFIL,2))
 . S FILTER=$S($D(^AGG(9009068.3,VFIL,7)):"Y",1:"N")
 . S VALID=$P($G(^AGG(9009068.3,VFIL,8)),U,1)
 . S VFILN=$P(VFSDATA,U,2),SVFILN=$P(VFSDATA,U,14)
 . D PRMS(SFIL)
 . ;S VALUE=$P(VFSDATA,U,1)_U_VFILN_U_$P(VFSDATA,U,4)_U_$P(VFSDATA,U,12)_U_$P(VFSDATA,U,13)
 . S VALUE=$P(VFSDATA,U,1)_U_VFILN_U_$P(VFSDATA,U,4)_U_BQPARM(3)_U_$P(VFSDATA,U,12)_U_BQPARM(4)_U_$P(VFSDATA,U,13)_U_BQPARM(5)_U_$P(VFSDATA2,U)_U_BQPARM(6)_U_FILTER_U_VALID
 . S ORD=""
 . F  S ORD=$O(^AGG(9009068.3,SFIL,10,"C",ORD)) Q:ORD=""  D
 .. S IEN=""
 .. F  S IEN=$O(^AGG(9009068.3,SFIL,10,"C",ORD,IEN)) Q:IEN=""  D RET(SFIL,IEN)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
RET(VFIL,IEN) ; Retrieve data
 S VDATA=^AGG(9009068.3,VFIL,10,IEN,0)
 I $P(VDATA,U,11)=1 Q
 S VDATA1=$G(^AGG(9009068.3,VFIL,10,IEN,1))
 S VDATA2=$G(^AGG(9009068.3,VFIL,10,IEN,2))
 S VDATA3=$G(^AGG(9009068.3,VFIL,10,IEN,3))
 S VDATA9=$G(^AGG(9009068.3,VFIL,10,IEN,9))
 NEW DA,IENS
 S DA(1)=VFIL,DA=IEN,IENS=$$IENS^DILF(.DA)
 S MULTR=$$GET1^DIQ(9009068.31,IENS,1.08,"E")
 ;
 ; Check for batch editable flag in 90506.1
 ;NEW CODE,LIEN,BATCH,LINK,LRPC,LINP
 ;S CODE=$P(VDATA,U,7),BATCH="NO"
 S LRPC=$P(VDATA9,U,1),LINP=$P(VDATA9,U,2),LINK=$P(VDATA1,U,10),NOSAVE=$P(VDATA1,U,11),CASE=$P(VDATA1,U,12)
 I NOSAVE="" S NOSAVE="N"
 I CASE="" S CASE="U"
 ;S LIEN=$O(^AGG(90506.1,"B",CODE,""))
 ;I LIEN'="" D
 ;. S BATCH=+$$GET1^DIQ(90506.1,LIEN_",",.17,"I")
 ;. S BATCH=$S(BATCH=1:"YES",1:"NO")
 ;
 ;Check default field for API - $P(VDATA1,U,4)
 S DEF=$P(VDATA1,U,4)
 I DEF["$$" D
 . NEW DVAL
 . X DEF
 . S $P(VDATA1,U,4)=DVAL
 ;
 ; Set the clear fields
 S CLEAR="",CN=0,CLRFLD=""
 F  S CN=$O(^AGG(9009068.3,VFIL,10,IEN,10,CN)) Q:'CN  D
 . S CLEAR=CLEAR_$P(^AGG(9009068.3,VFIL,10,IEN,10,CN,0),"^",1)_";"
 . S CLRFLD=$$TKO^AGGUL1(CLEAR,";")
 ;
 ; Set up the data fields
 S VFLD=$P(VDATA3,U,1),SVFLD=$P(VDATA3,U,7)
 S II=II+1,@DATA@(II)=VALUE_U_$P(VDATA,U,1,4)_U_$P(VDATA,U,12)_U_$P(VDATA,U,7)_U_$P(VDATA,U,14)_U
 S REQ=$P(VDATA1,U,6)
 F BJ=1:1:5 S @DATA@(II)=@DATA@(II)_$P(VDATA1,U,BJ)_U
 ;S PREQ=REQ
 I SVFILN'="",SVFLD'="" D
 . I SVFLD=.001 Q
 . S FLDNM=$P(^DD(SVFILN,SVFLD,0),U,1)
 . S RGN=$O(^AGFAC(DUZ(2),11,"B",SVFILN,"")) I RGN="" Q
 . S RGFN=$O(^AGFAC(DUZ(2),11,RGN,1,"B",FLDNM,"")) I RGFN="" Q
 . S VAL=$P(^AGFAC(DUZ(2),11,RGN,1,RGFN,0),U,2)
 . S REQ=$S(VAL=0:"O",VAL=1:"R",1:REQ)
 ;
 I VFILN'="",VFLD'="" D
 . I VFLD=.001 Q
 . S FLDNM=$P(^DD(VFILN,VFLD,0),U,1)
 . ;I FLDNM="SOCIAL SECURITY NUMBER" S FLDNM="SSN"
 . S RGN=$O(^AGFAC(DUZ(2),11,"B",VFILN,"")) I RGN="" Q
 . S RGFN=$O(^AGFAC(DUZ(2),11,RGN,1,"B",FLDNM,"")) I RGFN="" Q
 . S VAL=$P(^AGFAC(DUZ(2),11,RGN,1,RGFN,0),U,2)
 . S REQ=$S(VAL=0:"",VAL=1:"R",1:REQ)
 ;
 S @DATA@(II)=@DATA@(II)_REQ_U
 F BJ=7,9 S @DATA@(II)=@DATA@(II)_$P(VDATA1,U,BJ)_U
 S @DATA@(II)=@DATA@(II)_$G(BATCH)_U
 F BJ=1:1:5 S @DATA@(II)=@DATA@(II)_$P(VDATA2,U,BJ)_U
 S @DATA@(II)=@DATA@(II)_$G(^AGG(9009068.3,VFIL,10,IEN,6))_U_$P(VDATA,U,8)_U
 S @DATA@(II)=@DATA@(II)_$P(VDATA,U,9)_U_$P(VDATA,U,10)_U_$P(VDATA2,U,6)_U_$P(VDATA2,U,9)_U
 S @DATA@(II)=@DATA@(II)_$P(VDATA2,U,7)_U_$P(VDATA2,U,8)_U_MULTR_U_$P(VDATA3,U,4)_U
 S @DATA@(II)=@DATA@(II)_$P(VDATA3,U,5)_U_LINK_U_LRPC_U_LINP_U_NOSAVE_U_CASE_U_CLRFLD_U
 ;
 ;Check for HELP text
 K AGGHELPW,AGGHELP
 S VFLD=$P(VDATA3,U,1),VHELP="",SVFLD=$P(VDATA3,U,7)
 I SVFLD'="" D
 . D FIELD^DID(SVFILN,SVFLD,"","HELP-PROMPT","AGGHELP")
 . S VHELP=$G(AGGHELP("HELP-PROMPT"))
 . I VHELP="" D
 .. D FIELD^DID(SVFILN,SVFLD,"Z","DESCRIPTION","AGGHELPW")
 .. I $G(AGGHELPW("DESCRIPTION"))="" Q
 .. S BN=0,VHELP=""
 .. F  S BN=$O(AGGHELPW("DESCRIPTION",BN)) Q:BN=""  D
 ... S VHELP=VHELP_AGGHELPW("DESCRIPTION",BN,0)_$C(10)
 I VFLD'="" D
 . D FIELD^DID(VFILN,VFLD,"","HELP-PROMPT","AGGHELP")
 . S VHELP=$G(AGGHELP("HELP-PROMPT"))
 . I VHELP="" D
 .. D FIELD^DID(VFILN,VFLD,"Z","DESCRIPTION","AGGHELPW")
 .. I $G(AGGHELPW("DESCRIPTION"))="" Q
 .. S BN=0,VHELP=""
 .. F  S BN=$O(AGGHELPW("DESCRIPTION",BN)) Q:BN=""  D
 ... S VHELP=VHELP_AGGHELPW("DESCRIPTION",BN,0)_$C(10)
 I $P(VDATA3,U,6)'="" S VHELP=$P(VDATA3,U,6)
 S @DATA@(II)=@DATA@(II)_VHELP_$C(30)
 Q
 ;
USR() ;EP - Get the default user
 Q DUZ_$C(28)_$P($G(^VA(200,DUZ,0)),U,1)
 ;
TBL(FILE,VALUE) ; EP - Get a default for a specific table value
 NEW IEN
 S IEN=$$FIND1^DIC(FILE,"","MX",VALUE,"","","ERROR")
 Q IEN_$C(28)_VALUE
 ;
PRMS(VFIL) ;EP - Pull RPC parameters
 F BQN=3:1:6 D
 .S BQPARM(BQN)=""
 .N IDT,PRM,TIDT,TPRM
 .S BQP=0 F  S BQP=$O(^AGG(9009068.3,VFIL,BQN,BQP)) Q:'BQP  D
 ..S PRMND=$G(^AGG(9009068.3,VFIL,BQN,BQP,0))
 ..S PNAM=$P(PRMND,U)
 ..S PTYP=$P(PRMND,U,2) S:PTYP="" PTYP=$S(PNAM["=":"P",1:"I")
 ..S PORD=$P(PRMND,U,3) S:PORD="" PORD=BQP_PNAM
 ..;
 ..;Temp Store of Unique Identifiers
 ..I PTYP="I" D
 ...S TIDT(PORD)=PRMND
 ..;
 ..;Temp Store of Regular Parameters
 ..I PTYP="P" D
 ...S TPRM(PORD)=PRMND
 .;
 .;Form Parameter String
 .S IDT="",BQP="" F  S BQP=$O(TIDT(BQP)) Q:BQP=""  S IDT=IDT_$S(IDT]"":";",1:"")_$P(TIDT(BQP),U)
 .S PRM="",BQP="" F  S BQP=$O(TPRM(BQP)) Q:BQP=""  S PRM=PRM_$S(PRM]"":$C(28),1:"")_$P(TPRM(BQP),U)
 .S BQPARM(BQN)=IDT_$S(IDT]"":";",1:"")_PRM
 .S BQPARM(BQN)=$$TKO^AGGUL1(BQPARM(BQN),";")
 Q