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

AGGPTNAM.m

Go to the documentation of this file.
AGGPTNAM ;VNGT/HS/ALA-Patient Names ; 29 Jun 2010  3:27 PM
 ;;1.0;PATIENT REGISTRATION GUI;**1**;Nov 15, 2010
 ;
ALIAS(DATA,DFN,PROC,RIEN,PARMS) ;EP -- AGG UPDATE ALIASES
 NEW UID,II,BQ,PDATA,NAME,PFIEN,FIELD,EXEC,AGGDATA,AGGDATAI,PTYP,VALUE,CHIEN,AGI,AGWP
 NEW X,Y,RESULT,DA,AGIEN,DIC,DLAYGO,IENS,ERROR,AGGPTALS
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGPTALIAS",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^I00010RIEN"_$C(30)
 S AGIEN=$O(^AGG(9009068.3,"B","Aliases",""))
 ;if deleting an Alias
 I $G(PROC)="D" D  G DNE
 . NEW DIK,DA
 . S DA(1)=DFN,DA=RIEN
 . S DIK="^DPT("_DA(1)_",.01," D ^DIK
 ;if adding a new Alias
 D PARS
 I $G(PROC)="A" D
 . I $G(RIEN)="" D
 .. I $G(^DPT(DFN,.01,0))="" S ^DPT(DFN,.01,0)="^2.01A^^"
 .. S DA(1)=DFN
 .. S DLAYGO=2.01,DIC(0)="L",DIC="^DPT("_DA(1)_",.01,",X=AGGPTALS
 .. K DO,DD D FILE^DICN S RIEN=+Y
 ;if editing a Legal Name
 S DA(1)=DFN,DA=RIEN,IENS=$$IENS^DILF(.DA)
 ;
 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,AGIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC=NAME_" not a valid parameter for this update" Q
 . S FIELD=$P($G(^AGG(9009068.3,AGIEN,10,PFIEN,3)),U,1)
 . S EXEC=$G(^AGG(9009068.3,AGIEN,10,PFIEN,7))
 . I EXEC'="" X EXEC Q
 . I FIELD="" Q
 . S AGGDATA(2.01,IENS,FIELD)=@NAME
 ;
 S AGGDATAI(9000001,DFN_",",.03)=DT,AGGDATAI(9000001,DFN_",",.12)=DUZ
 I $D(AGGDATA) D FILE^DIE("","AGGDATA","ERROR")
 I $D(AGGDATAI) D FILE^DIE("I","AGGDATAI","ERROR")
 ;
DNE ;
 S RESULT=1_U_U_RIEN
 I $D(ERROR) S RESULT="-1"_U_$G(ERROR("DIERR",1,"TEXT",1))_U_U
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 ;
 I $P(RESULT,U,1)=1 D EDIT^AGGEXPRT(DFN)
 S NAME=""
 F  S NAME=$O(^AGG(9009068.3,AGIEN,10,"AC",NAME)) Q:NAME=""  I $G(@NAME)'="" K @NAME
 Q
 ;
