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

BSDX41H.m

Go to the documentation of this file.
BSDX41H ; IHS/OIT/HMW/MSC/SAT - WINDOWS SCHEDULING RPCS ;
 ;;3.0;IHS WINDOWS SCHEDULING;;DEC 09, 2010
 ;
MEAS ; ******************** MEASUREMENTS * 9000010.01 *******
 ; <SETUP>
 Q:'$D(^AUPNVMSR("AA",APCHSPAT))
 X APCHSBRK
 ; <DISPLAY>
 ;X APCHSCKP Q:$D(APCHSQIT)
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 S APCHSMT="" F APCHSQ=0:0 S APCHSMT=$O(^AUPNVMSR("AA",APCHSPAT,APCHSMT)) Q:APCHSMT=""  S APCHSND2=APCHSNDM D MEASDTYP Q:$D(APCHSQIT)
 ; <CLEANUP>
MEASX K APCHSMT,APCHSMT2,APCHSMT3,APCHSDFN,APCHSND2,APCHSDAT
 Q
MEASDTYP S APCHSMT2=$S($D(^AUTTMSR(APCHSMT,0)):$P(^(0),U,1),1:APCHSMT) S APCHSMT3=APCHSMT2
 S (APCHSIVD,APCHSDFN)="" F  S APCHSIVD=$O(^AUPNVMSR("AA",APCHSPAT,APCHSMT,APCHSIVD)) Q:APCHSIVD=""!(APCHSIVD>APCHSDLM)  S APCHSND2=APCHSND2-1 Q:APCHSND2=-1  D MEASDSP
 I APCHSMT3="" D
 . ;X APCHSCKP Q:$D(APCHSQIT)
 . S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 Q
MEASDSP S APCHSDFN=$O(^AUPNVMSR("AA",APCHSPAT,APCHSMT,APCHSIVD,"")),Y=-APCHSIVD\1+9999999
 X APCHSCVD
 S APCHSDAT=Y
 ;X APCHSCKP Q:$D(APCHSQIT)
 S:APCHSNPG!(APCHSMT3]"") BSDXTMP=APCHSMT2
 S APCHSMT3=""
 S BSDXTMP=BSDXTMP_$$FILL^BSDX41(5-$L(BSDXTMP))_APCHSDAT
 S BSDXTMP=BSDXTMP_$$FILL^BSDX541(18-$L(BSDXTMP))_$P(^AUPNVMSR(APCHSDFN,0),U,4)
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_$C(30)
 Q
 ;
IMMUN ; ******************** IMMUNIZATIONS * 9000010.11 *******
 I +$$VER^BILOGO>7.1 D IMMBI2,REF Q  ;IHS/CMI/MWR  8/19/03, for Immunization v8.x
 I $$BI^APCHS11C D IMMBI,REF Q  ;IHS/CMI/LAB - new imm package
 ; <SETUP>
 Q:'$D(^AUPNVIMM("AA",APCHSPAT))
 ;X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 ; <DISPLAY>
 S APCHSITP="" F APCHSQ=0:0 S APCHSITP=$O(^AUPNVIMM("AA",APCHSPAT,APCHSITP)) Q:APCHSITP=""  D IMMDTYP
 ; <CLEANUP>
REF ; display refusals/contraindications from imm package and from PCC
  S APCHY=0 F  S APCHY=$O(^BIPC("AC",APCHSPAT,APCHY)) Q:APCHY'=+APCHY  D
 .S APCHX=0 F  S APCHX=$O(^BIPC("AC",APCHSPAT,APCHY,APCHX)) Q:APCHX'=+APCHX  D
 ..S R=$P(^BIPC(APCHX,0),U,3)
 ..Q:R=""
 ..Q:'$D(^BICONT(R,0))
 ..Q:$P(^BICONT(R,0),U,1)'["Refusal"
 ..S D=$P(^BIPC(APCHX,0),U,4)
 ..Q:D=""
 ..S D=9999999-D
 ..Q:D>APCHSDLM
 ..;X APCHSCKP Q:$D(APCHSQIT)
 ..S BSDXTMP=$$VAL^XBDIQ1(9002084.11,APCHX,.02)_" -- "_$$VAL^XBDIQ1(9002084.11,APCHX,.03)
 ..S BSDXTMP=BSDXTMP_$$FILL^BSDX41(60-$L(BSDXTMP))_"("_$$DATE^APCHSMU($P(^BIPC(APCHX,0),U,4))_")"
 ..S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_$C(30)
 ..Q
 .Q
 S APCHSFN=9999999.14,APCHST="" D DISPREF^BSDX41F
 K APCHSFN,APCHST,APCHSS
