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

BSDX41A.m

Go to the documentation of this file.
BSDX41A ; IHS/OIT/HMW/MSC/SAT - WINDOWS SCHEDULING RPCS ;
 ;;3.0;IHS WINDOWS SCHEDULING;;DEC 09, 2010
 ;
 ; Support routines for BSDX HEALTH SUMMARY remote procedure
 ;
DEMOG ; ******************** DEMOGRAPHICS ********************
 ; <SETUP>
 S APCHSN=^DPT(APCHSPAT,0)
 S APCHSNAM=$P(APCHSN,U,1)
 S APCHSEX=$P(APCHSN,U,2),APCHSEX=$S(APCHSEX="M":"MALE",APCHSEX="F":"FEMALE",1:"<no sex>")
 S Y=$P(APCHSN,U,3)
 I 'Y S APCHSDOB="<NO DATE OF BIRTH>"
 E  X ^DD("DD") S APCHSDOB=Y
 S APCHSSN=$$SSN^APCHS1(APCHSPAT)
 ;S APCHSSN=$P(APCHSN,U,9) S:APCHSSN]"" APCHSSN=$E(APCHSSN,1,3)_"-"_$E(APCHSSN,4,5)_"-"_$E(APCHSSN,6,9)
 S APCHSN=$G(^DPT(APCHSPAT,.24))
 S APCHSMNM=$P(APCHSN,U,3)
 S APCHSFNM=$P(APCHSN,U)
 S APCHSN=^AUPNPAT(APCHSPAT,0)
 S Y=$P(APCHSN,U,3)
 I 'Y S APCHSLUD=""
 E  X ^DD("DD") S APCHSLUD=Y
 ;S APCHSBT=$P(APCHSN,U,13) S:APCHSBT="" APCHSBT="no blood type"
 ; start - vjm 9/20/01   logic for Blood Bank blood type
 ;                       1) use BB's ABO/Rh - if it exists
 ;                       2) use PCC blood type - if it exists
 ;                       3) otherwise, say 'no blood type'
 ;S APCHSBT=$P(APCHSN,U,13) S:APCHSBT="" APCHSBT="no blood type"
 D
 .  Q:'$D(^DPT(APCHSPAT,"LR"))
 .  S APCHX("LRDFN")=^DPT(APCHSPAT,"LR")   ; get pt's LRDFN
 .  D                        ; get Blood Bank blood type 
 .. Q:'$D(APCHX("LRDFN"))
 .. Q:APCHX("LRDFN")=""
 .. Q:'$D(^LR(APCHX("LRDFN"),0))
 ..  S APCHX("LR")=^LR(APCHX("LRDFN"),0)
 ..  S APCHX("ABO")=$P($G(APCHX("LR")),U,5)
 ..  Q:APCHX("ABO")=""
 ..  S APCHX("Rh")=$P($G(APCHX("LR")),U,6)
 ..  Q:APCHX("Rh")=""
 ..  S APCHX("ABO/Rh")=APCHX("ABO")_"/"_APCHX("Rh")
 ..  S:$D(APCHX("ABO/Rh")) APCHSBT="ABO/Rh:  "_APCHX("ABO/Rh")
 ..  Q
 .  Q
 I '$D(APCHX("ABO/Rh")) D   ; no BB data - data from ^DPT BType
 .  S APCHSBT=$P(APCHSN,U,13)
 .  S:APCHSBT="" APCHSBT="no blood type"
 .  Q
 K APCHX                     ; kill APCHX vars
 ; end - vjm 9/20/01
 ;S APCHSPP=$P(APCHSN,U,14) S:APCHSPP="" APCHSPP="<none identified>" I +APCHSPP S APCHSPP=$P(^DIC(6,+APCHSPP,0),U,1) I +APCHSPP S APCHSPP=$P(^DIC(16,+APCHSPP,0),U,1) ;*** file 200 conversion ***
 S APCHSPP=$P(APCHSN,U,14)
 S:APCHSPP=-1 APCHSPP=""  ;IHS/ANMC/LJF 8/5/99 prevent UNDEF
 S:APCHSPP="" APCHSPP="<none identified>"
 I +APCHSPP,$P(^DD(9000001,.14,0),U,2)[200 S APCHSPP=$P(^VA(200,APCHSPP,0),U) ;*** file 200 conversion ***
 I +APCHSPP,$P(^DD(9000001,.14,0),U,2)[6 S APCHSPP=$P(^DIC(6,+APCHSPP,0),U,1) I +APCHSPP S APCHSPP=$P(^DIC(16,+APCHSPP,0),U,1)
V ;
 S APCHSVST="" I $D(^DPT(APCHSPAT,"VET"))#2,$P(^DPT(APCHSPAT,"VET"),U)="Y" D VSTAT^APCHS1
 S APCHSN=$G(^AUPNPAT(APCHSPAT,11))
 S APCHSTR=$P(APCHSN,U,8)
 I 'APCHSTR S APCHSTR="<no tribe>"
 E  S APCHSTR=^AUTTTRI(APCHSTR,0) S APCHSTR=$P(APCHSTR,U,1)_$S($P(APCHSTR,U,4)="Y":" <old code>",1:"")
 S APCHSEL=$P(APCHSN,U,12)
 S X=$P(^DD(9000001,1112,0),U,3) F APCHSI=1:1 S APCHSP=$P(X,";",APCHSI) Q:APCHSP=""  I $P(APCHSP,":",1)=APCHSEL S APCHSEL=$P(APCHSP,":",2) Q
 S APCHSCMR=$P(APCHSN,U,18) S:APCHSCMR="" APCHSCMR="<NO COMMUNITY OF RESIDENCE>"
 S APCHSI=$O(^AUPNPAT(APCHSPAT,13,0)) S APCHSRE1=$S(APCHSI:^(APCHSI,0),1:"") S APCHSI=$O(^AUPNPAT(APCHSPAT,13,APCHSI)) S APCHSRE2=$S(APCHSI:^(APCHSI,0),1:"") S:$O(^AUPNPAT(APCHSPAT,13,APCHSI)) APCHSRE2=APCHSRE2_" [more]"
 S APCHSADR=""
 I $D(^DPT(APCHSPAT,.11)) S APCHSN=^DPT(APCHSPAT,.11) F E=1:1:6 S APCHSP=$P(APCHSN,U,E) I APCHSP]"" S:E=5 APCHSP=$P(^DIC(5,APCHSP,0),U,2) S APCHSADR=APCHSADR_","_APCHSP
 S APCHSADR=$E(APCHSADR,2,255)
 S:APCHSADR]"" APCHSCMR=APCHSCMR_" ("_APCHSADR_")  "
 S APCHSN=$G(^DPT(APCHSPAT,.13))
 S APCHSHPH=$P(APCHSN,U,1),APCHSOPH=$P(APCHSN,U,2)
 I APCHSHPH="",APCHSOPH="" S APCHSHPH="<no phone numbers recorded>"
 S:+APCHSHPH APCHSHPH="(H) "_APCHSHPH
 S:APCHSOPH]"" APCHSOPH="(W) "_APCHSOPH S:APCHSHPH]"" APCHSOPH=" "_APCHSOPH
 S APCHOTPH=$P($G(^AUPNPAT(APCHSPAT,18)),U,1)
 ;demographics output
