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

BHSRCIS.m

Go to the documentation of this file.
BHSRCIS ;IHS/CIA/MGH - Health Summary for Referred care ;22-Apr-2014 09:36;DU
 ;;1.0;HEALTH SUMMARY COMPONENTS;**9**;Jan 06, 2006;Build 16
 ;===================================================================
 ;Taken from BMCHS
 ; IHS/PHXAO/TMJ - RCIS HEALTH SUMMARY COMPONENT ;
 ;;2.0T1;REFERRED CARE INFO SYSTEM;;NOV 21, 2001
 ;;Health summary routine to get data from REFERRED CARE INFO SYSTEM;;NOV 21, 2001
 ;
 ; This routine generates the RCIS component of the Health Summary.
 ;
HS ;EP-called from health summary
 N X,X1,X2,Y
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W $$CTR^BMC(" <<<  RCIS ACTIVE REFERRALS  >>> ",80),!
 I '$D(^BMCREF("AA",BHSPAT)) D CKP^GMTSUP Q:$D(GMTSQIT)  W !,"No Referred Care Referral records on file.",! Q
 S X1=DT,X2=-365 D C^%DTC S BMCYAGO=X ;      date one year ago
 I $O(^BMCREF("AA",BHSPAT,""),-1)<BMCYAGO D CKP^GMTSUP Q:$D(GMTSQIT)  W !,"No Referred Care Referral records within last year.",! Q
 S BMCRDATE=""
 F  S BMCRDATE=$O(^BMCREF("AA",BHSPAT,BMCRDATE),-1) Q:BMCRDATE<BMCYAGO!($D(GMTSQIT))  D
 .S BMCRIEN=0 F  S BMCRIEN=$O(^BMCREF("AA",BHSPAT,BMCRDATE,BMCRIEN)) Q:'BMCRIEN!($D(GMTSQIT))  D WRTREF
XIT ;
 K DIEN,BMCPFH,BMCPFS,BMCPIEN,BMCYAGO,BMCMCC,BMCCHSCT,BMCDFN,BMCRDATE,BMCREC,BMCRIEN,BMCRIO,BMCRNUMB,BMCRREC,BMCRSTAT,BMCRTYPE,BMCX,BMCDIEN
 Q
 ;
WRTREF ; WRITE RCIS REFERRAL ENTRY
 S BMCRREC=^BMCREF(BMCRIEN,0)
 S Y=BMCRIEN
 D ^BMCREF
 ;
 Q:BMCRSTAT'="A"  ;Quit if Not an Active Referral
 ;
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W !,"BEGIN DOS: ",$$AVDOS^BMCRLU(BMCRIEN,"C"),"  ",$$AVDOS^BMCRLU(BMCRIEN,"E"),?37,"DISCHARGE CONSULT DT: ",$$FMTE^XLFDT($P(BMCRREC,U,18),"5D") W !,"DATE REFERRED: ",$$FMTE^XLFDT($P(BMCRREC,U),"5D") ;Y2000
 W ?37,"DISCHARGE CONSULT DT: ",$$FMTE^XLFDT($P(BMCRREC,U,18),"5D")
 W !,"DATE REFERRED: ",$$FMTE^XLFDT($P(BMCRREC,U),"5D")
 W ?37,"CHS STATUS: ",$$VAL^XBDIQ1(90001,BMCRIEN,1112)
 S BMCMCC=""
 I $D(^BMCPARM(DUZ(2),4100)) S BMCMCC=$P($G(^BMCPARM(DUZ(2),4100)),U)
 I BMCMCC="Y" W ?37,"MCC ACTION: ",$$VAL^XBDIQ1(90001,BMCRIEN,1123)
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W !,"REFERRED BY: ",$S($P(BMCRREC,U,6):$E($P(^VA(200,$P(BMCRREC,U,6),0),U),1,22),1:"???"),?37,"REFERRED TO: ",$$TOFAC^BMC(BMCRIEN)
 D CKP^GMTSUP Q:$D(GMTSQIT)
 W !,"PURPOSE: "_$$VAL^XBDIQ1(90001,BMCRIEN,1201)
 W !
 D WRTDXPX
 Q
 ;
WRTDXPX ; WRITE DX's and PX's
 D WRTDX
 Q:$D(GMTSQIT)
 D WRTPX
 Q
 ;
