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

AMHGUA.m

Go to the documentation of this file.
AMHGUA ; IHS/CMI/MAW - AMH Behavioral Health GUI Utilities continued 9/8/2008 2:00:25 PM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**1,4**;JUN 18, 2010;Build 28
 ;
 ;
DEBUG(RETVAL,AMHSTR)  ;replace tag below to allow Serenji debug of GUI
 D DEBUG^%Serenji("GETPAT^AMHGUA(.RETVAL,.AMHSTR)")
 Q
 ;
UU(RETVAL,AMHSTR) ;-- return a list of sites in from BH USER file
 N P,AMHUSR,AMHI
 S P="|"
 S AMHUSR=$P(AMHSTR,P)
 S AMHI=0
 S RETVAL="^AMHTMP("_$J_")"
 K ^AMHTMP($J)
 S @RETVAL@(AMHI)="T00030UUSite"_$C(30)
 I '$D(^AMHBHUSR(AMHUSR)) D  Q
 . S @RETVAL@(AMHI+1)=$C(31)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^AMHBHUSR(AMHUSR,11,AMHDA)) Q:'AMHDA  D
 . S AMHI=AMHI+1
 . N AMHLOC
 . S AMHLOC=$$GET1^DIQ(9999999.06,AMHDA,.01)
 . S @RETVAL@(AMHI)=AMHLOC_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
ACTCODE(RETVAL,AMHSTR) ;-- return activity code based on code passed in
 N P,AMHACT,AMHI,R
 S P="|",R="~"
 S AMHACT=$P(AMHSTR,P)
 S AMHI=0
 S RETVAL="^AMHTMP("_$J_")"
 K ^AMHTMP($J)
 S @RETVAL@(AMHI)="T00080Activity"_$C(30)
 N AMHIEN
 S AMHIEN=$O(^AMHTACT("B",AMHACT,0))
 I 'AMHIEN D  Q
 . S @RETVAL@(AMHI+1)=$C(31)
 N AMHDATA,AMHDSC
 S AMHDATA=$G(^AMHTACT(AMHIEN,0))
 S AMHDSC=$P(AMHDATA,U,2)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=AMHIEN_R_AMHDSC_R_AMHACT_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
VC(RETVAL,AMHSTR) ;-- get version number to see if client matches
 N P
 S P="|"
 K ^AMHTMP($J)
 N AMHVER,AMHVERI,AMHVERIN,AMHPKG,AMHI,AMHPTCH,AMHPTCHI,AMHVERI,AMHCHK
 S AMHI=0
 S AMHVERIN=$P(AMHSTR,P)
 ;S AMHVERIN=8.3
 S RETVAL="^AMHTMP("_$J_")"
 S ^AMHTMP($J,AMHI)="T00001VersionPresent"_$C(30)
 S AMHI=AMHI+1
 S AMHPKG=$O(^DIC(9.4,"C","AMH",0))
 I '$G(AMHPKG) D  Q
 . S ^AMHTMP($J,AMHI)=0_$C(30)
 . S ^AMHTMP($J,AMHI+1)=$C(31)
 S AMHVER=$G(^DIC(9.4,AMHPKG,"VERSION"))
 S AMHVERI=$O(^DIC(9.4,AMHPKG,22,"B",AMHVER,0))
 S AMHPTCH=$O(^DIC(9.4,AMHPKG,22,AMHVERI,"PAH","B",""),-1)
 I $S($G(AMHPTCH):$E(AMHVER,1,2)_AMHPTCH,1:$E(AMHVER,1,3)_AMHPTCH)=AMHVERIN D  Q
 . S ^AMHTMP($J,AMHI)=1_$C(30)
 . S ^AMHTMP($J,AMHI+1)=$C(31)
 S ^AMHTMP($J,AMHI)=0_$C(30)  ;remove the line below when done with testing and uncomment this one
 ;S ^AMHTMP($J,AMHI)=1_$C(30)
 S ^AMHTMP($J,AMHI+1)=$C(31)
 Q
 ;
