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

BHSENCS.m

Go to the documentation of this file.
BHSENCS ;IHS/CIA/MGH - Encounters from PCC ;23-Jun-2010 12:09;MGH
 ;;1.0;HEALTH SUMMARY COMPONENTS;**4**;March 17,2006;Build 13
 ;===================================================================
 ;Taken from APCHS2D
 ; IHS/TUCSON/LAB - PART 2D OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;  [ 03/01/04  10:50 AM ]
 ;;2.0;IHS RPMS/PCC Health Summary;**11,12,4**;JUN 24, 1997
 ;
 ;
SCHENC ; ********** SCHEDULED ENCOUNTERS * 2/44 **********
 ; <SETUP>
 N BHSPAT
 S BHSPAT=DFN
 Q:'$D(^DPT(BHSPAT,"S"))
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ; <DISPLAY>
 S BHSI=$O(^DPT(BHSPAT,"S",0)) I BHSI,BHSI<DT D PAST
 D:$O(^DPT(BHSPAT,"S",DT)) PEND
 ; <CLEANUP>
SCHENCX K BHSVDT,BHSVD1,BHSAM,BHSQIT,BHSQ,BHSIVD,BHSDAT,BHSPVD,BHSN,BHSVT,BHSCN,BHSCP,BHSTST,BHSI,BHSJ,BHSET,BHSHP,BHSVN,BHSVNT,Y,X
 Q
 ;
PAST ;
 K ^TMP($J,"BHS")
 S BHSVD1=9999999-GMTSDLM,BHSDAT=0,BHSI=0
 S BHSVDT=BHSVD1 F BHSQ=0:0 S BHSVDT=$O(^DPT(BHSPAT,"S",BHSVDT)) Q:'BHSVDT!(BHSVDT>DT)  D ADDONE
 Q:'$O(^TMP($J,"BHS",""))
 S BHSET="PAST:" D CKP^GMTSUP Q:$D(GMTSQIT)  W BHSET,!
 S BHSIVD=0 F BHSQ=0:0 S BHSIVD=$O(^TMP($J,"BHS",BHSIVD)) Q:'BHSIVD  S BHSVDT=^(BHSIVD) D ONEVIS Q:$D(GMTSQIT)
 K ^TMP($J,"BHS")
 Q
 ;
ADDONE S BHSIVD=9999999.9999-BHSVDT
 S BHSI=BHSI+1,^TMP($J,"BHS",BHSIVD)=BHSVDT,^TMP($J,"BHS","B",BHSVDT)=""
 I GMTSNDM>0,BHSI>GMTSNDM S BHSI=BHSI-1,BHSJ=$O(^TMP($J,"BHS","B","")) K ^(BHSJ) K ^TMP($J,"BHS",9999999.9999-BHSJ)
 Q
PEND ;
 S BHSET="PENDING:" D CKP^GMTSUP Q:$D(GMTSQIT)  W BHSET,!
 S BHSDAT=0,BHSVDT=DT-.01 F BHSQ=0:0 S BHSVDT=$O(^DPT(BHSPAT,"S",BHSVDT)) Q:'BHSVDT  D ONEVIS Q:$D(GMTSQIT)
 Q
 ;
ONEVIS S BHSN=^DPT(BHSPAT,"S",BHSVDT,0)
 Q:"CP"[$E($P(BHSN,U,2)_" ")
 S BHSAM="am"
 ;Q:$P(BHSN,U,7)=4  ;skip unscheduled
 I BHSVDT\1'=BHSDAT S X=BHSVDT\1 D REGDT4^GMTSU S (BHSPVD,BHSDAT)=X,GMTSNDM=GMTSNDM-1
 S BHSVT=$E($P(BHSVDT,".",2)_"000",1,4) S:BHSVT>1159 BHSAM="pm" S:BHSVT>1300 BHSVT=BHSVT-1200 S:$L(BHSVT)=3 BHSVT=" "_BHSVT S:$E(BHSVT)="0" BHSVT=" "_$E(BHSVT,2,4) S BHSVT=$E(BHSVT,1,2)_":"_$E(BHSVT,3,4)
 S BHSTST="" F BHSI=3,4,5 S BHSJ=$P(BHSN,U,BHSI) I BHSJ S:BHSTST]"" BHSTST=BHSTST_"," S BHSTST=BHSTST_$P("^^LAB^XRAY^EKG^",U,BHSI)
 S BHSCP=+BHSN,BHSCN=$P($G(^SC(BHSCP,0)),U,1) Q:BHSCN=""
 S BHSTST="",BHSVNT=""
 S BHSVN=0 F BHSQ=0:0 S BHSVN=$O(^SC(BHSCP,"S",BHSVDT,1,BHSVN)) Q:'BHSVN  I +^(BHSVN,0)=BHSPAT S BHSTST=$P(^(0),U,2),BHSVNT=$P(^(0),U,4) S:BHSTST BHSTST=BHSTST_" min."
 F BHSI=3,4,5 S BHSJ=$P(BHSN,U,BHSI) I BHSJ S:BHSTST]"" BHSTST=BHSTST_"," S BHSTST=BHSTST_$P("^^LAB^XRAY^EKG^",U,BHSI)
 D L1
 I BHSVNT]"" D CKP^GMTSUP Q:$D(GMTSQIT)  D:GMTSNPG L1 W ?18,BHSVNT,!
 Q
L1 D CKP^GMTSUP Q:$D(GMTSQIT)  I GMTSNPG W BHSET,! S BHSDAT=BHSPVD
 W ?2,BHSDAT,?14,BHSVT,?21,BHSCN W:BHSTST]"" " (",BHSTST,")"
 W:$P(BHSN,U,2)["N" ?35,"*** DNKA ***" W !
 Q
WAIT ;EP - active wait list entries for patient
 S BHSPAT=DFN
 I $T(WLDATA^BSDWLV)="" W !!,"The scheduling routine for Wait List is missing, cannot display data." Q
 K BHWAIT
 D WLDATA^BSDWLV(BHSPAT,,.BHWAIT)
 Q:'$D(BHWAIT)
 D CKP^GMTSUP Q:$D(GMTSQIT)
 ; <DISPLAY>
 W BHWAIT(0),!
 S BHSD="" F  S BHSD=$O(BHWAIT(BHSD)) Q:BHSD=""!($D(GMTSQIT))  D
 .S BHSX=0 F  S BHSX=$O(BHWAIT(BHSD,BHSX)) Q:BHSX=""!($D(GMTSQIT))  D
 ..D CKP^GMTSUP Q:$D(GMTSQIT)
 ..W $P(BHWAIT(BHSD,BHSX),U,2),!
 ; <CLEANUP>
WAITX K BHWAIT,BHSD,BHSPAT,BHSX
 Q