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

NURSACEN.m

Go to the documentation of this file.
NURSACEN ;HIRMFO/RM,FT-PATIENT CENSUS CALCULATION ;4/30/96  15:42
 ;;4.0;NURSING SERVICE;;Apr 25, 1997;
CALC ; CALCULATE PATIENT CENSUS FOR NURCENDT=DATE/TIME OF CENSUS
 ;    NURCUTDT=$S(D/T FOR CUTOFF TXFR DATE OR 0 FOR NO CUTOFF)
 ; RETURNS ^TMP($J,"NURCEN",NLOC,DFN)=""
 N DFN,NURSADM,NURSDT,NURSI,NURSWD,NLOC,VAIN
 K ^TMP($J,"NURCEN"),^TMP($J,"NURDFN")
 S NURSWD="" F NURSI=0:0 S NURSWD=$O(^DPT("CN",NURSWD)) Q:NURSWD=""  F DFN=0:0 S DFN=$O(^DPT("CN",NURSWD,DFN)) Q:DFN'>0  W:$E(IOST)="C" "." D IFADM
 F NURSDT(0)=(NURCENDT-.0000001):0 S NURSDT(0)=$O(^DGPM("AMV3",NURSDT(0))) Q:NURSDT(0)'>0  F DFN=0:0 S DFN=$O(^DGPM("AMV3",NURSDT(0),DFN)) Q:DFN'>0  W:$E(IOST)="C" "." D IFDIS
 K ^TMP($J,"NURDFN") D KVAR^VADPT
 Q
IFADM ; CHECK TO SEE IF AN ADMISSION EXISTS FROM NURCENDT< ADMISSION < NOW
 S NURSDT=0 D CALCADM I NURSADM F NURSDT=$P(NURSADM,"^",2):0 S NURSDT=$O(^DGPM("ATID3",DFN,NURSDT)) Q:NURSDT'>0!(NURSDT>(9999999-NURCENDT))  S NURSADM=0
 I 'NURSADM D STUTL
 Q
IFDIS ; CHECK TO SEE IF A DISCHARGE EXISTS BETWEEN CENSUS DATE AND NOW
 I '$D(^TMP($J,"NURDFN",DFN)) S NURSDT=9999999-NURSDT(0) D CALCADM S ^TMP($J,"NURDFN",DFN)="" I 'NURSADM D STUTL
 Q
CALCADM ;
 S NURSADM=0 F NURSDT=NURSDT:0 S NURSDT=$O(^DGPM("ATID1",DFN,NURSDT)) Q:NURSDT'>0!(NURSDT>(9999999-NURCENDT))  S NURSADM=$O(^DGPM("ATID1",DFN,NURSDT,0))_"^"_NURSDT
 Q
STUTL ; SETS NLOC=NURSING LOCATION CORR. TO PT. LOC. AT NURCENDT.
 W:$D(NURSMAN) "." S VAINDT=NURCENDT D NLOC Q:'NLOC
 I $G(NURCUTDT) D IFTXFR Q:'NLOC
 S ^TMP($J,"NURCEN",NLOC,DFN)=""
 Q
NLOC ; GET NURSING LOCATION
 D INP^VADPT
 I 'VAIN(6) S NLOC=0 Q
 F NLOC=0:0 S NLOC=$O(^NURSF(211.4,"C",+VAIN(4),NLOC)) Q:$S(NLOC'>0:1,'$D(^NURSF(211.4,NLOC,1)):0,$P(^(1),U)="A":1,1:0)
 Q
IFTXFR ; FIND IF PATIENT TRANSFERRED TO DIFFERENT NURSING LOCATION BETWEEN
 ; A CERTAIN CUTOFF DATE AND NURCENDT
 S NLOC(0)=NLOC
 F NDATE=(9999999-NURCENDT):0 S NDATE=$O(^DGPM("ATID2",DFN,NDATE)) Q:(NDATE<(9999999-NURCUTDT))!(NDATE'>0)  S VAINDT=NURCUTDT D NLOC Q
 S:'NLOC NLOC=NLOC(0)
 Q