IMMUNX K APCHSITP,APCHSITX,APCHSITL,APCHSDFN,APCHSDAT,APCHSIVD,APCHSVDF
 K APCHSIMC,APCHSIMR,APCHSN,APCHSIC,APCHSIR
 K APCHSNFL,APCHSNSH,APCHSNAB,APCHSVSC,APCHSITE
 Q
IMMDTYP S APCHSITX=$P(^AUTTIMM(APCHSITP,0),U,2),APCHSITL=$L(APCHSITX)
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 ;X APCHSCKP Q:$D(APCHSQIT)
 S BSDXTMP=APCHSITX S APCHSIVD="" F APCHSQ=0:0 S APCHSIVD=$O(^AUPNVIMM("AA",APCHSPAT,APCHSITP,APCHSIVD)) Q:'APCHSIVD  D IMMDSP
 Q
IMMDSP S APCHSDFN=0 F APCHSQ=0:0 S APCHSDFN=$O(^AUPNVIMM("AA",APCHSPAT,APCHSITP,APCHSIVD,APCHSDFN)) Q:APCHSDFN=""  D IMMDSP2
 Q
IMMDSP2 S Y=-APCHSIVD\1+9999999 X APCHSCVD S APCHSDAT=Y
 S APCHSN=^AUPNVIMM(APCHSDFN,0)
 S APCHSVDF=$P(APCHSN,U,3) D GETSITEV^APCHSUTL S APCHSITE=APCHSNSH
 S X=$P(APCHSN,U,6),Y=.06 D IMMGSET S APCHSIR=APCHSP
 S X=$P(APCHSN,U,7),Y=.07 D IMMGSET S APCHSIC=APCHSP S:APCHSIC]"" APCHSIC="DO NOT REPEAT"
 I APCHSIC]"",APCHSIR]"" S APCHSIR=APCHSIR_"; "
 S APCHSIR=APCHSIR_APCHSIC
 ;modified following line - LAB
 ;X APCHSCKP Q:$D(APCHSQIT)
 S:APCHSNPG BSDXTMP=APCHSITX
 S BSDXTMP=BSDXTMP_$$FILL^BSDX41((APCHSITL+1)-$L(BSDXTMP))_$P(^AUPNVIMM(APCHSDFN,0),U,4)
 S BSDXTMP=BSDXTMP_$$FILL^BSDX41(15-$L(BSDXTMP))_APCHSDAT
 S BSDXTMP=BSDXTMP_$$FILL^BSDX41(25-$L(BSDXTMP))_$$AGE(APCHSPAT,$P(+^AUPNVSIT(APCHSVDF,0),"."),"P")
 S BSDXTMP=BSDXTMP_$$FILL^BSDX41(34-$L(BSDXTMP))_APCHSITE
 S BSDXTMP=BSDXTMP_$$FILL^BSDX41(65-$L(BSDXTMP))_APCHSIR
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_$C(30)
 Q
IMMGSET S Y=$G(^DD(9000010.11,Y,0)),Y=$P(Y,U,3)
 S:'X Y=""
 F APCHSQ=1:1 S APCHSP=$P(Y,";",APCHSQ) Q:APCHSP=""  I $P(APCHSP,":",1)=X S APCHSP=$P(APCHSP,":",2) Q
 Q
 ;
 ;-----------
AGE(DFN,D,F) ;(DFN) Given DFN, return Age. ; AUPN*93.2*3
 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))
 I F="Y" Q %\365.25
 ;beginning Y2K
 ;NEW %1 S %1=%\365.25,%=$S(%1>2:%1_" YRS",%<31:%1_" DYS",1:%\30_" MOS") ;Y2000
 NEW %1 S %1=%\365.25,%=$S(%1>2:%1_" YRS",%<31:%_" DYS",1:%\30_" MOS") ;Y2000
 ;end Y2000
 Q %
 ;
 ;
