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

AMHEXD2.m

Go to the documentation of this file.
AMHEXD2 ; IHS/CMI/LAB - PROCESS RECORD ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;encryted patient id info, fixed sec prov to check for unknown
 ;
RECORD ;EP
 S (AMHE,AMHTX)="" K AMHRTYPE
 I '$D(^AMHREC(AMHR)) S AMHE="E026" Q
RECTYPE I AMHO("RUN")="NEW" S X=$P(AMHREC,U,22) I X="" S X=$S($P(AMHREC,U,24)]"":"M",1:"A")
 I AMHO("RUN")="REDO" S X=$P(^AMHXLOG(AMH("RUN LOG"),21,AMHR,0),U,3) I X="" S X="A"
 D TX
DATE S X=$P($P(AMHREC,U),".") I X="" S AMHE="E001" Q
 D TX
DUZ2 S X=$P(^AUTTLOC(DUZ(2),0),U,10) I X=""!($L(X)'=6) S AMHE="E002" Q
 D TX S AMHDUZ2=X
PROG S X=$P(AMHREC,U,2) I X="" S AMHE="E003" Q
 D TX
LOENC S X=$P(AMHREC,U,4) I X="" S AMHE="E004" Q
 S X=$P(^AUTTLOC(X,0),U,10) I X=""!($L(X)'=6) S AMHE="E005" Q
 D TX S AMHLOC=X
COMM S AMHCOM=$P(AMHREC,U,5) I AMHCOM="" S AMHE="E006" Q
 S X=$P(^AUTTCOM(AMHCOM,0),U,8) I X="" S AMHE="E007" Q
 I $L(X)'=7 S AMHE="E007" Q
 D TX
 K AMHTMP,^UTILITY("DIQ1",$J) S DIC="^AUTTCOM(",DR=".11991;.11992",DA=AMHCOM,DIQ="AMHTMP(",DIQ(0)="E" D EN^DIQ1 K DIC,DR,DIQ,^UTILITY("DIQ1",$J)
 S X=$G(AMHTMP(9999999.05,AMHCOM,.11992,"E"))_$G(AMHTMP(9999999.05,AMHCOM,.11991,"E"))_$P(^AUTTCOM(AMHCOM,0),U,7)
 I $L(X)'=7 S X="       "
 D TX
ACT S X=$P(AMHREC,U,6) I X="" S AMHE="E009" Q
 I '$D(^AMHTACT(X)) S AMHE="E009" Q
 S X=$P(^AMHTACT(X,0),U) I X="" S AMHE="E009" Q
 D TX
CONT S X=$P(AMHREC,U,7) I X="" S AMHE="E010" Q
 I '$D(^AMHTSET(X)) S AMHE="E010" Q
 S X=$P(^AMHTSET(X,0),U,2) I X="" S AMHE="E010" Q
 S:$L(X)=2 X=0
 D TX
NS ;S X=$P(AMHREC,U,9) I 'X S AMHE="E011" Q
 S X=$P(AMHREC,U,9) I X="" S X=0
 S X=$$LZERO(X,3)
 D TX
MIN S X=$P(AMHREC,U,12) I 'X S AMHE="E012" Q
 S X=$$LZERO(X,5)
 D TX
DISP ;inpatient disposition
 S X=$P(AMHREC,U,17) S:X X=$P(^AMHTPLT(X,0),U,3) S:X=10 X=0 S:X>9 X="" S X=$$LBLK(X,1) ;GONE TO 2 DIGITS!!  OLD VALUES SENT FOR NOW
 D TX
APWI ;
 S X=$P(AMHREC,U,11) S X=$$LBLK(X,1)
 D TX
INT ;
 S X=$P(AMHREC,U,15) S X=$$LBLK(X,1)
 D TX
PROV ;get providers
 I '$D(^AMHRPROV("AD",AMHR)) S AMHE="E022" Q
 S AMHAFF=$$PPAFFL^AMHUTIL(AMHR,"I") I AMHAFF=""!(AMHAFF["?") S AMHE="E023" Q
 S AMHDISC=$$PPCLSC^AMHUTIL(AMHR) I AMHDISC=""!(AMHDISC["?") S AMHE="E024" Q
 S AMHINI=$$PPINI^AMHUTIL(AMHR) I AMHINI["?" S AMHE="E025" Q
 S AMHINI=$$LBLK(AMHINI,3)
PROV1 S X=AMHAFF_AMHDISC_AMHINI D TX
 S AMHRIEN=0,AMHC=1 F  S AMHRIEN=$O(^AMHRPROV("AD",AMHR,AMHRIEN)) Q:AMHRIEN'=+AMHRIEN!(AMHE]"")  I $P(^AMHRPROV(AMHRIEN,0),U,4)'="P" S AMHX=$P(^AMHRPROV(AMHRIEN,0),U) D
 .S AMHAFF=$$PROVAFFL^XBFUNC1(AMHX,"I") I AMHAFF=""!(AMHAFF["?") S AMHE="E023" Q
 .S AMHDISC=$$PROVCLSC^XBFUNC1(AMHX) I AMHDISC=""!(AMHDISC["?")!(AMHDISC["UNKNOWN") S AMHE="E024" Q
 .S AMHINI=$$PROVINI^XBFUNC1(AMHX) I AMHINI=""!(AMHINI["?") S AMHE="E025" Q
 .S AMHINI=$$LBLK(AMHINI,3)
 .S X=AMHAFF_AMHDISC_AMHINI D TX
 .S AMHC=AMHC+1
 .Q
 F I=(AMHC+1):1:4 S X="",X=$$LBLK(X,6) D TX
 Q:AMHE]""
POVS ;get problems first 4
 I '$D(^AMHRPRO("AD",AMHR)) S AMHE="E021" Q
 S (AMHRIEN,AMHC)=0 F  S AMHRIEN=$O(^AMHRPRO("AD",AMHR,AMHRIEN)) Q:AMHRIEN'=+AMHRIEN!(AMHC=4)  S P=$P(^AMHRPRO(AMHRIEN,0),U),X=$P(^AMHPROB(P,0),U),X=$$LBLK(X,6),AMHC=AMHC+1 D TX
 F I=(AMHC+1):1:4 S X="",X=$$LBLK(X,6) D TX
 K AMHRIEN,P,X
PATIENT ;
 I $P(AMHREC,U,8)="" S X=$$LBLK($P(AMHREC,U,8),40) D TX Q
 S AMHPAT=$P(AMHREC,U,8)
 S Y=AMHPAT D ^AUPNPAT
 S AMHNAME=$P(^DPT(AMHPAT,0),U)
 I AMHNAME="DEMO,PATIENT" S X="",X=$$LBLK(X,40) D TX Q
CHART ;
 S X=$$ENC^AMHRLU2(AMHPAT)
 D TX
SEX ;
 I AUPNSEX="" S AMHE="E014" Q
 S X=AUPNSEX D TX
DOB ;
 I AUPNDOB="" S AMHE="E015" Q
 S X=AUPNDOB D TX
 I '$D(^AUPNPAT(AMHPAT,11)) S AMHE="E016" Q
COMRES ;
 S Y=0,AMHCOM="" F  S Y=$O(^AUPNPAT(AMHPAT,51,Y)) Q:Y'=+Y  S AMHCOM=Y
 I AMHCOM="" S AMHE="E016" Q
 S AMHCOM=$P(^AUPNPAT(AMHPAT,51,AMHCOM,0),U,3) I AMHCOM="" S AMHE="E017" Q
 I '$D(^AUTTCOM(AMHCOM,0)) S AMHE="E017" Q
 I AMHCOM]"" S X=$P(^AUTTCOM(AMHCOM,0),U,8) I X="" S AMHE="E017" Q
 D TX
 ;GET ASUCOMM CODE HERE AND D TX
 K AMHTMP,^UTILITY("DIQ1",$J) S DIC="^AUTTCOM(",DR=".11991;.11992",DA=AMHCOM,DIQ="AMHTMP(",DIQ(0)="E" D EN^DIQ1 K DIC,DR,DIQ,^UTILITY("DIQ1",$J)
 S X=$G(AMHTMP(9999999.05,AMHCOM,.11992,"E"))_$G(AMHTMP(9999999.05,AMHCOM,.11991,"E"))_$P(^AUTTCOM(AMHCOM,0),U,7)
 I $L(X)'=7 S X="       "
 D TX
TRIBE ;
 S X=$P(^AUPNPAT(AMHPAT,11),U,8) I X="" S AMHE="E018" Q
 I $P(^AUTTTRI(X,0),U,4)="Y" S AMHE="E019" Q
 S X=$P(^AUTTTRI(X,0),U,2) I X="" S AMHE="E020" Q
 D TX
MCARE ;
 S X=$$MCR^AMHRLU(AMHPAT,$P($P(AMHREC,U),"."))
 S X=$S(X:"Y",1:"N")
 D TX
MCAID ;
 S X=$$MCD^AMHRLU(AMHPAT,$P($P(AMHREC,U),"."))
 S X=$S(X:"Y",1:"N")
 D TX
PI ;EP
 S X=$$PI^AMHRLU(AMHPAT,$P($P(AMHREC,U),"."))
 S X=$S(X:"Y",1:"N")
 D TX
EM ;evaluation&management
 S X=$P(AMHREC,U,29)
 S X=$S(X="":"     ",1:$P($$CPT^ICPTCOD(X,$P($P(AMHREC,U),".")),U,2))
 D TX
CPT1 ;
 S Y=$O(^AMHRPROC("AD",AMHR,0))
 S X=$S(Y="":"     ",1:$P($$CPT^ICPTCOD($P(^AMHRPROC(Y,0),U),$P($P(^AMHREC(AMHR,0),U),".")),U,2))
 D TX
CPT2 ;
 S C=0,Y=0 F  S Y=$O(^AMHRPROC("AD",AMHR,Y)) Q:Y'=+Y!(C=2)  S C=C+1 I C=2 S %=Y
 S X=$S($G(%)="":"     ",1:$P($$CPT^ICPTCOD($P(^AMHRPROC(%,0),U),$P($P(^AMHREC(AMHR,0),U),".")),U,2))
 D TX
 Q
 ;
TX ;
 S AMHTX=AMHTX_X
 Q
 ;
LZERO(V,L) ;left zero fill
 NEW %,I
 S %=$L(V),Z=L-% F I=1:1:Z S V="0"_V
 Q V
LBLK(V,L) ;left blank fill
 NEW %,I
 S %=$L(V),Z=L-% F I=1:1:Z S V=" "_V
 Q V