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

AMHGVDEL.m

Go to the documentation of this file.
AMHGVDEL ; IHS/CMI/MAW - GUI V FILE VISIT CREATION ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**1**;JUN 18, 2010;Build 8
 ;;
TEST ;
 D EN(.RETVAL,24609)
 Q
EN(BPCARRAY,AMHR) ;EP CALL
 S BPCERR=""  ;,ZTQUEUED=""
 ;AMHR must be ien of MHSS RECORD that is to be deleted
 D
 .NEW AMHACTN
 .S AMHACTN=4
 .D CHECKREC Q:BPCERR'=""
 .D DELETE
 I BPCERR="" D MSG("1"),KILL Q
 I BPCERR'="" D ERROR(BPCERR)
 D KILL
 Q
 ;
CHECKREC ;
 I '$G(AMHR) S BPCERR="IEN MISSING" Q
 I '$D(^AMHREC(AMHR)) S BPCERR="INVALID RECORD IEN PASSED" Q
 Q
DELETE ;
 S AMHVDLT=$P(^AMHREC(AMHR,0),U,16)
 S AMHGRP=$P(^AMHREC(AMHR,0),U,34)
 S AMHPAT=$P(^AMHREC(AMHR,0),U,8)
 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,DI
 I $G(AMHGRP) D GRPDEL(AMHR,AMHPAT)
 D EOJ
 ;D PCCCHECK  cmi/maw 2/2/2011 not needed v4.0p1
 D PCCLINK
 Q
 ;
DELETE2 ;
 I AMHVFLE=9002011.13 D INTAKE Q
 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
 ;
GRPDEL(REC,PAT) ;-- delete the group record and patient entry from group
 N GDA
 S GDA=0 F  S GDA=$O(^AMHGROUP("AREC",REC,GDA)) Q:'GDA  D
 . S GIEN=0 F  S GIEN=$O(^AMHGROUP("AREC",REC,GDA,GIEN)) Q:'GIEN  D
 .. D GRECDIK(GDA,GIEN)
 .. D GPATDIK(PAT,GDA)
 Q
 ;
GRECDIK(D,I) ;-- delete the record from the group 6101 multiple
 S DA(1)=GDA
 S DA=I
 S DIK="^AMHGROUP("_DA(1)_",61,"
 D ^DIK
 Q
 ;
GPATDIK(PT,D) ;-- remove the patient from the group 5101 multiple
 K DA
 S DA=$O(^AMHGROUP(D,51,"B",PT,0))
 Q:'DA
 S DA(1)=D
 S DIK="^AMHGROUP("_DA(1)_",51,"
 D ^DIK
 Q
 ;
EOJ ; EOJ CLEANUP
 K AMHVDFN,AMHVDG,AMHRDEL,AMHVFLE,AMHVI,AMHVIGR,AMHVL,AMHVNM,AMHGRP,AMHPAT
 K %,X
 K D,D0,DA,DIC,DICR,DIE,DIG,DIH,DIU,DIV,DIW,DQ,DR,DIK,DITC
 Q
INTAKE ;
 Q  ;;
 S (C,AMHX)=0 F  S AMHX=$O(^AMHRINTK("AD",AMHRDEL,AMHX)) Q:AMHX'=+AMHX  D
 .I $P(^AMHRINTK(AMHX,0),U,3)=AMHRDEL D
 ..S DITC=1,DIE="^AMHRINTK(",DA=AMHX,DR=".03///@" D ^DIE K DIE,DA,DR,DITC
 ..S Z=$O(^AMHRINTK(AMHX,11,"B",AMHRDEL,0)) I 'Z Q
 ..S DIE="^AMHRINTK("_AMHX_",11,",DA(1)=AMHX,DA=Z,DR=".01///@" D ^DIE K DIE,DA,DR,DITC
 .S AMHY=0 F  S AMHY=$O(^AMHRINTK("AD",AMHRDEL,AMHX,AMHY)) Q:AMHY'=+AMHY  D
 ..I $P(^AMHRINTK(AMHX,11,AMHY,0),U)=AMHRDEL S DIE="^AMHRINTK("_AMHX_",11,",DA(1)=AMHX,DA=AMHY,DR=".01///@" D ^DIE K DIE,DA,DR
 .I $P(^AMHRINTK(AMHX,0),U,3)="",'$O(^AMHRINTK(AMHX,11,0)) S DIK="^AMHRINTK(",DA=AMHX D ^DIK Q
 .Q:$P(^AMHRINTK(AMHX,0),U,3)
 .S X=$O(^AMHRINTK(AMHX,11,0)),X=$P(^AMHRINTK(AMHX,11,X,0),U,1)
 .S DA=AMHX,DIE="^AMHRINTK(",DITC=1,DR=".03////"_X D ^DIE K DIE,DA,DR,DITC
 .Q
 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  v4.0p1 cmi/maw not needed 2/2/2011
 I $G(AMHVDLT)="",AMHACTN=4 Q
 S AMHBL=1
 S APCDVDLT=$G(AMHVDLT) I APCDVDLT="" Q
 D ^APCDVDLT K APCDVDLT,AMHBL
 Q
 ;
ERROR(BPCX) ;
 D MSG("-1"_$C(30)_BPCX)
 Q
 ;
MSG(BPCX) ;
 S BPCARRAY=BPCX
 Q
 ;
 ;
KILL ;
 K APCDALVR,BPCPARM,BPCERR,BPCVAL,AMHR,AMHACTN,AMHBL,AMHLPCC,AMHVDLT,AMHLPCCT,AMHVISIT
 Q