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

APCDFUNC.m

Go to the documentation of this file.
APCDFUNC ; IHS/CMI/LAB - FIX UNCODED DX ;
 ;;2.0;IHS PCC SUITE;**2,10,11**;MAY 14, 2009;Build 58
 ;
POV ;EP
 S APCDFILE=9000010.07,APCDTEMP="[APCD FUD POV]" D GETCODE,GETDATE G:$G(APCDQUIT) XIT G PROCESS
 ;
PROB ;EP
 ;
 S APCDFILE=9000011,APCDTEMP="[APCD FUD PROB]" D GETCODE,GETDATE G:$G(APCDQUIT) XIT G PROCESS
FAMILY ;EP
 S APCDFILE=9000014,APCDTEMP="[APCD FUD FAMHX]" D GETCODE,GETDATE G:$G(APCDQUIT) XIT G PROCESS
 ;
PERS ;EP
 S APCDFILE=9000013,APCDTEMP="[APCD FUD PER HX]" D GETCODE,GETDATE G:$G(APCDQUIT) XIT G PROCESS
 ;
PRO ;EP
 S APCDFILE=9000010.08,APCDTEMP="[APCD FUD PROC]"
 D GETDATE I $D(APCDQUIT) D XIT Q
 S APCD999=$P($$ICDOP^ICDEX(".9999",,2,"E"),U),APCD990=$P($$ICDOP^ICDEX("ZZZ999",,31,"E"),U) G PROCESS
 ;
 Q
GETDATE ;get beginning date ; -- add to code for a date range
 W !!,"The search for Uncoded "_$P(^DIC(APCDFILE,0),U),"'s can begin at any date",!,"that you specify.  To get all of the uncoded entries enter a really early "
 W !,"date like 01/01/1930.  If you want to only review data for visits ",!,"in the past week, enter T-7.",!
 S APCDFUDT=""
 S DIR(0)="D^::EP",DIR("A")="Enter the Beginning Date to Search for Uncoded "_$P(^DIC(APCDFILE,0),U)_"'s" KILL DA D ^DIR KILL DIR
 I $D(DIRUT) S APCDQUIT=1 Q
 S APCDFUDT=Y
LOC ;
 S APCDLOCT=""
 S DIR(0)="S^A:ALL Locations/Facilities;S:One SERVICE UNIT'S Locations/Facilities;O:ONE Location/Facility",DIR("A")="Include Visits to Which Location/Facilities",DIR("B")="A"
 S DIR("A")="Enter a code indicating what LOCATIONS/FACILITIES are of interest",DIR("B")="O" K DA D ^DIR K DIR,DA
 G:$D(DIRUT) GETDATE
 S APCDLOCT=Y
 I APCDLOCT="A" Q
 D @APCDLOCT
 G:$D(APCDQUIT) LOC
 Q
CHKDATE ;
 S APCDOK=0
 S APCDG=APCDVDG_"APCDDFN,0)" S Y=$P(@APCDG,U,2),APCDVSIT=$P(@APCDG,U,3) I Y=""!(APCDVSIT="") W !,"ERROR IN GLOBAL -- NOTIFY PROGRAMMER - PATIENT OR VISIT DFN MISSING" Q
 I $L(APCDFILE)>7 Q:'$D(^AUPNVSIT(APCDVSIT))  I $P($P(^AUPNVSIT(APCDVSIT,0),U),".")<APCDFUDT Q  ;before date wanted
 I $L(APCDFILE)=7,$P(@APCDG,U,3)<APCDFUDT Q  ;quit if problem modified before date
 S APCDOK=1
 Q
CHKLOC ;
 I APCDFILE=9000011 D  Q
 .S APCDOK=0
 .I $P(^AUPNPROB(APCDDFN,0),U,12)="D" Q  ;DELETED STATUS
 .Q:$P($G(^AUPNPROB(APCDDFN,800)),U,1)]""
 .I APCDLOCT="O",$P(^AUPNPROB(APCDDFN,0),U,6)'=APCDLOCT("ONE") Q
 .I APCDLOCT="S",$$VALI^XBDIQ1(9999999.06,$P(^AUPNPROB(APCDDFN,0),U,6),.05)'=APCDLOCT("SU") Q
 .S APCDOK=1
 I $L(APCDFILE)=7 S APCDOK=1 Q
 S APCDOK=0
 I APCDLOCT="O",$P(^AUPNVSIT(APCDVSIT,0),U,6)'=APCDLOCT("ONE") Q
 I APCDLOCT="S",$$VALI^XBDIQ1(9999999.06,$P(^AUPNVSIT(APCDVSIT,0),U,6),.05)'=APCDLOCT("SU") Q
 S APCDOK=1
 Q
