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

AMHBHDEL.m

Go to the documentation of this file.
AMHBHDEL ; IHS/CMI/LAB - GUI V FILE VISIT CREATION ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;;
TEST ;
 D EN(.RETVAL,0)
 Q
EN(AMHARRAY,AMHR) ;EP CALL
 S AMHERR="",ZTQUEUED=""
 ;AMHR must be ien of MHSS RECORD that is to be deleted
 D
 .NEW AMHACTN
 .S AMHACTN=4
 .D CHECKREC Q:AMHERR'=""
 .D DELETE
 I AMHERR="" D MSG("1") Q
 I AMHERR'="" D ERROR(AMHERR)
 D KILL
 Q
 ;
CHECKREC ;
 I '$G(AMHR) S AMHERR="IEN MISSING" Q
 I '$D(^AMHREC(AMHR)) S AMHERR="INVALID RECORD IEN PASSED" Q
 Q
DELETE ;
 S AMHVDLT=$P(^AMHREC(AMHR,0),U,16)
 S AMHRDEL=AMHR
 S AMHVFLE=9002011 F AMHVL=0:0 S AMHVFLE=$O(^DIC(AMHVFLE)) Q:AMHVFLE>9002011.49!(AMHVFLE'=+AMHVFLE)  D DELETE2
 S DA=$O(^AMHRCDST("B",AMHRDEL,0)) I DA S DIK="^AMHRCDST(" D ^DIK ;delete staging tool
 S DIK="^AMHREC(",DA=AMHRDEL,X=2 D ^DIK K DA,DIK
 D EOJ
 D PCCCHECK
 D PCCLINK
 Q
 ;
DELETE2 ;
 S AMHVNM=$P(^DIC(AMHVFLE,0),U)
 S AMHVDG=^DIC(AMHVFLE,0,"GL"),AMHVIGR=AMHVDG_"""AD"",AMHRDEL,AMHVDFN)"
 S AMHVDFN="" F AMHVI=1:1 S AMHVDFN=$O(@AMHVIGR) Q:AMHVDFN=""  W:'$D(ZTQUEUED) "." S DIK=AMHVDG,DA=AMHVDFN D ^DIK
 Q
 ;
EOJ ; EOJ CLEANUP
 K AMHVDFN,AMHVDG,AMHRDEL,AMHVFLE,AMHVI,AMHVIGR,AMHVL,AMHVNM
 K %,X
 K D,D0,DA,DIC,DICR,DIE,DIG,DIH,DIU,DIV,DIW,DQ,DR,DIK
 Q
PCCCHECK ;check to see if link to pcc active, set AMHLPCC IF SO
 K AMHLPCC
 S (AMHLPCC,AMHLPCCT)=$P(^AMHSITE(DUZ(2),0),U,12) I AMHLPCC S AMHLPCC=AMHLPCC-1
 I AMHLPCC="" S AMHLPCC=0 Q
 Q:'AMHLPCC
 I $D(^AUTTSITE(1,0)),$P(^(0),U,8)="Y",'$D(^APCCCTRL(DUZ(2),0))#2 S AMHLPCC=0 Q
 S AMHPKG=$O(^DIC(9.4,"C","AMH",""))
 I '$D(^APCCCTRL(DUZ(2),11,AMHPKG,0))#2 S AMHLPCC=0 Q
 I $D(^AUTTSITE(1,0)),$P(^(0),U,8)="Y",$D(^APCCCTRL(DUZ(2),0))#2,$D(^APCCCTRL(DUZ(2),11,AMHPKG,0))#2,$P(^(0),U,2) S AMHLPCC=AMHLPCC
 E  S AMHLPCC=0
 K AMHPKG
 Q
 Q:'AMHLPCC  ;quit if no pcc link
 I $G(AMHVDLT)="",AMHACTN=4 Q
 S AMHBL=1
 S APCDVDLT=$G(AMHVDLT) I APCDVDLT="" Q
 D ^APCDVDLT K APCDVDLT,AMHBL
 Q
 ;
ERROR(AMHX) ;
 D MSG("-1"_$C(30)_AMHX)
 Q
 ;
MSG(AMHX) ;
 S AMHARRAY=AMHX
 Q
 ;
 ;
KILL ;
 K APCDALVR,AMHPARM,AMHERR,AMHVAL,AMHR,AMHACTN,AMHBL,AMHLPCC,AMHVDLT,AMHLPCCT,AMHVISIT
 Q