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

AMHGRU.m

Go to the documentation of this file.
AMHGRU ;IHS/CMI/MAW - AMHG REPORT UTILITIES;
 ;;4.0;IHS BEHAVIORAL HEALTH;**1,2**;JUN 18, 2010;Build 23
 ;
 ;
 ;
 Q
 ;
DEBUG(AMHRET,AMHSTR) ;-- debugger
 D DEBUG^%Serenji("INTAKE^AMHGR(.AMHRET,.AMHSTR)")
 Q
 ;
PCCM(AMHPAT,BD,ED) ;EP -- get pcc medications
 S %=$$FMADD^XLFDT(DT,-731),%1=""
 D GETMEDS^AMHLEMD(AMHPAT,BD,ED,"L")
 D GETMHMD
 D SETARRAY
 Q
 ;
SETARRAY ;
 K ^TMP("AMHDSPMEDS",$J) S ^TMP("AMHDSPMEDS",$J,0)=0
 ;S X="Displayed is the MEDICATIONS PRESCRIBED data field from the BH data file" D S(X)
 ;S X="for the past 2 years of visits." D S(X)
 ;S X="Also, the last of each type of medication from the PCC Database is displayed." D S(X)
 S X=" " D S(X)
 S X=" " D S(X) S X="Medications Prescribed entries in BH Database for "_$$FMTE^XLFDT(BD)_" to "_$$FMTE^XLFDT(ED)_" " D S(X)
 S I=0 F  S I=$O(^TMP("AMHSMEDS",$J,"M",I)) Q:I'=+I  S X=^TMP("AMHSMEDS",$J,"M",I) D S(X)
 S X=" " D S(X) S X="The last of each type of medication from the PCC Database is displayed below." D S(X)
 S I=0 F  S I=$O(^TMP("AMHSMEDS",$J,"A",I)) Q:I'=+I  S X=^TMP("AMHSMEDS",$J,"A",I) D S(X)
 Q
