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

AMHGT.m

Go to the documentation of this file.
AMHGT ; IHS/CMI/MAW - AMH Behavioral Health GUI Tables 9/30/2008 10:31:41 AM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**2,4,9**;JUN 02, 2010;Build 11
 ;
 ;
 ;
DEBUG(RETVAL,AMHSTR) ;-- debug entry point
 D DEBUG^%Serenji("SEARCH^AMHGT(.RETVAL,.AMHSTR)")
 Q
 ;
 ;
 ;
HS(RETVAL) ;-- get all health summary types
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 K ^AMHTMP($J)
 S RETVAL="^AMHTMP("_$J_")"
 N AMHERRR,AMHI,AMHHS
 S AMHI=0
 S AMHERRR=""
 S @RETVAL@(AMHI)="T00080HealthSummary"_$C(30)
 S AMHHS=0 F  S AMHHS=$O(^APCHSCTL("B",AMHHS)) Q:AMHHS=""  D
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHHS_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
FILES(RETVAL) ;-- get all files in the system for searching later on
 N AMHDA,AMHI
 S AMHI=0
 D ADO^AMHGU
 S @RETVAL@(0)="T00050FileName^T00010NumberOfRecords"_$C(30)
 S AMHDA=0 F  S AMHDA=$O(^DIC(AMHDA)) Q:'AMHDA  D
 . N AMHFL,AMHGB,AMHREC
 . S AMHFL=$P($G(^DIC(AMHDA,0)),U)
 . S AMHGB=$G(^DIC(AMHDA,0,"GL"))_"0)"
 . Q:AMHGB'[U
 . S AMHREC=$P($G(@AMHGB),U,4)
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHFL_U_AMHREC_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
SEARCHO(RETVAL,AMHSTR) ;-- return search results to frmSearchSingle and frmSearchMultiple
 N AMHDA,AMHI,P,AMHFL,AMHIDX,AMHGB,AMHS,AMHSZ,AMHL
 S P="|"
 S AMHI=0
 D ADO^AMHGU
 S AMHFL=$P(AMHSTR,P)
 S AMHIDX=$P(AMHSTR,P,2)
 S AMHS=$P(AMHSTR,P,3)
 S AMHFLD1=$P(AMHSTR,P,4)
 S AMHFLD2=$P(AMHSTR,P,5)
 I AMHFLD1["." S AMHFLD1=+AMHFLD1
 I AMHFLD2["." S AMHFLD2=+AMHFLD2
 S AMHL=$L(AMHS)  ;length of string
 I AMHS]"",AMHS'?.N D
 . S AMHDA=AMHS
 . S AMHSZ=AMHS_"Z"
 I AMHS]"",AMHS?.N  D
 . S AMHDA=AMHS
 . S AMHSZ=AMHS_"99999999"
 I $G(AMHDA)="" S AMHDA=0
 S @RETVAL@(0)="T00010BMXIEN^T00050Value1^T00080Value2"_$C(30)
 S AMHGB=$G(^DIC(AMHFL,0,"GL"))_""""_AMHIDX_""""_")"
 F  S AMHDA=$O(@AMHGB@(AMHDA)) Q:AMHDA=""!($E(AMHDA,1,AMHL)'=AMHS)  D
 . N AMHIEN
 . S AMHIEN=0 F  S AMHIEN=$O(@AMHGB@(AMHDA,AMHIEN)) Q:'AMHIEN  D
 .. N AMHVAL1,AMHVAL2
 .. S AMHVAL1=$$GET1^DIQ(AMHFL,AMHIEN,AMHFLD1)
 .. I $G(AMHFLD2)]"" S AMHVAL2=$$GET1^DIQ(AMHFL,AMHIEN,AMHFLD2)
 .. S AMHI=AMHI+1
 .. S @RETVAL@(AMHI)=AMHIEN_U_AMHVAL1_U_$G(AMHVAL2)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
 N AMHDA,AMHI,P,AMHFL,AMHIDX,AMHGB,AMHS,AMHSZ,AMHL,AMHTGT,AMHFLDS,AMHSCR,AMHPR,AMHFLD1,AMHFLD2,AMHDT,AMHECD
 S P="|"
 S AMHI=0
 D ADO^AMHGU
 K ^AMHTMPD($J)
 S AMHTGT="^AMHTMPD("_$J_")"  ;target for find^dic lookup
 S AMHFL=$P(AMHSTR,P)
 S AMHIDX=$P(AMHSTR,P,2)
 I AMHIDX]"" S AMHIDX=$TR(AMHIDX,"*","^")
 S AMHS=$P(AMHSTR,P,3)
 I AMHFL=9999999.64 D HF(AMHS,"F") I $P($G(@RETVAL@(1)),U,2)]"" Q
 I AMHFL=9999999.64,$P($G(@RETVAL@(1)),U,2)']"" D HF(AMHS,"B") Q
 I AMHFL=9002012.2,AMHS="" S AMHIDX="BA"
 S AMHFLD1=$P(AMHSTR,P,4)
 S AMHFLD2=$P(AMHSTR,P,5)
 S AMHSCR=$P(AMHSTR,P,6)
 I AMHSCR="E" D  ;this is for e codes
 . I $E(AMHS,1,1)'="E" S AMHS="E"_AMHS  ;add the e code to e code lookup
 . S AMHECD=1
 . S AMHSCR=""  ;if screen is E code set this up
 S AMHDT=$P(AMHSTR,P,8)
 I $G(AMHSCR)["" S AMHSCR=$TR(AMHSCR,"*","^")
 S AMHPR=$P(AMHSTR,P,7)
 S AMHDT=$P(AMHSTR,P,8)
 I AMHFLD1["." S AMHFLD1=+AMHFLD1
 I AMHFLD2["." S AMHFLD2=+AMHFLD2
 I AMHFLD2=0 S AMHFLD2=""
 S AMHFLDS=$S(AMHFLD2]"":AMHFLD1_";"_AMHFLD2,1:AMHFLD1)
 I AMHS="" D
 . D LIST^DIC(AMHFL,"",AMHFLDS,"","","",AMHS,AMHIDX,AMHSCR,"",AMHTGT,"AMHERRR(1)")
 I AMHS]"" D
 . S X=AMHS X ^%ZOSF("UPPERCASE") S AMHS=Y  ;cmi/maw 03/05/2014 p4 change all to uppercase
 . D FIND^DIC(AMHFL,"",AMHFLDS,"",AMHS,"",AMHIDX,AMHSCR,"",AMHTGT,"AMHERRR(1)")
 S @RETVAL@(0)="T00010BMXIEN^T00050Value1^T00080Value2"_$C(30)
 S AMHDA=0  F  S AMHDA=$O(@AMHTGT@("DILIST","ID",AMHDA)) Q:'AMHDA  D
 . N AMHIEN,AMHBMX
 . S AMHIEN=0 F  S AMHIEN=$O(@AMHTGT@("DILIST","ID",AMHDA,AMHIEN)) Q:'AMHIEN  D
 .. S AMHBMX=$G(@AMHTGT@("DILIST",2,AMHDA))
 .. ;I AMHFL=9002012.2,'$$CHKD^AMHUTIL1(AMHBMX,AMHDT) K AMHBMX Q
 .. I AMHFL=9002012.2,'$$POVICD9^AMHUTIL1(AMHBMX,AMHDT) K AMHBMX Q  ;maw v4.0p9
 .. I AMHFL=81,'$$CHKCPT^AMHUTIL1(AMHBMX,AMHDT) K AMHBMX Q
 .. I AMHFL=80,'$G(AMHECD),'$$CHK^AUPNSICD(AMHBMX) K AMHBMX Q  ;for ecodes
 .. I AMHFL=80,$G(AMHECD),'$$CHKE1^AUPNSICD(AMHBMX) K AMHBMX Q  ;for ecodes
 .. S AMHFLD(AMHIEN)=$G(@AMHTGT@("DILIST","ID",AMHDA,AMHIEN))
 . Q:'$G(AMHBMX)
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHBMX_U_AMHFLD(AMHFLD1)_U_$S($G(AMHFLD2):$G(AMHFLD(AMHFLD2)),1:"")_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
ACTSCR(SIEN) ;-- activity code screen patient
 ;I '$P($G(^(0)),U,6),'$P($G(^(0)),U,9)
 Q 0
 ;
HF(AMHVAL,AMHIDX) ;-- health factor
 N AMHI,P,AMHL
 S AMHI=0
 S P="|"
 S AMHL=$L(AMHVAL)
 I AMHL=1 S AMHIDX="B"
 S RETVAL="^AMHTMP("_$J_")"
 S @RETVAL@(AMHI)="T00010BMXIEN^T00050Value1^T00080Value2"_$C(30)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^AUTTHF(AMHIDX,AMHDA)) Q:AMHDA=""  D
 . Q:$E(AMHDA,1,AMHL)'=AMHVAL
 . N AMHIEN
 . S AMHIEN=0 F  S AMHIEN=$O(^AUTTHF(AMHIDX,AMHDA,AMHIEN)) Q:'AMHIEN  D
 .. Q:$P($G(^AUTTHF(AMHIEN,0)),U,13)
 .. Q:$P($G(^AUTTHF(AMHIEN,0)),U,10)="C"
 .. N AMH01,AMH01
 .. S AMH01=$$GET1^DIQ(9999999.64,AMHIEN,.01)
 .. S AMH02=$$GET1^DIQ(9999999.64,AMHIEN,.03)
 .. S AMHI=AMHI+1
 .. S @RETVAL@(AMHI)=AMHIEN_U_AMH01_U_AMH02_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