LOCK(RETVAL,AMHSTR) ;-- check to see if record is locked
 N P,AMHFILE,AMHIEN,AMHI,R,AMHGL,AMHREC,AMHVAL
 S P="|",R="~"
 S AMHFILE=$P(AMHSTR,P)
 S AMHIEN=$P(AMHSTR,P,2)
 S AMHI=0
 S RETVAL="^AMHTMP("_$J_")"
 K ^AMHTMP($J)
 S @RETVAL@(AMHI)="T00001Lock"_$C(30)
 S AMHGL=$G(^DIC(AMHFILE,0,"GL"))
 S AMHREC=AMHGL_AMHIEN_")"
 S AMHVAL=0
 L @AMHREC:1
 I $T L -@AMHREC
 I '$T S AMHVAL=1
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=AMHVAL_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
TIME(RETVAL,AMHSTR) ;-- get system time out based on user or location
 N P,AMHDUZ,AMHDUZ2,AMHI,AMHVAL,AMHVALI
 S P="|"
 S AMHDUZ=$P(AMHSTR,P)
 S AMHDUZ2=$P(AMHSTR,P,2)
 S AMHI=0
 S RETVAL="^AMHTMP("_$J_")"
 K ^AMHTMP($J)
 S @RETVAL@(AMHI)="T00010TimeOut"_$C(30)
 S AMHVAL=$$GET1^DIQ(200,AMHDUZ,200.1)
 I '$G(AMHVAL) D
 . S AMHVAL=$$GET1^DIQ(8989.3,1,210)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$G(AMHVAL)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
VER(RETVAL,AMHSTR) ;-- check to see if verify code is valid
 N AMHVER,AMHVVER,AMHPVER,AMHVAL
 S AMHVER=AMHSTR
 S AMHVVER=$$EN^XUSHSH($$UP^XLFSTR(AMHVER))
 S AMHPVER=$P($G(^VA(200,DUZ,.1)),U,2)
 S AMHVAL=$S(AMHVVER=AMHPVER:1,1:0)
 S RETVAL=AMHVAL
 Q
 ;
POV(RET,AMHPAT,AMHD) ;EP -- filter POV if allowed to see
 ;v4.0p1 ihs/cmi/maw 11/4/2010 modified to prevent duplicates
 NEW AMHC1,AMHA,AMHMSG,%,AMHA,AMHB,AMHT,AMHV,AMHC,AMHCC,X,S,Y,Z,AMHVAL1,AMHVAL2,AMHCNT ;CMI/TUCSON/LAB - added X,S,Y,Z patch 1 10/06/97
 Q:'$G(AMHPAT)
 K ^TMP("AMHTMP",$J)
 S AMHC=$$VAL^XBDIQ1(9002013,DUZ(2),.25) S:'AMHC AMHC=10
 ;S AMHC=10  ;not using site parameter for GUI v4.0p1 02/23/2011
 S AMHC1=1
 S AMHCNT=0
 S (AMHA,AMHV,AMHCC)=0 F  S AMHA=$O(^AMHREC("AE",AMHPAT,AMHA)) Q:AMHA'=+AMHA!(AMHV)  D
 .S AMHT=0 F  S AMHT=$O(^AMHREC("AE",AMHPAT,AMHA,AMHT)) Q:AMHT'=+AMHT!(AMHV)  D
 ..I $P($G(^AMHSITE(DUZ(2),0)),U,26) Q:$$NOSHOW^AMHLESM(AMHT)
 ..Q:'$$ALLOWVI^AMHUTIL(DUZ,AMHT)
 ..S AMHB=0 F  S AMHB=$O(^AMHRPRO("AD",AMHT,AMHB)) Q:AMHB'=+AMHB  D
 ...Q:'$P(^AMHRPRO(AMHB,0),U,3)
 ...N AMHPIEN
 ...S AMHPIEN=$P($G(^AMHRPRO(AMHB,0)),U)
 ...;Q:'$$CURCOD(AMHPIEN)  ;v4.0p4 screen out codes not in the current code set
 ...Q:'$$CHKD^AMHUTIL1(AMHPIEN,AMHD)
 ...S AMHCC=AMHCC+1 I (AMHCC-1)=AMHC S AMHV=AMHT Q
 ...S AMHCNT=AMHCNT+1
 ...;S ^TMP("AMHTMP",$J,AMHB)=AMHCNT_U_AMHPIEN
 ...S ^TMP("AMHTMP",$J,AMHCNT,AMHB)=AMHPIEN
 N AMHTDA,AMHTCNT,AMHTIEN,AMHCN
 S AMHCN=0
 ;S AMHTDA=0 F  S AMHTDA=$O(^TMP("AMHTMP",$J,AMHTDA)) Q:'AMHTDA  D
 S AMHTCNT=0 F  S AMHTCNT=$O(^TMP("AMHTMP",$J,AMHTCNT)) Q:'AMHTCNT  D
 .;S AMHTCNT=$G(^TMP("AMHTMP",$J,AMHTDA))
 .S AMHTDA=0 F  S AMHTDA=$O(^TMP("AMHTMP",$J,AMHTCNT,AMHTDA)) Q:'AMHTDA  D
 ..S AMHCN=AMHCN+1
 ..S AMHTIEN=$P($G(^TMP("AMHTMP",$J,AMHTCNT,AMHTDA)),U)
 ..S AMHVAL1=$$GET1^DIQ(9002011.01,AMHTDA,.01)
 ..S AMHVAL2=$$GET1^DIQ(9002011.01,AMHTDA,.04)
 ..S @RET@(AMHCN)=AMHTIEN_U_AMHVAL1_U_AMHVAL2_$C(30)
 .;S AMHC1=AMHC1+1
 S @RET@(AMHCN+1)=$C(31)
 Q
 ;
