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

BHSAPRO.m

Go to the documentation of this file.
BHSAPRO ;IHS/CIA/MGH - Health Summary for Medication Profile ;17-Mar-2006 10:36;MGH
 ;;1.0;HEALTH SUMMARY COMPONENTS;;March 17, 2006
 ;===================================================================
 ;VA Health summary format of IHS health summary component action profiles
 ;Taken from AZOPCS7
 ;IHS/OHPRD/VJM - PART 7 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ; [ 01/23/98  9:01 AM ]
 ;;1.9;PCC HEALTH SUMMARY;*2*;APR 18, 1995
 ;
 ; IHS/OHPRD/LAB changed this routine to accomodate 4 medication
 ; summary types 11-15-94  patch 2
 ;
MEDSCURR ; ************** CURRENT MEDICATIONS * 9000010.14 ********
 S BHSMTY="CURR" G CONT
MEDSALL ; **************** ALL MEDICATIONS * 9000010.14 **********
 S BHSMTY="ALL" G CONT
MEDSCHRN ; ************* CHRONIC MEDCICATIONS ************
 S BHSMTY="CHRONIC" G CONT
MEDSNDUP ; ************* ALL, NON DUPLICATED *************
 S BHSMTY="NODUP" G CONT
 ;
CONT ; <SETUP>
 N BHSPAT,BHSQ
 S BHSPAT=DFN
 I GMTSDLM=9999999 S X1=DT,X2=-365 D C^%DTC S GMTSDLM=9999999-X K X1,X2
 Q:'$D(^AUPNVMED("AC",BHSPAT))
 D CKP^GMTSUP Q:$D(GMTSQIT)  I 'GMTSNPG W ! D CKP^GMTSUP
 ; <BUILD>
 K ^TMP($J,"BHSMTB"),^TMP($J,"BHSMTP")
 S BHSIVD=0 F BHSQ=0:0 S BHSIVD=$O(^AUPNVMED("AA",BHSPAT,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM)  S BHSMX=0 F BHSQ=0:0 S BHSMX=$O(^AUPNVMED("AA",BHSPAT,BHSIVD,BHSMX)) Q:BHSMX=""  D MEDBLD
 ; <DISPLAY>
 S BHSIVD=0 F BHSQ=0:0 S BHSIVD=$O(^TMP($J,"BHSMTP",BHSIVD)) Q:'BHSIVD  D MEDDSP
 ; <CLEANUP>
MEDX K BHSIVD,BHSMX,BHSMFX,BHSQTY,BHSIG,BHSSGY,BHSEXP,BHSMTS,BHSMED,BHSDTM,BHSDAT,BHSDYS,BHSN,BHSDC,BHSVDF,BHSP
 K BHSNFL,BHSNSH,BHSNAB,BHSVSC,BHSITE,BHSRX,BHSDRG,BHSCRN,BHSREF,BHSRFL,BHSALL,BHSTXT,BHSMTY,BHSNARC
 K ^TMP($J,"BHSMTB"),^TMP($J,"BHSMTP")
 K X1,X2,X,Y
 K BHSRTN ;IHS/OKCAO/POC 12/19/97
 Q
MEDBLD ;
 ;
 ;BUILD ARRAY OF MEDICATIONS
 ;BHSDC=DATE DISCONTINUED,DYS=DAYS PRESCRIBED,SIG=DIRECTIONS
 ;VDF=VISIT FILE DATE
 S BHSN=^AUPNVMED(BHSMX,0)
 Q:'$D(^PSDRUG($P(BHSN,U,1)))
 S BHSDTM=-BHSIVD\1+9999999
 S BHSDC=$P(BHSN,U,8),BHSDYS=$P(BHSN,U,7),BHSMFX=$S($P(BHSN,U,4)="":+BHSN,1:$P(BHSN,U,4)) ;XXXXXXXX
 S:BHSDYS="" BHSDYS=30
 ;SCREENS OUT MEDS NOT CURRENT; BHSALL FORCES INCLUSION OF ALL MED
 D @BHSMTY
 Q
 ;
CURR ; current meds only
 I $D(^TMP($J,"BHSMTB",BHSMFX)),^TMP($J,"BHSMTB",BHSMFX)="" Q
 S X1=DT,X2=BHSDTM D ^%DTC Q:X>60&(X>(2*BHSDYS))
 S ^TMP($J,"BHSMTB",BHSMFX)=BHSDC,^TMP($J,"BHSMTP",BHSIVD_"-"_BHSMFX)=BHSMX
 Q
ALL ;all meds included
 S ^TMP($J,"BHSMTB",BHSMFX)=BHSDC,^TMP($J,"BHSMTP",BHSIVD_"-"_BHSMFX)=BHSMX
 ;
 Q
NODUP ;
 I $D(^TMP($J,"BHSMTB",BHSMFX)) Q
 S ^TMP($J,"BHSMTB",BHSMFX)=BHSDC,^TMP($J,"BHSMTP",BHSIVD_"-"_BHSMFX)=BHSMX
 Q
CHRONIC ;chronic meds only
 I $D(^TMP($J,"BHSMTB",BHSMFX)) Q
 S X=$S($D(^PSRX("APCC",BHSMX)):$O(^(BHSMX,0)),1:0)
 S Y=$S(+X:$D(^PS(55,BHSPAT,"P","CP",X)),1:0)
 Q:'Y
 S ^TMP($J,"BHSMTB",BHSMFX)=BHSDC,^TMP($J,"BHSMTP",BHSIVD_"-"_BHSMFX)=BHSMX
 Q
MEDDSP ;
 ;
 ;DISPLAY MEDICATION
 ;BHSRX=RX# in FILE 52,CHRN=CHRONIC FLAG,REF=#REFILLS
 S BHSMX=^TMP($J,"BHSMTP",BHSIVD)
 S BHSN=^AUPNVMED(BHSMX,0)
 S BHSRX=$S($D(^PSRX("APCC",BHSMX)):$O(^(BHSMX,0)),1:0)
 S BHSCRN=$S(+BHSRX:$D(^PS(55,BHSPAT,"P","CP",BHSRX)),1:0)
 S (X,BHSDTM)=-BHSIVD\1+9999999 D REGDT4^GMTSU S BHSDAT=X
 S BHSDC=$P(BHSN,U,8),BHSDYS=$P(BHSN,U,7),BHSQTY=$P(BHSN,U,6),BHSIG=$P(BHSN,U,5),BHSVDF=$P(BHSN,U,3),BHSMFX=+BHSN
 S:BHSDYS="" BHSDYS=30
 S X1=DT,X2=BHSDTM D ^%DTC ;Q:X>60&(X>(2*BHSDYS))
 S BHSEXP=""
 I X>BHSDYS S X1=BHSDTM,X2=BHSDYS D C^%DTC  D REGDT4^GMTSU S BHSEXP="-- Ran out "_X
 S BHSMED=$S($P(BHSN,U,4)="":$P(^PSDRUG(BHSMFX,0),U,1),1:$P(BHSN,U,4)) ;MODIFIED FOR PHAR 6.0 IHS/OKCAO/POC 6/13/97
 ;MORE LOCAL CHANCES IHS/OKCAO/POC 10/28/96
 S BHSNARC=$P(^PSDRUG(BHSMFX,0),U,3),BHSNARC=+BHSNARC
 K BHSNARF I +BHSNARC=2 S BHSNARF=1 ;FOR JUST SCH 2 DRUGS
 ;END POC
 ;ADDED RETURNED TO STOCK FLAG FOR NEXT 4 LINES IHS/OKCAO/POC 12/19/97
 IF $P($G(^AUPNVMED(BHSMX,11)),U)="RETURNED TO STOCK" S BHSRTN="R"
 I BHSDC,$G(BHSRTN)="R" S X=BHSDC D REGDT4^GMTSU S BHSEXP="--RETN STOCK "_X
 I BHSDC,$G(BHSRTN)="" S X=BHSDC D REGDT4^GMTSU S BHSEXP="-- D/C "_X
 K BHSRTN
 ;END OF CHANGES
 D SIG S BHSIG=BHSSGY
 D REF I BHSREF S BHSIG=BHSIG_" "_BHSREF_$S(BHSREF=1:" refill",1:" refills")_" left."
 D SITE I BHSITE]"" S BHSIG=BHSIG_"  ["_BHSITE_"]"
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ;Q:$D(BHSNARF) ;POC QUIT IF NARCOTIC UNCOMMENT IF DO NOT WANT TO SEE NARCS
 ;S X="IOINHI;IOINLOW" D ENDR^%ZISS W !,BHSDAT,?10 W:BHSMTY'="CHRONIC" $S(BHSCRN:"(C)",1:"") W ?12,IOINHI,BHSMED," #",BHSQTY,IOINLOW," (",BHSDYS," days) ",BHSEXP,! ;POC DELETE CHRONIC SIGN CHANGE SPACING BOLD DRUGAND SIG
 W !,BHSDAT
 W ?10 W:BHSMTY'="CHRONIC" $S(BHSCRN:"(C)",1:"")
 ;S X="IOINHI" D ENDR^%ZISS W IOINHI
 W ?12,BHSMED," #",BHSQTY
 ;S X="IOINLOW" D ENDR^%ZISS W IOINLOW
 W " (",BHSDYS," days) ",BHSEXP,!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 S BHSICL=14,BHSNRQ="",BHSTXT=BHSIG D PRTTXT^BHSUTL K BHSICL,BHSNRQ,BHSP
 ;WRITE LOCAL CHANGES IHS/OKCAO/POC 10/29/96
 I $D(BHSNARF) W ?10," ------ MUST REWRITE THIS CONTROLLED DRUG----",!
 E  W ?14,"PROVIDER INITIALS:  ______________________________ DATE_________",!
 E  W ?14,"REFILL 1______2______3______4______5______NR______DC______",!
 ;END POC
 Q
 ;
