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

AMHGDVF2.m

Go to the documentation of this file.
AMHGDVF2 ; IHS/CMI/MAW - AMHG BH GUI Visit Form Continued (frmVisitDataEntry) 8/18/2009 2:18:49 PM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**1,2,6**;JUN 02, 2010;Build 10
 ;
 ;
DEBUG(RETVAL,AMHSTR) ;-- debug entry point
 D DEBUG^%Serenji("EP^AMHGD(RETVAL,.AMHSTR)")
 Q
 ;
EDU(RETVAL,AMHSTR) ;-- retrieve visit education topics
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIEN
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIEN=$P(AMHSTR,P)
 S @RETVAL@(AMHI)="T00010BMXIEN^T00030EducationTopic^T00010TimeSpent^T00030LevelOfUnderstanding^T00030CPT^T00030Goal^T00030Status^T00010Session^T00100Comment^T00050Readiness^T00010Provider IEN^T00030Provider"_$C(30)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^AMHREDU("AD",AMHIEN,AMHDA)) Q:'AMHDA  D
 . N AMHEDU,AMHTS,AMHLOU,AMHCMT,AMHGOAL,AMHCPT,AMHST,AMHSES,AMHLOUI,AMHLOUS,AMHSTI,AMHSTS,AMHCPT,AMHREA,AMHEPRVI,AMHEPRV
 . S AMHEDU=$$GET1^DIQ(9002011.05,AMHDA,.01)
 . S AMHTS=$$GET1^DIQ(9002011.05,AMHDA,.06)
 . S AMHLOUI=$$GET1^DIQ(9002011.05,AMHDA,.08,"I")
 . S AMHLOU=$$GET1^DIQ(9002011.05,AMHDA,.08)
 . S AMHLOUS=$S($G(AMHLOUI)]"":AMHLOUI_"-"_AMHLOU,1:"")
 . S AMHCPT=$$GET1^DIQ(9002011.05,AMHDA,.07)
 . S AMHCMT=$$GET1^DIQ(9002011.05,AMHDA,1101)
 . S AMHGOAL=$$GET1^DIQ(9002011.05,AMHDA,.09)
 . S AMHSTI=$$GET1^DIQ(9002011.05,AMHDA,.11,"I")
 . S AMHST=$$GET1^DIQ(9002011.05,AMHDA,.11)
 . S AMHSTS=$S($G(AMHSTI)]"":AMHSTI_"-"_AMHST,1:"")
 . S AMHSES=$$GET1^DIQ(9002011.05,AMHDA,.05,"I")
 . S AMHREA=$$GET1^DIQ(9002011.05,AMHDA,1102)
 . S AMHEPRVI=$$GET1^DIQ(9002011.05,AMHDA,.04,"I")
 . S AMHEPRV=$$GET1^DIQ(9002011.05,AMHDA,.04)
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHDA_U_AMHEDU_U_AMHTS_U_AMHLOU_U_AMHCPT_U_AMHGOAL_U_AMHST_U_AMHSES_U_AMHCMT_U_AMHREA_U_AMHEPRVI_U_AMHEPRV_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
HF(RETVAL,AMHSTR) ;-- retrieve visit health factors
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIEN
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIEN=$P(AMHSTR,P)
 S @RETVAL@(AMHI)="T00010BMXIEN^T00030HealthFactor^T00030LevelSeverity^T00010Quantity^T00030Provider^T00100Comment"_$C(30)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^AMHRHF("AD",AMHIEN,AMHDA)) Q:'AMHDA  D
 . N AMHHF,AMHSEV,AMHQTY,AMHPRV,AMHCMT
 . S AMHHF=$$GET1^DIQ(9002011.08,AMHDA,.01)
 . S AMHSEVI=$$GET1^DIQ(9002011.08,AMHDA,.04,"I")
 . S AMHSEV=$$GET1^DIQ(9002011.08,AMHDA,.04)
 . S AMHSEVS=$S($G(AMHSEVI)]"":AMHSEVI_"-"_AMHSEV,1:"")
 . S AMHQTY=$$GET1^DIQ(9002011.08,AMHDA,.06)
 . S AMHPRV=$$GET1^DIQ(9002011.08,AMHDA,.05)
 . S AMHCMT=$$GET1^DIQ(9002011.08,AMHDA,81101)
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHDA_U_AMHHF_U_AMHSEV_U_AMHQTY_U_AMHPRV_U_AMHCMT_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
SCREEN(RETVAL,AMHSTR) ;-- retrieve visit screening
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIEN
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIEN=$P(AMHSTR,P)
 S @RETVAL@(AMHI)="T00010BMXIEN^T00030AlcoholScreening^T00250AlcoholComment^T00030DepressionScreening^T00250DepressionComment^T00030IPVScreening^T00250IPVComment^T00010Alcohol Provider IEN^T00030Alcohol Provider"
 S @RETVAL@(AMHI)=@RETVAL@(AMHI)_"^T00010Depression Provider IEN^T00030Depression Provider^T00010IPV Provider IEN^T00030IPV Provider^T00030SRAScreening^T00250SRAComment^T00010SRA Provider IEN^T00030SRA Provider"_$C(30)
 N AMHA,AMHAC,AMHD,AMHDC,AMHIP,AMHIPC,AMHAPRVI,AMHAPRV,AMHDPRVI,AMHDPRV,AMHIPRVI,AMHIPRV
 N AMHSRA,AMHSRAC,AMHSPRVI,AMHSPRV
 S AMHA=$$GET1^DIQ(9002011,AMHIEN,1403)
 S AMHAC=$$GET1^DIQ(9002011,AMHIEN,1601)
 S AMHD=$$GET1^DIQ(9002011,AMHIEN,1405)
 S AMHDC=$$GET1^DIQ(9002011,AMHIEN,1701)
 S AMHIP=$$GET1^DIQ(9002011,AMHIEN,1401)
 S AMHIPC=$$GET1^DIQ(9002011,AMHIEN,1501)
 S AMHAPRVI=$$GET1^DIQ(9002011,AMHIEN,1404,"I")
 S AMHAPRV=$$GET1^DIQ(9002011,AMHIEN,1404)
 S AMHDPRVI=$$GET1^DIQ(9002011,AMHIEN,1406,"I")
 S AMHDPRV=$$GET1^DIQ(9002011,AMHIEN,1406)
 S AMHIPRVI=$$GET1^DIQ(9002011,AMHIEN,1402,"I")
 S AMHIPRV=$$GET1^DIQ(9002011,AMHIEN,1402)
 S AMHSRA=$$GET1^DIQ(9002011,AMHIEN,1407)
 S AMHSRAC=$$GET1^DIQ(9002011,AMHIEN,1901)
 S AMHSPRVI=$$GET1^DIQ(9002011,AMHIEN,1408,"I")
 S AMHSPRV=$$GET1^DIQ(9002011,AMHIEN,1408)
 S AMHI=AMHI+1
 I AMHA="",AMHAC="",AMHD="",AMHDC="",AMHIP="",AMHIPC="" D  Q
 . S @RETVAL@(AMHI)=$C(31)
 S @RETVAL@(AMHI)=AMHIEN_U_AMHA_U_AMHAC_U_AMHD_U_AMHDC_U_AMHIP_U_AMHIPC_U_AMHAPRVI_U_AMHAPRV_U_AMHDPRVI_U_AMHDPRV_U_AMHIPRVI_U_AMHIPRV
 S @RETVAL@(AMHI)=@RETVAL@(AMHI)_U_AMHSRA_U_AMHSRAC_U_AMHSPRVI_U_AMHSPRV_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
