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

AMHGPCC.m

Go to the documentation of this file.
AMHGPCC ; IHS/CMI/MAW - AMHG PCC Visit Links 3/5/2009 8:10:19 AM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;
 ;
DEBUG(RETVAL,AMHSTR) ;-- debug entry point
 D DEBUG^%Serenji("PCC^AMHGPCC(.RETVAL,.AMHSTR)")
 Q
 ;
PCC(RETVAL,AMHSTR) ;-- create/edit PCC visit from MHSS RECORD ENTRY
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIEN,AMHVS,AMHGRET,AMHREC,AMHER
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIEN=$P(AMHSTR,P)
 S AMHVS=$P(AMHSTR,P,2)
 I '$G(AMHVS) S AMHVS=$P($G(^AMHREC(AMHIEN,0)),U,16)
 D EN^AMHBHRU(.AMHGRET,AMHIEN,AMHVS)
 I $E($G(AMHGRET),1,2)="-1" D
 . S AMHER="0~"_$P(AMHGRET,$C(30),2)
 I $G(AMHGRET)=1 D
 . S AMHREC=$$GET1^DIQ(9002011,AMHIEN,.16,"I")
 S @RETVAL@(AMHI)="T00030Result"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($G(AMHER)]"":AMHER,1:$G(AMHREC))_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;
LIST(RETVAL,AMHSTR) ;-- get a list of visits for the user to choose from
 S X="MERR^AMHGU",@^%ZOSF("TRAP") ; m error trap
 N AMHI,P,R,AMHIEN,AMHSEL
 S P="|",R="~"
 S RETVAL="^AMHTMP("_$J_")"
 S AMHI=0
 K ^AMHTMP($J)
 S AMHIEN=$P(AMHSTR,P)
 D BSDAPI(.AMHSEL,AMHIEN)
 S @RETVAL@(AMHI)="T00010BMXIEN^T00030Date^T00005Time^T00030Location^T00030Provider^T00030Clinic^T00030ServiceCategory^T00080POV"_$C(30)
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(AMHSEL(AMHDA)) Q:'AMHDA  D
 . N AMHDATA,AMHDT,AMHTM,AMHLOC,AMHPRV,AMHCLN,AMHSC,AMHPOVC,AMHPOVN,AMHPOV
 . S AMHDT=$$LVDT^AMHGU($P($P(^AUPNVSIT(AMHDA,0),U),"."))
 . S AMHTM=$P($P(^AUPNVSIT(AMHDA,0),U),".",2)
 . S AMHTM=$S($L(AMHTM)=1:AMHTM_"000",$L(AMHTM)=2:AMHTM_"00",$L(AMHTM)=3:AMHTM_"0",1:AMHTM)
 . S AMHLOC=$$GET1^DIQ(9000010,AMHDA,.06)
 . S AMHPRV=$$PRIMPROV^APCLV(AMHDA,"N")
 . S AMHPOVC=$$PRIMPOV^APCLV(AMHDA,"C")
 . S AMHPOVN=$$PRIMPOV^APCLV(AMHDA,"N")
 . S AMHPOV=$S(AMHPOVN]"":AMHPOVC_"-"_AMHPOVN,1:"")
 . S AMHCLN=$$GET1^DIQ(9000010,AMHDA,.08)
 . S AMHSC=$$GET1^DIQ(9000010,AMHDA,.07)
 . S AMHI=AMHI+1
 . S @RETVAL@(AMHI)=AMHDA_U_AMHDT_U_AMHTM_U_AMHLOC_U_AMHPRV_U_AMHCLN_U_AMHSC_U_AMHPOV_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 K AMHIN
 Q
 ;
