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

BHSCPT.m

Go to the documentation of this file.
BHSCPT ;IHS/MSC/MGH - Health Summary for V MED file ;31-Dec-2015 13:12;DU
 ;;1.0;HEALTH SUMMARY COMPONENTS;**2,13**;March 17, 2006;Build 6
 ;===================================================================
 ; IHS/TUCSON/LAB - PART 6 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;  [ 05/04/04  2:46 PM ]
 ;;2.0;IHS RPMS/PCC Health Summary;**11,14,16**;JUN 24, 1997
 ;Patch 2 added components for CPT codes
CPTALL ;EP - display all cpt codes, date limits are applicable
 N BHSPAT,V,Y,BHSNAR
 S BHSPAT=DFN
 I '$D(^AUPNVCPT("AA",BHSPAT)),'$D(^AUPNVTC("AC",BHSPAT)) Q  ;no cpt codes for this patient
 ; <DISPLAY>
 K BHCPTA
 S BHCPTI=0 F  S BHCPTI=$O(^AUPNVCPT("AA",BHSPAT,BHCPTI)) Q:BHCPTI=""  D
 .S BHSIVD="" F  S BHSIVD=$O(^AUPNVCPT("AA",BHSPAT,BHCPTI,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)  D
 ..S BHIEN=0 F  S BHIEN=$O(^AUPNVCPT("AA",BHSPAT,BHCPTI,BHSIVD,BHIEN)) Q:BHIEN'=+BHIEN  D
 ...S BHCPT=$$VAL^XBDIQ1(9000010.18,BHIEN,.01)
 ...;IHS/MSC/MGH Patch 13
 ...S BHSNAR=$$VAL^XBDIQ1(9000010.18,BHIEN,.04)
 ...I BHSNAR="" S BHCPTA(BHSIVD,BHCPT,BHIEN)=$P($$CPT^ICPTCOD(BHCPTI,(9999999-BHSIVD)),U,3)_U_$$VAL^XBDIQ1(9000010.18,BHIEN,.16)_U_$$VALI^XBDIQ1(9000010,$P(^AUPNVCPT(BHIEN,0),U,3),.06)
 ...E  S BHCPTA(BHSIVD,BHCPT,BHIEN)=BHSNAR_U_$$VAL^XBDIQ1(9000010.18,BHIEN,.16)_U_$$VALI^XBDIQ1(9000010,$P(^AUPNVCPT(BHIEN,0),U,3),.06)
 ...S Y=$$VALI^XBDIQ1(9000010,$P(^AUPNVCPT(BHIEN,0),U,3),.08) S $P(BHCPTA(BHSIVD,BHCPT,BHIEN),U,4)=Y
 ;now get tran codes
 S BHIEN=0 F  S BHIEN=$O(^AUPNVTC("AC",BHSPAT,BHIEN)) Q:BHIEN=""  D
 .Q:'$D(^AUPNVTC(BHIEN))
 .S V=$P(^AUPNVTC(BHIEN,0),U,3)
 .Q:'V
 .Q:'$D(^AUPNVSIT(V,0))
 .S V=$P($P(^AUPNVSIT(V,0),U),".")
 .S BHSIVD=9999999-V
 .Q:BHSIVD>GMTSDLM
 .S BHCPT=$$VAL^XBDIQ1(9000010.33,BHIEN,.07)
 .Q:BHCPT=""
 .S BHCPTI=$P(^AUPNVTC(BHIEN,0),U,7)
 .Q:$D(BHCPTA(BHSIVD,BHCPT))
 .S BHCPTA(BHSIVD,BHCPT,BHIEN)=$P($$CPT^ICPTCOD(BHCPTI,(9999999-BHSIVD)),U,3)_U_1_U_$$VALI^XBDIQ1(9000010,$P(^AUPNVTC(BHIEN,0),U,3),.06)
 .S Y=$$VALI^XBDIQ1(9000010,$P(^AUPNVTC(BHIEN,0),U,3),.08) S $P(BHCPTA(BHSIVD,BHCPT,BHIEN),U,4)=Y
 G:'$D(BHCPTA) CPTALLX
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W ?28,"CODE",?34,"CPT NARRATIVE",?72,"UNITS",!
 S BHSIVD=0 F  S BHSIVD=$O(BHCPTA(BHSIVD)) Q:BHSIVD=""!($D(GMTSQIT))  D
 .D CKP^GMTSUP Q:$D(GMTSQIT)  I GMTSNPG W ?28,"CODE",?34,"CPT NARRATIVE",?72,"UNITS",!
 .W $$DATE^BHSMU((9999999-BHSIVD))
 .S BHCPT="" F  S BHCPT=$O(BHCPTA(BHSIVD,BHCPT)) Q:BHCPT=""!($D(GMTSQIT))  D
 ..S BHIEN=0 F  S BHIEN=$O(BHCPTA(BHSIVD,BHCPT,BHIEN)) Q:BHIEN'=+BHIEN!($D(GMTSQIT))  D
 ...D CKP^GMTSUP Q:$D(GMTSQIT)  I GMTSNPG W ?28,"CODE",?35,"CPT NARRATIVE",?72,"UNITS",!
 ...S %=$P(BHCPTA(BHSIVD,BHCPT,BHIEN),U,3)
 ...I % W ?9,$P($G(^AUTTLOC(%,0)),U,2)
 ...S %=$P(BHCPTA(BHSIVD,BHCPT,BHIEN),U,4)
 ...I % W ?22,$P($G(^DIC(40.7,%,9999999)),U)
 ...W ?28,BHCPT,?35,$E($P(BHCPTA(BHSIVD,BHCPT,BHIEN),U,1),1,36)
 ...W ?73,$P(BHCPTA(BHSIVD,BHCPT,BHIEN),U,2)
 ...W !
 ; <CLEANUP>
 ;now display CPT refusals
 S BHST="CPT",BHSFN=81 D DISPREF^BHSRAD
 K BHST,BHSFN
CPTALLX K BHSIVD,BHSDAT,BHCPT,BHIEN,BHCPTA,BHCPTI,%
 Q
CPTALLC ;EP - health summary component
 S BHMRO=0
CPTALLC1 ;EP - display all cpt codes, date limits are applicable
 S BHSPAT=DFN
 I '$D(^AUPNVCPT("AA",BHSPAT)),'$D(^AUPNVTC("AC",BHSPAT)) Q  ;no cpt codes for this patient
 ; <DISPLAY>
 K BHCPTA,BHSNAR
 S BHCPTI=0 F  S BHCPTI=$O(^AUPNVCPT("AA",BHSPAT,BHCPTI)) Q:BHCPTI=""  D
 .S BHSIVD="",BHSIVC=0 F  S BHSIVD=$O(^AUPNVCPT("AA",BHSPAT,BHCPTI,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)  D
 ..S BHIEN=0 F  S BHIEN=$O(^AUPNVCPT("AA",BHSPAT,BHCPTI,BHSIVD,BHIEN)) Q:BHIEN'=+BHIEN  D
 ...S BHCPT=$$VAL^XBDIQ1(9000010.18,BHIEN,.01)
 ...;IHS/MSC/MGH Patch 13
 ...S BHSNAR=$$VAL^XBDIQ1(9000010.18,BHIEN,.04)
 ...I BHSNAR="" S BHCPTA(BHCPT,BHSIVD,BHIEN)=$P($$CPT^ICPTCOD(BHCPTI,(9999999-BHSIVD)),U,3)_U_$$VAL^XBDIQ1(9000010.18,BHIEN,.16)_U_$$VALI^XBDIQ1(9000010,$P(^AUPNVCPT(BHIEN,0),U,3),.06)
 ...E  S BHCPTA(BHCPT,BHSIVD,BHIEN)=BHSNAR_U_$$VAL^XBDIQ1(9000010.18,BHIEN,.16)_U_$$VALI^XBDIQ1(9000010,$P(^AUPNVCPT(BHIEN,0),U,3),.06)
 ...S Y=$$VALI^XBDIQ1(9000010,$P(^AUPNVCPT(BHIEN,0),U,3),.08) S $P(BHCPTA(BHCPT,BHSIVD,BHIEN),U,4)=Y
 ;now get tran codes
 S BHIEN=0 F  S BHIEN=$O(^AUPNVTC("AC",BHSPAT,BHIEN)) Q:BHIEN=""  D
 .Q:'$D(^AUPNVTC(BHIEN))
 .S V=$P(^AUPNVTC(BHIEN,0),U,3)
 .Q:'V
 .Q:'$D(^AUPNVSIT(V,0))
 .S V=$P($P(^AUPNVSIT(V,0),U),".")
 .S BHSIVD=9999999-V
 .Q:BHSIVD>GMTSDLM
 .S BHCPT=$$VAL^XBDIQ1(9000010.33,BHIEN,.07)
 .Q:BHCPT=""
 .S BHCPTI=$P(^AUPNVTC(BHIEN,0),U,7)
 .Q:$D(BHCPTA(BHCPT,BHSIVD))
 .S BHCPTA(BHCPT,BHSIVD,BHIEN)=$P($$CPT^ICPTCOD(BHCPTI,(9999999-BHSIVD)),U,3)_U_1_U_$$VALI^XBDIQ1(9000010,$P(^AUPNVTC(BHIEN,0),U,3),.06)
 .S Y=$$VALI^XBDIQ1(9000010,$P(^AUPNVTC(BHIEN,0),U,3),.08) S $P(BHCPTA(BHCPT,BHSIVD,BHIEN),U,4)=Y
 G:'$D(BHCPTA) CPTALLCX
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W ?1,"CODE",?7,"DATE",?17,"CPT NARRATIVE",?54,"UNITS",?60,"FACILITY",?74,"CLN",!
 S BHCPT=0,BHMRC=0 F  S BHCPT=$O(BHCPTA(BHCPT)) Q:BHCPT=""!($D(GMTSQIT))  D
 .D CKP^GMTSUP Q:$D(GMTSQIT)  I GMTSNPG W ?1,"CODE",?7,"DATE",?17,"CPT NARRATIVE",?54,"UNITS",?60,"FACILITY",?74,"CLN",!
 .W BHCPT
 .I BHMRO D MREDISP Q
 .S BHSIVD="" F  S BHSIVD=$O(BHCPTA(BHCPT,BHSIVD)) Q:BHSIVD=""!($D(GMTSQIT))  D
 ..S BHMRC=0 S BHIEN=0 F  S BHIEN=$O(BHCPTA(BHCPT,BHSIVD,BHIEN)) Q:BHIEN'=+BHIEN!($D(GMTSQIT))  D
 ...D CKP^GMTSUP Q:$D(GMTSQIT)  I GMTSNPG W ?1,"CODE",?7,"DATE",?17,"CPT NARRATIVE",?54,"UNITS",?60,"FACILITY",?74,"CLN",!
 ...S BHMRC=BHMRC+1
 ...W ?7,$$DATE^BHSMU((9999999-BHSIVD))
 ...W ?17,$E($P(BHCPTA(BHCPT,BHSIVD,BHIEN),U,1),1,35)
 ...W ?54,$P(BHCPTA(BHCPT,BHSIVD,BHIEN),U,2)
 ...S %=$P(BHCPTA(BHCPT,BHSIVD,BHIEN),U,3)
 ...I % W ?60,$P($G(^AUTTLOC(%,0)),U,2)
 ...S %=$P(BHCPTA(BHCPT,BHSIVD,BHIEN),U,4)
 ...I % W ?74,$E($P($G(^DIC(40.7,%,9999999)),U),1,3)
 ...W !
 ; <CLEANUP>
 ;now display CPT refusals
 S BHST="CPT",BHSFN=81 D DISPREF^BHSRAD
 K BHST,BHSFN,BHMRO
CPTALLCX K BHSIVD,BHSDAT,BHCPT,BHMRC,BHSIVC,BHIEN,BHCPTA,BHCPTI,%
 Q
MREDISP ;
 S BHSIVD=0,BHSIVD=$O(BHCPTA(BHCPT,BHSIVD)) Q:BHSIVD>GMTSDLM  D
 .S BHIEN=0,BHIEN=$O(BHCPTA(BHCPT,BHSIVD,BHIEN)) D
 ..D CKP^GMTSUP Q:$D(GMTSQIT)  I GMTSNPG W ?1,"CODE",?7,"DATE",?17,"CPT NARRATIVE",?54,"UNITS",?60,"FACILITY",?74,"CLN",!
 ..W ?7,$$DATE^BHSMU((9999999-BHSIVD))
 ..W ?17,$E($P(BHCPTA(BHCPT,BHSIVD,BHIEN),U,1),1,35)
 ..W ?54,$P(BHCPTA(BHCPT,BHSIVD,BHIEN),U,2)
 ..S %=$P(BHCPTA(BHCPT,BHSIVD,BHIEN),U,3)
 ..I % W ?60,$P($G(^AUTTLOC(%,0)),U,2)
 ..S %=$P(BHCPTA(BHCPT,BHSIVD,BHIEN),U,4)
 ..I % W ?74,$P($G(^DIC(40.7,%,9999999)),U)
 ..W !
 .Q
 Q
CPTMRE ;EP - health summary component, most recent of each cpt code
 S BHMRO=1
 G CPTALLC1