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

AGED11A.m

Go to the documentation of this file.
AGED11A ; IHS/ASDS/EFG - EDIT DOCUMENT SUMMARY PAGE (PAGE 9) ; MAR 19, 2010
 ;;7.1;PATIENT REGISTRATION;**1,2,7,8**;AUG 25, 2005
 ;
 ;AG*7.1*7 - Modified code to allow the new page 10 to be called
 ;
VAR D DRAW
 Q:$D(AGSEENLY)
 K DIR
 S DIR("?")="Enter your choice now."
 S DIR("?",1)="You may enter the item number of the field you wish to edit,"
 S DIR("?",2)="OR you can enter 'P#' where P stands for 'page' and '#' stands for"
 S DIR("?",3)="the page you wish to jump to, OR enter '^' to go back one page"
 S DIR("?",4)="OR, enter '^^' to exit the edit screens, OR RETURN to go back to the main menu."
 S DIR("A")="CHANGE which item? (1-"_AG("N")_") NONE// "
 D READ^AGED1
 I $D(MYERRS("C","E")),(Y'?1N.N),(Y'=AGOPT("ESCAPE")) W !,"ERRORS ON THIS PAGE. PLEASE FIX BEFORE EXITING!!" H 3 G VAR
 Q:Y=AGOPT("ESCAPE")
 Q:$D(DTOUT)!$D(DFOUT)
 G ^AGED11:$D(DUOUT)&'$D(AGXTERN),VAR:$D(AG("ERR")),END:$D(DLOUT)!(Y["N") G:$D(AG("ED"))&'$D(AGXTERN) @("^AGED"_AG("ED"))
 I $D(DQOUT)!(+Y<1)!(+Y>AG("N")) W !!,"You must enter a number from 1 to ",AG("N") H 2 G VAR
 W !!
CC ;S AG("C")="EMOD,CHSTAT,PRIVA,LDOC,ADVDIRED,ROI,AOB,NPP,ACK,RHI"
 S AG("C")="EMOD,CHSTAT,LDOC,ADVDIRED,ROI,AOB,NPP,ACK,RHI"
C ;EP - Edit multiple fields on a Reg edit page.
 S AGY=Y F AGI=1:1 S AG("SEL")=+$P(AGY,",",AGI) Q:AG("SEL")<1!(AG("SEL")>AG("N"))  D @($P(AG("C"),",",AG("SEL")))
 D UPDATE1^AGED(DUZ(2),DFN,8,"") K AGI,AGY
 G VAR
END K AG,DFOUT,DQOUT,DTOUT,DA,DIC,DIE,DR,AGSCRN,Y,NUMCASES,CNT,MOD,MOVDT
 K ROUTID
 Q:$D(AGXTERN)
 Q:$D(DIROUT)
 Q:$D(AGSEENLY)
 G ^AGED10A
EMOD ;LOOKUP FOR ELIGIBILITY MODIFIER FIELD
 N DIC,DA,X,Y,DIR
 K DTOUT,DUOUT
 S DIR(0)="F"
 I $O(^AUPNPAT(DFN,34,0)) S DIR("A")="Do you wish to E(dit) or A(dd) an Eligibility Modifier ? "
 E  S DIR("A")="Do you wish to A(dd) an Eligibility Modifier ? "
 D ^DIR
 Q:$D(DTOUT)!(Y="^")
 I Y'="E"&(Y'="A") G EMOD
 I Y="A" D ADDMOD Q
 I Y="E",$O(^AUPNPAT(DFN,34,0)) D EDITMOD Q
 Q
ADDMOD ;ADD A NEW MODIFIER TO AUPNPAT FIELD 3401
 N DIR,X,Y
 N DIC,ELIG,X,Y
 S DIC="^AUPNELM("
 S DIC(0)="AEMQ"
 S DIC("A")="Select modifier : "
 S DIC("S")="I $P(^(0),U,2)=AGELSTS"  ;AGELSTS=CURRENT ELIG STATUS
 D ^DIC
 Q:$D(DTOUT)!($D(DUOUT))
 Q:+Y'>0
 S ELIG=Y
 N DA,DIC,DD,DLAYGO,DO,X,Y
 K DD,DO
 S X=$P(ELIG,U)
 S REC=X
 S DINUM=+ELIG
 S DA(1)=DFN
 S DIC="^AUPNPAT("_DA(1)_",34,"
 S DIC(0)="L"
 S DIC("P")=$P($G(^DD(9000001,3401,0)),U,2)
 S DLAYGO=9000001.03401
 D FILE^DICN
 K DINUM
 D CHKMOD
 Q
