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

APCHS5.m

Go to the documentation of this file.
APCHS5 ; IHS/CMI/LAB - PART 5 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS PCC SUITE;**6,7,11**;MAY 14, 2009;Build 58
 ;
INS ; ******************* INSURANCE * 9000003, 9000004, 9000006 *********
 I $O(^AUPNMCD("B",APCHSPAT,0))="",'$D(^AUPNMCR(APCHSPAT)),'$D(^AUPNPRVT(APCHSPAT)),'$D(^AUPNRRE(APCHSPAT)) Q
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 W "INSURANCE",?32,"NUMBER",?44,"SUFF",?49,"COV",?54,"EL DATE",?63,"SIG DATE",?72,"END DATE",!
 D MAID^APCHS5A,MCARE^APCHS5A,THIRD^APCHS5A,RR^APCHS5A
INSX K APCHSPDN,APCHSINS,APCHSEDN,APCHSN,APCHSIDN,APCHSDTL,APCHSDTN,APCHSUFF,APCHSCOV,APCHSDTS,APCHSI,APCHSJ,APCHSITB
 Q
 ;
ELDER1 ;
 I '$D(^AUPNVELD("AA",APCHSPAT)) Q
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 W "ADL",!
 F APCHSY=.04,.05,.06,.07,.08,.09 Q:$D(APCHSQIT)  S APCHSP=+$P(APCHSY,".",2),APCHSN=$P(^DD(9000010.35,APCHSY,0),U) D VAL(APCHSPAT,APCHSY,APCHSP,1) D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W ?2,APCHSN,?28,$$D($P($G(APCHSX(1)),U)),?40,$P($G(APCHSX(1)),U,2),!
 .Q
 W !,"IADL",!
 F APCHSY=.11,.12,.13,.14,.15,.16 Q:$D(APCHSQIT)  S APCHSP=+$P(APCHSY,".",2),APCHSN=$P(^DD(9000010.35,APCHSY,0),U) D VAL(APCHSPAT,APCHSY,APCHSP,1) D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W ?2,APCHSN,?28,$$D($P($G(APCHSX(1)),U)),?40,$P($G(APCHSX(1)),U,2),!
 .Q
 S APCHSN="CHANGE IN FUNCTIONAL STATUS",APCHSP=17,APCHSY=.17 D VAL(APCHSPAT,APCHSY,APCHSP,1)
 X APCHSCKP Q:$D(APCHSQIT)
 W !,APCHSN,?28,$$D($P($G(APCHSX(1)),U)),?40,$P($G(APCHSX(1)),U,2),!
 ;X APCHSCKP Q:$D(APCHSQIT)
 ;S APCHSN="PATIENT A CAREGIVER?",APCHSP=18,APCHSY=.18 D VAL(APCHSPAT,APCHSY,APCHSP,1)
 ;W APCHSN,?28,$$D($P($G(APCHSX(1)),U)),?40,$P($G(APCHSX(1)),U,2),!
 Q
 ;
ELDER2 ;elder care last 2 of each
 I '$D(^AUPNVELD("AA",APCHSPAT)) Q
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 W "ADL",!
 F APCHSY=.04,.05,.06,.07,.08,.09 Q:$D(APCHSQIT)  S APCHSP=+$P(APCHSY,".",2),APCHSN=$P(^DD(9000010.35,APCHSY,0),U) D VAL(APCHSPAT,APCHSY,APCHSP,2) D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W ?2,APCHSN,?28,$$D($P($G(APCHSX(1)),U)),?40,$P($G(APCHSX(1)),U,2),!
 .X APCHSCKP Q:$D(APCHSQIT)
 .I $G(APCHSX(2))]"" W ?28,$$D($P($G(APCHSX(2)),U)),?40,$P($G(APCHSX(2)),U,2),!
 .Q
 W !,"IADL",!
 F APCHSY=.11,.12,.13,.14,.15,.16 Q:$D(APCHSQIT)  S APCHSP=+$P(APCHSY,".",2),APCHSN=$P(^DD(9000010.35,APCHSY,0),U) D VAL(APCHSPAT,APCHSY,APCHSP,2) D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W ?2,APCHSN,?28,$$D($P($G(APCHSX(1)),U)),?40,$P($G(APCHSX(1)),U,2),!
 .X APCHSCKP Q:$D(APCHSQIT)
 .I $G(APCHSX(2))]"" W ?28,$$D($P($G(APCHSX(2)),U)),?40,$P($G(APCHSX(2)),U,2),!
 .Q
 S APCHSN="CHANGE IN FUNCTIONAL STATUS",APCHSP=17,APCHSY=.17 D VAL(APCHSPAT,APCHSY,APCHSP,2)
 X APCHSCKP Q:$D(APCHSQIT)
 W !,APCHSN,?28,$$D($P($G(APCHSX(1)),U)),?40,$P($G(APCHSX(1)),U,2),!
 X APCHSCKP Q:$D(APCHSQIT)
 I $G(APCHSX(2))]"" W ?28,$$D($P($G(APCHSX(2)),U)),?40,$P($G(APCHSX(2)),U,2),!
 X APCHSCKP Q:$D(APCHSQIT)
 ;S APCHSN="PATIENT A CAREGIVER?",APCHSP=18,APCHSY=.18 D VAL(APCHSPAT,APCHSY,APCHSP,2)
 ;X APCHSCKP Q:$D(APCHSQIT)
 ;W APCHSN,?28,$$D($P($G(APCHSX(1)),U)),?40,$P($G(APCHSX(1)),U,2),!
 ;X APCHSCKP Q:$D(APCHSQIT)
 ;I $G(APCHSX(2))]"" W ?28,$$D($P($G(APCHSX(2)),U)),?40,$P($G(APCHSX(2)),U,2),!
 Q
 ;
