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

NURSCPLU.m

Go to the documentation of this file.
NURSCPLU ;HIRMFO/RM,FT-Create NURSING FILE AND XREFS ;8/14/96  10:22
 ;;4.0;NURSING SERVICE;;Apr 25, 1997
EN1 ; ENTRY FROM OPTION NURSPT-WRDACT
 S X="A"
 G MAIN
EN2 ; ENTRY FROM OPTION NURSPT-WRDINA
 S X="I"
MAIN ;
 Q:'$D(^DIC(213.9,1,"OFF"))  Q:$P(^DIC(213.9,1,"OFF"),"^",1)=1
 S NURSTUS=X
 D CKMAS I NURSBAD Q
 S NURSEND=0
 D DATACK
 D:'NURSDATA FIRSTIME I NURSEND K NURSEND Q
 D WARDSEL I $G(NURSEND) K NURSEND Q
 D INIT214 K NURSEND
 Q
FIRSTIME ; IF NO DATA IN NURS PATIENT (214) FILE INITIALIZE IT
 D EN1^NURSCPL
 I NURSBAD S NURSEND=1 Q
 D INIT214 K NURSWRD
 S NURSDATA=1
 Q
DATACK ; CHECK TO SEE IF DATA IN THE 214 FILE
 S NURSDATA=0,NURSCK=$O(^NURSF(214,0))
 S:NURSCK>0 NURSDATA=1
 Q
WARDSEL ; SELECT WARD TO BE ACTIVATED
 S NURSEND=0,OUTSW=0
 F NURSI=1:1 S DIC="^NURSF(211.4,",DIC("S")="I $S('$D(^(""I"")):1,$P(^(""I""),U)'=""I"":1,1:0)",DIC(0)="AEM",DIC("A")="Select UNIT: " D ^DIC K DIC S:X="^" NURSEND=1,OUTSW=1 S:(X="")!(+Y'>0) OUTSW=1 S:(X="")&'$D(NURSWRD) NURSEND=1 Q:OUTSW  D
 .S NURSWRD(NURSI)=+Y
 .Q
 I NURSEND Q
 D:'$G(NURSEND) ACTWARD
 Q
ACTWARD ; SET WARD STATUS TO ACTIVE
 F NURSI=0:0 S NURSI=$O(NURSWRD(NURSI)) Q:NURSI'>0  S DA=NURSWRD(NURSI),DIE="^NURSF(211.4,",DR="1///^S X=NURSTUS" D ^DIE
 Q
CKMAS ; CHECKS EVERY MAS WARD TO SEE IF CORR. NURSING LOCATION
 W !!,"Checking to see if every MAS Ward has a corresponding NURSING unit"
 S NURSERR=0
 F NURSY=0:0 S NURSY=$O(^DIC(42,NURSY)) S:(NURSY'>0)&(NURSERR) NURSBAD=1 Q:NURSY'>0  S X=$P(^DIC(42,NURSY,0),"^",1) D ^NURSAWCK S:NURSBAD NURSERR=1
 I NURSBAD D BADWARD^NURSAWCK W !!!,$C(7),"Press return to continue: " R X:DTIME Q
 Q
INIT214 ; ENTERS PATIENTS INTO 214 FILE FROM 2 FILE
 W:'$G(NURSDATA) !!,"Set up initial Nursing Patient file entries for inpatients"
 W:$G(NURSDATA) !!,"Ward "_$S(NURSTUS="A":"A",1:"Dea")_"ctivation and Patient entry for the following Nursing unit(s):"
 D DT^DICRW S U="^" D F1:$G(NURSTUS)="A",F3:$G(NURSTUS)="I"
 W !!,"Done ... "
 Q
F1 ; ACTIVIATION PROCESS
 F NURSY=0:0 S NURSY=$O(NURSWRD(NURSY)) Q:NURSY'>0  S NPWARD=NURSWRD(NURSY) D EN6^NURSAUTL W !,"    ",NPWARD F NURSZ=0:0 S NURSZ=$O(^NURSF(211.4,NURSWRD(NURSY),3,NURSZ)) Q:NURSZ'>0  D F10
 Q
F10 ;
 S NURSWRD=$S($D(^NURSF(211.4,NURSWRD(NURSY),3,NURSZ,0)):$S($D(^DIC(42,+^NURSF(211.4,NURSWRD(NURSY),3,NURSZ,0),0)):$P(^(0),"^"),1:""),1:"")
 I NURSWRD'="" F DFN=0:0 S DFN=$O(^DPT("CN",NURSWRD,DFN)) Q:DFN'>0  D F2
 Q
F2 ; ACTIVATE PATIENT
 I '$D(^DPT(DFN,.1)),'$D(^DPT(DFN)) W !!,*7,*7,"PATIENT WITH IEN#",DFN," DOES NOT HAVE A RECORD",!,"IN THE PATIENT FILE." Q
 I '$D(^DPT(DFN,.1)) W !!,*7,*7,$P(^DPT(DFN,0),"^",1)," CANNOT BE ADMITTED INTO",!,"THE NURSING SERVICE BECAUSE OF A PROBLEM WITH THE MAS PATIENT FILE -- NOTIFY MAS" Q
 I NURSDATA D MASCK Q:NURSNOTV
 S X=^DPT(DFN,.1)
 S DA=DFN,DIC="" D EN1^NURSCPL
 Q
F3 ; DEACTIVATION PROCESS
 F NURSY=0:0 S NURSY=$O(NURSWRD(NURSY)) Q:NURSY'>0  S (NPWARD,NURSWRD)=NURSWRD(NURSY) D EN6^NURSAUTL W !,"    "_NPWARD F DA=0:0 S DA=$O(^NURSF(214,"AF","A",NURSWRD,DA)) Q:DA'>0  S X=NURSWRD D EN2^NURSCPL
 Q
MASCK ; CHECKS TO SEE IF THE MAS WARD IS AN ACTIVATED NURSE LOCATION.
 S NURSWARD=$S($P(^DPT(DFN,.1),"^",1)="":"",1:$O(^DIC(42,"B",$P(^DPT(DFN,.1),"^",1),"")))
 S NURSNOTV=1
 Q:NURSWARD=""
 F NURSWCK=0:0 S NURSWCK=$O(^NURSF(211.4,"C",NURSWARD,NURSWCK)) Q:NURSWCK'>0  D WARDCK Q:'NURSNOTV
 Q
WARDCK ; THIS CHECKS THAT THE NURSE LOCATION WAS ONE SELECTED TO ACTIVATE
 F NURSI=0:0 S NURSI=$O(NURSWRD(NURSI)) Q:(NURSI'>0)!('NURSNOTV)  S:NURSWCK=NURSWRD(NURSI) NURSNOTV=0
 Q