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

AGEDPRVP.m

Go to the documentation of this file.
AGEDPRVP ;IHS/ASDS/TPF - EDIT POLICY HOLDER FIELDS ;    
 ;;7.1;PATIENT REGISTRATION;**1,2,3,8**;AUG 25, 2005
 ;ALL CALLS TO THIS ROUTINE WILL BE FOR EDITING POLICY HOLDER FIELDS
 ;
 Q
 ;SOURCE = CALLED WHEN ADDING OR EDITING?
ADDMEMB(ID0,POLHPTR,AGINSPTR,SOURCE,POLMEMBS) ;EP - ADD POLICY MEMBER
 N NMEMPTR
 K DIC,DIE,DR,DIR,DA,DO,DD,DINUM
 S DIC="^DPT("
 S DIC(0)="QEAM"
 S DIC("A")="Select Member to Add..: "
 S TEMPDFN=DFN
 D ^DIC
 S DFN=TEMPDFN
 Q:Y<0
 S NMEMPTR=+Y
 K DIC,DIE,DR,DIR,DA
 ;I $D(^AUPN3PPH("C",NMEMPTR,POLHPTR)) W !,"ALREADY A MEMBER!" H 3 Q
 I $D(^AUPNPRVT("C",POLHPTR,NMEMPTR)) W !,"ALREADY A MEMBER!" H 3 Q  ;IHS/SD/TPF 6/5/2006 IM20982
 ;IF PATIENT DOES NOT HAVE AN ENTRY IN THE INSURER FILE CREATE ONE
 I '$D(^AUPNPRVT(NMEMPTR)) D  Q:+Y<0
 .K DIC,DA,DD,DO,DIR,DIE,DIR,X,DINUM
 .S DIC="^AUPNPRVT("
 .S DIC(0)="L"
 .S (X,DINUM)=NMEMPTR
 .S TEMPDFN=DFN
 .D FILE^DICN
 .S DFN=TEMPDFN
 .K DA,DIC,DIR,DD,DO,DIE,DIR,X,DINUM
 ;
 K DA,DIC,DIR,DD,DO,DIE,DIR,X,DINUM
 I '$D(^AUPNPRVT(NMEMPTR,11,0)) S DIC("P")=$P(^DD(9000006,1101,0),U,2)
 S DIC(0)="L"
 S DA(1)=NMEMPTR
 S X=AGINSPTR
 S DIC="^AUPNPRVT("_DA(1)_",11,"
 D FILE^DICN
 I +Y<0 D CLEANUP Q
 S NPVTENT=+Y
 K DA,DIC,DIR,DD,DO,DIE,DIR,X,DINUM,Y
 I SOURCE="A" D ADDOPT^AGEDPRVI(NMEMPTR,NPVTENT,POLHPTR,.POLMEMBS) Q
 D PHEDALL(NMEMPTR,NPVTENT,POLHPTR)
 Q
 ;CALLED WHEN ADDING PRVT INSURANCE FROM SUMMARY PAGE
PHEDALL(NMEMPTR,NPVTENT,POLHPTR,SAME,TYPE) ;EP - EDIT THE INDIVIDUAL FIELDS TO COMPLETE ADDING MEMBER
 D EDITREL^AGEDPRVI(NMEMPTR,NPVTENT,SAME)
 D EDITNAME^AGEDPRVI(NMEMPTR,NPVTENT,POLHPTR,"S")
 D EDITNAME^AGEDPRVI(NMEMPTR,NPVTENT,POLHPTR,"E")
 D EDITADDR(POLHPTR)
 D EDITCITY(POLHPTR)
 D EDITSTAT(POLHPTR)
 D EDITZIP(POLHPTR)
 D EDITPHON(POLHPTR)
 D EDITPOLN(POLHPTR)
 D EFFDT(POLHPTR)
 D EDITBDT^AGEDPRVI(NMEMPTR,NPVTENT,POLHPTR,"S")
 D EDITEXP(POLHPTR)
 D EDITEDT^AGEDPRVI(NMEMPTR,NPVTENT,POLHPTR,"S")
 D EDITGEN(POLHPTR)
 D EDITDOB(POLHPTR)
 D EDITEMPL(POLHPTR)
 D EDITEMP(POLHPTR)
 D EDITGRP(POLHPTR)
 D EDITCOV(POLHPTR)
 D EDITPCD^AGEDPRVI(NMEMPTR,NPVTENT)
 D EDITPCP^AGEDPRVI(NMEMPTR,NPVTENT)
 D EDITMNUM^AGEDPRVI(NMEMPTR,NPVTENT)
 D EDITCC^AGEDPRVI(NMEMPTR,NPVTENT)
 D EDITPH^AGEDPRVI(NMEMPTR,NPVTENT,POLHPTR)
 D UPDATE1^AGED(DUZ(2),NMEMPTR,7,NPVTENT)
 Q