D(X) ;
 I $G(X)="" Q ""
 Q $E(X,4,5)_"/"_$E(X,6,7)_"/"_(1700+$E(X,1,3))
VAL(P,F,V,I) ;
 K APCHSX
 NEW % F %=1:1:I S APCHSX(%)=""
 NEW C S C=0
 NEW X,Y
 S X=0 F  S X=$O(^AUPNVELD("AA",P,X)) Q:X=""!(C>I)  S Y=0 F  S Y=$O(^AUPNVELD("AA",P,X,Y)) Q:Y=""!(C>I)  I $P(^AUPNVELD(Y,0),U,V)]"" S C=C+1,APCHSX(C)=9999999-X_"^"_$$VAL^XBDIQ1(9000010.35,Y,F)
 Q
REFUSAL ;EP - refusal component
 ;Q:'$D(^AUPNPREF("AA",APCHSPAT))  ;no refusals on file
 ;gather any refusals from Immuniztion package
 K APCHSX
 S Y=0 F  S Y=$O(^BIPC("AC",APCHSPAT,Y)) Q:Y'=+Y  D
 .S X=0 F  S X=$O(^BIPC("AC",APCHSPAT,Y,X)) Q:X'=+X  D
 ..S R=$P(^BIPC(X,0),U,3)
 ..Q:R=""
 ..Q:'$D(^BICONT(R,0))
 ..Q:$P(^BICONT(R,0),U,1)'["Refusal"
 ..S D=$P(^BIPC(X,0),U,4)
 ..Q:D=""
 ..S D=9999999-D
 ..Q:D>APCHSDLM
 ..S APCHSX(D,"IMM",X)=""
 I '$D(^AUPNPREF("AA",APCHSPAT)),'$D(APCHSX) Q  ;no refusals
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 NEW X,F,I,D,E
 S F=0 F  S F=$O(^AUPNPREF("AA",APCHSPAT,F)) Q:F'=+F  D
 .S E=0 F  S E=$O(^AUPNPREF("AA",APCHSPAT,F,E)) Q:E'=+E  D
 ..S D=0 F  S D=$O(^AUPNPREF("AA",APCHSPAT,F,E,D)) Q:D'=+D!(D>APCHSDLM)  D
 ...S I=0 F  S I=$O(^AUPNPREF("AA",APCHSPAT,F,E,D,I)) Q:I'=+I  S APCHSX(D,"REF",I)=""
 NEW APCHSD,APCHSI S APCHSD=0 F  S APCHSD=$O(APCHSX(APCHSD)) Q:APCHSD'=+APCHSD!($D(APCHSQIT))  D
 .S APCHSI=0 F  S APCHSI=$O(APCHSX(APCHSD,"REF",APCHSI)) Q:APCHSI'=+APCHSI!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W ?3,$$FMTE^XLFDT(9999999-APCHSD),?17,$$VAL^XBDIQ1(9000022,APCHSI,.04),! ;"   (",$$VAL^XBDIQ1(9000022,APCHSI,.01),")",!
 ..W ?5,"Reason not Done:  ",$$REFR^AUPNVUTL(APCHSI),!
 ..I $P($G(^AUPNPREF(APCHSI,11)),U,1)]"",$P(^APCHSCTL(APCHSTYP,0),U,8) D
 ...;display comments using DIWP
 ...K ^UTILITY($J,"W")
 ...S X="Comments: "_$P(^AUPNPREF(APCHSI,11),U,1)
 ...S DIWL=0,DIWR=74
 ...D ^DIWP
 ...S APCHSZ=0 F  S APCHSZ=$O(^UTILITY($J,"W",DIWL,APCHSZ)) Q:APCHSZ'=+APCHSZ!($D(APCHSQIT))  D
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....W ?5,^UTILITY($J,"W",DIWL,APCHSZ,0),!
 ...K ^UTILITY($J,"W")
 .S APCHSI=0 F  S APCHSI=$O(APCHSX(APCHSD,"IMM",APCHSI)) Q:APCHSI'=+APCHSI!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W ?3,$$FMTE^XLFDT(9999999-APCHSD),?17,$$VAL^XBDIQ1(9002084.11,APCHSI,.02),!
 ..W ?5,"Reason not Done:  ",$$VAL^XBDIQ1(9002084.11,APCHSI,.03),!
 Q