TIG(RETVAL,AMHSTR) ;-- retrieve visit time in group
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIEN
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIEN=$P(AMHSTR,P)
 S @RETVAL@(AMHI)="T00010BMXIEN^T00010TimeInGroup"_$C(30)
 N AMHTIG
 S AMHTIG=$$GET1^DIQ(9002011,AMHIEN,1104)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=AMHIEN_U_AMHTIG_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
FLAG(RETVAL,AMHSTR) ;-- retrieve visit flag
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIEN
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIEN=$P(AMHSTR,P)
 S @RETVAL@(AMHI)="T00010BMXIEN^T00010Flag"_$C(30)
 N AMHFLG
 S AMHFLG=$$GET1^DIQ(9002011,AMHIEN,.27)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=AMHIEN_U_AMHFLG_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
MSRT(RETVAL,AMHSTR) ;-- get the patients measurements so they can be graphed
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHB,AMHE,AMHP
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHB=$P(AMHSTR,P,2)
 S AMHE=$P(AMHSTR,P,3)
 S AMHP=$P(AMHSTR,P)
 S AMHB=9999999-AMHB
 S AMHE=9999999-AMHE
 S @RETVAL@(AMHI)="T00010Type^T00050Description^T00030Count"_$C(30)
 N AMHT
 S AMHT=0 F  S AMHT=$O(^AMHRMSR("AA",AMHP,AMHT)) Q:'AMHT  D
 . Q:$$GET1^DIQ(9999999.07,AMHT,.01)="PR"
 . Q:$$GET1^DIQ(9999999.07,AMHT,.01)="AUD"
 . Q:$$GET1^DIQ(9999999.07,AMHT,.01)="SN"
 . Q:$$GET1^DIQ(9999999.07,AMHT,.01)="ED"
 . Q:$$GET1^DIQ(9999999.07,AMHT,.01)="HE"
 . Q:$$GET1^DIQ(9999999.07,AMHT,.01)="VC"
 . Q:$$GET1^DIQ(9999999.07,AMHT,.01)="VU"
 . Q:$$GET1^DIQ(9999999.07,AMHT,.01)="CXD"
 . Q:$$GET1^DIQ(9999999.07,AMHT,.01)="EF"
 . N AMHDA
 . S AMHDA=(AMHE-.0001) F  S AMHDA=$O(^AMHRMSR("AA",AMHP,AMHT,AMHDA)) Q:'AMHDA!(AMHDA>(AMHB+.9999))  D
 .. N AMHIEN
 .. S AMHIEN=0 F  S AMHIEN=$O(^AMHRMSR("AA",AMHP,AMHT,AMHDA,AMHIEN)) Q:'AMHIEN  D
 ... N AMHMSRTI,AMHMSRT,AMHMSRD,AMHV,AMHMDT,AMHMSR
 ... S:'$D(^AMHGTMP($J,AMHP,AMHT)) ^AMHGTMP($J,AMHP,AMHT)=0
 ... S ^AMHGTMP($J,AMHP,AMHT)=^AMHGTMP($J,AMHP,AMHT)+1
 N AMHTDA
 S AMHTDA=0 F  S AMHTDA=$O(^AMHGTMP($J,AMHP,AMHTDA)) Q:AMHTDA=""  D
 . N CNT,TYPE,DESC
 . S CNT=$G(^AMHGTMP($J,AMHP,AMHTDA))
 . S AMHI=AMHI+1
 . S TYPE=$$GET1^DIQ(9999999.07,AMHTDA,.01)
 . S DESC=$$GET1^DIQ(9999999.07,AMHTDA,.02)
 . S @RETVAL@(AMHI)=TYPE_U_DESC_U_CNT_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 K ^AMHGTMP($J,AMHP)
 Q
 ;
