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

BSDX41C.m

Go to the documentation of this file.
BSDX41C ; IHS/OIT/HMW/MSC/SAT - WINDOWS SCHEDULING RPCS ;
 ;;3.0;IHS WINDOWS SCHEDULING;;DEC 09, 2010
 ;                 
ALLRG ;EP; -- call to adverse reation/allergy component
 NEW APCHGMTS,GMTSNPG,GMTSLPG,GMTSLO,GMTSTYP
 NEW GMTSE,GMTSEGH,GMTSEGL,GMTSEGN,GMTSSC,GMTSDTM
 NEW GMTS,GMTSLCMP  ;variables not set here but left over after call
 S DFN=APCHSPAT,APCHGMTS=1
 S GMTSNPG=0,GMTSLPG=0,GMTSLO=3,GMTSTYP=0
 S GMTSE=1,GMTSEGH="***** ADVERSE REACTIONS/ALLERGIES *****"
 S GMTSSC="",GMTSDTM="",GMTSEGL="",GMTSEGN=1
 D ALLRG1
 Q
 ;
 ; External References
 ;   DBIA 10096  ^%ZOSF("TEST"
 ;   DBIA 10035  ^DPT(
 ;   DBIA   905  ^GMR(120.8
 ;   DBIA  2056  $$GET1^DIQ (file #120.86 and #200)
 ;   DBIA 10011  ^DIWP
 ;   DBIA 10099  EN1^GMRADPT 
 ;   DBIA 10060  ^VA(200,
 ;   DBIA  3449  ^GMR(120.86,
 ;                   
ALLRG1 ; Allergies
 N X,GMTSALAS,GMTSALAD,GMTSALAW,GMTSALAT,GMTSAV,GMTSAFN,GMRAL,GMTSAL
 N GMTSALNM,GMTSCNT,GMTSEACT,GMTSLN,GMTSMECH,GMTSPRT,GMTSTY,CC,C,KK
 N ALLRG,TITLE,JJ K GMTSA S (SEQ,ALLRG)=0,TITLE="ALLERGY/ADVERSE REACTION (AR)"
 S X="GMRADPT" X ^%ZOSF("TEST")
 I $T D  Q:$D(GMTSQIT)
 . D GETALLRG D:ALLRG TITLE,ALLRGP D:'ALLRG&($L($G(GMTSALAS))) TITLE,NKA
 I 'ALLRG,'$L($G(GMTSALAS)) D
 . I $D(GMTSPNF)&('ALLRG) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)="Unknown, please evaluate"_$C(30)
 K ALL,CC,CCC,CD,DIWF,DIWL,DIWR,GMTSALF,GMTSALNM,GMTSNODE,GMTSPRT,I,II,JJ,KK,L,M,MX,N,Z,X,SEQ,GMTSA,ALLRG,TITLE,GMRA,GMRAL,GMTSEACT,GMTSMECH,GMTSTY,GMTSPFN,GMTSAL,GMTSCNT,GMTSLN,ODT
 Q
ALLRGP ; Allergy Print
 S II="" F  S II=$O(GMTSAL(II)) Q:II']""  I $O(GMTSAL(II,""))]"" D
 . S BSDXI=BSDXI+1
 . S ^BSDXTMP($J,BSDXI)=""_$C(30) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=" "_$S(II="D":"Drug:",II="DF":"Drug/Food:",II="DFO":"Drug/Food/Other:",II="DO":"Drug/Other:",II="F":"Food:",II="FO":"Food/Other:",II="O":"Other:",1:II_":")_$C(30)
 . S JJ="" F  S JJ=$O(GMTSAL(II,JJ)) Q:JJ=""  D
 .. N WKK S KK=""  F  S KK=$O(GMTSAL(II,JJ,KK)) Q:KK=""  D
 ... S L=0 F  S L=$O(GMTSAL(II,JJ,KK,L)) Q:'L  S BSDXTMP="    "_JJ_": " S:$L(KK)>30 WKK=KK,WKK=$$WRAP^GMTSORC(WKK,30) S BSDXTMP=BSDXTMP_$$FILL^BSDX41(24-$L(BSDXTMP))_$S($L(KK)>30:$P(WKK,"|"),1:KK) D
 .... I $G(GMTSAV)=1 S BSDXTMP=BSDXTMP_" (AV"
 .... E  S BSDXTMP=BSDXTMP_$S($P(GMTSAL(II,JJ,KK,L),U,5)=1:" (V",$P(GMTSAL(II,JJ,KK,L),U,5)=0:" (NV",1:"")
 .... S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_$S($G(GMTSALNM)="":")",$P($G(^GMR(120.8,GMTSALNM,0)),U,6)="h":"/Historical)",$P($G(^(0)),U,6)="o":"/Observed)",1:")")_$C(30)
 .... I $L($P($G(WKK),"|",2)) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$P(WKK,"|",2)_$C(30)
 .... S (M,MX,ALL)=0 F  S M=$O(GMTSAL(II,JJ,KK,L,"S",M)) Q:M=""  D  Q:$D(GMTSQIT)
 ..... I ALL=0 S BSDXTMP=$$FILL^BSDX41(26)
 ..... S MX=MX+1
 ..... I MX>1 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_", "_$C(30)
 ..... S N=$P(GMTSAL(II,JJ,KK,L,"S",M),";")
 ..... S ALL=1 I (74)'>($X+$L(N)) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=N_$C(30) Q
 ..... S ALL=1 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=N_$C(30)
 .... D SIGBLK($P($G(GMTSAFN),U,5))
 .... S BSDXTMP=$$FILL^BSDX41(23)_"Date/Time:  " S ODT=$P($G(GMTSAFN),U,4) S X=ODT D REGDTM4^GMTSU S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_X_$C(30)
 ....I $G(GMTSALNM)'="" S CC="" F  S CC=$O(^GMR(120.8,GMTSALNM,26,"B",CC)) Q:CC=""  S BSDXTMP=$$FILL^BSDXTMP(23)_"Comments at: " S X=CC D REGDTM4^GMTSU S CD=X S CCC=0 F  S CCC=$O(^GMR(120.8,$G(GMTSALNM),26,"B",CC,CCC)) Q:'CCC  D TEXT
 Q
NKA ; No known allergies
 I $L($G(GMTSALAS))!($L($G(GMTSALAD))) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 I $L($G(GMTSALAS)) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(21)_$G(GMTSALAS)_$C(30)
 I $L($G(GMTSALAS))!($L($G(GMTSALAD)))!($L($G(GMTSALAW))) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(23)_"Assessment date:   "_$G(GMTSALAD)_$C(30)
 I $L($G(GMTSALAW)) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(27)_"Assessed by:   "_GMTSALAW_$C(30)
 I $L($G(GMTSALAW))&($L($G(GMTSALAT))) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(33)_"Title:   "_GMTSALAT_$C(30)
 Q
GETALLRG ; Get Allergies
 S GMRA="0^0^111" D EN1^GMRADPT I GMRAL="" S ALLRG=0 Q
 I +($G(DFN))>0,+($G(GMRAL))=0 D ALLAS S ALLRG=0 Q
 I $D(GMRAL)>9 D
 . S I=0 F GMTSCNT=1:1 S I=$O(GMRAL(I)) Q:'I  D
 .. S GMTSTY=$P(GMRAL(I),U,7) Q:GMTSTY']""
 .. S GMTSEACT=$P(GMRAL(I),U,2) Q:GMTSEACT']""
 .. S GMTSMECH=$P($P(GMRAL(I),U,8),";")
 .. S:GMTSMECH']"" GMTSMECH="UNKNOWN"
 .. S GMTSAL(GMTSTY,GMTSMECH,GMTSEACT,GMTSCNT)=I_"^"_GMRAL(I)
 .. S JJ=0 F  S JJ=$O(GMRAL(I,"S",JJ)) Q:'JJ  S GMTSAL(GMTSTY,GMTSMECH,GMTSEACT,GMTSCNT,"S",JJ)=GMRAL(I,"S",JJ)
 .. S ALLRG=1
 Q
ALLAS ; Allergy Assessment
 N X,GMTSALG1,GMTSALG2,GMTSALG3,GMTSAU S (GMTSALAS,GMTSALAD,GMTSALAW)="" S GMTSALAS="No known allergies"
 S GMTSALAD=$$GET1^DIQ(120.86,+($G(DFN)),3,"I",,"GMTSALG2") S:$D(GMTSALG2) GMTSALAD="" S:+GMTSALAD=0 GMTSALAD=""
 I +GMTSALAD>0 S X=GMTSALAD D REGDT4^GMTSU S GMTSALAD=X
 S GMTSAU=$$GET1^DIQ(120.86,+($G(DFN)),2,"I")
 S GMTSALAW=$$GET1^DIQ(200,(+GMTSAU_","),.01,"E",,"GMTSALG3")
 S GMTSALAT=$$GET1^DIQ(200,(+GMTSAU_","),20.3)
 S:$D(GMTSALG3) (GMTSALAW,GMTSALAT)=""
 Q
AUTOV ; Autoverify
 S GMTSAV=0,GMTSALNM=$P(GMTSAL(II,JJ,KK,L),U),GMTSAFN=$G(^GMR(120.8,GMTSALNM,0))
 I $P(GMTSAFN,U,18)="",$P(GMTSAFN,U,16)=1 S GMTSAV=1
 Q
TITLE ; Print title
 D CKP^GMTSUP Q:$D(GMTSQIT)
 I $D(GMTSPNF) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(20)_TITLE_$C(30)
 E  S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(20)_"Title: "_TITLE_$C(30)
 Q
TEXT ; Setup for print of allergy comments
 S BSDXTMP=BSDXTMP_$$FILL^BSDX41(30-$L(BSDXTMP))_CD Q:$D(GMTSQIT)
 K ^UTILITY($J,"W") S GMTSLN=0 F  S GMTSLN=$O(^GMR(120.8,GMTSALNM,26,CCC,2,GMTSLN)) Q:'GMTSLN  S GMTSPRT=^GMR(120.8,GMTSALNM,26,CCC,2,GMTSLN,0) D FORMAT
 I $D(^UTILITY($J,"W")) F GMTSLN=1:1:^UTILITY($J,"W",DIWL) D LINE Q:$D(GMTSQIT)
 K ^UTILITY($J,"W")
 Q:'GMTSLN
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXTMP_$C(30)
 Q
FORMAT ; Formats each line
 S DIWL=3,DIWR=80,DIWF="C58",X=GMTSPRT D ^DIWP
 Q
LINE ; Writes formatted lines of text
 Q:$D(GMTSQIT)  S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(23)_^UTILITY($J,"W",DIWL,GMTSLN,0)_$C(30)
 Q
SIGBLK(GMTSALF) ; Signature block
 Q:+GMTSALF'>0  N GMTSSB,GMTSST,GMTSSN S GMTSSB=$$GET1^DIQ(200,(+GMTSALF_","),20.2),GMTSST=$$GET1^DIQ(200,(+GMTSALF_","),20.3),GMTSSN=$$GET1^DIQ(200,(+GMTSALF_","),.01)
 S BSDXDSP=$C(10,13)_$C(10,13)_$$FILL^BSDX41(23)_"Originator: "_$S(GMTSSB'="":GMTSSB,1:GMTSSN)
 I $L(GMTSST) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30) S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$$FILL^BSDX41(23)_"Title:      "_GMTSST_$C(30)
 Q
 ;
PROBA ; ************ ALLERGY PROB * 9000011 *********
 ; for PROBLEM LIST codes only!
 I '$D(^AUPNPROB("AC",APCHSPAT)) X APCHSCKP G:$D(APCHSQIT) PROBAX I 'APCHSNPG S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30) X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30) D PROBADNR Q
 K APCHSPT S (APCHSFND,APCHSLEN)=0
 S APCHSDFN="" F APCHSQ=0:0 S APCHSDFN=$O(^AUPNPROB("AC",APCHSPAT,APCHSDFN)) Q:'APCHSDFN  D PROBASCH
 X APCHSCKP G:$D(APCHSQIT) PROBAX I 'APCHSNPG S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30) X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=$C(30)
 I 'APCHSFND D PROBADNR G PROBAX
 S APCHSDFN="" F APCHSQ=0:0 S APCHSDFN=$O(APCHSPT(APCHSDFN)) Q:'APCHSDFN  D PROBADSP
PROBAX K APCHSPT,APCHSFND,APCHSDFN,APCHSLEN,APCHSDAT,APCHSNKA
 Q
 ;
PROBASCH ;active problem search
 ;S APCHSP=$P(^ICD9(+^AUPNPROB(APCHSDFN,0),0),U,1) D PROBACHK I  D PROBALLG  cmi/anch/maw 8/27/2007 orig line
 S APCHSP=$P($$ICDDX^ICDCODE(+^AUPNPROB(APCHSDFN,0),0),U,2) D PROBACHK I  D PROBALLG  ;cmi/anch/maw 8/27/2007 code set versioning
 Q
PROBACHK ;checking for allergy codes
 Q:$P(^AUPNPROB(APCHSDFN,0),U,5)=""  ;IHS/CMI/LAB - no narr
 S APCHSNKA=0
 I APCHSP="692.3" Q
 I APCHSP="693.0" Q
 I APCHSP="995.0" Q
 I APCHSP="995.2" Q
 I (+APCHSP'<999.4),(+APCHSP'>999.89) Q
 I APCHSP?1"V14."1E Q
 I APCHSP="692.5" Q
 I APCHSP="693.1" Q
 ;I APCHSP="V15.0" Q
 I APCHSP["V15.0" Q
 I $E(APCHSP,1,3)=692,APCHSP'="692.9" Q
 I APCHSP="693.8" Q
 I APCHSP="693.9" Q
 I APCHSP="989.5" Q
 I APCHSP="989.82" Q
 I APCHSP="995.3" Q
 I APCHSP["995.2" Q
 S N=$P(^AUTNPOV($P(^AUPNPROB(APCHSDFN,0),U,5),0),U) I APCHSP="799.9"!(APCHSP="V82.9"),N["NO KNOWN ALLERG"!(N["NKA")!(N["NKDA")!(N["NO KNOWN DRUG ALLERG") S APCHSNKA=1 Q
 ;I APCHSP="799.9",$P(^AUTNPOV($P(^AUPNPROB(APCHSDFN,0),U,5),0),U,1)["NO KNOWN ALLERG"!($P(^AUTNPOV($P(^AUPNPROB(APCHSDFN,0),U,5),0),U,1)["NKA")!($P(^AUTNPOV($P(^AUPNPROB(APCHSDFN,0),U,5),0),U)["NKDA") S APCHSNKA=1 Q
 Q
 ;
PROBADSP ;display allergies
 S:$L(APCHSPT(APCHSDFN))<APCHSLEN APCHSL1=$L(APCHSPT(APCHSDFN))/2,APCHSL1=(APCHSLEN/2)-APCHSL1 ;                       center recorded allergies
 S BSDXDSP=$$FILL^BSDX41((IOM-APCHSLEN-12)/2)_"***** "
 S BSDXDSP=BSDXDSP_$$FILL^BSDX41(((IOM-APCHSLEN)/2)-$L(BSDXDSP))_+$G(APCHSL1)_APCHSPT(APCHSDFN)
 S BSDXDSP=BSDXDSP_$$FILL^BSDX41(((IOM+APCHSLEN)/2))_" *****"
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXDSP_$C(30)
 K APCHSL1
 Q
 ;
PROBADNR ;display "NONE RECORDED", if no allergies recorded
 S BSDXDSP=$$FILL^BSDX41((IOM-13-12)/2)_"***** "
 S BSDXDSP=BSDXDSP_$$FILL^BSDX41(((IOM-13)/2)-$L(BSDXDSP))_"NONE RECORDED"
 S BSDXDSP=BSDXDSP_$$FILL^BSDX41(((IOM+13)/2)-$L(BSDXDSP))_" *****"
 S BSDXI=BSDXI+1 S ^BSDXTMP($J,BSDXI)=BSDXDSP_$C(30)
 Q
 ;
PROBALLG ;if allergy
 S APCHSFND=1
 I APCHSNKA D  I 1
 . S Y=$P(^AUPNPROB(APCHSDFN,0),U,8) X APCHSCVD S APCHSDAT=Y
 . S APCHSPT(APCHSDFN)="NO ALLERGY NOTED ON "_APCHSDAT
 . S:$L($P(APCHSPT(APCHSDFN),U))>APCHSLEN APCHSLEN=$L($P(APCHSPT(APCHSDFN),U))
 . Q
 E  D
 . ;Q:$P(^AUPNPROB(APCHSDFN,0),U,5)=""  ;IHS/CMI/LAB - added this to prevent subscript
 . S APCHSPT(APCHSDFN)=$P(^AUTNPOV(+$P(^AUPNPROB(APCHSDFN,0),U,5),0),U,1)
 . I APCHSPT(APCHSDFN)="" S APCHSPT(APCHSDFN)="???"
 . S:$L(APCHSPT(APCHSDFN))>APCHSLEN APCHSLEN=$L(APCHSPT(APCHSDFN))
 . Q
 Q
 ;