BSDAPI(AMHV,AMHR) ;-- get list of visits and return amhv
 K AMHIN ;clean out array
 D KILL
 S AMHR0=$G(^AMHREC(AMHR,0))
 S AMHIN("VISIT DATE")=$P(AMHR0,U)
 D GETTYPE
 S AMHIN("VISIT TYPE")=APCDALVR("APCDTYPE")
 S AMHIN("PAT")=$P(AMHR0,U,8)
 S AMHIN("SITE")=$P(AMHR0,U,4)
 ;determine service category based on type of contact
 S AMHIN("SRV CAT")=$P(^AMHTSET($P(AMHR0,U,7),0),U,3)
 ;D GETCLN
 ;I APCDALVR("APCDCLN")]"" S AMHIN("CLINIC CODE")=APCDALVR("APCDCLN")
 S AMHIN("APCDAPPT")=$P(AMHR0,U,11)
 S AMHIN("APCDOLOC")=$P(AMHR0,U,26)
 S AMHIN("APCDEVM")=$P(AMHR0,U,29)
 S AMHIN("APCDOPT")=$P($G(XQY0),U) I AMHIN("APCDOPT")]"" S AMHIN("APCDOPT")=$O(^DIC(19,"B",AMHIN("APCDOPT"),0))
 S AMHIN("APCDCAF")=$S($P($G(^AMHSITE(DUZ(2),18)),U,8):"I",1:"R")
 S AMHIN("NEVER ADD")=1  ;never add a visit just find matches
 S AMHIN("TIME RANGE")=-1
 S AMHIN("USR")=DUZ
 K APCDALVR
 K AMHV
 D GETVISIT^BSDAPI4(.AMHIN,.AMHV)
 S AMHERRR=$P(AMHV(0),U,2)
 I AMHERRR]"" Q  ;errored
 I $P(AMHV(0),U)=1 S V=$O(AMHV(0)) I AMHV(V)="ADD" S AMHVSIT=V Q
 ;since more than one passed back display them to the user and quit
 Q
 ;
GETTYPE ;get type of visit - use loc current type or affiliation of provider
 S APCDALVR("APCDTYPE")=$S($P($G(^AMHSITE(DUZ(2),0)),U,2)]"":$P(^(0),U,2),1:"") Q:APCDALVR("APCDTYPE")]""
 ;S X=$P(^AUTTLOC($P(AMHR0,U,4),0),U,25) I X]"" S APCDALVR("APCDTYPE")=$S(X=1:"I",X=2:"6",X=3:"C",X=4:"U",X=5:"S",X=6:"T",1:"O") Q
 S X=$P($G(^APCCCTRL($P(AMHR0,U,4),0)),U,4) I X]"" S APCDALVR("APCDTYPE")=X Q  ;use pcc master control for site of loc of enc ihs/tucson/lab 11/30/95 patch 1
 S X=$$PPAFFL^AMHUTIL(AMHR,"I") I X S APCDALVR("APCDTYPE")=$S(X=1:"I",X=2:"C",X=3:"T",X=8:"6",1:"") I APCDALVR("APCDTYPE")]"" Q
 S X=$P($G(^APCCCTRL(DUZ(2),0)),U,4) I X]"" S APCDALVR("APCDTYPE")=X Q  ;use pcc master control
 S APCDALVR("APCDTYPE")="I" ;default to I if can't determine
 Q
 ;
GETCLN ;determine clinic to pass
 S APCDALVR("APCDCLN")=""
 NEW X
 S X=$P(AMHR0,U,7)
 I X="" G GETCLN1
 I $P($G(^AMHTSET(X,0)),U,2)=9 S APCDALVR("APCDCLN")=$O(^DIC(40.7,"C",30,"")) Q:APCDALVR("APCDCLN")]""
 I $P($G(^AMHTSET(X,0)),U,2)=5 S APCDALVR("APCDCLN")=$O(^DIC(40.7,"C",11,"")) Q:APCDALVR("APCDCLN")]""
GETCLN1 ;
 S APCDALVR("APCDCLN")=$P(AMHR0,U,25)
 Q:APCDALVR("APCDCLN")]""
 S APCDALVR("APCDCLN")=$S($P(AMHR0,U,2)="M":$O(^DIC(40.7,"C",14,"")),$P(AMHR0,U,2)="S":$O(^DIC(40.7,"C",48,"")),$P(AMHR0,U,2)="C":$O(^DIC(40.7,"C",43,0)),1:$O(^DIC(40.7,"C",C4,"")))
 I APCDALVR("APCDCLN")="" S APCDALVR("APCDCLN")=$O(^DIC(40.7,"C",25,""))
 Q
KILL ;
 K APCDALVR,APCDPAT,APCDLOC,APCDTYPE,APCDCAT,APCDCLN,APCDTPRO,APCDTPS,APCDTPOV,APCDTNQ,APCDTTOP,APCDTLOU,APCDTPRV,APCDTAT,APCDATMP,APCDAFLG,APCDAUTO,APCDANE,AUPNTALK,APCDAPPT,APCDOLOC
 Q
 ;
ACT(RETVAL,AMHSTR) ;-- check to see if the activity code can be passed to PCC
 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)="T00030Error"_$C(30)
 S AMHI=AMHI+1
 S @RETVAL@(AMHI)=$S($P($G(^AMHTACT(AMHIEN,0)),U,4):"",1:1)_$C(30)
 S @RETVAL@(AMHI+1)=$C(31)
 Q
 ;