DEMDSP ; output for demographics taken from APCHS1
 I $G(APCHSBRK)]"" X APCHSBRK
 I $$DOD^AUPNPAT(APCHSPAT)]"" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="*** DOD: "_$$FMTE^XLFDT($$DOD^AUPNPAT(APCHSPAT),"2D")_" ***"_$C(30)
 S BSDXTMP=APCHSNAM_$$FILL^BSDX41(34-$L(APCHSNAM)," ")
 I APCHSDOB]"" S BSDXTMP=BSDXTMP_"DOB: "_APCHSDOB_"  "_$$AGE(APCHSPAT,DT,"R")_"  "
 I APCHSEX]"" S BSDXTMP=BSDXTMP_APCHSEX_"    "
 D
 .  I APCHSBT["/" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_$C(30) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(33)_APCHSBT_$C(30) Q
 .  I APCHSBT]"" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_APCHSBT_$C(30)
 .  Q
 I APCHSTR]""!(APCHSMNM]"") S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$S(APCHSTR]"":$E(APCHSTR,1,33),1:"")_$S(APCHSSN]"":$$FILL^BSDX41($S((APCHSTR]"")&(APCHSSN]""):34-$L(APCHSTR),1:34))_"SSN: "_APCHSSN,1:"")_$C(30)
 I APCHSMNM]"" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(33)_"MOTHER'S MAIDEN NAME: "_APCHSMNM_$C(30)
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=APCHSHPH_APCHSOPH_$S(APCHSFNM]"":$$FILL^BSDX41(33-($L(APCHSHPH)+$L(APCHSOPH)))_"FATHER'S NAME: "_APCHSFNM,1:"")_$C(30)
 I APCHOTPH]"" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="OTHER PHONE: "_APCHOTPH_$C(30)
 I APCHSCMR]"" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=APCHSCMR_$C(30) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 I APCHSLUD]""!(APCHSEL]"") D
 . I APCHSLUD]"" S BSDXTMP="LAST UPDATED: "_APCHSLUD_"   "
 . I APCHSEL]"" D
  . . S BSDXTMP=BSDXTMP_$$FILL^BSDX41(33-$L("LAST UPDATED: "_APCHSLUD_"   "))_"ELIGIBILITY: "_APCHSEL
 . S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_$C(30)
 I APCHSVST]"" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=APCHSVST_$C(30)
 ;IHS/CMI/LAB - patch 11 added Notice of Privacy act display
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 S APCHSNPP=$G(^AUPNNPP(APCHSPAT,0))
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="NOTICE OF PRIVACY PRACTICES REC'D BY PATIENT?  "_$$VAL^XBDIQ1(9000038,APCHSPAT,.02)_$C(30)
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="                    DATE RECEIVED BY PATIENT:  "_$$FMTE^XLFDT($P(APCHSNPP,U,3))_$C(30)
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="                  WAS ACKNOWLEDGEMENT SIGNED?  "_$$VAL^XBDIQ1(9000038,APCHSPAT,.04)_$C(30)
 I $P(APCHSNPP,U,5)]"" D
 .S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="                                      REASON:  "_$P(APCHSNPP,U,5)_$C(30)
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 K APCHSNPP
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 I $D(^AUPNPAT(APCHSPAT,41)) S LCNT=0 S BSDXTMP="HEALTH RECORD NUMBERS:" F APCHSFP=0:0 S LCNT=LCNT+1 S APCHSFP=$O(^AUPNPAT(APCHSPAT,41,APCHSFP)) Q:'APCHSFP  D
 . S APCHSHRN=$P(^AUPNPAT(APCHSPAT,41,APCHSFP,0),U,2),APCHSFAC=$P(^DIC(4,APCHSFP,0),U,1)
 . S BSDXTMP=BSDXTMP_$S(LCNT=1:" ",1:"                       ")_$E(1000000+APCHSHRN,2,7)_"  "_APCHSFAC
 I $G(APCHSKP)]"" X APCHSCKP Q:$D(APCHSQIT)  ;SAT What is this.
 I $O(^BDPRECN("C",APCHSPAT,0)) D BDPDISP G REM
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_"DESIGNATED PROVIDER: "_APCHSPP_$C(30)
REM ;
 ;IHS/ANMC/LAB - added next 3 lines per Mosley 2/12/01
 I $P($G(^BWP(APCHSPAT,0)),U,25) S A="WOMEN'S HEALTH DESIGNATED PROVIDER" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(38-$L(A))_A_":  "_$$VAL^XBDIQ1(9002086,APCHSPAT,.25)_$C(30)
 I $P($G(^AUPNPAT(APCHSPAT,17)),U,1) S A="PRIMARY MENTAL HEALTH PROVIDER" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(38-$L(A))_A_":  "_$E($$VAL^XBDIQ1(9000001,APCHSPAT,1701),1,22)_$C(30)
 I $P($G(^AUPNPAT(APCHSPAT,17)),U,4) S A="SECONDARY MENTAL HEALTH PROVIDER" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(38-$L(A))_A_":  "_$$VAL^XBDIQ1(9000001,APCHSPAT,1704)_$C(30)
 I APCHSRE1]"" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="REMARKS: "_APCHSRE1_$C(30) I APCHSRE2]"" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="        "_APCHSRE2_$C(30)
 I $D(^BCPP(APCHSPAT)) D  ;IHS/ANMC/LAB
 .S X="BCPAPI" X ^%ZOSF("TEST") I '$T Q
 .S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 .S BSDXTMP="CHRONIC PAIN REGISTRY STATUS: "_$$VAL^XBDIQ1(90246,APCHSPAT,.02) ;IHS/ANMC/LAB - added for chronic pain registry
 .D ACTAGR^BCPAPI(.APCHAG,APCHSPAT,1) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_" "_$S(APCHAG:"Opioid Agreement",1:"No Opioid Agreement")_$C(30)
 D DSPCMSRG
