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

AGGDCUPD.m

Go to the documentation of this file.
AGGDCUPD ;VNGT/HS/ALA-Document Update ; 19 May 2010  3:32 PM
 ;;1.0;PATIENT REGISTRATION GUI;**1**;Nov 15, 2010
 ;
 ;
UPD(DATA,DEF,DFN,PARMS) ; EP - AGG UPDATE DOCUMENTS
 ; Input
 ;   DEF   - Definition Name
 ;   DFN   - Patient IEN
 ;   PARMS - Parameters
 NEW UID,II,BN,LIST,PDATA,NAME,VALUE,VFIEN,FILE,PTYP,CHIEN,FIELD,EXEC,WDATA
 NEW AGGDATA,ERROR,RESULT,AGGINT,PTYP,AGGPTRSI,AGGRHIDT,AGGRHIO,AGGRHTXT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGDCUPD",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGPTUPD D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 S @DATA@(II)="I00010RESULT^T01024ERROR"_$C(30)
 ;
 S VFIEN=$O(^AGG(9009068.3,"B",DEF,""))
 I VFIEN="" S BMXSEC="RPC Call Failed: "_DEF_" Definition does not exist." Q
 S FILE=$P(^AGG(9009068.3,VFIEN,0),U,2),SECFILE=$P(^AGG(9009068.3,VFIEN,0),U,14)
 ;
 I $G(^AUPNNPP(DFN,0))="" D NEWP
 ;
 ; Get previous data
 NEW FLD,LIST
 S FLD="",LIST="" F  S FLD=$O(^AGG(9009068.3,VFIEN,10,"AD",FLD)) Q:FLD=""  S LIST=LIST_FLD_";"
 S LIST=$$TKO^AGGUL1(LIST,";")
 D GETS^DIQ(FILE,DFN_",",LIST,"I","AGGINT")
 ;
 NEW FLD,LIST
 S DA=$O(^AUPNRHI("B",DFN,""))
 I DA'="" D
 . S FLD="",LIST="" F  S FLD=$O(^AGG(9009068.3,VFIEN,10,"AG",FLD)) Q:FLD=""  S LIST=LIST_FLD_";"
 . D GETS^DIQ(SECFILE,DA_",",LIST,"I","AGGINT")
 ;
 S PARMS=$G(PARMS,"")
 I PARMS="" D
 . S LIST="",BN=""
 . F  S BN=$O(PARMS(BN)) Q:BN=""  S LIST=LIST_PARMS(BN)
 . K PARMS
 . S PARMS=LIST
 . K LIST
 ;
 F BQ=1:1:$L(PARMS,$C(28)) D  Q:$G(BMXSEC)'=""
 . S PDATA=$P(PARMS,$C(28),BQ) Q:PDATA=""
 . S NAME=$P(PDATA,"=",1),VALUE=$P(PDATA,"=",2,99)
 . ;I VALUE="" S VALUE="@"
 . ;I VALUE="" Q
 . S PFIEN=$O(^AGG(9009068.3,VFIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC=NAME_" not a valid parameter for this update" Q
 . S PTYP=$P($G(^AGG(9009068.3,VFIEN,10,PFIEN,1)),U,1)
 . I PTYP="D" S VALUE=$$DATE^AGGUL1(VALUE)
 . ;I PTYP="T" S VALUE=VALUE
 . I PTYP="C"!(PTYP="K") D
 .. I VALUE="" Q
 .. S CHIEN=$O(^AGG(9009068.3,VFIEN,10,PFIEN,5,"B",VALUE,"")) I CHIEN="" Q
 .. S VALUE=$P(^AGG(9009068.3,VFIEN,10,PFIEN,5,CHIEN,0),U,2)
 . I PTYP="W" D  Q
 .. F AGI=1:1  S AGJ=$P(VALUE,$C(10),AGI) Q:AGJ=""  D
 ... S AGWP(AGI,0)=$$CTRL^AGGUL1(AGJ)
 . ;
 . S FIELD=$P($G(^AGG(9009068.3,VFIEN,10,PFIEN,3)),U,1),SECFLD=$P($G(^AGG(9009068.3,VFIEN,10,PFIEN,3)),U,7)
 . I FIELD'="",$G(AGGINT(FILE,DFN_",",FIELD,"I"))'="",VALUE="" S VALUE="@"
 . I SECFLD'="",$G(AGGINT(SECFILE,DA_",",SECFLD,"I"))'="",VALUE="" S VALUE="@"
 . S @NAME=VALUE
 ;
 F BQ=1:1:$L(PARMS,$C(28)) D  Q:$G(BMXSEC)'=""
 . S PDATA=$P(PARMS,$C(28),BQ) Q:PDATA=""
 . S NAME=$P(PDATA,"=",1)
 . S PFIEN=$O(^AGG(9009068.3,VFIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC=NAME_" not a valid parameter for this update" Q
 . S FIELD=$P($G(^AGG(9009068.3,VFIEN,10,PFIEN,3)),U,1),SECFLD=$P($G(^AGG(9009068.3,VFIEN,10,PFIEN,3)),U,7)
 . S PTYP=$P($G(^AGG(9009068.3,VFIEN,10,PFIEN,1)),U,1)
 . S EXEC=$G(^AGG(9009068.3,VFIEN,10,PFIEN,7))
 . I EXEC'="" X EXEC Q
 . I FIELD="",SECFLD="" Q
 . S PTYP=$P($G(^AGG(9009068.3,VFIEN,10,PFIEN,1)),U,1)
 . I PTYP="C"!(PTYP="T")!(PTYP="K") D  Q
 .. I FIELD'="" S AGGDATAI(FILE,DFN_",",FIELD)=@NAME Q
 .. I SECFLD'="" S AGGDATAI(SECFILE,DA_",",SECFLD)=@NAME
 . I FIELD'="" S AGGDATA(FILE,DFN_",",FIELD)=@NAME Q
 . I SECFLD'="" S AGGDATA(SECFILE,DA_",",SECFLD)=@NAME
 ;
 S RESULT=1_U
 ;
 I $D(AGGWP) D
 . NEW FL,FD,IENS,FLAG
 . S FL=""
 . F  S FL=$O(AGGWP(FL)) Q:FL=""  D
 .. S IENS=""
 .. F  S IENS=$O(AGGWP(FL,IENS)) Q:IENS=""  D
 ... S FD=""
 ... F  S FD=$O(AGGWP(FL,IENS,FD)) Q:FD=""  D
 .... S FLAG=""
 .... ;I FL=9000001,FD=1301 S FLAG="A"
 .... I $D(WDATA) D WP^DIE(FL,IENS,FD,FLAG,WDATA,"ERROR")
 ;
 K AGGWP,AGWP
 I $D(ERROR)>0 S RESULT=-1_U_$G(ERROR("DIERR",1,"TEXT",1))
 K ERROR
 I $D(AGGDATA)>0 D FILE^DIE("","AGGDATA","ERROR")
 I $D(AGGDATAI)>0 D FILE^DIE("I","AGGDATAI","ERROR")
 I $D(ERROR)>0 S RESULT=-1_U_$G(ERROR("DIERR",1,"TEXT",1))
 I $P(RESULT,U,1)'=-1 S RESULT=1_U
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 ;
 I $P(RESULT,U,1)=1 D
 . S AGGDATAI(9000001,DFN_",",.03)=DT,AGGDATAI(9000001,DFN_",",.12)=DUZ
 . D FILE^DIE("","AGGDATAI","ERROR")
 . D EDIT^AGGEXPRT(DFN)
 ;
 K AGGDATA,AGGDATAI
 S NAME=""
 F  S NAME=$O(^AGG(9009068.3,VFIEN,10,"AC",NAME)) Q:NAME=""  K @NAME
 ;
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
NEWP ;
 NEW DIC,DLAYGO,Y,X,DINUM
 S DIC="^AUPNNPP("
 S DIC(0)="L"
 S DLAYGO=9000038
 ;S X="`"_DFN
 S (X,DINUM)=DFN
 ;D ^DIC
 ;I Y=-1 K DO,DD D FILE^DICN
 K DO,DD D FILE^DICN
 S DA=+Y
 S AGGDATAI(FILE,DA_",",.06)=$$NOW^XLFDT()
 S AGGDATAI(FILE,DA_",",.07)=DUZ
 Q
 ;
NEWR ;
 NEW DIC,DLAYGO,Y,X
 S DIC="^AUPNRHI("
 S DIC(0)="L"
 S DLAYGO=9000039
 S X=DFN
 D ^DIC
 I Y=-1 K DO,DD D FILE^DICN
 S DA=+Y
 Q
 ;
RHI ; EP
 I $G(AGGPTRSI)="" Q
 NEW FLD,DA,STAT
 S DA=$O(^AUPNRHI("B",DFN,""))
 I DA="" D NEWR
 S DA=$O(^AUPNRHI("B",DFN,""))
 S STAT=AGGPTRSI
 S AGGDATA(9000039,DA_",",.03)=AGGPTRSI
 S FLD=$S(STAT="P":.11,STAT="A":.21,STAT="R":.41,STAT="N":.31,1:"")
 I $G(AGGRHIDT)="",FLD'="" S AGGDATAI(9000039,DA_",",FLD)=$$DT^XLFDT()
 I $G(AGGRHIDT)'="",FLD'="" S AGGDATAI(9000039,DA_",",FLD)=AGGRHIDT
 S FLD=$S(STAT="A":.22,STAT="R":.42,STAT="N":.32,1:"")
 I $G(AGGRHIO)'="",FLD'="" S AGGDATA(9000039,DA_",",FLD)=AGGRHIO
 I $G(AGGRHTXT)'="" S AGGDATA(9000039,DA_",",.02)=AGGRHTXT
 S FLD=$S(STAT="P":.12,STAT="A":.23,STAT="R":.43,STAT="N":.33,STAT="E":.51,1:"")
 I FLD'="" S AGGDATAI(9000039,DA_",",FLD)=DUZ
 S FLD=$S(STAT="E":.52,STAT="P":.13,STAT="A":.24,STAT="R":.44,STAT="N":.34,1:"")
 I FLD'="" S AGGDATAI(9000039,DA_",",FLD)=$$NOW^XLFDT()
 Q
 ;
MRECU(DFN,AGGPTMRS) ; EP
 I $G(AGGPTMRS)="" Q
 I $G(DFN)="" Q
 I $G(^AUPNPAT(DFN,41,DUZ(2),0))="" Q
 NEW DA,IENS
 S DA(1)=DFN,DA=DUZ(2),IENS=$$IENS^DILF(.DA)
 S AGGDATAI(9000001.41,IENS,.04)=$G(AGGPTMRS)
 Q