EDITMOD ;
 N DIE,DR,X,Y,DIR,REC
 S DIC(0)="AEMQZ"
 S DA(1)=DFN
 S DIC="^AUPNPAT("_DA(1)_",34,"
 D ^DIC S REC=+Y
 Q:$D(DTOUT)!($D(DUOUT))!(Y=-1)
 S DIE=DIC
 S DA=REC
 S DR=".01"
 D ^DIE
 Q:$D(Y)    ;USER ENTERED AN "^" NO CHANGE MADE
 S ELIG=$P($G(^AUPNELM(REC,0)),U)
 D CHKMOD
 Q
CHKMOD ;CHECK MOD FOR "MOVED OUT OF CHSDA" OR "DOUBTFUL CASES" TO
 ;ALLOW UPDATE OF SECONDARY FIELDS
 ;IF MODIFIER IS "MOVED FROM CHSDA", ENTER DATE FIELD
MD ;
 I REC=10&$D(^AUPNPAT(DFN,34,10,0)) D
 . S DIE="^AUPNPAT("
 . S DA=DFN
 . S DR=4901
 . D ^DIE
 . I $P($G(^AUPNPAT(DFN,49)),U)="" G MD
 ;IF MODIFIER "MOVED FROM CHSDA" WAS DELETED, DELETE DATE FIELD
 I '$D(^AUPNPAT(DFN,34,10,0))&($D(^AUPNPAT(DFN,49))) K ^AUPNPAT(DFN,49)
 ;IF MODIFIER IS "DOUBTFUL CASES", ENTER # OF VISITS ALLOWED
DC I REC=22&$D(^AUPNPAT(DFN,34,22,0)) D
 . S DIE="^AUPNPAT("
 . S DA=DFN
 . S DR=.26
 . D ^DIE
 . I $P($G(^AUPNPAT(DFN,0)),U,26)="" G DC
 ;IF MODIFIER "DOUBTFUL CASES WAS DELETED, DELETE # VISITS ALLOWED
 I '$D(^AUPNPAT(DFN,34,22,0))&($P($G(^AUPNPAT(DFN,0)),U,26)'="") S $P(^AUPNPAT(DFN,0),U,26)=""
 Q
CHSTAT ;STATUS OF MEDICAL RECORD
 N DIC,DIE,DR,DA
 S DA(1)=DFN
 S DA=DUZ(2)
 S DIE="^AUPNPAT("_DA(1)_",41,"
 S DR=".04"
 D ^DIE
 Q
PRIVA ;PRIVACY ACT
 N DIC,DIE,DR,DA
 S DIE="^AUPNPAT("
 S DR=.27
 S DA=DFN
 D ^DIE
 Q
LDOC ;ASK ADD OR EDIT LEGAL DOCS ENTRY
 D LDOC^AGLDOC
 Q
MCRMSG ;IMPORTANT MESSAGE FORM MEDICARE DATE
 I '$D(^AUPNMCR(DFN,0)) W !,"THIS PATIENT HAS NO MEDICARE COVERAGE" H 2
 Q:'$D(^AUPNMCR(DFN,0))
 N DIC,DIE,DA,DR,DA
 S DIE="^AUPNMCR("
 S DR="1201;"
 S DR(1,9000003)="1201;",DR(2,9000003.1201)=".01"
 S DA=DFN
 D ^DIE
 Q
ROI ;RELEASE OF INFORMATION
 N DIC,DIE,DR,DA
 S DIE="^AUPNPAT("
 S DR="3601;"
 S DR(1,9000001)="3601;",DR(2,9000001.03601)=".01"
 S DA=DFN
 D ^DIE
 ;
 ;Force entry if required
 I $G(Y)="",$O(^AUPNPAT(DFN,36,"B",""))="",$$RQROI^AGEDERR4(DUZ(2)) W "?? Required" G ROI
 Q
