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

AMHEYC1.m

Go to the documentation of this file.
AMHEYC1 ; IHS/CMI/LAB - RECORD REVIEW PROCESS ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;
 ;
 ;
START ;
 S (AMHBT,AMHBTH)=$H,AMHJOB=$J,AMH("ERROR COUNT")=0,AMHO("RUN")="NEW"
 D DATE,XIT
 Q
 ;
DATE ; Run by encounter date
 S X1=AMHBD,X2=-1 D C^%DTC S AMHSD=X
 S AMHODAT=AMHSD_".9999" F  S AMHODAT=$O(^AMHREC("AEX",AMHODAT)) Q:AMHODAT=""!((AMHODAT\1)>AMHED)  D D1
 Q
 ;
XIT ;
 S AMHET=$H
 D EOJ
 Q
EOJ ;
 Q
D1 ;
 S (AMHR,AMHRCNT)=0 F  S AMHR=$O(^AMHREC("AEX",AMHODAT,AMHR)) Q:AMHR'=+AMHR  S AMHREC=^AMHREC(AMHR,0) D PROC
 Q
PROC ;
 K AMHE,AMHTX D RECORD
 Q:AMHE=""
 S AMH("ERROR COUNT")=AMH("ERROR COUNT")+1
 S AMHE("ERR DFN")=$O(^AMHERR("B",AMHE,"")) I AMHE("ERR DFN")="" S AMHE("MSG")=AMHE_"-ERROR INFORMATION NOT IN ERROR FILE" G ERR
 S AMHE("MSG")=AMHE_"-"_$P(^AMHERR(AMHE("ERR DFN"),0),U,2) S:$L(AMHE("MSG"))=5 AMHE("MSG")=AMHE("MSG")_"- ERROR INFORMATION NOT IN ERROR FILE" S AMHE("MSG")=$E(AMHE("MSG"),1,45)
ERR S ^XTMP("AMHEYC",AMHJOB,AMHBT,"ERRORS",AMHR)=AMHE("MSG")
 Q
 ;
RECORD ;EP
 S (AMHE,AMHTX)="" K AMHRTYPE
 I '$D(^AMHREC(AMHR)) S AMHE="E026" Q
 ;
D S X=$P($P(AMHREC,U),".") I X="" S AMHE="E001" Q
 ;
PROG S X=$P(AMHREC,U,2) I X="" S AMHE="E003" Q
 ;
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
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
 ;
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
 ;
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
 ;
PROV ;get providers
 I '$D(^AMHRPROV("AD",AMHR)) S AMHE="E022" Q
 S X=0 F  S X=$O(^AMHRPROV("AD",AMHR,X)) Q:X'=+X  S Y=$P($G(^AMHRPROV(X,0)),U) I '$D(^VA(200,Y,0)) S AMHE="E023" 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 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
 Q:AMHE]""
POVS ;get problems first 4
 I '$D(^AMHRPRO("AD",AMHR)) S AMHE="E021" Q
PATIENT ;
 I $P(AMHREC,U,8)="" Q
 S AMHPAT=$P(AMHREC,U,8)
 S Y=AMHPAT D ^AUPNPAT
SEX ;
 I AUPNSEX="" S AMHE="E014" Q
 S X=AUPNSEX ;
DOB ;
 I AUPNDOB="" S AMHE="E015" Q
 S X=AUPNDOB ;
 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
 ;
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
 ;
 Q