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

GMRGRUT3.m

Go to the documentation of this file.
GMRGRUT3 ;HIRMFO/RM-GMRG ROUTINE UTILITIES ;9/11/95
 ;;3.0;Text Generator;;Jan 24, 1996
EN1 ;SELECT PATIENT CARE PLAN
 ;   INPUT: GMRGRT=PRIME DOC IEN^PD TEXT
 ;                 DFN=PATIENT IEN
 ;          (optional) GMRGXPRT=$S(1:ALL PLANS E/E OR NOT,0:ONLY ACTIVE)
 ;            _"^"_$S(1:CAN LAYGO NEW PLANS,0:LAYGO NOT ALLOWED)_"^"_
 ;            $S(1:ENTRY IN ERROR OF PLANS ALLOWED,0:E/E NOT ALLOWED)
 ;                     DEFAULT VALUE IS "0^1^0"
 ;  OUTPUT:  GMRGPDA=ENTRY IN 124.3
 ;           GMRGOUT=$S(1:ABNORMAL EXIT,0:NORMAL EXIT)
 Q:'$D(GMRGRT)!'$D(DFN)  S GMRGOUT=0,GMRGPDA=-1 S:'$D(GMRGXPRT)#2 GMRGXPRT="0^1^0"
 S (GMRGZ(0),GMRGZ)=1 F GMRGX=0:0 S GMRGX=$O(^GMR(124.3,"AA",DFN,+GMRGRT,GMRGX)) Q:GMRGX'>0  F GMRGY=0:0 S GMRGY=$O(^GMR(124.3,"AA",DFN,+GMRGRT,GMRGX,GMRGY)) Q:GMRGY'>0  D STRY
 S GMRGXSEL=GMRGZ-1,GMRGXERR=GMRGZ(0)-1,GMRGXREF="GMRGXSEL"
 G:GMRGXSEL>0 CPCH
YNNP ; IF NO 124.3 ENTRIES EXIST
 W !,"There is no previous "_$P(GMRGRT,"^",2)_" for this patient."
 G:'$P(GMRGXPRT,"^",2) Q1:GMRGXERR'>0!'$P(GMRGXPRT,"^"),CPCH
 W !,"Would you like to add one" S %=1 D YN^DICN S:%=-1 GMRGOUT=1 I '% W !?3,$C(7),"Answer Yes or No." G YNNP
 D:%=1 NEWCP
 G Q1
 ;