AOB ;ASSIGNMENT OF BENEFITS
 N DIE,DR,X,Y,DIR,REC,DEF
 S DIC(0)="AELMQZ"
 S DA(1)=DFN
 S DIC="^AUPNPAT("_DA(1)_",71,"
 S DEF=$O(^AUPNPAT(DFN,71,"B",""),-1) S:DEF]"" DIC("B")=$$FMTE^DILIBF(DEF,"5U")
 D ^DIC S REC=+Y
 Q:$D(DTOUT)!($D(DUOUT))
 ;
 ;Force entry if required
 I $O(^AUPNPAT(DFN,71,"B",""))="",$$RQAOB^AGEDERR4(DUZ(2)) W "??  Required" G AOB
 ;
 Q:Y=-1
 ;
 S DIE=DIC
 S DA=REC
 S DR=".01"
 D ^DIE
 Q:$D(Y)
 ;
 ;Force entry if last entry deleted during edit
 I $O(^AUPNPAT(DFN,71,"B",""))="",$$RQAOB^AGEDERR4(DUZ(2)) G AOB
 ;
 ;AG*7.1*8 - Plug AOB into ROI
 I AGOPT(25)="Y" D
 . N AOB,ROI,AGAOB,DA,ERROR,DIC,X,Y
 . ;
 . ;Pull ROI - quit if populated
 . S ROI=$O(^AUPNPAT(DFN,36,"B",""),-1) Q:ROI]""  ;Pull ROI
 . ;
 . ;Plug in AOB
 . S AOB=$O(^AUPNPAT(DFN,71,"B",""),-1) Q:AOB=""  ;Pull AOB
 . ;
 . S DA(1)=DFN
 . S DIC="^AUPNPAT("_DFN_",36,"
 . S DIC(0)="L"
 . S X=AOB
 . D ^DIC
 ;
 Q
NPP ;EP - WAS NPP RECEIVED
 N DIC,DIE,DR,DA,DLAYGO
 K AG("STAMP")
 S DIC="^AUPNNPP("
 S DIC(0)="L"
 S DLAYGO=9000038
 S X="`"_DFN
 D ^DIC
 Q:$D(DTOUT)!$D(DUOUT)!(Y=-1)
 S DIE=DIC
 K DIC,DA,DR,X
 S DA=+Y
 D NOW^%DTC S AG("STAMP")=%
 S DR=".02;.03;.06///^S X=AG(""STAMP"");.07////^S X=DUZ"
 D ^DIE
 I $P($G(^AUPNNPP(DA,0)),U,2)="" W !,"This is a mandatory HIPAA related field and must be answered." H 2 G NPP
 Q
ACK ;EP - ACKNOWLEDGEMENT AND REASON
 D NPPCHK
 I AG("NPPCHK")'=DFN&($D(AG("NPPADD"))) Q
 I AG("NPPCHK")'=DFN W !,"Please answer question # 8 first." H 3 G DRAW
 N DIC,DIE,DR,DA
 S DIE="^AUPNNPP("
 S DA=DFN
 S DR=.04
 D ^DIE
 I $P($G(^AUPNNPP(DA,0)),U,4)="" W !,"This is another mandatory HIPAA related field and must be answered." H 2 G ACK
 I $P($G(^AUPNNPP(DFN,0)),U,4)="N"  D
 . S DR=.05
 . D ^DIE
 I $P($G(^AUPNNPP(DFN,0)),U,4)="Y"  D
 . S DR=".05///@"
 . D ^DIE
 K AG("NPPCHK")
 Q
NPPCHK ;LOOK FOR EXISTANCE OF AUPNNPP RECORD
 K AG("NPPCHK")
 S AG("NPPCHK")=$O(^AUPNNPP("B",DFN,""))
 Q
RHI ;EP - RESTRICTED HEALTH INFORMATION
 D RHICHK^AGED11B
 I AG("RHICHK")>0 D EDITRHI^AGED11B Q
 I AG("RHICHK")<1 D ADDRHI^AGED11B Q
 Q
ADVDIR(DAX) ;DISP ADVANCE DIRECTIVE
 K AG("ADVDIR")  ;KILL DEFAULT VARIABLE
 S DAX=","_DAX_","
 D LIST^DIC(9000040.11,DAX,".02;.03;.04",,"*",,,,,,"ADVDIR","ADVDIRER")
 I $D(ADVDIRER) K ADVDIRER Q  ;CAN'T FIND ENTRY FOR DA PASSED
 I $P(ADVDIR("DILIST",0),U)=0 Q  ;DID NOT FIND ANY ENTRIES
 S ADVLAST=$P(ADVDIR("DILIST",0),U)
 W ADVDIR("DILIST","ID",ADVLAST,.02)
 W ?40,"DATE: ",ADVDIR("DILIST",1,ADVLAST)
 I ADVDIR("DILIST","ID",ADVLAST,.02)="NO" W !?3,"REASON: ",ADVDIR("DILIST","ID",ADVLAST,.04)
 E  I ADVDIR("DILIST","ID",ADVLAST,.03)'="" W !?3,"TYPE:",ADVDIR("DILIST","ID",ADVLAST,.03)
 S AG("ADVDIR")=ADVDIR("DILIST","ID",ADVLAST,.02)
 K ADVDIR
 Q
