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

AMHGDGP.m

Go to the documentation of this file.
AMHGDGP ; IHS/CMI/MAW - AMH Group Data Entry 1/22/2009 1:54:47 PM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**1,4,5**;JUN 02, 2010;Build 18
 ;
 ;
 ;
DEBUG(RETVAL,AMHSTR) ;-- debug entry point
 D DEBUG^%Serenji("EP^AMHGDGP(RETVAL,.AMHSTR)")
 Q
 ;
ENC(RETVAL,AMHSTR) ;-- retrieve group encounter information
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S @RETVAL@(AMHI)="T00010BMXIEN^T00030PrimaryProvider^T00030Program^T00030GroupName^T00030Clinic^T00030TypeofContact^T00030EncounterLocation^T00020EncounterDate^T00010ArrivalTime^T00050CommofService^T00050Activity^T00010ActivityTime"
 S @RETVAL@(AMHI)=@RETVAL@(AMHI)_"^T00250ChiefComplaint"_$C(30)
 N AMHIEN,AMHPRVI,AMHPRV,AMHPRGI,AMHPRG,AMHCLNI,AMHCLN,AMHCLNS,AMHCTI,AMHCT,AMHCTS,AMHARR,AMHENCDT,AMHELOCI,AMHELOC,AMHACI,AMHAC,AMHACS,AMHCOMMI,AMHCOMM
 N AMHPRVS,AMHPRGS,AMHCLNS,AMHTOCS,AMHLOCS,AMHAPWIS,AMHCOMMS,AMHDT,AMHGRP,AMHGAT,AMHCC
 S AMHIEN=$P(AMHSTR,P)
 S AMHDT=$$GET1^DIQ(9002011.67,AMHIEN,.01,"I")
 S AMHDT=$$VCDT^AMHGU(AMHDT)
 S AMHGRP=$$GET1^DIQ(9002011.67,AMHIEN,.03,"I")
 S AMHCTI=$$GET1^DIQ(9002011.67,AMHIEN,.08,"I")
 S AMHCT=$$GET1^DIQ(9002011.67,AMHIEN,.08)
 S AMHCTS=$S(AMHCTI:AMHCTI_R_AMHCT,1:"")
 S AMHPRG=$$GET1^DIQ(9002011.67,AMHIEN,.02)
 S AMHPRVI=$$GETPRVG^AMHGU(AMHIEN,"P")
 S AMHPRV=$S($G(AMHPRVI):$$GET1^DIQ(200,AMHPRVI,.01),1:"")
 S AMHPRVS=$S(AMHPRVI:AMHPRVI_R_AMHPRV,1:"")
 S AMHACI=$$GET1^DIQ(9002011.67,AMHIEN,.07,"I")
 S AMHAC=$S(AMHACI:$$GET1^DIQ(9002012,AMHACI,.02),1:"")
 S AMHACS=$S(AMHACI:AMHACI_R_AMHAC,1:"")
 S AMHCLNI=$$GET1^DIQ(9002011.67,AMHIEN,.14,"I")
 S AMHCLN=$$GET1^DIQ(9002011.67,AMHIEN,.14)
 S AMHCLNS=$S(AMHCLNI:AMHCLNI_R_AMHCLN,1:"")
 S AMHARR=$P($$GET1^DIQ(9002011.67,AMHIEN,.01,"I"),".",2)
 ;I $G(AMHARR) D
 ;. I $L(AMHARR=1) S AMHARR=AMHARR_"000" Q
 ;. I $L(AMHARR=2) S AMHARR=AMHARR_"00" Q
 ;. I $L(AMHARR=3) S AMHARR=AMHARR_"0" Q
 S AMHARR=""
 S AMHELOCI=$$GET1^DIQ(9002011.67,AMHIEN,.05,"I")
 I AMHELOCI,$P($G(^AUTTLOC(AMHELOCI,0)),U,27) S AMHELOCI=""  ;don't bring back inactive
 S AMHELOC=$$GET1^DIQ(9002011.67,AMHIEN,.05)
 S AMHLOCS=$S(AMHELOCI:AMHELOCI_R_AMHELOC,1:"")
 S AMHCOMMI=$$GET1^DIQ(9002011.67,AMHIEN,.06,"I")
 I $G(AMHCOMMI),$P($G(^AUTTCOM(AMHCOMMI,0)),U,18) S AMHCOMMI=""  ;don't bring back inactive
 S AMHCOMM=$$GET1^DIQ(9002011.67,AMHIEN,.06)
 S AMHCOMMS=$S(AMHCOMMI:AMHCOMMI_R_AMHCOMM,1:"")
 S AMHGAT=$$GET1^DIQ(9002011.67,AMHIEN,.11)
 S AMHCC=$$GET1^DIQ(9002011.67,AMHIEN,1200)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=AMHIEN_U_AMHPRVS_U_AMHPRG_U_AMHGRP_U_AMHCLNS_U_AMHCTS_U_AMHLOCS_U_AMHDT_U_AMHARR_U_AMHCOMMS_U_AMHACS_U_AMHGAT_U_AMHCC_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