SIG ;
 ;CONSTRUCT THE FULL TEXT FROM THE ENCODED SIG
 ;I $$VALI^XBDIQ1(9001015,GMTSTYP,3.5)="S" S BHSSGY=BHSIG Q
 S BHSSGY="" F BHSP=1:1:$L(BHSIG," ") S X=$P(BHSIG," ",BHSP) I X]"" D
 . S Y=$O(^PS(51,"B",X,0)) I Y>0 S X=$P(^PS(51,Y,0),"^",2) I $D(^(9)) S Y=$P(BHSIG," ",BHSP-1),Y=$E(Y,$L(Y)) S:Y>1 X=$P(^(9),"^",1)
 . S BHSSGY=BHSSGY_X_" "
 Q
 ;
REF ;
 ;DETERMINE THE NUMBER OF REFILLS REMAINING
 I 'BHSRX S BHSREF=0 Q
 S BHSRFL=$P(^PSRX(BHSRX,0),U,9) S BHSREF=0 F  S BHSREF=$O(^PSRX(BHSRX,1,BHSREF)) Q:'BHSREF  S BHSRFL=BHSRFL-1
 S BHSREF=BHSRFL
 Q
 ;
SITE ;
 ;DETERMINE IF OUTSIDE LOCATION INFO PRESENT
 S BHSITE=""
 I $D(^AUPNVSIT(BHSVDF,21))#2 S BHSITE=$P(^(21),U)
 Q