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

NURCRL2.m

Go to the documentation of this file.
NURCRL2 ;HIRMFO/RM-PT. CENSUS FOR CARE PLANS ;9/10/91
 ;;4.0;NURSING SERVICE;;Apr 25, 1997
 ;;
CENSUS(BGT,EDT,RDT,SRT) ; 
 ; GIVEN BGT AS BEGINNING DATE FOR CENSUS, AND EDT AS ENDING DATE
 ; FOR CENSUS, RDT AS THE CURRENT DATE/TIME, AND SRT AS TO WHETHER
 ; THE DATA WILL BE BY ADMITTING LOC, OR ANY LOCATION PT WAS ON
 ; DURING THE LENGHT OF STAY, THIS ENTRY WILL CALCULATE THE CENSUS
 ; AND STORE IN ^TMP($J,"NURCEN",DFN,DGPM)
 ;   GIVEN ARRAY NURSMAS(MASLOC) TO SCREEN OUT PARTICULAR LOCS.
 N DFN,DGCOR,DGMAS,DGPM,DSDT,MASW K ^TMP($J,"NURCEN")
 F DSDT=BGT:0 S DSDT=$O(^DGPM("AMV3",DSDT)) Q:DSDT'>0!(DSDT>RDT)  F DFN=0:0 S DFN=$O(^DGPM("AMV3",DSDT,DFN)) Q:DFN'>0  F DGPM=0:0 S DGPM=$O(^DGPM("AMV3",DSDT,DFN,DGPM)) Q:DGPM'>0  D CHSTCEN
 S MASW="" F  S MASW=$O(^DGPM("CN",MASW)) Q:MASW=""  F DGPM=0:0 S DGPM=$O(^DGPM("CN",MASW,DGPM)) Q:DGPM'>0  S DFN=$P($G(^DGPM(+DGPM,0)),"^",3) D:DFN>0 CHSTCEN
 Q ''$O(^TMP($J,"NURCEN",0))
CHSTCEN ; CHECK TO SEE IF PATIENT IN HOSPITAL, AND IF IS PUT IN CENSUS
 S DGCOR=$$CORRADM(DGPM),DGMAS=$$MASW(DGCOR),DGMAS=$S($L(DGMAS):DGMAS,1:$G(MASW)) Q:'$L(DGMAS)
 I SRT=1,$$MDATE(DGCOR)<EDT,$D(NURSMAS(DGMAS)) S ^TMP($J,"NURCEN",DFN,DGPM)=""
 I SRT=2 D
 .   N MVDT,DGMPM,DGNPM,NXDT
 .   S (DGNPM,MVDT)=0 F  S MVDT=$O(^DGPM("APMV",DFN,DGCOR,MVDT)) Q:MVDT'>0  S DGMPM=0 F  S DGMPM=$O(^DGPM("APMV",DFN,DGCOR,MVDT,DGMPM)) Q:DGMPM'>0  D:$$TTYP(DGMPM)'=3
 .   .   S DGMAS=$$MASW(DGMPM) Q:'$L(DGMAS)
 .   .   I $$MDATE(DGMPM)<EDT,DGNPM'>0!($$MDATE(DGNPM)>BGT),$D(NURSMAS($$MASW(DGMPM))) S ^TMP($J,"NURCEN",DFN,DGMPM)=""
 .   .   S DGNPM=DGMPM
 .   .   Q
 .   Q
 Q
MDATE(DGPM) ; GET MOVEMENT DATE FOR MOVEMENT DGPM
 Q +$G(^DGPM(+DGPM,0))
TTYP(DGPM) ; GET TRANSFER TYPE FOR MOVEMENT DGPM
 Q +$P($G(^DGPM(+DGPM,0)),"^",2)
CORRADM(DGPM) ; GET CORRESPONDING ADMISSION FOR MOVEMENT DGPM
 Q +$P($G(^DGPM(+DGPM,0)),"^",14)
MASW(DGPM) ; GET FREE TEXT MAS WARD FOR MOVEMENT DGPM
 Q $P($G(^DIC(42,+$P($G(^DGPM(+DGPM,0)),"^",6),0)),"^")