LEGL(DATA,DFN,PROC,RIEN,PARMS) ;EP -- AGG UPDATE LEGAL NAMES
 NEW UID,II,BQ,PDATA,NAME,PFIEN,FIELD,EXEC,AGGDATA,AGGDATAI,PTYP,VALUE,CHIEN,AGI,AGWP
 NEW X,Y,RESULT,DA,AGIEN,DIC,DLAYGO,IENS,ERROR,AGGLNDTC
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGPTNAM",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^I00010RIEN"_$C(30)
 S AGIEN=$O(^AGG(9009068.3,"B","Legal Names",""))
 ;
 ;if deleting a Legal Name
 I $G(PROC)="D" D  G DONE
 . NEW DIK,DA
 . S DIK="^AUPNNAMC(",DA=RIEN D ^DIK
 ;if adding a new Legal Name
 D PARS
 I $G(PROC)="A" D
 . I $G(RIEN)="" D
 .. I $G(AGGLNDTC)="" S AGGLNDTC=DT
 .. S DLAYGO=9000033,DIC(0)="L",DIC="^AUPNNAMC(",X=AGGLNDTC
 .. D ^DIC S RIEN=+Y
 ;if editing a Legal Name
 S DA=RIEN,IENS=$$IENS^DILF(.DA)
 ;
 S AGGDATAI(9000033,IENS,.02)=DFN
 S AGGDATAI(9000033,IENS,.06)=DUZ
 S AGGDATAI(9000001,DFN_",",.03)=DT,AGGDATAI(9000001,DFN_",",.12)=DUZ
 ;
 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,AGIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC=NAME_" not a valid parameter for this update" Q
 . S FIELD=$P($G(^AGG(9009068.3,AGIEN,10,PFIEN,3)),U,1)
 . S EXEC=$G(^AGG(9009068.3,AGIEN,10,PFIEN,7))
 . I EXEC'="" X EXEC Q
 . I FIELD="" Q
 . S AGGDATA(9000033,IENS,FIELD)=@NAME
 I $D(AGGDATA) D FILE^DIE("","AGGDATA","ERROR")
 I $D(AGGDATAI) D FILE^DIE("I","AGGDATAI","ERROR")
 ;
DONE ;
 S RESULT=1_U_U_RIEN
 I $D(ERROR) S RESULT="-1"_U_$G(ERROR("DIERR",1,"TEXT",1))_U_U
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 ;
 I $P(RESULT,U,1)=1 D EDIT^AGGEXPRT(DFN)
 S NAME=""
 F  S NAME=$O(^AGG(9009068.3,AGIEN,10,"AC",NAME)) Q:NAME=""  I $G(@NAME)'="" K @NAME
 Q
 ;
PARS ;
 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)
 . S PFIEN=$O(^AGG(9009068.3,AGIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC=NAME_" not a valid parameter for this update" Q
 . S PTYP=$P($G(^AGG(9009068.3,AGIEN,10,PFIEN,1)),U,1)
 . I PTYP="D" S VALUE=$$DATE^AGGUL1(VALUE)
 . I PTYP="C" D
 .. I VALUE="" Q
 .. S CHIEN=$O(^AGG(9009068.3,AGIEN,10,PFIEN,5,"B",VALUE,"")) I CHIEN="" Q
 .. S VALUE=$P(^AGG(9009068.3,AGIEN,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 @NAME=VALUE
 Q
 ;
LINIT(DATA,PROC) ;EP -- AGG LEGAL NAME INIT TRIG
 ; Input
 ;   PROC - Transaction type
 ;
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE,AGGECREL
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGLNMTR",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGWTRIG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 D HDR
 S @DATA@(II)=HDR_$C(30)
 I $G(PROC)="A" D
 . S SOURCE="AGGLNPRF",VALUE="",ABLE="N",TYPE="X",CLEAR="",HELP="" D UP
 . S SOURCE="AGGLGDOC",VALUE="",ABLE="N",TYPE="X",CLEAR="",HELP="" D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
NMUP(DATA,AGGLNMC) ; EP -- AGG NAME CHANGE TRIG
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE,AGGECREL
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGLNMCTR",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGWTRIG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 D HDR
 S @DATA@(II)=HDR_$C(30)
 I $G(AGGLNMC)'="" D
 . S SOURCE="AGGLNPRF",VALUE="",ABLE="Y",TYPE="X",CLEAR="",HELP="" D UP
 . S SOURCE="AGGLGDOC",VALUE="",ABLE="Y",TYPE="X",CLEAR="",HELP="" D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
UP ;
 S II=II+1,@DATA@(II)=SOURCE_U_TYPE_U_VALUE_U_ABLE_U_$G(CLEAR)_U_HELP_$C(30)
 Q
 ;
HDR ;
 S HDR="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00100CLEAR_FIELDS^T00200HELP_TEXT"
 Q