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

BHSSUR.m

Go to the documentation of this file.
BHSSUR ;IHS/CIA/MGH - Health Summary for minor surgery ;14-Dec-2015 16:56;DU
 ;;1.0;HEALTH SUMMARY COMPONENTS;**1,2,9,11,12**;March 17, 2006;Build 3
 ;===================================================================
 ;Taken from APCHS6A
 ; IHS/TUCSON/LAB - PART 6 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS RPMS/PCC Health Summary;;JUN 24, 1997
 ;VA health summary for minor surgery
 ;Patch 1 made changes up to patch 14 of health summary
 ;Patch 2 made changes for patch 16 of health summary and filters out duplicate ICD0/CPT codes
 ;Patch 12 used new API for taxonomies
 ;
MINORO ; ******** MINOR HISTORY OF SURGERY * 9000010.08 (V PROCEDURE) *******
 ; <SETUP>
 N BHSPAT,BHSNTE,BHSN,BHSQ,TAXIEN
 S BHSPAT=DFN
 S TAXARR="",ARRAY=""
 Q:'$D(^AUPNVPRC("AC",BHSPAT))
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ; <DISPLAY>
 S TAXIEN=$O(^ATXAX("B","APCH MINOR SURGICAL PROCS",0))
 S BHSIVD=0 F BHSQ=0:0 S BHSIVD=$O(^AUPNVPRC("AA",BHSPAT,BHSIVD)) Q:'BHSIVD  D
 .S BHSDFN=0 F BHSQ=0:0 S BHSDFN=$O(^AUPNVPRC("AA",BHSPAT,BHSIVD,BHSDFN)) Q:'BHSDFN  D
 ..D HOSDSP Q:$D(GMTSQIT)
 ;Patch 2 changes for refusals
 S BHSFN=80.1,BHST="PROCEDURE"
 S BHSS="S %=0,BHSICD=$P(^AUPNPREF(BHSI,0),U,6) Q:'BHSICD  D HOSCHK^BHSSUR I BHSICD S %=1"
 D DISPREF^BHSRAD
 K BHSDN,BHST,BHSS
 ;
 ; <CLEANUP>
MINOROX K BHSDFN,BHSICD,BHSNRQ,BHSDAT,BHSDS,BHSICL,BHSIVD,BHSCOD,BHSOPN,BHSOP,Y
 Q
HOSDSP ;Get diagnosis
 N X,Y
 S BHSN=^AUPNVPRC(BHSDFN,0)
 S BHSICD=$P(BHSN,U,1)
 D HOSCHK Q:BHSICD=""
 D GETICDOP^BHSUTL
 S Y=$P(BHSN,U,3),X=+^AUPNVSIT(Y,0)\1 D REGDT4^GMTSU  S BHSDAT=X
 S BHSNRQ=$P(BHSN,U,4)
 ;Patch 8 changes
 I BHSNRQ D GETNARR^BHSUTL
 ;I BHSNRQ="" S BHSNRQ=$P(^ICD0($P(BHSN,U,1),0),U,4)
 I $$AICD^BHSUTL D
 .I BHSNRQ="" S BHSNRQ=$P($$ICDOP^ICDEX($P(BHSN,U,1),BHSDAT,"","I"),U,5)  ;cmi/anch/maw 8/28/2007 code set versioning
 E  D
 .I BHSNRQ="" S BHSNRQ=$P($$ICDOP^ICDCODE($P(BHSN,U,1),BHSDAT),U,5)  ;cmi/anch/maw 8/28/2007 code set versioning
 ;end changes
 S BHSDS="DATE?",X=$P(BHSN,U,6) I Y]"" D REGDT4^GMTSU S BHSDS=X
 D GETOPRV
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W BHSDS W ?10,BHSOP S BHSNTE="" S BHSICL=26 D PRTICD^BHSUTL
 K BHSOP
 Q