LER ;refusal component
 ;Q:'$D(^AUPNPREF("AA",APCHSPAT))  ;no refusals on file
 ;gather any refusals from Immuniztion package
 K APCHSX
 S Y=0 F  S Y=$O(^BIPC("AC",APCHSPAT,Y)) Q:Y'=+Y  D
 .S X=0 F  S X=$O(^BIPC("AC",APCHSPAT,Y,X)) Q:X'=+X  D
 ..S R=$P(^BIPC(X,0),U,3)
 ..Q:R=""
 ..Q:'$D(^BICONT(R,0))
 ..Q:$P(^BICONT(R,0),U,1)'["Refusal"
 ..S D=$P(^BIPC(X,0),U,4)
 ..Q:D=""
 ..S D=9999999-D
 ..Q:D>APCHSDLM
 ..S APCHSX("REF","IMMUNIZATION",$$VAL^XBDIQ1(9002084.11,X,.02),D)=X_U_$$VAL^XBDIQ1(9002084.11,X,.03)
 I '$D(^AUPNPREF("AA",APCHSPAT)),'$D(APCHSX) Q  ;no refusals
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 NEW X,F,I,D,E
 S F=0 F  S F=$O(^AUPNPREF("AA",APCHSPAT,F)) Q:F'=+F  D
 .S E=0 F  S E=$O(^AUPNPREF("AA",APCHSPAT,F,E)) Q:E'=+E  D
 ..S D=0 F  S D=$O(^AUPNPREF("AA",APCHSPAT,F,E,D)) Q:D'=+D!(D>APCHSDLM)  D
 ...S I=0 F  S I=$O(^AUPNPREF("AA",APCHSPAT,F,E,D,I)) Q:I'=+I  D
 ....S APCHSX("REF",$S($$VAL^XBDIQ1(9000022,I,.05)]"":$$VAL^XBDIQ1(9000022,I,.05),1:"NOT ENTERED"),$S($$VAL^XBDIQ1(9000022,I,.04)]"":$$VAL^XBDIQ1(9000022,I,.04),1:"NOT ENTERED"),D)=I_U_$$REFR^AUPNVUTL(I)
 NEW APCHSD,APCHSI S APCHSC="" F  S APCHSC=$O(APCHSX("REF",APCHSC)) Q:APCHSC=""!($D(APCHSQIT))  D
 .S APCHSI="" F  S APCHSI=$O(APCHSX("REF",APCHSC,APCHSI)) Q:APCHSI=""!($D(APCHSQIT))  D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..S APCHSD=$O(APCHSX("REF",APCHSC,APCHSI,0))
 ..S APCHSDA=$P(APCHSX("REF",APCHSC,APCHSI,APCHSD),U)
 ..S APCHSRT=$P(APCHSX("REF",APCHSC,APCHSI,APCHSD),U,2)
 ..W ?3,$E(APCHSI,1,30),?65,$$FMTE^XLFDT(9999999-APCHSD,5),!
 ..W ?5,"Reason not Done:  ",APCHSRT,!
 ..I $P($G(^AUPNPREF(APCHSDA,11)),U,1)]"",$P(^APCHSCTL(APCHSTYP,0),U,8) D
 ...;display comments using DIWP
 ...K ^UTILITY($J,"W")
 ...S X="Comments: "_$P(^AUPNPREF(APCHSDA,11),U,1)
 ...S DIWL=0,DIWR=74
 ...D ^DIWP
 ...S APCHSZ=0 F  S APCHSZ=$O(^UTILITY($J,"W",DIWL,APCHSZ)) Q:APCHSZ'=+APCHSZ!($D(APCHSQIT))  D
 ....X APCHSCKP Q:$D(APCHSQIT)
 ....W ?5,^UTILITY($J,"W",DIWL,APCHSZ,0),!
 ...K ^UTILITY($J,"W")
 Q