DEMOGX K APCHSNAM,APCHSTR,APCHSEX,APCHSDOB,APCHSSN,APCHSMNM,APCHSCMR,APCHSEL,APCHSFP,APCHSFAC,APCHSHRN,APCHSBT,APCHSPP,APCHSADR,APCHSN,APCHSP,APCHSI,APCHSJ,APCHSHPH,APCHSOPH,APCHSVST,APCHSLUD,APCHSRE1,APCHSRE2,E,X,Y
 Q
 ;
DSPCMSRG ; DISPLAY MEMBERSHIP IN CMS REGISTER
 Q:'$D(^ACM(41,"D",APCHSPAT))
 S APCHSJ=1
 F APCHSI=0:0 S APCHSI=$O(^ACM(41,"AC",APCHSPAT,APCHSI)) Q:'APCHSI  I $P(^ACM(41.1,APCHSI,0),U,7) S BSDXTMP=APCHSJ_" ON CMS REGISTER(S): " D
 .S APCHSJ=0 S BSDXTMP=BSDXTMP_$P(^ACM(41.1,APCHSI,0),U)
 .S APCHSK=^ACM(41,"AC",APCHSPAT,APCHSI) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_"  Status: "_$$VAL^XBDIQ1(9002241,APCHSK,1)_$C(30)
 Q
 ;
