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

APCHS10.m

Go to the documentation of this file.
APCHS10 ; IHS/CMI/LAB - PART 10 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS PCC SUITE;**2,11**;MAY 14, 2009;Build 58
 ;IHS/CMI/LAB - took screen out of education topics service cat
 ;IHS/CMI/LAB - patch 11 added behavior code and obj to pt ed display
 ;IHS/CMI/LAB - added dental ada codes for education to pt ed display (1310, 1320, 1330)
 ;cmi/anch/maw 8/27/2007 code set versioning in PEDCHK and REORDER
 ;
PTED ; ********** PATIENT EDUCATION * 9000010.16 **********
 ; <SETUP>
 ;Q:'$D(^AUPNVPED("AA",APCHSPAT))
 K APCHSDEN D DENTED
 I '$D(^AUPNVPED("AA",APCHSPAT)),'$D(APCHSDEN) Q  ;no ada or v pt ed
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 ; <DISPLAY>
 S APCHSIVD="" F APCHSQ=0:0 S APCHSIVD=$O(^AUPNVPED("AA",APCHSPAT,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)  D ONEDATE
 S APCHSIVD=0 F  S APCHSIVD=$O(APCHSDEN(APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)!('APCHSNDM)  S Y=-APCHSIVD\1+9999999 X APCHSCVD S APCHSDAT=Y S APCHSDTU=0 D
 .S APCHSDFN=0 F  S APCHSDFN=$O(APCHSDEN(APCHSIVD,"PED",APCHSDFN)) Q:APCHSDFN'=+APCHSDFN!($D(APCHSQIT))!('APCHSNDM)  D PEDCHK S APCHSNDM=APCHSNDM-APCHSDTU
 .S APCHSDFN=0,APCHSCNT=0 F  S APCHSDFN=$O(APCHSDEN(APCHSIVD,"DEN",APCHSDFN)) Q:APCHSDFN'=+APCHSDFN!($D(APCHSQIT))!('APCHSNDM)  D
 ..S APCHX=APCHSDEN(APCHSIVD,"DEN",APCHSDFN)
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W ! S APCHSVDF=$P(^AUPNVDEN(APCHSDFN,0),U,3)
 ..Q:'$D(^AUPNVSIT(APCHSVDF,0))
 ..D GETSITEV^APCHSUTL W:'APCHSCNT APCHSDAT,?10,APCHSNSH W ?23,"ADA: ",$P(^AUTTADA(APCHX,0),U)," - ",$E($P(^AUTTADA(APCHX,0),U,2),1,40),! S APCHSCNT=APCHSCNT+1
 ..Q
 ; <CLEANUP>
 ;now display PTED refusals
 S APCHST="EDUCATION",APCHSFN=9999999.09 D DISPREF^APCHS3C
 K APCHST,APCHSFN
PTEDX K APCHSIVD,APCHSDAT,APCHSDFN,APCHSFO,APCHSFAC,APCHSN,APCHSDTU,APCHSLVL,APCHSLVT,APCHSPED,APCHSPTB,APCHSQ,Y
 K APCHSNFL,APCHSNSH,APCHSNAB,APCHSVSC,APCHSVDF,APCHSDEN,APCHSDE1,APCHSDE2,APCHSDE3,APCHX
 Q
ONEDATE S APCHSDFN="" F APCHSQ=0:0 S APCHSDFN=$O(^AUPNVPED("AA",APCHSPAT,APCHSIVD,APCHSDFN)) Q:APCHSDFN=""  D
 .S X=$P($G(^AUPNVPED(APCHSDFN,0)),U)
 .Q:'X
 .Q:'$D(^AUTTEDT(X,0))
 .S APCHSDEN(APCHSIVD,"PED",APCHSDFN)=""
 Q
PEDCHK S APCHSN=^AUPNVPED(APCHSDFN,0)
 S APCHSVDF=$P(APCHSN,U,3) D GETSITEV^APCHSUTL
 X APCHSCKP Q:$D(APCHSQIT)  S:APCHSNPG APCHSDTU=0
 I 'APCHSDTU W APCHSDAT S APCHSFO=""
 I APCHSNSH=APCHSFO S APCHSFAC=""
 E  S (APCHSFAC,APCHSFO)=APCHSNSH
 S APCHSDTU=1
 S APCHSPED=$P(APCHSN,U,1),APCHSPEM=$P(^AUTTEDT(APCHSPED,0),U,2),APCHSPED=$P(^AUTTEDT(APCHSPED,0),U,1)
 S APCHSLVL=$P(APCHSN,U,6),APCHSLVT=""
 I APCHSLVL]"" D
 .  S APCHSLVT=$P(^DD(9000010.16,.06,0),U,3)
 .  S APCHSLVT=$P(APCHSLVT,APCHSLVL_":",2)
 .  S APCHSLVT=$P(APCHSLVT,";",1)
 .  S:"^GOOD^FAIR^POOR^"[("^"_APCHSLVT_"^") APCHSLVT=APCHSLVT_" UNDERSTANDING"
 .  ;S APCHSLVT="- "_APCHSLVT
 .  Q
 X APCHSCKP Q:$D(APCHSQIT)  W:APCHSNPG APCHSDAT W ?10,APCHSFAC,?23,$E(APCHSPEM,1,12),?35,$E(APCHSPED,1,35),$S($P(APCHSN,U,7)="":"",$P(APCHSN,U,7)="I":" - (IND)",$P(APCHSN,U,7)="G":" - (GRP)",1:""),!
 I APCHSLVT]"" W ?35,APCHSLVT,!
 I $P(APCHSN,U,13)]""!($P(APCHSN,U,14)]"") D
 .X APCHSCKP Q:$D(APCHSQIT)
 .W ?23,"Behavior Code: ",$$VAL^XBDIQ1(9000010.16,APCHSDFN,.13),?51,"Objectives Met: ",$P(APCHSN,U,14),!
 I $P($G(^AUPNVPED(APCHSDFN,11)),U)]"" S APCHSTXT=$P(^AUPNVPED(APCHSDFN,11),U),APCHSNRQ="",APCHSICL=23 D PRTTXT^APCHSUTL
 ;cmi/anch/maw 8/27/2007 mods follow for code set versioning
 ;I $P($G(^AUPNVPED(APCHSDFN,11)),U)="",$P(APCHSN,U,4)]"" S APCHSTXT=$P(^ICD9($P(APCHSN,U,4),0),U,3),APCHSNRQ="",APCHSICL=23 D PRTTXT^APCHSUTL
 N APCHSVDT
 S APCHSVDT=$P($P($G(^AUPNVSIT(APCHSVDF,0)),U),".")  ;get visit date
 I $P($G(^AUPNVPED(APCHSDFN,11)),U)="",$P(APCHSN,U,4)]"" S APCHSTXT=$P($$ICDDX^ICDEX($P(APCHSN,U,4),APCHSVDT),U,4),APCHSNRQ="",APCHSICL=23 D PRTTXT^APCHSUTL
 ;cmi/anch/maw 8/27/2007 end of mods
 I $P(APCHSN,U,11)]"" S APCHSTXT=$P(APCHSN,U,11),APCHSNRQ="",APCHSICL=23 D PRTTXT^APCHSUTL Q
 Q
 ;
