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

64 lines
3.7 KiB
Mathematica
Raw Permalink Normal View History

2009-11-29 13:37:14 -05:00
GMRGRUT0 ;CISC/RM-ROUTINE UTILITIES ;10/25/88
;;3.0;Text Generator;;Jan 24, 1996
STAT ; ENTRY TO GIVE THE TYPE AND DATE OF THE LAST MODIFICATION ON THE
; SELECTION DEFINED BY GMRGST, AND GMR TEXT ENTRY GMRGST(1),
; AND GMRGST(2) IF PASSED WILL BE THE DATE/TIME THAT YOU
; WANT THE INFORMATION FOR THIS TERM.
; RETURNED IS GMRGSTAT=IEN OF AUDIT TRAIL^D/T^MOD
Q:'$D(GMRGST) I '$D(GMRGST(2)) S GMRGST(2)=0
E S GMRGST(2)=9999999-GMRGST(2)-.000001
S GMRGST("DT")=$O(^GMR(124.3,GMRGST(1),1,GMRGST,2,"AA",GMRGST(2))),GMRGST("MOD")=$S(GMRGST("DT")>0:$O(^(GMRGST("DT"),0)),1:""),GMRGST(0)=$S(GMRGST("MOD")>0:$O(^(GMRGST("MOD"),0)),1:"")
S GMRGSTAT=$S(GMRGST(0)>0:GMRGST(0)_"^"_(9999999-GMRGST("DT"))_"^"_GMRGST("MOD"),1:0)
K GMRGST
Q
FNDPRM ; FIND PRIME DOCUMENT(S) FOR THE TERM IN NODE GMRGND RETURNED IS
; IS GMRGPRM(IEN) WITH ALL PRIME DOCUMENTS FOR THIS TERM
S GMRGND(1)=1
S GMRGND(2)=0 F GMRGND(1)=1:1 S GMRGND(2)=$O(^GMRD(124.2,"AKID",GMRGND,GMRGND(2))) Q:GMRGND(2)'>0 S:GMRGND(2)=GMRGCYC(0)!$D(GMRGCYC(GMRGND(2))) GMRGCYC=1 D:GMRGND(2)'=GMRGCYC(0)&'$D(GMRGCYC(GMRGND(2))) PRMCHK
K GMRGCYC(GMRGND),GMRGND,GMRGTMP
Q
PRMCHK ;
S GMRGND("C")=$S($D(^GMRD(124.2,GMRGND(2),0)):$P(^(0),"^",4),1:""),GMRGND("CI")=$S(GMRGND("C")="":"",$D(^GMRD(124.25,$P(^GMRD(124.2,GMRGND(2),0),"^",4),0)):$P(^(0),"^"),1:"")
I GMRGND("CI")="PRIME DOCUMENT" S GMRGPRM(GMRGND(2))="" Q
S GMRGTMP=GMRGND(2) N GMRGND S GMRGND=GMRGTMP,GMRGCYC(GMRGND)="" D FNDPRM
Q
STLST ; GIVEN THAT GMRGND=ENTRY IN 124.3, AND GMRGND(0)=TERM THAT HAS BEEN
; ADDED TO PLAN, UPDATE THE LIST XREF FOR GMRGND(0)'S PARENT
F GMRGND(1)=0:0 S GMRGND(1)=$O(^GMRD(124.2,"AKID",GMRGND(0),GMRGND(1))) Q:GMRGND(1)'>0 S:'$D(GMRGRT)&$D(GMRG(0,GMRGND(1)))&'$D(^GMR(124.3,GMRGND,1,"ALIST",GMRGND(1))) ^(GMRGND(1),1)="^0" D:$D(^GMR(124.3,GMRGND,1,"ALIST",GMRGND(1))) PARST
K GMRGND
Q
PARST ;
K GMRGND("L")
S GMRGND("O")=0,GMRGND("L")=""
F GMRGND(2)=0:0 S GMRGND(2)=$O(^GMR(124.3,GMRGND,1,"ALIST",GMRGND(1),GMRGND(2))) Q:GMRGND(2)'>0 S GMRGND("L",GMRGND(2))=^GMR(124.3,GMRGND,1,"ALIST",GMRGND(1),GMRGND(2)) I GMRGND("L",GMRGND(2))[("^"_GMRGND(0)_"^") S GMRGND("O")=1 Q
I 'GMRGND("O") D ST0
I 'GMRGND("O"),GMRGND("L")'="" S ^GMR(124.3,GMRGND,1,"ALIST",GMRGND(1),GMRGND("L")+1)="^"_GMRGND(0)_"^0"
Q
ST0 F GMRGND(2)=0:0 S GMRGND(2)=$O(GMRGND("L",GMRGND(2))) Q:GMRGND(2)'>0 D ST2
Q
ST2 S GMRGND("L")=GMRGND(2)
I ($L($P(GMRGND("L",GMRGND(2)),U,1,($L(GMRGND("L",GMRGND(2)),U)-1)))+2+$L(GMRGND(0))+$L($P(GMRGND("L",GMRGND(2)),U,$L(GMRGND("L",GMRGND(2)),U))))<245 D ST1
Q
ST1 S ^GMR(124.3,GMRGND,1,"ALIST",GMRGND(1),GMRGND(2))=$P(GMRGND("L",GMRGND(2)),U,1,($L(GMRGND("L",GMRGND(2)),U)-1))_U_GMRGND(0)_U_$P(GMRGND("L",GMRGND(2)),U,$L(GMRGND("L",GMRGND(2)),U)) S GMRGND("O")=1
Q
DLLST ; GIVEN THAT GMRGND=ENTRY IN 124.3, AND GMRGND(0)=TERM THAT HAS BEEN
; DELETED FROM PLAN, UPDATE THE LIST XREF FOR GMRGND(0)'S PARENT(S)
F GMRGND(1)=0:0 S GMRGND(1)=$O(^GMRD(124.2,"AKID",GMRGND(0),GMRGND(1))) Q:GMRGND(1)'>0 D PARDL
K GMRGND
Q
PARDL ;
S GMRGND("O")=0
F GMRGND(2)=0:0 S GMRGND(2)=$O(^GMR(124.3,GMRGND,1,"ALIST",GMRGND(1),GMRGND(2))) Q:GMRGND(2)'>0 S GMRGND("L")=^GMR(124.3,GMRGND,1,"ALIST",GMRGND(1),GMRGND(2)) I GMRGND("L")[("^"_GMRGND(0)_"^") D DL0
Q
DL0 ;
S GMRGND("L")=$P(GMRGND("L"),("^"_GMRGND(0)_"^"))_"^"_$P(GMRGND("L"),("^"_GMRGND(0)_"^"),2)
S ^GMR(124.3,GMRGND,1,"ALIST",GMRGND(1),GMRGND(2))=GMRGND("L")
Q
ALIST(IEN,PAR,CHIL) ; GIVEN THE 124.3 IEN (IEN), PARENT (PAR), AND CHILD
; (CHIL), THIS FUNCTION WILL RETURN TRUE(1)/FALSE(0) IF THIS CHILD IS
; PART OF "ALIST" XREF FOR THIS PARENT.
N X,FXN S FXN=0
S Y=$P($G(^GMRD(124.2,PAR,0)),"^",2) I Y=3 S FXN=1
E S X=0 F S X=$O(^GMR(124.3,IEN,1,"ALIST",PAR,X)) Q:X'>0 I $G(^GMR(124.3,IEN,1,"ALIST",PAR,X))[("^"_CHIL_"^") S FXN=1 Q
Q FXN