GETCODE ;
 K APCDQUIT ;IHS/CMI/LAB
 D SETDEF Q
SETDEF ;SET DEFAULT OF .9999
 S APCD999=$P($$ICDDX^ICDEX(".9999",,1,"E"),U,1)
 S APCD990=$P($$ICDDX^ICDEX("ZZZ.999",,30,"E"),U,1)
 Q
O ;one community
 S DIC="^AUTTLOC(",DIC(0)="AEMQ",DIC("A")="Which LOCATION: " D ^DIC K DIC
 I Y=-1 S APCDQUIT="" Q
 S APCDLOCT("ONE")=+Y
 Q
S ;all communities within APCDSU su
 S DIC="^AUTTSU(",DIC("B")=$$VAL^XBDIQ1(9999999.06,DUZ(2),.05),DIC(0)="AEMQ",DIC("A")="Which SERVICE UNIT: " D ^DIC K DIC
 I Y=-1 S APCDQUIT="" Q
 S APCDLOCT("SU")=+Y
 Q
 ;
XIT ;
 K APCDFILE,APCDDFN,APCDVDG,APCDVIGR,APCDCONT,APCDTEMP,APCD999,APCD990,APCDG,APCDL,APCDHRN,APCDDOB,APCDVSIT,AUPNSEX,AUPNPAT,AUPNDOB,AUPNDAYS,APCDEIN,AUPNDOD,APCDCAT,APCDFUDT,APCDOK,APCDQUIT ;IHS/CMI/LAB - added APCDQUIT
 Q
PROCESS ;
 I APCD999="" W !!,"ERROR -- .9999 NOT IN ICD ",$S(APCDFILE=9000010.08:"PROCEDURE",1:"DIAGNOSIS")," FILE, NOTIFY YOUR SUPERVISOR" G XIT
 I APCD990="" W !!,"ERROR -- ",$S(APCFILE=9000010.08:"ZZZ999",1:"ZZZ.999")," NOT IN ICD ",$S(APCDFILE=9000010.08:"PROCEDURE",1:"DIAGNOSIS")," FILE, NOTIFY YOUR SUPERVISOR" G XIT
 S APCDEIN="",APCDDFN="",U="^"
 I '$D(^DIC(APCDFILE)) W !!,"FILE DOES NOT EXIST -- NOTIFY YOUR SUPERVISOR" G XIT
 S APCDVDG=$P(^DIC(APCDFILE,0),U) I APCDVDG="" W !,"ERROR IN ^DIC -- NOTIFY PROGRAMMER" G XIT
 S APCDVDG=^DIC(APCDFILE,0,"GL")
 S APCDG=APCDVDG_"""B"",APCD999)"
 S APCDG0=APCDVDG_"""B"",APCD990)"
 I '$D(@APCDG),'$D(APCDG0) W !!,"There are no Uncoded codes to change." Q
 S APCDVIGR=APCDVDG_"""B"",APCD999,APCDDFN)"
 W !!,"Searching the ",$P(^DIC(APCDFILE,0),U)," File",!
 S APCDDFN=0,APCDCONT=1 F APCDL=0:0 S APCDDFN=$O(@APCDVIGR) Q:APCDDFN'=+APCDDFN  D CHKDATE I APCDOK D CHKLOC I APCDOK D CONT Q:'APCDCONT  D APCDDIE
 S APCDVIGR=APCDVDG_"""B"",APCD990,APCDDFN)"
 S APCDDFN=0,APCDCONT=1 F APCDL=0:0 S APCDDFN=$O(@APCDVIGR) Q:APCDDFN'=+APCDDFN  D CHKDATE I APCDOK D CHKLOC I APCDOK D CONT Q:'APCDCONT  D APCDDIE
 W !!,"All done with the ",$P(^DIC(APCDFILE,0),U)," file",!
 D XIT
 Q