MRPTED ; ********** MOST RECENT PATIENT EDUCATION * 9000010.16 **********
 ; <SETUP>
 ;Q:'$D(^AUPNVPED("AA",APCHSPAT))
 K APCHSDEN D DENTEDL
 I '$D(^AUPNVPED("AA",APCHSPAT)),'$D(APCHSDEN) Q  ;no ada or v pt ed
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 ; <DISPLAY>
 K APCHSPTB
 ;S APCHSIVD="" F APCHSQ=0:0 S APCHSIVD=$O(^AUPNVPED("AA",APCHSPAT,APCHSIVD)) Q:'APCHSIVD  S Y=-APCHSIVD\1+9999999 X APCHSCVD S APCHSDAT=Y D ONEDAY Q:$D(APCHSQIT)
 ;IHS/CMI/LAB - PATCH 9 modified this to look at date range and max visit limits
 S APCHSIVD="" F APCHSQ=0:0 S APCHSIVD=$O(^AUPNVPED("AA",APCHSPAT,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)  D ONEDAY
 S APCHSIVD=0 F  S APCHSIVD=$O(APCHSDEN(APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)!('APCHSNDM)  S Y=-APCHSIVD\1+9999999 X APCHSCVD S APCHSDAT=Y S APCHSDTU=0 D
 .S APCHSDFN=0 F  S APCHSDFN=$O(APCHSDEN(APCHSIVD,"PED",APCHSDFN)) Q:APCHSDFN'=+APCHSDFN!($D(APCHSQIT))!('APCHSNDM)  D PEDCHK S APCHSNDM=APCHSNDM-APCHSDTU
 .S APCHSDFN=0,APCHSCNT=0 F  S APCHSDFN=$O(APCHSDEN(APCHSIVD,"DEN",APCHSDFN)) Q:APCHSDFN'=+APCHSDFN!($D(APCHSQIT))!('APCHSNDM)  D
 ..S APCHX=APCHSDEN(APCHSIVD,"DEN",APCHSDFN)
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W ! S APCHSVDF=$P(^AUPNVDEN(APCHSDFN,0),U,3) D GETSITEV^APCHSUTL W:'APCHSCNT APCHSDAT,?10,APCHSNSH W ?23,"ADA: ",$P(^AUTTADA(APCHX,0),U)," - ",$E($P(^AUTTADA(APCHX,0),U,2),1,40),! S APCHSCNT=APCHSCNT+1
 ..Q
 ; <CLEANUP>
 ;now display PTED refusals
 S APCHST="EDUCATION",APCHSFN=9999999.09 D DISPREF^APCHS3C
 K APCHST,APCHSFN
MRPTEDX K APCHSPTB,APCHSEVT
 K APCHSIVD,APCHSDAT,APCHSDFN,APCHSFO,APCHSFAC,APCHSN,APCHSDTU,APCHSLVL,APCHSLVT,APCHSPED
 K APCHSNFL,APCHSNSH,APCHSNAB,APCHSVSC,APCHSVDF
 Q
 ;
ONEDAY  ;
 S APCHSDFN="" F APCHSQ=0:0 S APCHSDFN=$O(^AUPNVPED("AA",APCHSPAT,APCHSIVD,APCHSDFN)) Q:'APCHSDFN  D
 .S X=$P($G(^AUPNVPED(APCHSDFN,0)),U)
 .Q:X=""
 .Q:'$D(^AUTTEDT(X,0))
 .S APCHSEVT=+^AUPNVPED(APCHSDFN,0) I '$D(APCHSPTB(APCHSEVT)) S APCHSPTB(APCHSEVT)="",APCHSDEN(APCHSIVD,"PED",APCHSDFN)=""
 Q
MRPE ;EP - called from component
 ; <SETUP>
 ;Q:'$D(^AUPNVPED("AA",APCHSPAT))
 K APCHSDEN D DENTAL
 I '$D(^AUPNVPED("AA",APCHSPAT)),'$D(APCHSDEN) Q  ;no ada or v pt ed
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 ; <DISPLAY>
 K APCHSPTB
 ;S APCHSIVD="" F APCHSQ=0:0 S APCHSIVD=$O(^AUPNVPED("AA",APCHSPAT,APCHSIVD)) Q:'APCHSIVD  S Y=-APCHSIVD\1+9999999 X APCHSCVD S APCHSDAT=Y D ONEDAY Q:$D(APCHSQIT)
 ;IHS/CMI/LAB - PATCH 9 modified this to look at date range and max visit limits
 S APCHSIVD="" F APCHSQ=0:0 S APCHSIVD=$O(^AUPNVPED("AA",APCHSPAT,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)!('APCHSNDM)  D
 .S Y=-APCHSIVD\1+9999999 X APCHSCVD S APCHSDAT=Y  S APCHSDTU=0 D MRPEOD Q:$D(APCHSQIT)  S APCHSNDM=APCHSNDM-APCHSDTU Q:'APCHSNDM
 D REORDER
 ; <CLEANUP>
 ;now display PTED refusals
 S APCHST="EDUCATION",APCHSFN=9999999.09 D DISPREF^APCHS3C
 K APCHST,APCHSFN
MRPEX K APCHSPTB,APCHSEVT,APCHSDSP,APCHSX
 K APCHSIVD,APCHSDAT,APCHSDFN,APCHSFO,APCHSFAC,APCHSN,APCHSDTU,APCHSLVL,APCHSLVT,APCHSPED
 K APCHSNFL,APCHSNSH,APCHSNAB,APCHSVSC,APCHSVDF
 Q
 ;
MRPEOD ;
 S APCHSDFN="" F APCHSQ=0:0 S APCHSDFN=$O(^AUPNVPED("AA",APCHSPAT,APCHSIVD,APCHSDFN)) Q:'APCHSDFN  S APCHSEVT=+^AUPNVPED(APCHSDFN,0) I '$D(APCHSPTB(APCHSEVT)) S APCHSPTB(APCHSEVT)=APCHSIVD_U_APCHSDFN,APCHSDTU=1
 Q
REORDER ;reorder by name and print
 S APCHSEVT=0 F  S APCHSEVT=$O(APCHSPTB(APCHSEVT)) Q:APCHSEVT'=+APCHSEVT  I $D(^AUTTEDT(APCHSEVT,0)) S APCHSDSP($P(^AUTTEDT(APCHSEVT,0),U))=APCHSPTB(APCHSEVT)
 S APCHSX="" F  S APCHSX=$O(APCHSDSP(APCHSX)) Q:APCHSX=""!($D(APCHSQIT))  D
 .S APCHSDFN=$P(APCHSDSP(APCHSX),U,2)
 .S APCHSIVD=$P(APCHSDSP(APCHSX),U) S Y=-APCHSIVD\1+9999999 X APCHSCVD S APCHSDAT=Y
 .I $P(APCHSDSP(APCHSX),U,3)="D" S APCHSN=^AUPNVDEN(APCHSDFN,0)
 .E  S APCHSN=^AUPNVPED(APCHSDFN,0)
 .S APCHSVDF=$P(APCHSN,U,3) D GETSITEV^APCHSUTL
 .I $P(APCHSDSP(APCHSX),U,3)="D" D  Q
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W $E(APCHSX,1,43),"  ADA Code: ",$P(^AUTTADA($P(^AUPNVDEN(APCHSDFN,0),U),0),U),?57,APCHSDAT,?67,APCHSNSH,! Q
 .S APCHSLVL=$P(APCHSN,U,6),APCHSLVT=""
 .I APCHSLVL]"" D
 ..  S APCHSLVT=$P(^DD(9000010.16,.06,0),U,3)
 ..  S APCHSLVT=$P(APCHSLVT,APCHSLVL_":",2)
 ..  S APCHSLVT=$P(APCHSLVT,";",1)
 ..  S:"^GOOD^FAIR^POOR^"[("^"_APCHSLVT_"^") APCHSLVT=APCHSLVT_" UNDERSTANDING"
 ..  S APCHSLVT="- "_APCHSLVT
 .X APCHSCKP Q:$D(APCHSQIT)  W APCHSX,"  ",$S($P(APCHSN,U,7)="":"",$P(APCHSN,U,7)="I":" - (IND)",$P(APCHSN,U,7)="G":" - (GRP)",1:""),"  ",APCHSLVT,?57,APCHSDAT,?67,APCHSNSH,!
 .I $P(APCHSN,U,13)]""!($P(APCHSN,U,14)]"") D
 ..X APCHSCKP Q:$D(APCHSQIT)
 ..W ?23,"Behavior Code: ",$$VAL^XBDIQ1(9000010.16,APCHSDFN,.13),?51,"Objectives Met: ",$P(APCHSN,U,14),!
 .I $P($G(^AUPNVPED(APCHSDFN,11)),U)]"" S APCHSTXT=$P(^AUPNVPED(APCHSDFN,11),U),APCHSNRQ="",APCHSICL=5 D PRTTXT^APCHSUTL
 .;cmi/anch/maw 8/27/2007 mods follow for code set versioning
 .;I $P($G(^AUPNVPED(APCHSDFN,11)),U)="",$P(APCHSN,U,4)]"" S APCHSTXT=$P(^ICD9($P(APCHSN,U,4),0),U,3),APCHSNRQ="",APCHSICL=5 D PRTTXT^APCHSUTL
 .N APCHSVDT
 .S APCHSVDT=$P($P($G(^AUPNVSIT(APCHSVDF,0)),U),".")  ;get visit date
 .I $P($G(^AUPNVPED(APCHSDFN,11)),U)="",$P(APCHSN,U,4)]"" S APCHSTXT=$P($$ICDDX^ICDEX($P(APCHSN,U,4),APCHSVDT),U,4),APCHSNRQ="",APCHSICL=5 D PRTTXT^APCHSUTL
 .;cmi/anch/maw 8/27/2007 end of mods
 .I $P(APCHSN,U,11)]"" S APCHSTXT=$P(APCHSN,U,11),APCHSNRQ="",APCHSICL=5 D PRTTXT^APCHSUTL Q
 ;now print all dental ADA
 Q