SC(RETVAL,AMHSTR) ;-- return a set of codes based upon input
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 K ^AMHTMP($J)
 S RETVAL="^AMHTMP("_$J_")"
 N AMHERRR,AMHI,AMHFL,AMHFLD,AMHGB,AMHSC,P,AMHSCI,AMHSCR,AMHNO
 S P="|"
 S AMHI=0
 S AMHERRR=""
 S AMHFL=$P(AMHSTR,P)
 S AMHFLD=$P(AMHSTR,P,2)
 S @RETVAL@(AMHI)="T00030SetOfCodes"_$C(30)
 S AMHGB="^DD("_AMHFL_","_AMHFLD_")"
 S AMHSC=$P(@AMHGB@(0),U,3)
 S AMHSCR=$G(@AMHGB@(12.1))
 N I
 F I=1:1 D  Q:$P(AMHSC,";",I)=""
 . N AMHSCE
 . S AMHSCI=$P(AMHSC,";",I)
 . Q:AMHSCI=""
 . I $G(AMHSCR)]"" D  Q:$G(AMHNO)
 .. S AMHNO=0
 .. N AMHSCIN
 .. S AMHSCIN=$P(AMHSCI,":",1)
 .. I AMHSCR'[AMHSCIN S AMHNO=1 Q
 . S AMHSCE=$P(AMHSCI,":",2)
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHSCE_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
SCI(FL,FLD,VAL) ;EP -- get the internal value of a set of codes based on external passed in
 N RET
 I VAL="" Q ""
 N AMHGB,AMHSCI,AMHSCD,AMHSC
 S AMHGB="^DD("_FL_","_FLD_")"
 S AMHSC=$P(@AMHGB@(0),U,3)
 N I
 F I=1:1 D  Q:$P(AMHSC,";",I)=""!($G(RET)]"")
 . N AMHSCE,AMHSCI
 . S AMHSCD=$P(AMHSC,";",I)
 . S AMHSCI=$P(AMHSCD,":",1)
 . S AMHSCE=$P(AMHSCD,":",2)
 . I AMHSCE=VAL S RET=AMHSCI Q
 Q $G(RET)
 ;
SCE(FL,FLD,VAL) ;EP -- get the external value of a set of codes based on internal passed in
 I VAL="" Q ""
 N AMHGB,AMHSCI,AMHSCD,AMHSC
 S AMHGB="^DD("_FL_","_FLD_")"
 S AMHSC=$P(@AMHGB@(0),U,3)
 N I
 F I=1:1 D  Q:$P(AMHSCD,";",I)=""!($G(RET)]"")
 . N AMHSCE,AMHSCI
 . S AMHSCD=$P(AMHSC,";",I)
 . S AMHSCI=$P(AMHSCD,":",1)
 . S AMHSCE=$P(AMHSCD,":",2)
 . I AMHSCI=VAL S RET=AMHSCE Q
 Q $G(RET)
 ;