MSRC(RETVAL,AMHSTR) ;-- get the chartable measurement
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIEN,AMHMST,AMHBD,AMHED
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIEN=$P(AMHSTR,P)
 S AMHMST=$P(AMHSTR,P,2)
 S AMHBD=$P(AMHSTR,P,3)
 S AMHED=$P(AMHSTR,P,4)
 S INST=999999  ;for testing
 ;S @RETVAL@($J,AMHI)="T00020Begin Date^T00020End Date^T00020Date^T00004Systolic^T00004Diastolic^T00007Chart"_$C(30)
 N AMHDA
 S AMHCNT=0
 S AMHBDA=9999999-AMHBD
 S AMHEDA=9999999-AMHED
 S AMHMSTI=$O(^AUTTMSR("B",AMHMST,0))
 D SETHDR(RETVAL,AMHMSTI)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^AMHRMSR("AA",AMHIEN,AMHMSTI,AMHDA)) Q:'AMHDA!(AMHDA>AMHBDA)!(AMHCNT>INST)  D
 . ;Q:AMHCNT>INST
 . N AMHOEN
 . S AMHOEN=0 F  S AMHOEN=$O(^AMHRMSR("AA",AMHIEN,AMHMSTI,AMHDA,AMHOEN)) Q:'AMHOEN  D
 .. N AMHVAL,AMHVDT,AMHVAL1,AMHVAL2
 .. Q:AMHCNT>INST
 .. S AMHCNT=AMHCNT+1
 .. S AMHVAL=$P($G(^AMHRMSR(AMHOEN,0)),U,4)
 .. S AMHVAL1=$P(AMHVAL,"/")
 .. S AMHVAL2=$P(AMHVAL,"/",2)
 .. S AMHVDT=9999999-AMHDA
 .. ;S AMHI=AMHI+1
 .. ;S @RETVAL@(AMHI)=$$LVDT^AMHGU(AMHVDT)_U_AMHVAL1_U_AMHVAL2_$C(30)
 .. S ^TMP($J,"AMHGUI",AMHVDT,AMHIEN)=$$LVDT^AMHGU(AMHVDT)_U_AMHVAL1_$S(AMHVAL2]"":U_AMHVAL2,1:"")
 N AMHTDA,AMHTIEM
 S AMHTDA=0 F  S AMHTDA=$O(^TMP($J,"AMHGUI",AMHTDA)) Q:'AMHTDA  D
 . S AMHTIEN=0 F  S AMHTIEN=$O(^TMP($J,"AMHGUI",AMHTDA,AMHTIEN)) Q:'AMHTIEN  D
 .. S AMHI=AMHI+1
 .. S @RETVAL@(AMHI)=$G(^TMP($J,"AMHGUI",AMHTDA,AMHTIEN))_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 K ^TMP($J,"AMHGUI")
 Q
 ;