DENTEDL ;gather up last of each
 K APCHSDEN S APCHSDTU=0
 S APCHSDE1=$O(^AUTTADA("B",1310,0))
 S APCHSDE2=$O(^AUTTADA("B",1320,0))
 S APCHSDE3=$O(^AUTTADA("B",1330,0))
 S APCHSIVD="" F APCHSQ=0:0 S APCHSIVD=$O(^AUPNVDEN("AA",APCHSPAT,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)  D
 .S APCHSDFN="" F  S APCHSDFN=$O(^AUPNVDEN("AA",APCHSPAT,APCHSIVD,APCHSDFN)) Q:'APCHSDFN  D
 ..S X=$P($G(^AUPNVDEN(APCHSDFN,0)),U) I X=APCHSDE1!(X=APCHSDE2)!(X=APCHSDE3) I '$D(APCHSDEN("DEN",X)) S APCHSDEN(APCHSIVD,"DEN",APCHSDFN)=$P(^AUPNVDEN(APCHSDFN,0),U),APCHSDEN("DEN",X)=""
 .Q
 Q
DENTED ;gather up all 1310, 1320, 1330
 K APCHSDEN S APCHSDTU=0
 S APCHSDE1=$O(^AUTTADA("B",1310,0))
 S APCHSDE2=$O(^AUTTADA("B",1320,0))
 S APCHSDE3=$O(^AUTTADA("B",1330,0))
 S APCHSIVD="" F APCHSQ=0:0 S APCHSIVD=$O(^AUPNVDEN("AA",APCHSPAT,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)  D
 .S APCHSDFN="" F  S APCHSDFN=$O(^AUPNVDEN("AA",APCHSPAT,APCHSIVD,APCHSDFN)) Q:'APCHSDFN  D
 ..S X=$P($G(^AUPNVDEN(APCHSDFN,0)),U) I X=APCHSDE1!(X=APCHSDE2)!(X=APCHSDE3) S APCHSDEN(APCHSIVD,"DEN",APCHSDFN)=$P(^AUPNVDEN(APCHSDFN,0),U),APCHSDTU=APCHSDTU+1
 .Q
 Q
DENTAL ;
 K APCHSDEN,APCHSDSP
 K APCHSDEN S APCHSDTU=0
 S APCHSDE1=$O(^AUTTADA("B",1310,0))
 S APCHSDE2=$O(^AUTTADA("B",1320,0))
 S APCHSDE3=$O(^AUTTADA("B",1330,0))
 S APCHSIVD="" F APCHSQ=0:0 S APCHSIVD=$O(^AUPNVDEN("AA",APCHSPAT,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)  D
 .S APCHSDFN="" F  S APCHSDFN=$O(^AUPNVDEN("AA",APCHSPAT,APCHSIVD,APCHSDFN)) Q:'APCHSDFN  D
 ..S X=$P($G(^AUPNVDEN(APCHSDFN,0)),U) I X=APCHSDE1!(X=APCHSDE2)!(X=APCHSDE3) I '$D(APCHSDEN("DEN",X)) S APCHSDSP($P(^AUTTADA(X,0),U,2))=APCHSIVD_U_APCHSDFN_U_"D",APCHSDEN("DEN",X)=""
 .Q