AGE(DFN,D,F) ;EP - Given DFN, return Age.
 I '$G(DFN) Q -1
 I '$D(^DPT(DFN,0)) Q -1
 I $$DOB^AUPNPAT(DFN,"")<0 Q -1
 S:$G(D)="" D=DT
 S:$G(F)="" F="Y"
 NEW %
 S %=$$FMDIFF^XLFDT(D,$$DOB^AUPNPAT(DFN,""))
 S %1=%\365.25
 I F="Y" Q %1
 ;beginning Y2K fix
 ;Q $S(%1>2:%1_" YRS",%<31:%1_" DYS",1:%\30_" MOS") ;Y2000
 Q $S(%1>2:%1_" YRS",%<31:%_" DYS",1:%\30_" MOS") ;Y2000
 ;
BDPDISP ;EP - display providers from desg prov package
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="DESIGNATED PROVIDERS"_$C(30)
 S APCHSX=0 F  S APCHSX=$O(^BDPRECN("C",APCHSPAT,APCHSX)) Q:APCHSX'=+APCHSX  D
 .X APCHSCKP Q:$D(APCHSQIT)
 .;get category and check health summary status
 .S A=$P($G(^BDPRECN(APCHSX,0)),U)
 .Q:A=""
 .Q:'$D(^BDPTCAT(A,0))
 .Q:$P(^BDPTCAT(A,0),U,8)="N"
 .S A=$$VAL^XBDIQ1(90360.1,APCHSX,.01) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=A_":  "_$$VAL^XBDIQ1(90360.1,APCHSX,.03)_$C(30)
 .Q
 Q
 ;