ADDPOLH(NMEMPTR,NPVTENT,NEWPOLH,POLHPTR,REGISTER,SAME) ;EP - ADD NEW POLICY HOLDER TO POLICY HOLDER FILE
 K DIE,DIC,DO,DD,DR,DIR,DA,DINUM
 S X=NEWPOLH
 S DIC(0)=""
 ;S DR=".01"
 S DIC("DR")=""  ;AG*7.1*2 FOUND DURING ALPHA
 ;I REGISTER S DR=DR_";.02///"_NMEMPTR
 ;I REGISTER S DIC("DR")=DIC("DR")_".02///"_NMEMPTR  ;AG*7.1*2 FOUND DURING ALPHA
 ;S DIC("DR")=DIC("DR")_$S(DIC("DR")="":".03///",1:";.03///")_AGINSPTR  ;AG*7.1*2 FOUND DURING ALPHA
 I REGISTER S DIC("DR")=DIC("DR")_".02////"_NMEMPTR  ;AG*7.1*2 FOUND DURING ALPHA
 S DIC("DR")=DIC("DR")_$S(DIC("DR")="":".03////",1:";.03////")_AGINSPTR  ;AG*7.1*3 IM23952
 S DIC="^AUPN3PPH("
 D FILE^DICN
 Q:Y<0
 S POLHPTR=+Y
 D PHEDALL(NMEMPTR,NPVTENT,POLHPTR,SAME,"E")
 K DIE,DIC,DO,DD,DR,DIR,DA,DINUM
 Q
