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

39 lines
2.6 KiB
Mathematica

GMRGPNB1 ;HIRMFO/RM-SENTENCE BUILDER ;1/23/96
;;3.0;Text Generator;;Jan 24, 1996
SNT ;
S GMRGSNT(1)=GMRGA0,(GMRGSPTR("C"),GMRGSPTR)=1,GMRGSPTR("P",1)=0
S GMRGSNT(1,"LEAD")=$S($D(^GMRD(124.2,GMRGA0,4)):^(4),1:""),GMRGSNT(1,"TRAIL")=$S($D(^GMRD(124.2,GMRGA0,5)):^(5),1:""),GMRGSNT(1,"SUB")=0,GMRGSNT(1,0)=$S($D(^GMRD(124.2,GMRGA0,0)):^(0),1:"")
S GMRGF0(0)=GMRGA0
F GMRGF0=0:0 S GMRGF0=$O(^GMRD(124.2,GMRGA0,1,"B",GMRGF0)) Q:GMRGF0'>0 I $S(GMRGCSW&'$D(^GMR(124.3,GMRGPDA,1,"ALIST",GMRGF0)):0,GMRGCSW:1,1:$D(^GMR(124.3,"B",GMRGF0,GMRGPDA))!$D(^GMR(124.3,GMRGPDA,1,"B",GMRGF0))) D SNT1
F GMRGSNT=0:0 S GMRGSNT=$O(GMRGSNT(GMRGSNT)) Q:GMRGSNT'>0 I $O(GMRGSNT(GMRGSNT,0))!($P(GMRGSNT(GMRGSNT,0),"^",2)=3) D SNTP^GMRGPNB2
S GMRGSSW=0
Q
SNT1 ;
I GMRGF0(0) Q:'$D(^GMRD(124.2,"AKID",GMRGF0,GMRGF0(0)))
S GMRGC0=GMRGF0 N GMRGF0 S GMRGF0(0)=GMRGC0
S GMRGE0(4)=$S($D(^GMRD(124.2,GMRGC0,4)):^(4),1:""),GMRGE0(5)=$S($D(^GMRD(124.2,GMRGC0,5)):^(5),1:""),GMRGE0(0)=$S($D(^GMRD(124.2,GMRGC0,0)):^(0),1:"")
I (GMRGE0(4)=""&(GMRGE0(5)="")) D INSERT Q
S GMRGSPTR=GMRGSPTR+1,GMRGSPTR("P",GMRGSPTR)=GMRGSPTR("C"),GMRGSPTR("C")=GMRGSPTR,GMRGSNT(GMRGSPTR("C"))=GMRGF0(0),GMRGSNT(GMRGSPTR("C"),"LEAD")=GMRGE0(4),GMRGSNT(GMRGSPTR("C"),"TRAIL")=GMRGE0(5),GMRGSNT(GMRGSPTR("C"),"SUB")=0
S GMRGSNT(GMRGSPTR("C"),0)=GMRGE0(0)
F GMRGF0=0:0 S GMRGF0=$O(^GMRD(124.2,GMRGF0(0),1,"B",GMRGF0)) Q:GMRGF0'>0 D
. Q:'$$ALIST^GMRGRUT0(GMRGPDA,GMRGF0(0),GMRGF0)
. I $S(GMRGCSW&'$D(^GMR(124.3,GMRGPDA,1,"ALIST",GMRGF0)):0,GMRGCSW:1,1:$D(^GMR(124.3,"B",GMRGF0,GMRGPDA))!$D(^GMR(124.3,GMRGPDA,1,"B",GMRGF0))) D SNT1
. Q
S GMRGSPTR("C")=GMRGSPTR("P",GMRGSPTR("C"))
Q
INSERT ;
S GMRGSNT(GMRGSPTR("C"),"INS",GMRGF0(0),"CPE")=0
S GMRGSNT(GMRGSPTR("C"),"INS",GMRGF0(0),"PRE")=$S($D(GMRGSNT(GMRGSPTR("C"),"INS"))#2:GMRGSNT(GMRGSPTR("C"),"INS"),1:0),GMRGSNT(GMRGSPTR("C"),"INS")=GMRGF0(0)
F GMRGF0=0:0 S GMRGF0=$O(^GMRD(124.2,GMRGF0(0),1,"B",GMRGF0)) Q:GMRGF0'>0 I $S(GMRGCSW&'$D(^GMR(124.3,GMRGPDA,1,"ALIST",GMRGF0)):0,GMRGCSW:1,1:$D(^GMR(124.3,"B",GMRGF0,GMRGPDA))!$D(^GMR(124.3,GMRGPDA,1,"B",GMRGF0))) D INS1
I 'GMRGSNT(GMRGSPTR("C"),"INS",GMRGF0(0),"CPE") D INSTRM
I 'GMRGSNT(GMRGSPTR("C"),"INS",GMRGF0(0),"PRE") K GMRGSNT(GMRGSPTR("C"),"INS")
E S GMRGSNT(GMRGSPTR("C"),"INS")=GMRGSNT(GMRGSPTR("C"),"INS",GMRGF0(0),"PRE") K GMRGSNT(GMRGSPTR("C"),"INS",GMRGF0(0))
Q
INS1 ;
Q:'$D(^GMRD(124.2,"AKID",GMRGF0,GMRGF0(0))) S GMRGSNT(GMRGSPTR("C"),"INS",GMRGF0(0),"CPE")=GMRGSNT(GMRGSPTR("C"),"INS",GMRGF0(0),"CPE")+1
D SNT1
Q
INSTRM ;
S GMRGSNT(GMRGSPTR("C"),"SUB")=GMRGSNT(GMRGSPTR("C"),"SUB")+1,GMRGSNT(GMRGSPTR("C"),GMRGSNT(GMRGSPTR("C"),"SUB"))=GMRGF0(0)
Q