CURCOD(PIEN) ;-- check the code to see if it is the current version of code set
 N CV
 S CV=$$DSMVDT^AMHUTIL1(DUZ(2))
 I '$G(CV) S CV=4
 I $$GET1^DIQ(9002012.2,PIEN,.1)=CV Q 1
 Q 0
 ;
LABG(RETVAL,AMHSTR) ;-- graph labs
 N P,AMHI,AMHB,AMHE,AMHBD,AMHED,AMHP,AMHL,AMHD,AMHR,AMHA,AMHRL,AMHRH
 S P="|"
 S AMHB=$P(AMHSTR,P)
 S AMHE=$P(AMHSTR,P,2)
 S AMHP=$P(AMHSTR,P,3)
 S AMHL=$P(AMHSTR,P,4)
 S AMHI=0
 K ^AMHTMP($J)
 S RETVAL="^AMHTMP("_$J_")"
 S @RETVAL@(AMHI)="T00030Date^T00050Normal Result^T00010Abnormal Result"_$C(30)  ;^T00010Abnormal^T00030Ref Low^T00030Ref High"_$C(30)
 S AMHBD=9999999-AMHB
 S AMHED=9999999-AMHE
 N AMHDA,AMHIEN
 S AMHDA=AMHED F  S AMHDA=$O(^AUPNVLAB("AA",AMHP,AMHL,AMHDA)) Q:'AMHDA!(AMHDA>AMHBD)  D
 . S AMHIEN=0 F  S AMHIEN=$O(^AUPNVLAB("AA",AMHP,AMHL,AMHDA,AMHIEN)) Q:'AMHIEN  D
 .. S AMHD=9999999-AMHDA
 .. S AMHR=$$GET1^DIQ(9000010.09,AMHIEN,.04)
 .. S AMHA=$$GET1^DIQ(9000010.09,AMHIEN,.05)
 .. S AMHRL=$$GET1^DIQ(9000010.09,AMHIEN,1104)
 .. S AMHRH=$$GET1^DIQ(9000010.09,AMHIEN,1105)
 .. S AMHI=AMHI+1
 .. S @RETVAL@(AMHI)=$$LVDT^AMHGU(AMHD)_U_AMHR_U_$S(AMHA]"":AMHR,1:"")_$C(30)  ;U_AMHA_U_AMHRL_U_AMHRH_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
CLNWP(FL,ND,REC) ;-- lets clean up a wp field before refiling
 N RDA,GL,GLN
 S DA(1)=REC
 S GL=$G(^DIC(FL,0,"GL"))
 S GLN=GL_REC_","_ND_")"
 S RDA=0 F  S RDA=$O(@GLN@(RDA)) Q:'RDA  D
 . S DA=RDA
 . S DIK=GL_REC_","_ND_","
 . D ^DIK
 Q
 ;
VEXIST(RETVAL,AMHSTR) ;-- check to see if there is a visit on the record (used for group edit)
 N P,AMHREC,AMHI,AMHX
 S P="|"
 S AMHREC=$P(AMHSTR,P)
 K ^AMHTMP($J)
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 S @RETVAL@(AMHI)="T00001VisitExists"_$C(30)
 S AMHI=AMHI+1
 S AMHX=$S($$GET1^DIQ(9002011,AMHREC,.16,"I"):1,1:0)
 S @RETVAL@(AMHI)=AMHX_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
CHKDSM(RETVAL,AMHSTR) ;-- check which version of DSM
 N P,AMHS,AMHD
 S P="|"
 S AMHS=$P(AMHSTR,P)
 K ^AMHTMP($J)
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 S @RETVAL@(AMHI)="T00001DSM"_$C(30)
 S AMHI=AMHI+1
 S AMHD=$$GET1^DIQ(9002013,AMHS,1811,"I")
 I AMHD="" S AMHD=9999999
 ;S AMHD=$S($G(AMHD)]"":5,1:4)  ;default to DSM-IV if blank
 S @RETVAL@(AMHI)=AMHD_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;