IMMBI ;IHS/CMI/LAB - new subroutine for new imm package
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 ;
 ;
 ;
 NEW APCH31,APCHIMM,APCHBIER
 S APCH31=$C(31)_$C(31),APCHIMM=""
 D IMMFORC^BIRPC(.APCHIMM,APCHSPAT)
 ;
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="  "_"IMMUNIZATION FORECAST:"_$C(30)
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 ;
 S APCH31="||"
 D
 .;---> Check for error in 2nd piece of return value.
 .S APCHBIER=$P(APCHIMM,APCH31,2)
 .;---> If there's an error, display it and quit.
 .I APCHBIER]"" Q
 .;
 .;---> No error, so take 1st piece of return value and process it.
 .S APCHIMM=$P(APCHIMM,APCH31,1)
 .;
 .NEW APCHX,APCHI F APCHX=1:1 S APCHI=$P(APCHIMM,"^",APCHX) Q:APCHI=""!($D(APCHSQIT))  D
 ..;X APCHSCKP Q:$D(APCHSQIT)
 ..S BSDXTMP="  "_$P(APCHI,"|")
 ..S BSDXTMP=BSDXTMP_$$FILL^BSDX41(23-$L(BSDXTMP))_$P(APCHI,"|",2)
 ..S BSDXTMP=BSDXTMP_$$FILL^BSDX41(36-$L(BSDXTMP))_$P(APCHI,"|",3)
 ..S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_$C(30)
 ..Q
 ;
CONTRAS ;
 ;
 N APCHCONT S APCHCONT=""
 ;
 ;---> RPC to retrieve Contraindications.
 D CONTRAS^BIRPC5(.APCHCONT,APCHSPAT)
 ;
 S APCH31="||"
 ;---> If APCHBIER has a value, display it and quit.
 S APCHBIER=$P(APCHCONT,APCH31,2)
 I APCHBIER]"" D
 .;X APCHSCKP Q:$D(APCHSQIT)
 .;D EN^DDIOL("* "_APCHBIER,"","!!?5")
 .G HX
 ;
 ;---> Set APCHC=to a string of Contraindications for this patient.
 N APCHC S APCHC=$P(APCHCONT,APCH31,1)
 I APCHC]"" D
 .;X APCHSCKP Q:$D(APCHSQIT)
 .S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 ;
 ;---> Build Listmanager array from APCHC string.
 ;
 F I=1:1 S Y=$P(APCHC,U,I) Q:Y=""  D
 .;---> Build display line for this Contraindication.
 .N V S V="|",X="      "
 .S:I=1 X=X_"* Contraindications:" S X=$$PAD(X,28)
 .;
 .;---> Display "Vaccine:  Date  Reason"
 .S X=X_$P(Y,V,2)_":",X=$$PAD(X,40)_$P(Y,V,4)
 .S X=$$PAD(X,53)_$P(Y,V,3)
 .;---> Set formatted Contraindication line and index in ^TMP.
 .;X APCHSCKP Q:$D(APCHSQIT)
 .S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=X_$C(30)
 .Q
 ;
 ;
 ;
HX ;
 NEW APCHBIDE,I F I=8,26,27,60,33,44,57 S APCHBIDE(I)=""
 ;call to get imm hx
 D IMMHX^BIRPC(.APCHIMM,APCHSPAT,.APCHBIDE,,0)
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="  "_"IMMUNIZATION HISTORY:"_$C(30)
 ;
 S APCH31="||"
 S APCHBIER=$P(APCHIMM,APCH31,2)
 I APCHBIER]"" Q  ;X APCHSCKP Q:$D(APCHSQIT)  D EN^DDIOL("* "_APCHBIER,"","!!?5") Q
 S APCHIMM=$P(APCHIMM,APCH31,1)
 NEW APCHI,APCHV,APCHX,APCHY,APCHZ
 S APCHZ="",APCHV="|"
 F APCHI=1:1 S APCHY=$P(APCHIMM,U,APCHI) Q:APCHY=""!($D(APCHSQIT))  D
 .Q:$P(APCHY,APCHV)'="I"
 .I $P(APCHY,APCHV,4)'=APCHZ D
 ..;X APCHSCKP Q:$D(APCHSQIT)
 ..S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 ..S APCHZ=$P(APCHY,APCHV,4)
 .NEW X,APCHSDG K %DT S X=$P(APCHY,APCHV,8),%DT="P" D ^%DT S APCHSDG=Y
 .;X APCHSCKP Q:$D(APCHSQIT)
 .S BSDXTMP="  "_$P(APCHY,APCHV,2)
 .S BSDXTMP=BSDXTMP_$$FILL^BSDX41(22-$L(BSDXTMP))_$P(APCHY,APCHV,8)
 .S BSDXTMP=BSDXTMP_$$FILL^BSDX41(34-$L(BSDXTMP))_$$AGE(APCHSPAT,APCHSDG,"P")
 .S BSDXTMP=BSDXTMP_$$FILL^BSDX41(45-$L(BSDXTMP))_$E($P(APCHY,APCHV,3),1,20)
 .S BSDXTMP=BSDXTMP_$$FILL^BSDX41(66-$L(BSDXTMP))_$P(APCHY,APCHV,5)
 .S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_$C(30)
 .I $P(APCHY,APCHV,6)]"" S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(21)_"Reaction: "_$P(APCHY,APCHV,6)_$C(30)
 .Q
 ;----------
 K APCHIMM,APCHY,APCHV,APCHBIDE,APCHZ
 Q
 ;
 ;
 ;----------