POV(RETVAL,AMHSTR) ;-- retrieve POV information
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIEN,AMHDUPE,AMHDATE
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIEN=$P(AMHSTR,P)
 S AMHDUPE=$P(AMHSTR,P,2)  ;p5
 S AMHDATE=$P(AMHSTR,P,3)
 S AMHDATE=$S(AMHDATE]"":AMHDATE,1:DT)
 S @RETVAL@(AMHI)="T00010BMXIEN^T00010Code^T00100Narrative"_$C(30)
 N AMHDA,AMHPOVI
 S AMHDA=0 F  S AMHDA=$O(^AMHGROUP(AMHIEN,21,AMHDA)) Q:'AMHDA  D
 . N AMHPOVI,AMHPOV,AMHPOVC,AMHPOVE,AMHPOVN
 . S AMHPOVI=+$G(^AMHGROUP(AMHIEN,21,AMHDA,0))
 . I $G(AMHDUPE) Q:'$$CHKD^AMHUTIL1(AMHPOVI,AMHDATE)
 . S AMHPOV=$$GET1^DIQ(9002012.2,AMHPOVI,.01,"I")
 . S AMHPOVC=$$GET1^DIQ(9002012.2,AMHPOVI,.01)
 . S AMHPOVN=$P($G(^AMHGROUP(AMHIEN,21,AMHDA,0)),U,2)
 . S AMHPOVE=$S($G(AMHPOVN)]"":$$GET1^DIQ(9999999.27,AMHPOVN,.01),1:$$GET1^DIQ(9002012.2,AMHPOVI,.02))
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHPOVI_U_AMHPOVC_U_AMHPOVE_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
SOAP(RETVAL,AMHSTR) ;-- retrieve the SOAP for the group data tab
 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)="T00250Soap"_$C(30)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^AMHGROUP(AMHIEN,31,AMHDA)) Q:'AMHDA  D
 . N AMHDATA
 . S AMHDATA=$G(^AMHGROUP(AMHIEN,31,AMHDA,0))
 . ;I AMHDATA'[$C(10) S AMHDATA=AMHDATA_$C(10)  ;cmi/maw 06/16/2010 try removing this and see what happens 11/18/2010
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHDATA_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
CPT(RETVAL,AMHSTR) ;-- retrieve cpt codes for group data
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIEN,AMHDUPE,AMHDATE
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIEN=$P(AMHSTR,P)
 S AMHDUPE=$P(AMHSTR,P,2)
 S AMHDATE=$P(AMHSTR,P,3)
 S AMHDATE=$S(AMHDATE]"":AMHDATE,1:DT)
 S @RETVAL@(AMHI)="T00010BMXIEN^T00010Code^T00050Narrative^T00010Quantity^T00010Mod1IEN^T00010Mod1^T00010Mod2IEN^T00010Mod2"_$C(30)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^AMHGROUP(AMHIEN,41,AMHDA)) Q:'AMHDA  D
 . N AMHCPTI,AMHCPT,AMHCPTE,AMHQTY,AMHMOD1I,AMHMOD1,AMHMOD2I,AMHMOD2
 . S AMHCPTI=$P($G(^AMHGROUP(AMHIEN,41,AMHDA,0)),U)
 . I $G(AMHDUPE) D CPT^AMHUTIL1(AMHCPTI,AMHDATE) I '$T Q
 . S AMHQTY=$P($G(^AMHGROUP(AMHIEN,41,AMHDA,0)),U,2)
 . I AMHQTY="" S AMHQTY=1
 . I AMHQTY<1 S AMHQTY=1
 . S AMHMOD1I=$P($G(^AMHGROUP(AMHIEN,41,AMHDA,0)),U,3)
 . S AMHMOD1=$$GET1^DIQ(81.3,AMHMOD1I,.01)
 . S AMHMOD2I=$P($G(^AMHGROUP(AMHIEN,41,AMHDA,0)),U,4)
 . S AMHMOD2=$$GET1^DIQ(81.3,AMHMOD2I,.01)
 . S AMHCPT=$$GET1^DIQ(81,AMHCPTI,.01)
 . S AMHCPTE=$$GET1^DIQ(81,AMHCPTI,2)
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHCPTI_U_AMHCPT_U_AMHCPTE_U_AMHQTY_U_AMHMOD1I_U_AMHMOD1_U_AMHMOD2I_U_AMHMOD2_$C(30)  ;v4.0p1 ihs/cmi/maw changed 2nd piece to AMHCPT from AMHCPTI
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
SP(RETVAL,AMHSTR) ;-- retrieve secondary providers for group data tab
 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^T00030Provider"_$C(30)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^AMHGROUP(AMHIEN,11,AMHDA)) Q:'AMHDA  D
 . N AMHSPRV,AMHSPRVI
 . Q:$P($G(^AMHGROUP(AMHIEN,11,AMHDA,0)),U,2)'="S"  ;filter out primary
 . S AMHSPRVI=$P($G(^AMHGROUP(AMHIEN,11,AMHDA,0)),U)
 . S AMHSPRV=$$GET1^DIQ(200,AMHSPRVI,.01)
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHSPRVI_U_AMHSPRV_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
EDU(RETVAL,AMHSTR) ;-- retrieve group 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^T00100Comment^T00050CPT^T00030Status^T00030Goal^T00050Provider"_$C(30)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^AMHGROUP(AMHIEN,71,AMHDA)) Q:'AMHDA  D
 . N AMHEDU,AMHTS,AMHLOU,AMHCMT,AMHGOAL,AMHCPT,AMHST,AMHDATA,AMHEDUI,AMHCPT,AMHPRVI,AMHPRV
 . S AMHDATA=$G(^AMHGROUP(AMHIEN,71,AMHDA,0))
 . S AMHEDUI=$P(AMHDATA,U)
 . S AMHEDU=$S(AMHEDUI:$$GET1^DIQ(9999999.09,AMHEDUI,.01),1:"")
 . S AMHTS=$P(AMHDATA,U,4)
 . S AMHLOU=$P(AMHDATA,U,6)
 . I $G(AMHLOU)]"" S AMHLOU=$$SCE^AMHGT(9002011.6771,.06,AMHLOU)
 . S AMHCMT=$G(^AMHGROUP(AMHIEN,71,AMHDA,11))
 . S AMHGOAL=$P(AMHDATA,U,7)
 . S AMHST=$P(AMHDATA,U,8)
 . I $G(AMHST)]"" S AMHST=$$SCE^AMHGT(9002011.6771,.08,AMHST)
 . S AMHCPT=$P(AMHDATA,U,5)
 . S AMHPRVI=$P(AMHDATA,U,2)
 . S AMHPRV=$S(AMHPRVI:AMHPRVI_"-"_$$GET1^DIQ(200,AMHPRVI,.01),1:"")
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHDA_U_AMHEDU_U_AMHTS_U_AMHLOU_U_AMHCMT_U_AMHCPT_U_AMHST_U_AMHGOAL_U_AMHPRV_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
PAT(RETVAL,AMHSTR) ;-- get patients for group patients tab
 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^T00010PatientIEN^T00010AMHREC^T00030PatientName^T00001Sex^T00010Age^T00020DOB^T00010Chart^T00030DOD"_$C(30)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^AMHGROUP(AMHIEN,51,AMHDA)) Q:'AMHDA  D
 . N AMHPAT,AMHPNM,AMHSX,AMHAGE,AMHDOB,AMHCHT,AMHREC,AMHDOD
 . S AMHPAT=$G(^AMHGROUP(AMHIEN,51,AMHDA,0))
 . S AMHREC=$$GETREC^AMHGU(AMHPAT,AMHIEN)
 . S AMHPNM=$$GET1^DIQ(2,AMHPAT,.01)
 . S AMHSX=$$GET1^DIQ(2,AMHPAT,.02,"I")
 . S AMHAGE=$$AGE^AUPNPAT(AMHPAT)
 . S AMHDOB=$$GET1^DIQ(2,AMHPAT,.03,"I")
 . S AMHCHT=$$HRN^AUPNPAT(AMHPAT,DUZ(2))
 . S AMHDOD=$$GET1^DIQ(2,AMHPAT,.351)
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHIEN_U_AMHPAT_U_AMHREC_U_AMHPNM_U_AMHSX_U_AMHAGE_U_$$LVDT^AMHGU(AMHDOB)_U_AMHCHT_U_AMHDOD_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;