ADVDIRED ;ADD/EDIT AN ADVANCE DIRECTIVE
 I $D(AG("ADVDIR")) D EDADVDIR  ;EDIT EXISTING ENTRY
 E  D ADADVDIR   ;NO ENTRY YET ADD IT
 Q
ADADVDIR ;ADD ADVANCE DIRECTIVE
 N DIC,DIE,DR,DA
 S DIC="^AUPNADVD("
 S DIC(0)="L"
 S DLAYGO=9000040
 S X="`"_DFN
 D ^DIC
 Q:+Y<0
 D EDADVDIR
 Q
EDADVDIR ;EDIT EXISTING ADVANCE DIRECTIVE
 N DIC,DIE,DR,DA
 S DA=DFN
 S (DIE,DIC)="^AUPNADVD("
 S DR="1101"
 ;IF ADVANCE DIRECTIVE=NO ASK ONLY REASON
 ;IF ADVANCE DIRECTIVE=YES ASK ONLY TYPE
 S DR(2,9000040.11)=".01;.02;S:X=""N"" Y=""@1"" S:X=""Y"" Y=.03 S:X="""" Y=""@5"";.03;.04///@;S Y=0;@1;.04;.03///@;S Y=0;@5;.03///@;.04///@;.01///@"
 D ^DIE
 ;IF NO ADVANCE DIRECTIVE YES OR NO THEN THERE SHOULD NOT BE A
 ;REASON OR A TYPE OTHERWISE DELETE THE FIELD NOT NEEDED DEPENDING
 ;ON IF ITS YES OR NO
 ;
 Q
DRAW ;EP
 D CHKRHI^AG
 S AG("PG")=9
 S ROUTID=$P($T(+1)," ")  ;SET ROUTINE ID FOR PROGRAMMER VIEW
 D ^AGED
 K ^UTILITY("DIQ1",$J)
 F AG=1:1 D  Q:$G(AGSCRN)[("**END ITEMS**")
 . S AGSCRN=$P($T(@1+AG),";;",2,13)
 . Q:AGSCRN[("**END ITEMS**")
 . S AGNEWLN=$P(AGSCRN,U,5)
 . I AG'=1 D
 .. I AGNEWLN'="" W @AGNEWLN,AG,".",?$P(AGSCRN,U,2),$P(AGSCRN,U)," :  "
 .. E  W ?$P(AGSCRN,U,2),AG,".",$P(AGSCRN,U)," :  "
 . ;I AG'=1&(AG'=2) D
 . I AG'=1&(AG'=2)&(AG'=3) D  ;AG*7.1*1 IM18991
 .. S DA=DFN
 .. S DIC=$P(AGSCRN,U,3)
 .. S DR=$P(AGSCRN,U,4)
 .. Q:'DIC!('DR)  ;DISP ADDED TO CHECK FOR FILLER ITEMS IN TAG 1
 .. ;SHOW LAST AOB
 .. ;I AG=7 D
 .. I AG=6 D
 ... S AG("AOB")=$O(^AUPNPAT(DFN,71,"B",""),-1)
 ... I $G(AG("AOB"))'="" W $E(AG("AOB"),4,5)_"/"_$E(AG("AOB"),6,7)_"/"_($E(AG("AOB"),1,3)+1700)
 .. K AGRES
 .. S TEMPDIC=DIC
 .. S DIQ="AGRES",DIQ(0)="E" D EN^DIQ1
 .. S DIC=TEMPDIC
 .. W $G(AGRES(DIC,DA,DR,"E"))
 .. K AGRES,TEMPDIC,AGRES
 . I AG=1 D
 .. W !,AG,".",?2,"REASON FOR "_$S(AGELSTS="C":"CHS & DIRECT",AGELSTS="I":"INELIGIBLE",AGELSTS="D":"DIRECT ONLY",AGELSTS="P":"PENDING",1:"NONE")_" : "
 .. S (D1,CNT)=0,MOD="",MOVDT="",NUMCASES=""
 .. F  S D1=$O(^AUPNPAT(DFN,34,D1)) Q:'D1  D
 ... S MOD=$P($G(^AUPNELM(D1,0)),U)
 ... I MOD["MOVED OUT OF CHSDA"  D
 .... S MOVDT=$P($G(^AUPNPAT(DFN,49)),U)
 .... I MOVDT="" S Y=""
 .... E  S Y=$E(MOVDT,4,5)_"/"_$E(MOVDT,6,7)_"/"_($E(MOVDT,1,3)+1700)
 ... I MOD["DOUBTFUL CASES"  D
 .... S NUMCASES=$P($G(^AUPNPAT(DFN,0)),U,26)
 ... W ?29,$E(MOD,1,45)
 ... I MOD["MOVED OUT OF CHSDA" W ?51,"DATE MOVED : ",Y
 ... I MOD["DOUBTFUL CASES" W ?63,"# VISITS : ",NUMCASES
 ... S CNT=CNT+1
 ... I CNT<$P($G(^AUPNPAT(DFN,34,0)),U,4) W !
 . I AG=2  D
 .. S DA(1)=DFN
 .. S DA=DUZ(2)
 .. S DIC="^AUPNPAT("_DA(1)_",41,"
 .. I AG=2 S DR=".04"
 .. K AGRES
 .. S TEMPDIC=DIC
 .. S DIQ="AGRES",DIQ(0)="E" D EN^DIQ1
 .. S DIC=TEMPDIC
 .. W $G(AGRES(9000001.41,DA,DR,"E"))
 .. K AGRES,TEMPDIC,AGRES
 . ;I AG=4 D
 .  I AG=3 D
 .. S D1=0 K DOCSTR,DOCPTR,DOC
 .. F  S D1=$O(^AUPNPLDC("C",DFN,D1)) Q:'D1  D
 ... S DOCSTR=$G(^AUPNPLDC(D1,0))
 ... S DOCPTR=$P(DOCSTR,U,3)
 ... I DOCPTR'="",$D(^AUPNELM(DOCPTR,0)) S DOC=$P($G(^AUPNELM(DOCPTR,0)),U)
 .. I $D(DOC) W DOC
 . ;I AG=5 D ADVDIR(DFN)
 . I AG=4 D ADVDIR(DFN)
 . ;I AG=6 D
 .  I AG=5 D
 .. S AG("ROI")=$O(^AUPNPAT(DFN,36,"B",""),-1)
 .. I $G(AG("ROI"))'="" W $E(AG("ROI"),4,5)_"/"_$E(AG("ROI"),6,7)_"/"_($E(AG("ROI"),1,3)+1700)
 . ;I AG=1!(AG=4)!(AG=5)!(AG=7) W !,AGLINE("-")
 . I AG=1!(AG=4)!(AG=6) W !,AGLINE("-")
 . ;I AG=8&($D(^AUPNNPP(DFN,0))) D
 . I AG=7&($D(^AUPNNPP(DFN,0))) D
 .. S NPPDT=$P($G(^AUPNNPP(DFN,0)),U,3)
 .. Q:NPPDT=""
 .. S Y=$E(NPPDT,4,5)_"/"_$E(NPPDT,6,7)_"/"_($E(NPPDT,1,3)+1700)
 .. W ?63,"DATE:",Y
 . ;I AG=9&($P($G(^AUPNNPP(DFN,0)),U,5)'="")  D
 . I AG=8&($P($G(^AUPNNPP(DFN,0)),U,5)'="")  D
 .. W !,?5,"REASON: ",$P($G(^AUPNNPP(DFN,0)),U,5)
 . ;I AG=10 D FINDRHI^AGED11B
 . I AG=9 D FINDRHI^AGED11B
 S AG("N")=AG-1
 W !,AGLINE("EQ")
 K MYERRS,MYVARS
 D FETCHERR^AGEDERR(AG("PG"),.MYERRS)
 S MYVARS("DFN")=DFN,MYVARS("FINDCALL")="",MYVARS("SITE")=DUZ(2)
 D EDITCHEK^AGEDERR(.MYERRS,.MYVARS,1)
 W !,$G(AGLINE("-"))
 D VERIF^AGUTILS
 Q
 ;FORMAT OF LINES BELOW
 ;ITEM CAPTION^INDENT^FILE #/SUB FILE#^FIELD #^NEW LINE?
 ;DATE PRIVACY ACT OBTAINED^3^9000001^.27^!  ;AG*7.1* REMOVED PER Cancellation of IHS 819 & 820
1 ;
 ;;REASON FOR^1^9000001.34^.01^!
 ;;STATUS OF MEDICAL RECORD^3^9000001.41^.04^!
 ;;OTHER LEGAL DOCUMENTS^3^9000034^.03^!
 ;;ADVANCE DIRECTIVES^3^^^!
 ;;REL OF INFORMATION^3^9000001.03601^.01^
 ;;ASSIGNMENT OF BENEFITS^40^9000001^7101^^
 ;;NOTICE OF PRIVACY PRACTICES (NPP) REC'D BY PATIENT^1^9000038^.02^!
 ;;ACKNOWLEDGEMENT OF RECEIPT OF NPP SIGNED^1^9000038^.04^!
 ;;RESTRICTED HEALTH INFORMATION^1^9000039^.03^!
 ;;**END ITEMS**