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

APCDDUPP.m

Go to the documentation of this file.
  1. APCDDUPP ; IHS/CMI/LAB - find and delete duplicate visits ;
  1. ;;2.0;IHS PCC SUITE;;MAY 14, 2009
  1. ;
  1. ;
  1. W !!,"This routine will find all visits that have duplicate primary providers"
  1. W !,"and delete one of the primary provider entries.",!!
  1. D EN^XBVK("APCD")
  1. ;
  1. GETDATES ;
  1. DATES ;
  1. S (APCDBD,APCDED,APCDSD)=""
  1. K DIR W ! S DIR(0)="DO^::EXP",DIR("A")="Enter Beginning Visit Date"
  1. D ^DIR Q:Y<1 S APCDBD=Y
  1. K DIR S DIR(0)="DO^::EXP",DIR("A")="Enter Ending Visit Date"
  1. D ^DIR Q:Y<1 S APCDED=Y
  1. ;
  1. I APCDED<APCDBD D G DATES
  1. . W !!,$C(7),"Sorry, Ending Visit Date MUST not be earlier than Beginning Visit Date."
  1. S APCDSD=$$FMADD^XLFDT(APCDBD,-1)_".9999"
  1. ;
  1. S DIR(0)="Y",DIR("A")="Do you want to continue",DIR("B")="N" KILL DA D ^DIR KILL DIR
  1. I 'Y D EOJ Q
  1. ;
  1. PROCESS ;
  1. S APCDCNT=0
  1. F S APCDSD=$O(^AUPNVSIT("B",APCDSD)) Q:APCDSD=""!($P(APCDSD,".")>APCDED) D
  1. .;W "+"
  1. .S APCDV=0 F S APCDV=$O(^AUPNVSIT("B",APCDSD,APCDV)) Q:APCDV'=+APCDV D CHECK
  1. .Q
  1. W !!,"A total of ",APCDCNT," duplicate primary providers were deleted."
  1. D EOJ
  1. Q
  1. ;
  1. EOJ ;
  1. D EN^XBVK("APCD")
  1. D ^XBFMK
  1. D KILL^AUPNPAT
  1. K AUPNVSIT
  1. Q
  1. CHECK ;
  1. Q:$P(^AUPNVSIT(APCDV,0),U,11) ;deleted visit, do not check
  1. Q:'$P(^AUPNVSIT(APCDV,0),U,9) ;no dependent entries so don't bother
  1. ;loop through V PROVIDER and check for duplicate primary providers
  1. K APCDPRV ;array of primary providers
  1. S APCDP=0 F S APCDP=$O(^AUPNVPRV("AD",APCDV,APCDP)) Q:APCDP'=+APCDP D
  1. .Q:'$D(^AUPNVPRV(APCDP,0)) ;bad xref
  1. .Q:$P(^AUPNVPRV(APCDP,0),U,4)'="P" ;not primary so don't bother
  1. .S X=$P(^AUPNVPRV(APCDP,0),U) ;provider pointer
  1. .I $D(APCDPRV(X)) D DELETE Q ;already have this one so delete it
  1. .S APCDPRV(X)=""
  1. .Q
  1. Q
  1. DELETE ;
  1. W !,"Deleting provider ",$P(^VA(200,X,0),U)," from visit: "
  1. W !?10,"Patient: ",$$VAL^XBDIQ1(9000010,APCDV,.05)," visit date: ",$$VAL^XBDIQ1(9000010,APCDV,.01)
  1. S APCDCNT=APCDCNT+1
  1. S DA=APCDP,DIK="^AUPNVPRV(" D ^DIK D ^XBFMK
  1. S AUPNVSIT=APCDV D MOD^AUPNVSIT K AUPNVSIT
  1. Q