HOSCHK ;
 ;S BHSCOD=+^ICD0(BHSICD,0)
 ;PATCH 9 for ICD-10
 I $$AICD^BHSUTL S BHSCOD=$P($$ICDOP^ICDEX(BHSICD,"","","I"),U,1)
 E  S BHSCOD=$P($$ICDOP^ICDCODE(BHSICD),U,2)  ;cmi/anch/maw 8/27/2007
 ;IHS/MSC/MGH Patch 11
 Q:$$ICD^ATXAPI(BHSCOD,$O(^ATXAX("B","APCH MINOR SURGICAL PROCS",0)),0)
 ;Q:BHSCOD\1>85
 ;Q:BHSCOD=69.7
 ;Q:BHSCOD\1=23
 ;Q:BHSCOD\1=24
 S BHSICD=""
 Q
GETOPRV ;get Operating Provider
 NEW BHSOPN
 S BHSOP=""
 S BHSOPN=$P(BHSN,U,11)
 Q:'+BHSOPN
 S BHSOP=$E($P($G(^VA(200,BHSOPN,0)),U,1),1,15)     ;provider name
 Q
MINOR ; ************* HISTORY OF SURGERY * 9000010.08 (V PROCEDURE) & V CPT *
 ; <SETUP>
 K BHHOSA,BHHOSC,TAXIEN,CODE,BHSNRQ1
 S BHSPAT=DFN
 I '$D(^AUPNVPRC("AC",BHSPAT)),'$D(^AUPNVCPT("AC",BHSPAT)) G MINORX
 D CKP^GMTSUP Q:$D(GMTSQIT)
 S BHSCNT=0
 S TAXIEN=$O(^ATXAX("B","APCH MINOR SURGICAL PROCS",0))
 ; <DISPLAY>
 S BHSIVD=0 F  S BHSIVD=$O(^AUPNVPRC("AA",BHSPAT,BHSIVD)) Q:'BHSIVD  D
 .S BHSDFN=0 F  S BHSDFN=$O(^AUPNVPRC("AA",BHSPAT,BHSIVD,BHSDFN)) Q:'BHSDFN  D
 ..S BHSICD=$P(^AUPNVPRC(BHSDFN,0),U)
 ..S BHSN=^AUPNVPRC(BHSDFN,0)
 ..D HOSCHK Q:BHSICD=""
 ..S BHSCNT=BHSCNT+1
 ..D GETICDOP^BHSUTL
 ..S Y=$P(BHSN,U,3),X=+^AUPNVSIT(Y,0)\1 D REGDT4^GMTSU S BHSDAT=X
 ..S BHSNRQ=$P(BHSN,U,4)
 ..I BHSNRQ D GETNARR^BHSUTL
 ..;I BHSNRQ="" S BHSNRQ=$P(^ICD0($P(BHSN,U,1),0),U,4)
 ..;Patch 9 for ICD-10
 ..I $$AICD^BHSUTL D
 ...I BHSNRQ="" S BHSNRQ1=$P($$ICDOP^ICDEX($P(BHSN,U,1),BHSDAT,"","I"),U,5)  ;cmi/anch/maw 8/28/2007 code set versioning
 ...E  S BHSNRQ1=BHSNRQ
 ...S BHSNRQ=$P($$ICDOP^ICDEX($P(BHSN,U,1),BHSDAT,"","I"),U,2)_" "_BHSNRQ1  ;cmi/anch/maw 8/28/2007 code set versioning
 ..E  D
 ...I BHSNRQ="" S BHSNRQ=$P($$ICDOP^ICDCODE($P(BHSN,U,1),BHSDAT),U,5)  ;cmi/anch/maw 8/28/2007 code set versioning
 ..S BHSDS="DATE?",X=$P(BHSN,U,6) I X]"" D REGDT4^GMTSU S BHSDS=X
 ..D GETOPRV
 ..S BHHOSA(BHSIVD,"PRC",BHSDFN)=BHSDS_U_BHSNRQ_U_BHSOP
 ;now go through v cpt
 S BHT=$O(^ATXAX("B","APCH HS MINOR PROCEDURE CPTS",0))
 S BHCPTI=0 F  S BHCPTI=$O(^AUPNVCPT("AA",BHSPAT,BHCPTI)) Q:BHCPTI'=+BHCPTI  D
 .S CODE=$P($G(^ICPT(BHCPTI,0)),U)
 .I '$$ICD^ATXCHK(BHCPTI,BHT,1) Q  ;not a cpt wanted on this component
 .S BHSIVD=0 F  S BHSIVD=$O(^AUPNVCPT("AA",BHSPAT,BHCPTI,BHSIVD)) Q:BHSIVD=""  D
 ..S BHSIEN=0 F  S BHSIEN=$O(^AUPNVCPT("AA",BHSPAT,BHCPTI,BHSIVD,BHSIEN)) Q:BHSIEN'=+BHSIEN  D
 ...S X=(9999999-BHSIVD) D REGDT4^GMTSU S BHSDS=X
 ...S BHSN=^AUPNVCPT(BHSIEN,0)
 ...S BHSICD=$P(BHSN,U,1)
 ...D GETCPT^BHSUTL
 ...S BHSNRQ=$P(BHSN,U,4)
 ...I BHSNRQ D GETNARR^BHSUTL
 ...N BHSVDT
 ...S BHSVDT=$S($P(BHSN,U,3):$P(+$G(^AUPNVSIT($P(BHSN,U,3),0)),"."),1:"")
 ...;I BHSNRQ="" S BHSNRQ=$P(^ICPT($P(BHSN,U,1),0),U,2)
 ...I BHSNRQ="" S BHSNRQ=$P($$CPT^ICPTCOD($P(BHSN,U,1),BHSVDT),U,3)
 ...S CODE=$P($$CPT^ICPTCOD($P(BHSN,U,1),BHSVDT),U,2)
 ...;IHS/MSC/MGH filter out duplicates
 ...S MATCH=0
 ...S I="" F  S I=$O(BHHOSA(BHSIVD,"PRC",I)) Q:I=""  D
 ....S Z=$G(BHHOSA(BHSIVD,"PRC",I))
 ....S BHSCPT2=$P(BHSICD,"-",1)
 ....I $D(^ICPT(BHSCPT2,"ICD",0)) D
 .....S SCODE=0 F  S SCODE=$O(^ICPT(BHSCPT2,"ICD",SCODE)) Q:SCODE=""!(SCODE="B")!(MATCH=1)  D
 ......I $P($G(^ICD0(SCODE,0)),U,1)=$P($P(Z,U,4),"-",1) S MATCH=1
 ...I MATCH=0 D
 ....S BHSCNT=BHSCNT+1
 ....S BHHOSA(BHSIVD,"CPT",BHSIEN)=BHSDS_U_BHSNRQ_U_$S($P($G(^AUPNVCPT(BHSIEN,12)),U,4):$$VAL^XBDIQ1(9000010.18,BHSIEN,1204),1:$$VAL^XBDIQ1(9000010.18,BHSIEN,1202))_U_CODE
 ....S BHHOSC(BHSIVD,"CPT",$P(^ICPT($P(BHSN,U,1),0),U,1))=""
 ;now get all tran codes hcpcs
 S BHSIEN=0 F  S BHSIEN=$O(^AUPNVTC("AC",BHSPAT,BHSIEN)) Q:BHSIEN=""  D
 .Q:'$D(^AUPNVTC(BHSIEN))
 .S V=$P(^AUPNVTC(BHSIEN,0),U,3)
 .Q:'V
 .Q:'$D(^AUPNVSIT(V,0))
 .S V=$P($P(^AUPNVSIT(V,0),U),".")
 .S X=V D REGDT4^GMTSU  S BHSDS=X
 .S BHSIVD=9999999-V
 .S BHCPT=$$VAL^XBDIQ1(9000010.33,BHSIEN,.07)
 .S BHCPTI=$P(^AUPNVTC(BHSIEN,0),U,7)
 .Q:BHCPTI=""         ;Patch 12 quit if no CPT on the transcode
 .I '$$ICD^ATXAPI(BHCPTI,BHT,1) Q  ;not a cpt wanted on this component
 .Q:$D(BHHOSC(BHSIVD,"CPT",BHCPT))
 .S BHSNRQ=$P(^ICPT(BHCPTI,0),U,2)
 .S BHSICD=BHCPTI
 .D GETCPT^BHSUTL
 .S BHHOSA(BHSIVD,"CPT",BHSIEN)=BHSDS_U_BHSNRQ_U_$S($P($G(^AUPNVTC(BHSIEN,12)),U,4):$$VAL^XBDIQ1(9000010.33,BHSIEN,1204),1:$$VAL^XBDIQ1(9000010.33,BHSIEN,1202))_U_BHSICD
 ;now display the procedures/cpt codes
 S BHSIVD=0 F  S BHSIVD=$O(BHHOSA(BHSIVD)) Q:BHSIVD=""!($D(GMTSQIT))  D
 . D CKP^GMTSUP Q:$D(GMTSQIT)
 . S BHIEN=0 F  S BHIEN=$O(BHHOSA(BHSIVD,"PRC",BHIEN)) Q:BHIEN'=+BHIEN!($D(GMTSQIT))  D
 .. S BHSOP=$P(BHHOSA(BHSIVD,"PRC",BHIEN),U,3)
 .. S BHSNRQ=$P(BHHOSA(BHSIVD,"PRC",BHIEN),U,2)
 .. S BHSDS=$P(BHHOSA(BHSIVD,"PRC",BHIEN),U,1)
 .. S BHSICD=$P(BHHOSA(BHSIVD,"PRC",BHIEN),U,4)
 .. W BHSDS,?12,$E(BHSOP,1,15) S BHSNTE="" S BHSICL=26 D PRTICD^BHSUTL
 . S BHIEN=0 F  S BHIEN=$O(BHHOSA(BHSIVD,"CPT",BHIEN)) Q:BHIEN'=+BHIEN!($D(GMTSQIT))  D
 .. S BHSOP=$P(BHHOSA(BHSIVD,"CPT",BHIEN),U,3)
 .. S BHSNRQ=$P(BHHOSA(BHSIVD,"CPT",BHIEN),U,2)
 .. S BHSDS=$P(BHHOSA(BHSIVD,"CPT",BHIEN),U,1)
 .. S BHSICD=$P(BHHOSA(BHSIVD,"CPT",BHIEN),U,4)
 .. W BHSDS,?12,$E(BHSOP,1,15) S BHSNTE="" S BHSICL=26 D PRTICD^BHSUTL
 I 'BHSCNT D CKP^GMTSUP Q:$D(GMTSQIT)  W "Minor procedures are on file but have not been displayed.",!
 ; <CLEANUP>
 ; now display refusals for icd procedures
 S BHSFN=80.1,BHST="PROCEDURE"
 S BHSS="S %=0,BHSICD=$P(^AUPNPREF(BHSI,0),U,6) Q:'BHSICD  D HOSCHK^BHSSUR I BHSICD S %=1"
 D DISPREF^BHSRAD
 S BHSFN=81,BHST="CPT"
 ;IHS/MSC/MGH Patch 10
 S BHSS="S %=0,BHCPT=$P(^AUPNPREF(BHSI,0),U,6) Q:'BHCPT  I $$ICD^ATXCHK(BHCPT,$O(^ATXAX(""B"",""APCH HS MINOR PROCEDURE CPTS"",0)),1) S %=1"
 D DISPREF^BHSRAD
HOSX K BHSFN,BHSOP,BHST,BHSS,BHSDFN,BHSICD,BHSNRQ,BHSDAT,BHSDS,BHSICL,BHSIVD,BHSCOD,BHSCNT,BHSOPN,BHSOP,Y,X,V
 K BHHOSA,BHHOSC,MATCH,SCODE,I,Z,BHSCPT2
 Q
MINORX K BHSFN,BHSOP,BHST,BHSS,BHSDFN,BHSICD,BHSNRQ,BHSDAT,BHSDS,BHSICL,BHSIVD,BHSCOD,BHSCNT,BHSOPN,BHSOP,Y,X,V,I,Z,BHCPTI,BIEN,BHSIEN,BHT,BHCPT,BHIEN,MATCH,SCODE,BHSCPT2,
 Q