SETHDR(RV,MSTI) ;-- set the header based on measurement type
 N MSRD,MSRT
 S MSRT=$P($G(^AUTTMSR(MSTI,0)),U)
 S MSRD=$P($G(^AUTTMSR(MSTI,0)),U,2)
 S @RV@(0)="T00030Date^T00030"_MSRD_$C(30)
 I MSRT="BP" D
 . S @RV@(0)="T00030Date^T00030Systolic^T00030Diastolic"_$C(30)
 Q
 ;
TIU(RETVAL,AMHSTR) ;EP -- return the TIU notes into a data table for the visit
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIN
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIN=$P(AMHSTR,P)
 S @RETVAL@(0)="T00250Soap"_$C(30)
 D TIUN(.AMHARRAY,AMHIN)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^TMP("AMHS",$J,"DCS",AMHDA)) Q:'AMHDA  D
 . N AMHDATA
 . S AMHDATA=$G(^TMP("AMHS",$J,"DCS",AMHDA))
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHDATA_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 K ^TMP("AMHOENPS",$J)
 K ^TMP("AMHS",$J)
 Q
 ;
TIUN(AMHARRAY,AMHIEN) ;EP called to return TIU notes in an array
 N AMHR,AMHTIU,AMHDOC,AMHERR,AMHSTR,AMHGBL,AMHX1,AMHX
 I '$O(^AMHREC(AMHIEN,54,0)) Q
 S AMHARRAY="^TMP(""AMHS"","_$J_",""DCS"")"
 S AMHR=AMHIEN
 K @AMHARRAY S @AMHARRAY@(0)=0
 S X="" D S(X) D S("TIU DOCUMENTS") D S("-------------")
 S AMHDOC=0 F  S AMHDOC=$O(^AMHREC(AMHIEN,54,"B",AMHDOC)) Q:AMHDOC'=+AMHDOC  D
 .K AMHTIU,AMHERR
 .K ^TMP("AMHOENPS",$J)
 .D TIUDSP
 .D S(" ")  ;cmi/maw pr582
 .K ^TMP("AMHEONPS",$J)
 .K AMHTIU
 .Q
 Q
 ;
