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

BHSENCW.m

Go to the documentation of this file.
BHSENCW ;IHS/CIA/MGH - Encounters from PCC ;17-Mar-2006 10:36;MGH
 ;;1.0;HEALTH SUMMARY COMPONENTS;;March 17, 2006
 ;===================================================================
 ;Taken from APCHS2J
 ; IHS/TUCSON/LAB - PART 2D OF BHS -- SUMMARY PRODUCTION COMPONENTS ;  [ 03/01/04  10:50 AM ]
 ;;2.0;IHS RPMS/PCC Health Summary;**11,12**;JUN 24, 1997
 ;
 ;
SCHENC ; ********** SCHEDULED ENCOUNTERS * 2/44 W/ CHART REQ AND WALK INS**********
 ; <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,BHSIVD,BHSDAT,BHSPVD,BHSN,BHSVT,BHSCN,BHSCP,BHSTST,BHSI,BHSJ,BHSET,BHSHP,BHSVN,BHSVNT,BHSQ,Y
 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)_" ")
 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>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