CONT ;
 W !!
 S DIR("A")="Continue",DIR("B")="Y",DIR(0)="Y" D ^DIR
 I $D(DIRUT) S X="N"
 S:"Nn"[X APCDCONT=""
 W !
 K DIR,DIRUT,DUOUT,DTOUT,DIROUT
 Q
APCDDIE ;
 S APCDG=APCDVDG_"APCDDFN,0)" S Y=$P(@APCDG,U,2),APCDVSIT=$P(@APCDG,U,3) I Y=""!(APCDVSIT="") W !,"ERROR IN GLOBAL -- NOTIFY PROGRAMMER - PATIENT OR VISIT DFN MISSING" Q
 D ^AUPNPAT
 I $L(APCDFILE)>7,AUPNDOB]"" S X2=AUPNDOB,X1=$P(^AUPNVSIT(APCDVSIT,0),U)\1 D ^%DTC S AUPNDAYS=X ; re-set days of age to visit date-dob
 S Y=AUPNDOB X ^DD("DD") S APCDDOB=Y
 S APCDHRN="" I $D(^AUPNPAT(AUPNPAT,41,DUZ(2),0)) S APCDHRN=$P(^AUPNPAT(AUPNPAT,41,DUZ(2),0),U,2)
 W !,"NAME: ",$P(^DPT(AUPNPAT,0),U),"  DOB: ",APCDDOB,"  SEX: ",AUPNSEX,"  HRN: ",$S(APCDHRN]"":APCDHRN,1:"NONE")
 I $L(APCDFILE)>7 S APCDCAT=$P(^AUPNVSIT(APCDVSIT,0),U,7) W !,"DATE OF VISIT: " S Y=$P(^AUPNVSIT(APCDVSIT,0),U) D DT^DIO2 S Y="" W "  LOC: ",$P(^DIC(4,$P(^AUPNVSIT(APCDVSIT,0),U,6),0),U)
 S DA=APCDDFN,DIC=APCDVDG D EN^DIQ
 I APCDFILE=9000010.07,$$VAL^XBDIQ1(APCDFILE,APCDDFN,1101)]"" NEW APCDLOOK S APCDLOOK=APCDDFN D EN^XBNEW("MAP^APCDFUNC","APCDLOOK")
 S DA=APCDDFN,DIE=APCDVDG,DR=APCDTEMP D ^DIE K DA,DIE,DR
 I $L(APCDFILE)>7 S AUPNVSIT=APCDVSIT D MOD^AUPNVSIT
 Q
DOC ;
 ; need to change to go thru PT node of ICD9 and 
 ; fix all files in the 9000001-9000099 range.
 ;
MAP ;EP - CALLED FROM XBDBQUE
 S D=$$VD^APCLV($P(^AUPNVPOV(APCDLOOK,0),U,3))
 S D=$$IMP^AUPNSICD(D)
 I D'=30 Q  ;ICD10 ONLY
 S C=$$VAL^XBDIQ1(9000010.07,APCDLOOK,1101)
 ;GET MAP ADVICE
 S D=$$I10ADV^BSTSAPI("APCDV",C)
 I 'D Q  ;NO MAP ADVICE
 ;ASK TO DISPLAY
 W !!,"This POV has been SNOMED coded and there is map advice available."
 K DIR
 S DIR(0)="Y",DIR("A")="Do you wish to see the Map Advice",DIR("B")="Y" KILL DA
 D ^DIR KILL DIR
 I $D(DIRUT) Q
 I 'Y Q
 ;ZW APCDV
 S X=0 F  S X=$O(APCDV(X)) Q:X'=+X  S APCDJ(X,0)=APCDV(X)
 K APCDV
 D ARRAY^XBLM("APCDJ(","Map Advice for SNOMED Concept ID: "_C)
 ;REDISPLAY POV
 S DA=APCDLOOK,DIC="^AUPNVPOV(" D EN^DIQ
 Q