CPCH ; CHOOSE FROM EXISTING 124.3 ENTRIES
 I @GMRGXREF>0 W !!,"The following is a list of previous "_$P(GMRGRT,"^",2)_$E("s",("Ss"'[$E($P(GMRGRT,"^",2),$L($P(GMRGRT,"^",2))))),! W:GMRGXREF="GMRGXERR" "that have been entered in error",!
 F GMRGZ=0:0 S GMRGZ=$O(@(GMRGXREF_"("_GMRGZ_")")) Q:GMRGZ'>0  S GMRGX=((GMRGZ#10)=1&(GMRGZ'=1)),X="" W:GMRGX !,"'^' TO STOP: " R:GMRGX X:DTIME S:GMRGX&(X="^^"!'$T) GMRGOUT=1 Q:(X="^"!GMRGOUT)&GMRGX  D PRTC
 I GMRGOUT Q:GMRGXREF="GMRGXERR"  G Q1
 W !!,"Enter Selection: "
 R GMRGX:DTIME S:'$T GMRGX="^^"
 I "^^"[GMRGX S:GMRGX="^^"!(GMRGX="^") GMRGOUT=1 Q:GMRGXREF="GMRGXERR"  G Q1
 S:GMRGX?1L GMRGX=$C($A(GMRGX)-32) S:GMRGXREF="GMRGXERR"&(GMRGX'?1N.N)!(GMRGX["@"&'$P(GMRGXPRT,"^",3)) GMRGX="??"
 I '(GMRGX?1N.N."@"!(GMRGX="N"&$P(GMRGXPRT,"^",2))!(GMRGX="E"&$P(GMRGXPRT,"^"))) W !?3,$C(7),"ENTER THE NUMBER OF THE SELECTION TO BE CHOSEN" W:$P(GMRGXPRT,"^",3) ",",!?3,"OR THE NUMBER FOLLOWED BY AN '@' TO DELETE A SELECTION"
 I  W:GMRGXREF'="GMRGXERR"&$P(GMRGXPRT,"^",2) ",",!?3,"OR THE LETTER 'N' TO ADD A NEW ",$P(GMRGRT,"^",2) W:GMRGXREF'="GMRGXERR"&$P(GMRGXPRT,"^") ",",!?3,"OR TYPE AN 'E' TO LIST THE PLANS ENTERED IN ERROR" W "." G CPCH
 I GMRGX?1N.N."@",(+GMRGX<1!(+GMRGX>@GMRGXREF)) W !?3,$C(7),"Select a number in the range 1"_$S(@GMRGXREF>1:"-"_@GMRGXREF,1:"") G CPCH
 I "Ee"[GMRGX S GMRGXREF="GMRGXERR" D:@GMRGXREF>0 CPCH W:@GMRGXREF'>0 !?5,$C(7),"THERE ARE NO RECORDS ENTERED IN ERROR, TRY AGAIN." S GMRGXREF="GMRGXSEL" G Q1:GMRGPDA>0!GMRGOUT,CPCH
 I "Nn"[GMRGX D NEWCP G Q1
 I GMRGX["@" D DELPL G Q1:GMRGOUT,CPCH:+GMRGX<0
 S GMRGPDA=$P(@(GMRGXREF_"("_+GMRGX_")"),"^",2)_$S(GMRGX'["@":"",1:"^@") Q:GMRGXREF="GMRGXERR"
Q1 K %,DA,DIC,DIE,DR,GMRGXERR,GMRGXPRT,GMRGXREF,GMRGXSEL,GMRGX,GMRGY,GMRGZ,X,Y Q
PRTC ; PRINT AN ENTRY FROM FILE 124.3
 W !,$J(GMRGZ,3,0),". " S Y=$P(@(GMRGXREF_"("_GMRGZ_")"),"^") D DT^DIQ S GMRGY=$S($D(^GMR(124.3,$P(@(GMRGXREF_"("_GMRGZ_")"),"^",2),0)):$P(^(0),"^",5),1:""),GMRGY=$S(GMRGY="":"",$D(^VA(200,GMRGY,0)):$P(^(0),"^"),1:"") W ?30,GMRGY
 Q
NEWCP ; ADD A NEW 124.3 ENTRY
 D NOW^%DTC W !,"Let me create a new record..." S GMRGX=%,X=+GMRGRT,DIC="^GMR(124.3,",DIC(0)="Q",DIC("DR")=".02///^S X=""`""_DFN;.03///^S X=GMRGX" K DD D FILE^DICN S GMRGPDA=+Y
 Q
DELPL ; ENTER A 124.3 ENTRY IN ERROR
 W !,?3,$C(7),"ARE YOU SURE YOU WANT TO ENTER THIS ",$P(GMRGRT,"^",2)," IN ERROR" S %=0 D YN^DICN I '% W !?5,$C(7),"Answer Yes to enter this selection in error, else answer No." G DELPL
 S:%=-1 GMRGOUT=1 S:%=2 GMRGX=-1 Q:%'=1
 S DA=$P(GMRGXSEL(+GMRGX),"^",2),DIE="^GMR(124.3,",DR="5///1" D ^DIE W "."
 Q
STRY ; SET UP GMRGXSEL( AND GMRGXERR( OF 124.3 ENTRIES TO BE SELECTED
 S X=$S($D(^GMR(124.3,+GMRGY,5)):+^(5),1:0) Q:X&'$P(GMRGXPRT,"^")
 I 'X S GMRGXSEL(GMRGZ)=(9999999-GMRGX)_"^"_GMRGY,GMRGZ=GMRGZ+1
 I X S GMRGXERR(GMRGZ(0))=(9999999-GMRGX)_"^"_GMRGY,GMRGZ(0)=GMRGZ(0)+1
 Q
EN4 ; PRUNE A SUBTREE FROM SOME PATIENT DATA SET
 ; GMRGPDA=ENTRY IN FILE 124.3
 ; GMRGTERM=ENTRY IN FILE 124.2 WHICH IS THE ROOT OF THE SUBTREE
 G Q4:'$D(GMRGPDA)!'$D(GMRGTERM)
 S X=GMRGTERM N GMRGTERM,GMRGOUT,GMRGPRC,GMRGRT,GMRGX,GMRGZZ S GMRGTERM=X
 S GMRGTERM(0)=$G(^GMRD(124.2,+GMRGTERM,0)),GMRGX=$G(^GMR(124.3,+GMRGPDA,0)) G Q4:GMRGTERM(0)=""!(GMRGX="")
 S GMRGRT=+GMRGX_"^"_$P($G(^GMRD(124.2,+GMRGX,0)),"^"),GMRGOUT=0 D PTDATA
 I +GMRGTERM'=+GMRGRT D DELETE^GMRGED6 G Q4
 F GMRGZZ=0:0 S GMRGZZ=$O(^GMRD(124.2,+GMRGRT,1,GMRGZZ)) Q:GMRGZZ'>0  S GMRGTERM=+$G(^GMRD(124.2,+GMRGRT,1,GMRGZZ,0)),GMRGTERM(0)=$G(^GMRD(124.2,+GMRGTERM,0)) I +GMRGTERM D PTDATA,DELETE^GMRGED6
Q4 ;
 Q
PTDATA ;
 S GMRGX=$O(^GMR(124.3,GMRGPDA,1,"B",GMRGTERM,0)),GMRGX(0)=$P($G(^GMR(124.3,GMRGPDA,1,+GMRGX,0)),"^",2),GMRGPRC=GMRGTERM_"^@^11",GMRGPRC(0)=$P(GMRGTERM(0),"^")_"^"_GMRGX_"^"_GMRGX(0)
 Q