EDITEM1(PATPTR,POLHPTR) ;EP - EDIT ITEM 1 ON PAGE 1. ALLOWS EDIT OF
 ;NAME,STREET,CITY,STATE,ZIP AND PHONE
 S NONREG=0,EXIT=0
 D POLHCHK(PATPTR,.POLHPTR,.EXIT) I $G(EXIT)&('NONREG) K EXIT Q
 W !
 S DIE="^AUPN3PPH("
 S DA=POLHPTR
 S DR=".01Name as Stated on Policy..: "
 S DR=DR_";.09;.11;.12;.13;.14"
 D ^DIE
 Q
POLHCHK(PATPTR,POLHPTR,EXIT) ;EP - CHECK THE POLICY HOLDER LINKAGE
 Q:$G(POLHPTR)=""
 N TARGET,PTR
 I $$ISREG(POLHPTR,.PTR) D  Q:$G(NEWLINK)!(NONREG)!(EXIT)
 .W !!?5,"The Policy Holder is presently linked to "
 .W $P($G(^DPT(PTR,0)),U),$S($D(^AUPNPAT(PTR,41,DUZ(2),0)):" ["_$P($G(^AUPNPAT(PTR,41,DUZ(2),0)),U,2)_"]",1:"")
 .W !?5,"in your Patient Registration data base."
 .K DIR
 .W !
 .S DIR("A")="Want to REMOVE the linkage with this Registered Patient (Y/N)"
 .S DIR(0)="Y",DIR("B")="N"
 .D ^DIR
 .K DIR
 .I $D(DTOUT)!(Y=U)!(Y=0) S EXIT=1 Q
 .I Y=1 D  D CONT1 Q
 ..S NEWLINK=1
 ..S DIE="^AUPN3PPH("
 ..S DA=POLHPTR
 ..S DR=".02///@;.08///@;.19///@"
 ..D ^DIE
 ;
 W !!,"Presently the POLICY HOLDER is NOT known as a REGISTERED PATIENT."
CONT1 ;EP - CONT ON
 W !
 K DIR
 S DIR(0)="Y",DIR("B")="Y"
 S DIR("A")="Want to SCAN to see if the Policy Holder is Registered"
 D ^DIR
 K DIR
 Q:$D(DTOUT)!(Y=U)
 I Y=0 S NONREG=1 Q
CONT2 ;
 K DIC,DIE,DIR,DR,DA
 S DIC(0)="QZEAM",DIC="^AUPNPAT("
 S TEMPDFN=$G(DFN)
 D ^DIC
 S DFN=TEMPDFN
 K DIC,DIE,DIR,DR,DA
 I +Y<0 Q
 S TARGET=+Y
 W !
 K DIC,DIE,DIR,DR,DA
 S DIR(0)="Y",DIR("B")="Y"
 S DIR("A")="Is "_Y(0,0)_" the Policy Holder (Y/N)"
 D ^DIR
 K DIC,DIE,DIR,DR,DA
 Q:$D(DTOUT)!(Y=U)
 I Y=0 K TARGET G CONT2
 K DIC,DIE,DIR,DR,DA
 S DIE="^AUPN3PPH("
 S DA=POLHPTR
 S DR=".02////"_TARGET
 D ^DIE
 K DIC,DIE,DIR,DR,DA
 Q
NAME(POLHPTR) ;EP - EDIT
 W !
 S DIE="^AUPN3PPH(",DA=POLHPTR
 S DR=".01Name as Stated on Policy..: "
 S DR=DR_";.09;.11;.12;.13;.14"
 D ^DIE
 Q
ISREG(POLHPTR,PTR) ;EP - IS THE POLICY HOLDER REGISTERED?
 Q:$G(POLHPTR)="" 0
 S PTR=$P($G(^AUPN3PPH(POLHPTR,0)),U,2) Q:'PTR 0
 Q $D(^DPT(PTR))
 ;
EDITPH(POLHPTR) ;EP - EDIT POLICY HOLDER NAME
 K DR,DIE,DIC,DA,DIR
 W !
 S DIE="^AUPN3PPH("
 S DA=POLHPTR
 S DR=".01Name as Stated on Policy..: "
 D ^DIE
 K DR,DIE,DIC,DA,DIR
 Q
EDITGEN(POLHPTR,CALLER) ;EP - EDIT POLICY HOLDER GENDER
 K DR,DIE,DIC,DA,DIR
 I $G(CALLER)="SCREEN" W !!
 S DIE="^AUPN3PPH("
 S DA=POLHPTR
 S DR=.08
 D ^DIE
 K DR,DIE,DIC,DA,DIR
 Q
EDITPOLN(POLHPTR) ;EP - EDIT POLICY NUMBER
 K DR,DIE,DIC,DA,DIR
 S DR=".04R~[2] Policy or SSN...: "
 S DIE("NO^")=""
 S DIE="^AUPN3PPH("
 S DA=POLHPTR
 D ^DIE
 K DR,DIE,DIC,DA,DIR
 Q
EDITDOB(POLHPTR,CALLER) ;EP - EDIT DOB
 K DR,DIE,DIC,DA,DIR
 I $G(CALLER)="SCREEN" W !!
 S DIE="^AUPN3PPH("
 S DA=POLHPTR
 S DR=.19
 D ^DIE
 K DR,DIE,DIC,DA,DIR
 Q
EFFDT(POLHPTR) ;EP - EDIT EFFECTIVE DATE
EFFDT1 K DR,DIE,DIC,DA,DIR
 N AGOLDDT
 S AGOLDDT=$$GET1^DIQ(9000003.1,POLHPTR_",",.17,"")  ;AG*7.1*2 IM20317
 S DR=".17R~[3] Effective Date..: "
 S DIE("NO^")=""
 S DIE="^AUPN3PPH("
 S DA=POLHPTR
 D ^DIE
 ;AG*7.1*2 FOUND IN TESTING
 I $$GET1^DIQ(9000003.1,POLHPTR_",",.18,"I"),($$GET1^DIQ(9000003.1,POLHPTR_",",.17,"I")>$$GET1^DIQ(9000003.1,POLHPTR_",",.18,"I")) D  G EFFDT1
 .W !!,"EFFECTIVE DATE CANNOT BE GREATER THAN TERMINATION DATE!" H 3
 ;BEGIN IHS/SD/TPF 4/3/2006 AG*7.1*2 IM20317
 S AGNEWDT=$P($G(^AUPN3PPH(POLHPTR,0)),U,17)
 Q:AGOLDDT=AGNEWDT  ;QUIT IF NO CHANGE
 D UPDEFF(POLHPTR,AGNEWDT,AGOLDDT)  ;UPDATE POL H EFF DATE
 ;IHS/SD/TPF 4/3/2006 AG*7.1*2 IM20317
 K DR,DIE,DIC,DA,DIR
 ;AUTO UPDATE THE EFF DT IN PRVT ELIG
 ;ONLY IF THE POL H IS REGISTERED PATIENT
 ;I $G(POLMEMBS("SELF"))=AGPATDFN D  Q
 ;.S DA(1)=AGPATDFN
 ;.S DIE="^AUPNPRVT("_DA(1)_",11,"
 ;.S DA=$P(COMPIEN,",",3)
 ;.S DR=".06///^S X=$$GET1^DIQ(9000003.1,POLHPTR_"","",.17,""E"")"
 ;.D ^DIE
 ;.K DIC,DR,DIE,DA,DIR
 Q
UPDEFF(POLHPTR,AGNEWDT,AGOLDDT) ;EP - IHS/SD/TPF 4/3/2006 AG*7.1*2 IM20317
 N POLMEM,RECNO
 K DIE,DR,DIC,DIR,DA
 S POLMEM=""
 F  S POLMEM=$O(^AUPNPRVT("C",POLHPTR,POLMEM)) Q:'POLMEM  D
 .S RECNO=""
 .S RECNO=$O(^AUPNPRVT("C",POLHPTR,POLMEM,RECNO)) Q:'RECNO  D
 .S DA(1)=POLMEM
 .S DA=RECNO
 .I ($G(POLMEMBS("SELF"))'=POLMEM) Q  ;DON'T UPDATE IF THEY HAVE SOMETHING ENTERED.
 .S DR=".06///^S X=AGNEWDT"
 .S DIE="^AUPNPRVT("_DA(1)_",11,"
 .D ^DIE
 K DIE,DR,DIC,DIR,DA
 ;IHS/SD/TPF 4/3/2006 AG*7.1*2 IM20317
 Q
EDITEXP(POLHPTR) ;EP - EDIT EXPIRATION DATE
 K DIC,DA,DIE,DIR,DR
 N AGOLDDT
 S AGOLDDT=$$GET1^DIQ(9000003.1,POLHPTR_",",.18,"")  ;AG*7.1*2 IM20317
 S DR=".18[4] Expiration Date: "
 S DIE="^AUPN3PPH("
 S DA=POLHPTR
 D ^DIE
 ;BEGIN IHS/SD/TPF 4/3/2006 AG*7.1*2 IM20317
 S AGNEWDT=$P($G(^AUPN3PPH(POLHPTR,0)),U,18)
 Q:AGOLDDT=AGNEWDT  ;QUIT IF NO CHANGE
 D UPDTERM(POLHPTR,AGNEWDT,AGOLDDT)  ;UPDATE ALL MEMBERS EXP DATE
 ;IHS/SD/TPF 4/3/2006 AG*7.1*2 IM20317
 K DR,DIE,DIC,DA,DIR
 Q
UPDTERM(POLHPTR,AGNEWDT,AGOLDDT) ;EP - IHS/SD/TPF 4/3/2006 AG*7.1*2 IM20317
 N POLMEM,RECNO
 K DIE,DR,DIC,DIR,DA
 S POLMEM=""
 F  S POLMEM=$O(^AUPNPRVT("C",POLHPTR,POLMEM)) Q:'POLMEM  D
 .S RECNO=""
 .S RECNO=$O(^AUPNPRVT("C",POLHPTR,POLMEM,RECNO)) Q:'RECNO  D
 .S DA(1)=POLMEM
 .S DA=RECNO
 .I $$GET1^DIQ(9000006.11,RECNO_","_POLMEM_",",.07)'="",($G(POLMEMBS("SELF"))'=POLMEM) Q  ;DON'T UPDATE IF THEY HAVE SOMETHING ENTERED.
 .I AGOLDDT'="",(AGNEWDT="") S DR=".07///@"
 .E  S DR=".07///^S X=AGNEWDT"
 .S DIE="^AUPNPRVT("_DA(1)_",11,"
 .D ^DIE
 K DIE,DR,DIC,DIR,DA
 ;IHS/SD/TPF 4/3/2006 AG*7.1*2 IM20317
 Q
EDITEMPL(POLHPTR,TYPE,DATA,CALLER) ;EP - EDIT EMPLOYMENT STATUS
 K DIE,DIC,DR,DA,DIR
 I $G(CALLER)="SCREEN" W !!
 I $G(TYPE)="S" S DR=".15///"_$G(DATA)
 E  S DR=.15
 S DIE="^AUPN3PPH("
 S DA=POLHPTR
 D ^DIE
 K DIE,DIC,DR,DA,DIR
 Q
EDITEMP(POLHPTR,CALLER) ;EP - EDIT EMPLOYER
 K DIE,DIC,DR,DA,DIR
 I $G(CALLER)="SCREEN" W !!
 S DIE="^AUPN3PPH("
 S DR=".16"
 S DA=POLHPTR
 D ^DIE
 S EMPLPTR=$P($G(^AUPN3PPH(POLHPTR,0)),U,16)
 I EMPLPTR="" D EDITEMPL(POLHPTR,"S",9) Q
 K DIE,DIC,DR,DA,DIR
 S DIE="^AUTNEMPL("
 S DA=EMPLPTR
 W !!,"<---------EDIT EMPLOYER DEMOGRAPHICS--------->"
 S DR=".02;.03:;.04"
 S DR=DR_";.05;.06"
 D ^DIE
 K DIE,DIC,DR,DA,DIR
 Q
EDITGRP(POLHPTR,CALLER) ;EP - EDIT GROUP NAME
 ;CHECKS TO SEE IF THEY ADDED A GROUP
 N NMOFGRPS,NEWNMGRP,NEWGRP
 S NMOFGRPS=$P($G(^AUTNEGRP(0)),U,4)  ;NUMBER OF GROUPS IN FILE
 K DIE,DIC,DR,DA,DIR
 I $G(CALLER)="SCREEN" W !!
 S DIE="^AUPN3PPH("
 S DR=".06[11] Select GROUP NAME: "
 S DA=POLHPTR
 D ^DIE
 K DIE,DIC,DR,DA,DIR
 ;
 S NEWNMGRP=$P($G(^AUTNEGRP(0)),U,4)  ;NOW HOW MANY GROUPS WERE ANY ADDED?
 Q:NMOFGRPS=NEWNMGRP
 Q:'$G(X)  ;NOTHING ENTERED
 I $D(Y) Q  ;USER EXITED THE ROUTINE NO NEW GROUP WAS ADDED OR EDITED?
 S NEWGRP=X
 W !
 W !!?5 W "NOTE: Some Insurers assign different Group Numbers based upon the"
 W !?11,"particular type of visit (dental, outpatient, etc.) that"
 W !?11,"occurred."
 W !
 K DIR
 S DIR("B")="N"
 S DIR(0)="Y"
 S DIR("A")="Do the Group Numbers vary depending on Visit Type (Y/N)"
 S DIR("B")=$S($O(^AUTNEGRP(NEWGRP,11,0)):"Y",1:"N")
 D ^DIR
 Q:$D(DTOUT)!(Y[U)!($D(DUOUT))
 W !
 I Y=0 D  Q
 .;EDIT GROUP #
 .K DIE,DIC,DR,DA,DIR
 .S DIE="^AUTNEGRP("
 .S DA=NEWGRP
 .S DR=".02R"
 .D ^DIE
 .K DIE,DIC,DR,DA,DIR
 ;EDIT VISIT TYPE
 K DIE,DIC,DR,DA,DIR
 S DA=NEWGRP
 S DIE="^AUTNEGRP("
 S DR="11"
 D ^DIE
 K DIE,DIC,DR,DA,DIR
 Q
EDITADDR(POLHPTR) ;EP - EDIT PH ADDRESS
 K DIE,DIC,DR,DA,DIR
 S DIE="^AUPN3PPH("
 S DR=".09"
 S DA=POLHPTR
 D ^DIE
 K DIE,DIC,DR,DA,DIR
 Q
EDITCITY(POLHPTR) ;EP - EDIT PH CITY
 K DIE,DIC,DR,DA,DIR
 S DIE="^AUPN3PPH("
 S DR=".11"
 S DA=POLHPTR
 D ^DIE
 K DIE,DIC,DR,DA,DIR
 Q
EDITSTAT(POLHPTR) ;EP - EDIT PH STATE
 K DIE,DIC,DR,DA,DIR
 S DIE="^AUPN3PPH("
 S DR=".12"
 S DA=POLHPTR
 D ^DIE
 K DIE,DIC,DR,DA,DIR
 Q
EDITZIP(POLHPTR) ;EP - EDIT PH ZIP
 K DIE,DIC,DR,DA,DIR
 S DIE="^AUPN3PPH("
 S DR=".13"
 S DA=POLHPTR
 D ^DIE
 K DIE,DIC,DR,DA,DIR
 Q
EDITPHON(POLHPTR) ;EP - EDIT PH PHONE
 K DIE,DIC,DR,DA,DIR
 S DIE="^AUPN3PPH("
 S DR=".14"
 S DA=POLHPTR
 D ^DIE
 K DIE,DIC,DR,DA,DIR
 Q
EDCARDNM(POLHPTR) ;EP - EDIT CARD NAME
 K DIE,DIC,DR,DA,DIR
 S DIE="^AUPN3PPH("
 S DR="2[8] CD Name: "                                                                ;AG*7.1*8
 S DA=POLHPTR
 D ^DIE
 K DIE,DIC,DR,DA,DIR
 Q
EDITCOV(POLHPTR,CALLER) ;EP - EDIT COVERAGE TYPE
 K DIE,DIC,DR,DA,DIR
 I $G(CALLER)="SCREEN" W !!
 S DIE="^AUPN3PPH("
 S DR=".05[12] Select COVERAGE TYPE: "
 S DA=POLHPTR
 D ^DIE
 S COVPTR=$P($G(^AUPN3PPH(POLHPTR,0)),U,5)
 S:$G(AGINSREC)'="" $P(AGINSREC,U,3)=$P($G(^AUPN3PPH(POLHPTR,0)),U,5)
 K DIE,DIC,DR,DA,DIR
 Q
CLEANUP(NMEMPTR) ;EP - CLEAN UP ENTRY IF NOT NEEDED
 ;IF ADDING AN INSURER FAILED THEN SEE IF THERE ANY
 ;INSURERS FOR THIS 11 NODE AT ALL. IF NOT DELETE THE TOP NODE
 ;THERE IS A CALL IN THE OLD CODE??
 Q:$O(^AUPNPRVT(NMEMPTR,11,0))  ;IF ENTRIES LEAVE ALONE
 S DA=NMEMPTR
 S DIK="^AUPNPRVT("
 D ^DIK
 Q
DELMEM(POLHPTR,POLMCNT,POLMEMBS,LASTDEL,DELALL,CANCELED) ;EP - DELETE A POLICY MEMBER
 N CNT,POLMEM,CHOICE,ITEM
 W !!?5,"------------POLICY MEMBERS------------"
 I '$D(POLMEMBS) W !!,"NO MEMBERS FOUND IN MEMBER LIST!" H 3 Q
 S CNT=""
 F ITEM=1:1 S CNT=$O(POLMEMBS(CNT)) Q:'CNT  D
 .W !?10,ITEM,")"
 .S POLMEM=""
 .F  S POLMEM=$O(POLMEMBS(CNT,POLMEM)) Q:'POLMEM  D
 ..W $P($G(^DPT(POLMEM,0)),U)
 K DIR
 S DIR(0)="NO^1:"_POLMCNT,DIR("A")="  DELETE which Member" D ^DIR K DIR
 Q:+Y<1
 S CHOICE=$O(POLMEMBS(Y+13,""))
 S RECORD=$O(POLMEMBS(Y+13,CHOICE,""))
 I $G(POLMEMBS("SELF"))=CHOICE D  Q:'Y
 .W !,"THIS IS THE POLICY HOLDER. IF YOU DELETE THE POLICY HOLDER"
 .W !,"THE PRIVATE INSURANCE ELIGIBILITIES OF ALL MEMBERS OF THIS"
 .W !,"POLICY WILL BE DELETED INCLUDING THE POLICY HOLDER"
 .W !,"DO YOU REALLY WANT TO DO THIS?"
 .K DIR
 .S DIR("B")="N"
 .S DIR(0)="Y"
 .D ^DIR
 .S DELALL=Y=1
 ;DELETE ALL MEMBERS INCLUDING POLICY HOLDER
 I $G(DELALL) D DELALL(.POLMEMBS,POLHPTR,.CANCELED) Q
 ;DELETE ONE MEMBER
 ;
 D DELETE(CHOICE,RECORD,.CANCELED)
 Q
DELALL(POLMEMBS,POLHPTR,CANCELED) ;EP - DELETE ALL POLICY MEMBERS INCLUDING POLICY HOLDER
 Q:'$D(POLMEMBS)
 N ITEM
 S ITEM=""
 F  S ITEM=$O(POLMEMBS(ITEM)) Q:'ITEM  D  Q:$G(CANCELED)
 .S CHOICE=$O(POLMEMBS(ITEM,""))
 .S RECORD=$O(POLMEMBS(ITEM,CHOICE,""))
 .D DELETE(CHOICE,RECORD,.CANCELED)
 Q:$G(CANCELED)
 ;
 ;SINCE WE ARE DELETING ALL MEMBERS INCLUDING THE HOLDER,
 ;DELETE THE POLICY HOLDER ENTRY AS WELL
 K DIE,DIC,DIK,DA,DIR
 S DA=$G(POLHPTR)
 S DIK="^AUPN3PPH("
 D ^DIK
 K POLMEMBS
 Q
DELETE(CHOICE,RECORD,CANCELED) ;EP - DELETE MEMBER
 Q:'$G(CHOICE)!('$G(RECORD))
 ;CHECK IF THERE ARE BILLS OR CLAIMS OUTSTANDING FOR THIS MEMBER
 S IN3PB=$$USED^AGUTILS(CHOICE,"",8,RECORD)
 I $L(IN3PB) D  Q:$G(CANCELED)
 .W !?15,"WARNING: This member has outstanding claims and/or bills!!!"
 .W !?24,"Deleting this member may cause data integrity problems"
 .W !?24,"in the Third Party Billing package!!"
 .K DIR,DIE,DA,DIC,DR
 .S DIR(0)="Y"
 .S DIR("B")="N"
 .S DIR("A")="Continue to delete?"
 .D ^DIR
 .S CANCELED=Y=0
 K DIE,DIC,DIK,DA,DIR
 S DA(1)=$G(CHOICE)
 S DIK="^AUPNPRVT("_DA(1)_",11,"
 S DA=$G(RECORD)
 D ^DIK
 K DIE,DIC,DIK,DA,DIR
 ;IF THIS IS THE LAST PRIVATE INSURER STORED FOR THIS PATIENT THEN
 ;CLEAN UP TOP RECORD
 I '$O(^AUPNPRVT(CHOICE,11,0)) D
 .K DIE,DIC,DIK,DA,DIR
 .S DA=$G(CHOICE)
 .S DIK="^AUPNPRVT("
 .D ^DIK
 .K DIE,DIC,DIK,DA,DIR
 Q