GETMHMD ;set array ^TMP("AMHSMEDS",$J,"M" OF MEDS IN MH FILE
 K ^TMP("AMHSMEDS",$J,"M")
 NEW AMHLAST,AMHC S AMHLAST=9999999-(DT-20000),AMHC=0
 NEW I S I=0 F  S I=$O(^AMHREC("AE",AMHPAT,I)) Q:I=""!(I>AMHLAST)  D
 .S X=0 F  S X=$O(^AMHREC("AE",AMHPAT,I,X)) Q:X=""  D
 ..Q:'$D(^AMHREC(X,41,0))
 ..Q:'$$ALLOWVI^AMHUTIL(DUZ,X)
 ..S AMHC=AMHC+1,^TMP("AMHSMEDS",$J,"M",AMHC)=$$FMTE^XLFDT((9999999-$P(I,".")),"2E")
 ..S C=0 F  S C=$O(^AMHREC(X,41,C)) Q:C'=+C  S AMHC=AMHC+1,^TMP("AMHSMEDS",$J,"M",AMHC)=^AMHREC(X,41,C,0)
 ..Q
 Q
S(Y,F,C,T) ;
 I '$G(F) S F=0
 I '$G(T) S T=0
 ;blank lines
 F F=1:1:(T-1) S X=" "_X
 F %=1:1:T S X=" "_Y
 D S1
 Q
S1 ;
 S %=$P(^TMP("AMHDSPMEDS",$J,0),U)+1,$P(^TMP("AMHDSPMEDS",$J,0),U)=%
 S ^TMP("AMHDSPMEDS",$J,%,0)=X
 Q
 ;
PAD(DATA,LENGTH) ;EP -- SUBRTN to pad length of data
 Q $E(DATA_$$REPEAT^XLFSTR(" ",LENGTH),1,LENGTH)
 ;
SP(N) ;EP -- SUBRTN to pad N number of spaces
 Q $$PAD(" ",N)
 ;
PCCL(PAT,BD,ED,DM) ;EP -- get pcc labs
 K ^TMP("AMHLABG",$J)
 K ^TMP("AMHLABV",$J)
 N BBD,BED,AMHDA,AMHIEN,CNT,AMHOEN,AMHCNT
 N AMHTEST,AMHVST,AMHRES,AMHABN,AMHRL,AMHRH,AMHCDT,AMHOP,AMHTSTI,AMHVSTI,AMHCDTI
 S BBD=9999999-BD,BED=9999999-(ED+1)
 S AMHDA=0 F  S AMHDA=$O(^AUPNVLAB("AA",PAT,AMHDA)) Q:'AMHDA  D
 . S AMHOEN=BED F  S AMHOEN=$O(^AUPNVLAB("AA",PAT,AMHDA,AMHOEN)) Q:'AMHOEN!(AMHOEN>BBD)  D
 .. S AMHIEN=0 F  S AMHIEN=$O(^AUPNVLAB("AA",PAT,AMHDA,AMHOEN,AMHIEN)) Q:'AMHIEN  D
 ... S AMHTEST=$$GET1^DIQ(9000010.09,AMHIEN,.01)
 ... S AMHTSTI=$$GET1^DIQ(9000010.09,AMHIEN,.01,"I")
 ... S AMHVST=$$GET1^DIQ(9000010.09,AMHIEN,.03)
 ... S AMHVSTI=9999999-AMHOEN
 ... S AMHRES=$$GET1^DIQ(9000010.09,AMHIEN,.04)
 ... S AMHABN=$$GET1^DIQ(9000010.09,AMHIEN,.05)
 ... S AMHRL=$$GET1^DIQ(9000010.09,AMHIEN,1104)
 ... S AMHRH=$$GET1^DIQ(9000010.09,AMHIEN,1105)
 ... S AMHCDT=$$GET1^DIQ(9000010.09,AMHIEN,1201)
 ... S AMHCDTI=$$GET1^DIQ(9000010.09,AMHIEN,1201,"I")
 ... S AMHCDTI=9999999-AMHCDTI
 ... S AMHOP=$$GET1^DIQ(9000010.09,AMHIEN,1202)
 ... I DM="G" D  Q
 .... S:'$D(AMHRES(AMHTSTI)) AMHRES(AMHTSTI)=0
 .... I $G(AMHRES)]"" S AMHRES(AMHTSTI)=AMHRES(AMHTSTI)+1
 .... S:'$D(AMHTEST("EARLY")) AMHTEST("EARLY")=9999999
 .... S:'$D(AMHTEST("LAST")) AMHTEST("LAST")=0
 .... I AMHVSTI<AMHTEST("EARLY") S AMHTEST("EARLY")=AMHVSTI
 .... I AMHVSTI>AMHTEST("LAST") S AMHTEST("LAST")=AMHVSTI
 .... S:'$D(AMHCNT(AMHTEST)) AMHCNT(AMHTEST)=0
 .... S AMHCNT(AMHTEST)=AMHCNT(AMHTEST)+1
 .... S ^TMP("AMHLABG",$J,AMHTEST)=AMHTSTI_U_AMHCNT(AMHTEST)_U_$G(AMHTEST("EARLY"))_U_$G(AMHTEST("LAST"))
 ... I DM="V" D  Q
 .... ;S ^TMP("AMHLABV",$J,AMHVST,AMHTEST)=AMHVST_U_AMHRES_U_AMHABN_U_AMHRL_U_AMHRH_U_AMHOP
 .... S ^TMP("AMHLABV",$J,AMHCDTI,AMHTEST)=AMHVST_U_AMHRES_U_AMHABN_U_AMHRL_U_AMHRH_U_AMHOP_U_AMHCDT  ;v4.0p1 pr781
 ... S ^TMP("AMHLABV",$J,AMHTEST,AMHVST)=AMHVST_U_AMHRES_U_AMHABN_U_AMHRL_U_AMHRH_U_AMHOP_U_AMHCDT  ;v4.0p1 pr781
 Q
 ;