WRTDX ; WRITE DX'S FOR THIS REFERRAL
 I '$O(^BMCDX("AD",BMCRIEN,0)) D WRTCATD Q  ; no dx's so write category
 W "DIAGNOSES",!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 S BMCPFS="F"
 D WRTDXLP ;                                          write finals
 I BMCRSTAT="A"!('BMCPFH) S BMCPFS="P" D WRTDXLP ;    write provisionals
 Q
 ;
WRTDXLP ; LOOP THRU DX ENTRIES
 S (BMCDIEN,BMCPFH)=0
 F  S BMCDIEN=$O(^BMCDX("AD",BMCRIEN,BMCDIEN)) Q:'BMCDIEN  D WRTDX2 Q:$D(GMTSQIT)
 Q
 ;
WRTDX2 ; WRITE ONE DX
 S X=^BMCDX(BMCDIEN,0)
 Q:$P(X,U,4)'=BMCPFS
 ;Patch 9
 I $$AICD^BHSUTL D
 .W ?10,$P($$ICDDX^ICDEX($P(X,U),0,"","I"),U),?18,$S($P(X,U,4)="P":"PROV",$P(X,U,4)="F":"FINAL",1:"???")," ",$S($P(X,U,5)="P":"PRI",$P(X,U,5)="S":"SEC",1:"???")
 E  D
 .W ?10,$P($$ICDDX^ICDCODE($P(X,U),0),U),?18,$S($P(X,U,4)="P":"PROV",$P(X,U,4)="F":"FINAL",1:"???")," ",$S($P(X,U,5)="P":"PRI",$P(X,U,5)="S":"SEC",1:"???")
 ;W ?10,$P(^ICD9($P(X,U),0),U),?18,$S($P(X,U,4)="P":"PROV",$P(X,U,4)="F":"FINAL",1:"???")," ",$S($P(X,U,5)="P":"PRI",$P(X,U,5)="S":"SEC",1:"???")
 S X=$P(X,U,6)
 I X S:$D(^AUTNPOV(X,0)) X=$P(^AUTNPOV(X,0),U) I 1
 E  D ENP^XBDIQ1(90001.01,BMCDIEN,".019","BMCX(","E") S:BMCX(".019")]"" X=BMCX(".019")
 W ?27,X
 W !
 S BMCPFH=1
 D CKP^GMTSUP
 Q
 ;
WRTPX ; WRITE PX'S FOR THIS REFERRAL
 I '$O(^BMCPX("AD",BMCRIEN,0)) D WRTCATS Q  ; no px's so write category
 W "PROCEDURES",!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 S BMCPFS="F"
 D WRTPXLP ;                                         write finals
 I BMCRSTAT="A"!('BMCPFH) S BMCPFS="P" D WRTPXLP ;   write provisionals
 Q
 ;
WRTPXLP ; LOOP THRU PX ENTRIES
 S (BMCPIEN,BMCPFH)=0
 F  S BMCPIEN=$O(^BMCPX("AD",BMCRIEN,BMCPIEN)) Q:'BMCPIEN  D WRTPX2 Q:$D(GMTSQIT)
 Q
 ;
WRTPX2 ; WRITE ONE PX
 S X=^BMCPX(BMCPIEN,0)
 Q:$P(X,U,4)'=BMCPFS
 ;W ?10,$S($P(X,U)'=1:$P(^ICPT($P(X,U),0),U),1:"???"),?18,$S($P(X,U,4)="P":"PROV",$P(X,U,4)="F":"FINAL",1:"???")," ",$S($P(X,U,5)="P":"PRI",$P(X,U,5)="S":"SEC",1:"???")
 W ?10,$S($P(X,U)'=1:$P($$CPT^ICPTCOD($P(X,U),0),U,2),1:"???"),?18,$S($P(X,U,4)="P":"PROV",$P(X,U,4)="F":"FINAL",1:"???")," ",$S($P(X,U,5)="P":"PRI",$P(X,U,5)="S":"SEC",1:"???")
 S X=$P(X,U,6)
 I X S:$D(^AUTNPOV(X,0)) X=$P(^AUTNPOV(X,0),U) I 1
 E  D ENP^XBDIQ1(90001.02,BMCPIEN,".019","BMCX(","E") S:BMCX(".019")]"" X=BMCX(".019")
 W ?27,X
 W !
 S BMCPFH=1
 D CKP^GMTSUP
 Q
 ;
WRTCAT ; WRITE DX/SVC CAT
 D WRTCATD
 D WRTCATS
 Q
 ;
WRTCATD ; WRITE DX CAT
 D ENP^XBDIQ1(90001,BMCRIEN,".12","BMCX(","E") S X=BMCX(".12")
 W "DIAGNOSTIC CATEGORY:",?25,X,!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 Q
 ;
WRTCATS ; WRITE PX CAT
 Q  ;Remove from HS per Dr. Griffith 11-23-00
 D ENP^XBDIQ1(90001,BMCRIEN,".13","BMCX(","E") S X=BMCX(".13")
 W "CPT SERVICE CATEGORY:",?25,X,!
 D CKP^GMTSUP Q:$D(GMTSQIT)
 Q