VistA-WorldVistAEHR/r/GEN_MED_REC_GENERATOR-GMRG/GMRGUT0.m

39 lines
3.0 KiB
Mathematica

GMRGUT0 ;HIRMFO/RM-UTILITIES ROUTINE FOR GMRG FILES (CONT.) ;9/11/95
;;3.0;Text Generator;;Jan 24, 1996
EN1 ; ENTRY FROM AUDT XREF ON SELECTION:AUDIT TRAIL:MODIFICATION
; FIELD OF THE GMR TEXT FILE (#124.3). THIS XREF SETS THE
; SELECTION:AUDIT TRAIL:MODIFIED TEXT FIELD TO THE VALUE OF THE
; SELECTION:ADDITIONAL TEXT FIELD AND DELETES THE DATA IN THE
; SELECTION:ADDITIONAL FIELD IF A RECORD IS BEING FLAGGED AS
; DELETED.
S GMRG("DAX")=DA(2)_"^"_DA(1)_"^"_DA_"^"_X,GMRGT=$S($D(^GMR(124.3,DA(2),1,DA(1),0)):^(0),1:""),X=$P(GMRGT,"^",2),$P(GMRG(0),"^",2)=$P(GMRGT,"^"),$P(GMRG(0),"^",3)=$S($D(^GMR(124.3,DA(2),1,DA(1),2,DA,0)):$P(^(0),"^"),1:"")
S DA=0 F GMRG=0:0 S GMRG=$O(^GMR(124.3,DA(2),1,DA(1),2,"AA",GMRG)) Q:GMRG'>0!(DA>0) F GMRG(1)=0:0 S GMRG(1)=$O(^(GMRG,GMRG(1))) Q:GMRG(1)'>0!(DA>0) F DA=0:0 S DA=$O(^(GMRG(1),DA)) Q:DA'>0 I DA'=$P(GMRG("DAX"),"^",3) Q
I X'="" D TEXT^GMRGUTL,DELAD
S X=$S($D(^GMR(124.3,DA(2),1,DA(1),"ADD")):^("ADD"),1:"") I X'="" D ADTX^GMRGUTL,DELTX
S $P(GMRG(0),"^")=$S($D(^GMR(124.3,DA(2),1,DA(1),0)):$P(^(0),"^"),1:"")
I $P(GMRG(0),"^")'="" F GMRG(1)=0:0 S GMRG(1)=$O(^GMRD(124.2,$P(GMRG(0),"^"),1,"B",GMRG(1))) Q:GMRG(1)'>0 D:$D(^GMR(124.3,DA(2),1,"B",GMRG(1))) DELCH
S DA(2)=$P(GMRG("DAX"),"^"),DA(1)=$P(GMRG("DAX"),"^",2),DA=$P(GMRG("DAX"),"^",3),X=$P(GMRG("DAX"),"^",4) K GMRG,GMRGLDT,GMRGT
Q
DELAD ; DELETE ADDITIONAL TEXT IF SELECTION IS BEING FLAGGED AS DELETED
S GMRGDAZ(1)=DA(1),GMRGDAZ=DA,DA(1)=DA(2),DA=DA(1) F GMRG=0:0 S GMRG=$O(^DD(124.31,1,1,GMRG)) Q:GMRG'>0 X:$P(^DD(124.31,1,1,GMRG,0),"^",2)'="AUD2"&$D(^DD(124.31,1,1,GMRG,2)) ^(2)
S DA(1)=GMRGDAZ(1),DA=GMRGDAZ,$P(^GMR(124.3,DA(2),1,DA(1),0),"^",2)="" K GMRGDAZ
Q
DELTX ;
S GMRGDAZ(1)=DA(1),GMRGDAZ=DA,DA(1)=DA(2),DA=DA(1) F GMRG=0:0 S GMRG=$O(^DD(124.31,1,2,GMRG)) Q:GMRG'>0 X:$P(^DD(124.31,1,2,GMRG,0),"^",2)'="AUD3"&$D(^DD(124.31,1,2,GMRG,2)) ^(2)
S DA(1)=GMRGDAZ(1),DA=GMRGDAZ,^GMR(124.3,DA(2),1,DA(1),"ADD")="" K GMRGDAZ
Q
DELCH ; DELETE CHILDREN OF A SELECTION IF ITSELF IS DELETED.
S GMRGT=$P(GMRG(0),"^",2,3)_"^"_GMRG(1) N GMRG W:$D(GMRGDFLG) "."
S GMRG(1)=$P(GMRGT,"^",3),DA(1)=$O(^GMR(124.3,DA(2),1,"B",GMRG(1),0)),GMRGXY("DT0")=$P(GMRGT,"^",2),$P(GMRG(0),"^",2)=$P(GMRGT,"^")
S GMRGT=1 F GMRGT(0)=0:0 S GMRGT(0)=$O(^GMRD(124.2,"AKID",GMRG(1),GMRGT(0))) Q:GMRGT(0)'>0 I $D(^GMR(124.3,DA(2),1,"ALIST",GMRGT(0))),GMRGT(0)'=$P(GMRG(0),"^",2) S GMRGT=0 Q
G:'GMRGT QD
I DA(1)'>0 G QD
S DA=$P(^GMR(124.3,DA(2),1,DA(1),2,0),"^",3)
LD S DA=DA+1 I $D(^GMR(124.3,DA(2),1,DA(1),2,DA,0)) G LD
S GMRGST(1)=DA(2),GMRGST=DA(1) D STAT^GMRGRUT0 G QD:'$P(GMRGSTAT,"^",3) S GMRGLDT=+$P(GMRGSTAT,"^",2),%=GMRGXY("DT0") D PAST^GMRGUTL:%'>GMRGLDT
S GMRGXY("DT0")=%,^GMR(124.3,DA(2),1,DA(1),2,DA,0)=GMRGXY("DT0")_"^"_0_"^"_DUZ,$P(^GMR(124.3,DA(2),1,DA(1),2,0),"^",3,4)=DA_"^"_($P(^GMR(124.3,DA(2),1,DA(1),2,0),"^",4)+1)
F GMRGXY=.01,1,2 S X=$S(GMRGXY=.01:GMRGXY("DT0"),GMRGXY=1:0,1:DUZ) F GMRGXY(0)=0:0 S GMRGXY(0)=$O(^DD(124.313,GMRGXY,1,GMRGXY(0))) Q:GMRGXY(0)'>0 X:$D(^DD(124.313,GMRGXY,1,GMRGXY(0),1)) ^(1)
D EN1
QD K GMRGXY,GMRGSTAT
Q