PAD(D,L,C) ;EP
 ;---> Pad the length of data to a total of L characters
 ;---> by adding spaces to the end of the data.
 ;     Example: S X=$$PAD("MIKE",7)  X="MIKE   " (Added 3 spaces.)
 ;---> Parameters:
 ;     1 - D  (req) Data to be padded.
 ;     2 - L  (req) Total length of resulting data.
 ;     3 - C  (opt) Character to pad with (default=space).
 ;
 Q:'$D(D) ""
 S:'$G(L) L=$L(D)
 S:$G(C)="" C=" "
 Q $E(D_$$REPEAT^XLFSTR(C,L),1,L)
 ;
 ;
 ;----------
IMMBI2 ;EP
 ;---> Call to Immunization Package v8.x to build local array of formatted
 ;---> lines for Imm Health Summary Component.  ;IHS/CMI/MWR 8/19/03
 ;---> Mike Remillard
 ;
 ;X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 N APCHSARR S APCHSARR=""
 D IMMBI^BIAPCHS(APCHSPAT,.APCHSARR)
 ;first find out if VARICELLA is forecasted
 N N,F S N=0,F=0
 NEW F S (F,N)=0 F  S N=$O(APCHSARR(N)) Q:'N  D
 .Q:APCHSARR(N,0)["IMMUNIZATION HISTORY:"
 .I APCHSARR(N,0)["VARICELLA" S F=1  ;varicella forecast as due
 .Q
 S N=0
 F  S N=$O(APCHSARR(N)) Q:'N  D  ;X APCHSCKP Q:$D(APCHSQIT)
 .I APCHSARR(N,0)["IMMUNIZATION HISTORY" D
 ..I F S X=$$PHCP(APCHSPAT) I X]"" D
 ...S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 ...S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="Patient has a Hx of chicken pox not yet entered as a contraindication"_$C(30)
 ...S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="in the Immunization Package."_$C(30)
 ...S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=X_$C(30)
 ...S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 .S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=APCHSARR(N,0)_$C(30)
 D KILLALL^BIUTL8()
 Q
PHCP(P) ;EP
 ;is there a personal history of chicken pox or is chicken pox on the problem list
 NEW X,Y,Z,I,G
 S G="",X=0 F  S X=$O(^AUPNPH("AC",P,X)) Q:X'=+X!(G)  D
 .Q:'$D(^AUPNPH(X,0))
 .S I=$P(^AUPNPH(X,0),U)
 .Q:I=""
 .;S I=$P($G(^ICD9(I,0)),U)  ;cmi/anch/maw 8/28/2007 orig line
 .S I=$P($$ICDDX^ICDCODE(I),U,2)  ;cmi/anch/maw 8/28/2007 code set versioning
 .Q:$E(I,1,3)'="052"
 .S G=X
 .Q
 I G Q "Personal History: "_I_" - "_$$VAL^XBDIQ1(9000013,G,.04)
 ;now check problem list
 S X=0 F  S X=$O(^AUPNPH("AC",P,X)) Q:X'=+X!(G)  D
 .Q:'$D(^AUPNPH(X,0))
 .S I=$P(^AUPNPH(X,0),U)
 .Q:I=""
 .S I=$P($G(^ICD9(I,0)),U)
 .Q:$E(I,1,3)'="052"
 .S G=X
 .Q
 I G Q "Problem List: "_I_" - "_$$VAL^XBDIQ1(9000011,G,.05)
 Q ""