TIUDSP ;
 S AMHSTR="" D S(AMHSTR)
 I '+$$CANDO^TIULP(AMHDOC,"PRINT RECORD",DUZ) Q  ;S AMHSTR="You do not have security clearance to display the TIU NOTE." D S(AMHSTR) Q
 ; Extract specified note
 S AMHGBL=$NA(^TMP("AMHOENPS",$J)),AMHHLF=IOM\2
 K @AMHGBL
 D EXTRACT^TIULQ(AMHDOC,AMHGBL,.AMHERR,".01;.02;.03;.05;.07;.08;1202;1203;1205;1208;1209;1301;1307;1402;1501:1505;1507:1513;1701","",1,"E")
 M AMHTIU=^TMP("AMHOENPS",$J,AMHDOC)
 K ^TMP("AMHOENPS",$J)
 S AMHSTR="TIU DOCUMENT:  "_AMHTIU(.01,"E") D S(AMHSTR)
 S AMHSTR="AUTHOR: "_AMHTIU(1202,"E") D S(AMHSTR)
 S AMHSTR="SIGNED BY: "_AMHTIU(1502,"E")_"               STATUS: "_AMHTIU(.05,"E") D S(AMHSTR)
 S AMHSTR="LOCATION: "_AMHTIU(1205,"E") D S(AMHSTR)
 F AMHX=0:0 S AMHX=$O(AMHTIU("TEXT",AMHX)) Q:'AMHX  S AMHSTR=AMHTIU("TEXT",AMHX,0) D S(AMHSTR)
 I $L($G(AMHTIU(1501,"E"))) D
 .S AMHSTR="/es/ "_$G(AMHTIU(1503,"E")) D S(AMHSTR)
 .S AMHSTR="Signed: "_$G(AMHTIU(1501,"E")) D S(AMHSTR)
 ;NOW GET ADDENDA USING "DAD" XREF
 I $O(^TIU(8925,"DAD",AMHDOC,0)) S AMHSTR="" D S(AMHSTR)   ;S AMHSTR="This document has addenda." D S(AMHSTR)
 S AMHX1=0 F  S AMHX1=$O(^TIU(8925,"DAD",AMHDOC,AMHX1)) Q:AMHX1'=+AMHX1  D
 .I '+$$CANDO^TIULP(AMHX1,"PRINT RECORD",DUZ) Q  ;S AMHSTR="You do not have security clearance to display the addendum." D S(AMHSTR) Q
 .S AMHGBL=$NA(^TMP("AMHOENPS",$J))
 .K @AMHGBL
 .K AMHTIU
 .D EXTRACT^TIULQ(AMHX1,AMHGBL,.AMHERR,".01;.02;.03;.05;.07;.08;1202;1203;1205;1208;1209;1301;1307;1402;1501:1505;1507:1513;1701","",1,"E")
 .M AMHTIU=^TMP("AMHOENPS",$J,AMHX1)
 .K ^TMP("AMHOENPS",$J)
 .S AMHSTR=" " D S(AMHSTR)
 .S AMHSTR=AMHTIU(.01,"E") D S(AMHSTR)
 .S AMHSTR="AUTHOR: "_AMHTIU(1202,"E") D S(AMHSTR)
 .S AMHSTR="SIGNED BY: "_AMHTIU(1502,"E")_"               STATUS: "_AMHTIU(.05,"E") D S(AMHSTR)
 .S AMHSTR="LOCATION: "_AMHTIU(1205,"E") D S(AMHSTR)
 .F AMHX=0:0 S AMHX=$O(AMHTIU("TEXT",AMHX)) Q:'AMHX  S AMHSTR=AMHTIU("TEXT",AMHX,0) D S(AMHSTR)
 .I $L($G(AMHTIU(1501,"E"))) D
 ..S AMHSTR="/es/ "_$G(AMHTIU(1503,"E")) D S(AMHSTR)
 ..S AMHSTR="Signed: "_$G(AMHTIU(1501,"E")) D S(AMHSTR)
 ;
 Q
S(Y,F,C,T) ;set up array
 NEW %
 I '$G(F) S F=0
 I '$G(T) S T=0
 ;blank lines
 F F=1:1:F S X="" D S1
 S X=Y
 I $G(C) S L=$L(Y),T=(80-L)/2 D  D S1 Q
 .F %=1:1:(T-1) S X=" "_X
 F %=1:1:T S X=" "_Y
 D S1
 Q
S1 ;
 S %=$P(^TMP("AMHS",$J,"DCS",0),U)+1,$P(^TMP("AMHS",$J,"DCS",0),U)=%
 S ^TMP("AMHS",$J,"DCS",%)=X
 Q
 ;