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

ONCACD1.m

Go to the documentation of this file.
ONCACD1 ;HINES OIFO/GWB - Extract NAACCR/STATE/VACCR data ;09/06/11
 ;;2.2;ONCOLOGY;**1,4,5,8,9,13,14,15,17,18,20**;Jul 31, 2013;Build 5
 ;
 ;P5 added in RQRS the Analytic Cases selection.
 ;P8 allows BLANK in TNM Clin/Path data fields & others.
 ;P9 discard in State Extract -  COC=34 & Analytic=NO
EN1 ;Entry point
 K ^TMP($J)
 N EXPORT,PAGE,STOPDT,OIEN,ZTREQ
 ;P18 
 I $D(EDT),($P(EDT,".",2))="" S EDT=EDT_.2500
 I $D(DATE1),($P(DATE1,".",2))="" S DATE1=DATE1_.2500
 S PAGE=1,OIEN=0
 S EXPORT="YES"
 D SETUP
 I 'DEVICE W $C(26) H 30
 Q
 ;
SETUP ;Loop through appropriate cross-reference
 I 'DEVICE S X=0 X ^%ZOSF("RM") ;Disable autowrap
 N BLANK,DCLC,FDNUM,IEN,NC,NINE,TPG,ZERO,ZNINE,X
 S BLANK=" "
 S (IEN,ZERO)=0
 S NINE=9,ZNINE="09"
 S OUT=$G(OUT,0)
 ;P14
 N ONCX21,ONCDTNW,ONCDT,ONCPRNT,ONCIE160,ONCTZONE
 S ONCPRNT=0
 I ('DEVICE),((EXTRACT=3)!(EXTRACT=5)!(EXTRACT=6)!(EXTRACT=7)) D
 .N ONC11,ONC22,ONC33,ONC44,ONC55,ONCNN,ONCPP,ONCTT,ONCDTIME,ONCDIC,ONCTYPE,ONCXPRT,ONCTHR,ONCTMN,ONCTSN
 .S ONCT=$$NOW^XLFDT()
 .S ONCTZONE=$$TZ^XLFDT()
 .S ONCTHR=$E(ONCT,9,10),ONCTMN=$E(ONCT,11,12),ONCTSN=$E(ONCT,13,14)
 .S:ONCTSN="" ONCTSN="00"
 .S:($L(ONCTSN)=1) ONCTSN="0"_ONCTSN
 .S ONCTSN=ONCTSN_".000"_$E(ONCTZONE,1,3)_":"_$E(ONCTZONE,4,5)
 .S ONCDTNW=""""_(1700+$E(ONCT,1,3))_"-"_$E(ONCT,4,5)_"-"_$E(ONCT,6,7)_"T"_ONCTHR_":"_ONCTMN_":"_ONCTSN_""""
 .S ONCX21=1
 .S ONCTYPE="""A"""
 .I EXTRACT=7 S ONCTYPE="""I"""
 .S ONCDIC="""http://naaccr.org/naaccrxml/naaccr-dictionary-230.xml"""
 .S ONC11=" baseDictionaryUri="
 .S ONC22=" recordType=",ONC33=" timeGenerated=",ONC44=" specificationVersion="
 .W "<?xml version=""1.0"" encoding=""UTF-8""?>",!
 .W "<NaaccrData xmlns=""http://naaccr.org/naaccrxml""",ONC11,ONCDIC,!
 .W ONC22,ONCTYPE,ONC33,ONCDTNW,ONC44,"""1.4""",">"
 .S ONCXPRT=1
 ;
 ;NCDB EXTRACT
 ;Loop through DATE DX (165.5,3) "ADX" cross-reference
 S ONCDT=DATE
 I STEXT=0 F  S ONCDT=$O(^ONCO(165.5,"ADX",ONCDT)) Q:(ONCDT>DATE1)!(ONCDT="")  S IEN=0 F  S IEN=$O(^ONCO(165.5,"ADX",ONCDT,IEN)) Q:IEN=""  I $$DIV^ONCFUNC(IEN)=DUZ(2) D  Q:OUT
 .I $G(NCDB)=2 S DCLC=$P($G(^ONCO(165.5,IEN,7)),U,21) Q:(DCLC<SDT)!(DCLC>EDT)
 .I $G(NCDB)=3 S ACCN=$P($G(^ONCO(165.5,IEN,0)),U,5) Q:(ACCN<SDT)!(ACCN>EDT)
 .D LOOP
 ;
 ;VACCR/STATE EXTRACT
 ;Loop through DATE CASE COMPLETED (165.5,90) "AAD" cross-reference
 I ($G(STEXT)=1),($G(ONCLDT)=1) S SDT=SDT-.00001 F  S SDT=$O(^ONCO(165.5,"AAD",SDT)) Q:(SDT<1)!(SDT>EDT)!(OUT=1)  F  S IEN=$O(^ONCO(165.5,"AAD",SDT,IEN)) Q:IEN<1  I $$DIV^ONCFUNC(IEN)=DUZ(2) D  Q:OUT
 .Q:$G(^ONCO(165.5,IEN,0))=""
 .D LOOP
 ;Loop through DATE CASE LAST CHANGED (165.5,198) "AAE" cross-reference
 I ($G(STEXT)=1),($G(ONCLDT)=2) S SDT=SDT-.00001 F  S SDT=$O(^ONCO(165.5,"AAE",SDT)) Q:(SDT<1)!(SDT>EDT)!(OUT=1)  F  S IEN=$O(^ONCO(165.5,"AAE",SDT,IEN)) Q:IEN<1  I $$DIV^ONCFUNC(IEN)=DUZ(2) D  Q:OUT
 .Q:$G(^ONCO(165.5,IEN,0))=""
 .D LOOP
 ;Loop through ACCESSION NUMBER (165.5,.05) "AA" cross-reference
 I ($G(STEXT)=1),($G(ONCLDT)=3) S SDT=SDT-1 F  S SDT=$O(^ONCO(165.5,"AA",SDT)) Q:(SDT<1)!(SDT>EDT)!(OUT=1)  F  S IEN=$O(^ONCO(165.5,"AA",SDT,IEN)) Q:IEN<1  I $$DIV^ONCFUNC(IEN)=DUZ(2) D  Q:OUT
 .Q:$G(^ONCO(165.5,IEN,0))=""
 .D LOOP
 ;
 ;VACCR/STATE EXTRACT
 ;Loop through DATE CASE LAST CHANGED (165.5,198) "AAE" cross-reference
 I ($G(STEXT)=2) S SDT=SDT-1 F  S SDT=$O(^ONCO(165.5,"AAE",SDT)) Q:(SDT<1)!(SDT>EDT)!(OUT=1)  F  S IEN=$O(^ONCO(165.5,"AAE",SDT,IEN)) Q:IEN<1  I $$DIV^ONCFUNC(IEN)=DUZ(2) D  Q:OUT
 .Q:$G(^ONCO(165.5,IEN,0))=""
 .D LOOP
 ;
 ;RQRS EXTRACT
 ;Loop through DATE DX (165.5,3) "ADX" cross-reference
 I ($G(STEXT)=3),($G(ONCLDT)=1) S SDT=SDT-1 F  S SDT=$O(^ONCO(165.5,"ADX",SDT)) Q:(SDT<1)!(SDT>EDT)!(OUT=1)  F  S IEN=$O(^ONCO(165.5,"ADX",SDT,IEN)) Q:IEN<1  I $$DIV^ONCFUNC(IEN)=DUZ(2) D  Q:OUT
 .Q:$G(^ONCO(165.5,IEN,0))=""
 .S TPG=$P($G(^ONCO(165.5,IEN,2)),U,1)
 .S NC=0
 .F FDNUM=.03,.05,.06,3,20,22.3 I $$GET1^DIQ(165.5,IEN,FDNUM,"I")="" S NC=1
 .Q:NC=1
 .S ONCCLCA=$E($$GET1^DIQ(165.5,IEN,.04),1,2)
 .I ($G(ONCR12)=2),(ONCCLCA<23) D LOOP Q
 .I ($G(ONCR12)=1),(($E(TPG,3,4)=50)!($E(TPG,3,4)=18)!($E(TPG,3,4)=20))&(TPG'=67181) D LOOP  ; screen out 67181 (appendix) cases - p2.2*4
 ;
 ;Loop through DATE CASE LAST CHANGED (165.5,198) "AAE" cross-reference
 ;Quit if "ADX" is before 2008 - p2.2*4
 I ($G(STEXT)=3),($G(ONCLDT)=2) S SDT=SDT-.00001 F  S SDT=$O(^ONCO(165.5,"AAE",SDT)) Q:(SDT<1)!(SDT>EDT)!(OUT=1)  F  S IEN=$O(^ONCO(165.5,"AAE",SDT,IEN)) Q:IEN<1  I $$DIV^ONCFUNC(IEN)=DUZ(2) D  Q:OUT
 .Q:$G(^ONCO(165.5,IEN,0))=""
 .Q:$P($G(^ONCO(165.5,IEN,0)),U,16)<3060101
 .S TPG=$P($G(^ONCO(165.5,IEN,2)),U,1)
 .S NC=0
 .F FDNUM=.03,.05,.06,3,20,22.3 I $$GET1^DIQ(165.5,IEN,FDNUM,"I")="" S NC=1
 .Q:NC=1
 .S ONCCLCA=$E($$GET1^DIQ(165.5,IEN,.04),1,2)
 .I ($G(ONCR12)=2),(ONCCLCA<23) D LOOP Q
 .I ($G(ONCR12)=1),($E(TPG,3,4)=50)!($E(TPG,3,4)=18)!($E(TPG,3,4)=20)&(TPG'=67181) D LOOP
 ;
 ;Loop through ACCESSION NUMBER (165.5,.05) "AA" cross-reference
 I ($G(STEXT)=3),($G(ONCLDT)=3) S SDT=SDT-1 F  S SDT=$O(^ONCO(165.5,"AA",SDT)) Q:(SDT<1)!(SDT>EDT)!(OUT=1)  F  S IEN=$O(^ONCO(165.5,"AA",SDT,IEN)) Q:IEN<1  I $$DIV^ONCFUNC(IEN)=DUZ(2) D  Q:OUT
 .Q:$G(^ONCO(165.5,IEN,0))=""
 .Q:$P($G(^ONCO(165.5,IEN,0)),U,16)<3060101
 .S TPG=$P($G(^ONCO(165.5,IEN,2)),U,1)
 .S NC=0
 .F FDNUM=.03,.05,.06,3,20,22.3 I $$GET1^DIQ(165.5,IEN,FDNUM,"I")="" S NC=1
 .Q:NC=1
 .S ONCCLCA=$E($$GET1^DIQ(165.5,IEN,.04),1,2)
 .I ($G(ONCR12)=2),(ONCCLCA<23) D LOOP Q
 .I ($G(ONCR12)=1),($E(TPG,3,4)=50)!($E(TPG,3,4)=18)!($E(TPG,3,4)=20)&(TPG'=67181) D LOOP
 I ('DEVICE),$G(ONCPRNT)>20,((EXTRACT=3)!(EXTRACT=5)!(EXTRACT=6)!(EXTRACT=7)) D
 .W !,?5,"</Tumor>"
 .W !,?3,"</Patient>"
 .W !,"</NaaccrData>",!
 Q
 ;
LOOP ;Apply extract selection rules
 ;P#9
 ;P#13
 Q:OUT
 I ($G(EXTRACT)=2)!($G(EXTRACT)=5),($E($$GET1^DIQ(165.5,IEN,.04),1,2)=34),($G(ACO)=0) Q
 N LINE,RULES,VALID,JUMP
 S RULES=0
 F  S RULES=$O(^ONCO(160.16,EXTRACT,"RULES",RULES)) Q:RULES<1  D
 .S LINE=^ONCO(160.16,EXTRACT,"RULES",RULES,0)
 .X LINE
 Q:'VALID
 S ^TMP($J,IEN)=""
 D OUTPUT(IEN,EXTRACT,JUMP,.OUT)
 ;I 'DEVICE W !
 Q
 ;
OUTPUT(IEN,EXTRACT,JUMP,OUT) ;Output
 S ACD160=$P(^ONCO(165.5,IEN,0),U,2)
 I DEVICE D HEAD(IEN,.OUT) Q:OUT
 N POS S POS=0
 ;P14 xml format
 I $G(ONCX21)=1 D  Q
 .Q:$D(ONCIE160(IEN))
 .W:$G(ONCPRNT)>20 !,?5,"</Tumor>"
        .W:$G(ONCPRNT)>20 !,?3,"</Patient>"
 .D XML21
 .;S ONCPRNT=1
 .S ONCXPRT=1
 .Q
 F  S POS=$O(^ONCO(160.16,EXTRACT,"FIELD","B",POS)) Q:POS<1  D  Q:OUT
 .N NODE S NODE=0
 .F  S NODE=$O(^ONCO(160.16,EXTRACT,"FIELD","B",POS,NODE)) Q:NODE<1  D  Q:OUT
 ..N STRING,DEFAULT,FILL,LEN
 ..Q:$G(^ONCO(160.16,EXTRACT,"FIELD",NODE,0))=""
 ..D DISPLAY(DEVICE,$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,0),U,1)_U_$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,0),U,4),.OUT)
 ..Q:OUT
 ..S LEN=$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,0),U,2)
 ..S STRING=$TR(^ONCO(160.16,EXTRACT,"FIELD",NODE,1),"~","^")
 ..S DEFAULT=$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,2),U,1)
 ..S FILL=$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,3),U,1)
 ..D DATA(IEN,ACD160,STRING,DEFAULT,FILL,LEN,JUMP,NODE,POS)
 ..;=========================================================
 ..; This Code supports the PCE Extracts (currently disabled)
 ..;=========================================================
 ..I $G(^ONCO(160.16,EXTRACT,0))["ZZNCDB" D
 ...I $O(^ONCO(160.16,EXTRACT,"FIELD","B",POS))>1 Q  ;QUIT if not end
 ...N EXTRACT,NODE,POS
 ...S EXTRACT=100,JUMP=0
 ...;S:$D(^ONCO(165.5,"APCE","BLA",IEN)) EXTRACT=1
 ...; ^==== Bladder 95,90,85
 ...;S:$D(^ONCO(165.5,"APCE","THY",IEN)) EXTRACT=2
 ...; ^==== Thyroid 96,91,86
 ...;S:$D(^ONCO(165.5,"APCE","STS",IEN)) EXTRACT=3
 ...; ^==== Soft Tissue 96,91,86
 ...;S:$D(^ONCO(165.5,"APCE","COL",IEN)) EXTRACT=4
 ...; ^==== Colorectal 97,92,87
 ...;S:$D(^ONCO(165.5,"APCE","NHL",IEN)) EXTRACT=5
 ...; ^==== Non-Hodgkins 97,92,87
 ...;S:$D(^ONCO(165.5,"APCE","BRE",IEN)) EXTRACT=6
 ...; ^==== Breast 98,93,88
 ...;S:$D(^ONCO(165.5,"APCE","PRO2",IEN)) EXTRACT=7
 ...; ^==== Prostate 98,93,88
 ...;S:$D(^ONCO(165.5,"APCE","MEL",IEN)) EXTRACT=8
 ...; ^==== Melanoma 99,94,89
 ...;S:$D(^ONCO(165.5,"APCE","HEP",IEN)) EXTRACT=9
 ...; ^==== Hepatocellular Cancers 00,95,90
 ...;S:$D(^ONCO(165.5,"APCE","CNS",IEN)) EXTRACT=10
 ...; ^==== Primary Intracranial/CNS Tumors 00,95,90
 ...;S:$D(^ONCO(165.5,"APCE","LNG",IEN)) EXTRACT=11
 ...; ^==== Lung (NSCLC) 01,96,91
 ...;S:$D(^ONCO(165.5,"APCE","GAS",IEN)) EXTRACT=12
 ...; ^==== Gastric Cancers 01,96,91
 ...S POS=0
 ...F  S POS=$O(^ONCO(160.17,EXTRACT,"FIELD","B",POS)) Q:POS<1  D  Q:OUT
 ....N NODE S NODE=0
 ....F  S NODE=$O(^ONCO(160.17,EXTRACT,"FIELD","B",POS,NODE)) Q:NODE<1  D  Q:OUT
 .....N DEFAULT,FILL,LEN,STRING
 .....Q:$G(^ONCO(160.17,EXTRACT,"FIELD",NODE,0))=""
 .....D DISPLAY(DEVICE,$P(^ONCO(160.17,EXTRACT,"FIELD",NODE,0),U,1)_U_$P(^ONCO(160.17,EXTRACT,"FIELD",NODE,0),U,4),.OUT)
 .....Q:OUT
 .....S STRING=$TR(^ONCO(160.17,EXTRACT,"FIELD",NODE,1),"~","^")
 .....S DEFAULT=^ONCO(160.17,EXTRACT,"FIELD",NODE,2)
 .....S FILL=^ONCO(160.17,EXTRACT,"FIELD",NODE,3)
 .....S LEN=$P(^ONCO(160.17,EXTRACT,"FIELD",NODE,0),U,2)
 .....D DATA(IEN,ACD160,STRING,DEFAULT,FILL,LEN,JUMP,NODE,POS)
 Q
 ;
 N FLG
 I IEN=OIEN S FLG=0
 I IEN'=OIEN S OIEN=IEN,FLG=1
 I 'FLG Q:$Y+4<IOSL
 I PAGE'=1 D  Q:OUT
 .Q:$E(IOST,1,2)'="C-"
 .N DIR,Y
 .S DIR(0)="E" D ^DIR
 .I 'Y S OUT=1 Q
 D HEADER
 Q
 ;
 I PAGE'=1 W @IOF
 I PAGE=1,$E(IOST,1,2)="C-" W @IOF
 I STEXT=3 W !,"RCRS EXTRACT",?70,"Page: ",PAGE S PAGE=PAGE+1
 E  W !,$P(^ONCO(160.16,EXTRACT,0),U),?70,"Page: ",PAGE S PAGE=PAGE+1
 W !,"Patient: ",$$GET1^DIQ(160,ACD160,.01,"E")
 W ?55,"SSN: ",$$GET1^DIQ(160,ACD160,2,"E")
 W !,"Col#",?5,"Item name",?51,"Value",!
 F I=1:1:79 W "="
 Q
XML21 ;P14
 N ONCRTYP,ONCOLD,ONCPOS
 S ONCOLD="TEST",(ONCPOS,POS)="A",ONCRTYP=""
 S ONCIE160(IEN)=IEN
 F  S POS=$O(^ONCO(160.16,EXTRACT,"FIELD","D",POS)) Q:POS=""  D  Q:OUT
 .N NODE,ONCXDATA S NODE=0
 .;I POS="N" S ONCRTYP="<NaaccrData>"
 .I POS="P" S ONCRTYP="<Patient>"
 .I POS="T" S ONCRTYP="<Tumor>"
 .F  S NODE=$O(^ONCO(160.16,EXTRACT,"FIELD","D",POS,NODE)) Q:NODE<1  D  Q:OUT
 ..N STRING,DEFAULT,FILL,LEN,ONCXDATA
 ..Q:$G(^ONCO(160.16,EXTRACT,"FIELD",NODE,0))=""
 ..S ONCXDATA=$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,0),U,5)
 ..Q:ONCXDATA=""
 ..I (POS'=ONCPOS),(ONCOLD'=ONCRTYP),(ONCRTYP'="") D
 ...W:POS="P" !,?3,ONCRTYP
 ...W:POS="T" !,?5,ONCRTYP
 ...S ONCOLD=ONCRTYP,ONCPOS=POS
 ..;D DISPLAY(DEVICE,$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,0),U,1)_U_$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,0),U,4),.OUT)
 ..;Q:OUT
 ..S LEN=$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,0),U,2)
 ..S STRING=$TR(^ONCO(160.16,EXTRACT,"FIELD",NODE,1),"~","^")
 ..S DEFAULT=$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,2),U,1)
 ..S FILL=$P(^ONCO(160.16,EXTRACT,"FIELD",NODE,3),U,1)
 ..D DATA(IEN,ACD160,STRING,DEFAULT,FILL,LEN,JUMP,NODE,POS)
 .S ONCXPRT=1
 Q
 ;
DISPLAY(DEVICE,WRITE,OUT) ; Display preview
 Q:'DEVICE
 N DOTS,COL,ITEM
 I DEVICE,($Y+5)>IOSL D HEAD(0,.OUT) Q:OUT
 S COL=$P(WRITE,U,1)
 S COL=$S($L(COL)=1:"   "_COL,$L(COL)=2:"  "_COL,$L(COL)=3:" "_COL,1:COL)
 S ITEM=$P(WRITE,U,2),ITEM=$E(ITEM,1,45)
 S DOTS=(46-$L(ITEM))
 W !,COL,?5,ITEM
 F I=1:1:DOTS W "."
 Q
 ;
DATA(IEN,ACD160,STRING,DEFAULT,FILL,LEN,JUMP,NODE,POS) ;Compute extract value
 N ACDANS,EXIT S EXIT=0
 I $G(ONCX21)=1 D  Q
 .I $G(ONCPRNT)>20,(POS="N") Q
 .X STRING
        .;If value = "", extract DEFAULT value
 .I (ACDANS=""),(DEFAULT="BLANK") Q
 .N I,X S X=""
 .I DEFAULT=8 D
 ..F I=1:1:LEN S ACDANS=ACDANS_@DEFAULT
 .I @DEFAULT="09" S ACDANS=@DEFAULT
 .;F I=1:1:LEN S ACDANS=ACDANS_@DEFAULT
 .I (ACDANS["&")!(ACDANS["<")!(ACDANS[">") D STRIP
 .D XFILL
 .I ('DEVICE),(ACDANS=""),((EXTRACT=3)!(EXTRACT=5)!(EXTRACT=6)!(EXTRACT=7)) Q
 .W:POS="N" !,?2
 .W:POS="P" !,?5
 .W:POS="T" !,?7
 .W "<Item naaccrId=""",ONCXDATA,""">",ACDANS,"</Item>"
 .S ONCPRNT=ONCPRNT+1
 .Q
 I JUMP'="0" D
 .I POS<$P(JUMP,U) Q
 .I POS>$P(JUMP,U,2) Q
 .N I
 .S EXIT=1
 .F I=1:1:LEN W BLANK
 Q:EXIT
 X STRING
 ;
 ;If value = "", extract DEFAULT value
 I ACDANS="" D  Q
 .N I,X S X=""
 .I DEFAULT=8 D  Q
 ..F I=1:1:LEN W DEFAULT
 .I @DEFAULT="09" W @DEFAULT Q
 .F I=1:1:LEN W @DEFAULT
 ;
 ;If value too long, truncate to LENGTH (160.161,1)
 ;If value too short, pad with FILL (160.161,6)
 I $L(ACDANS)=LEN W ACDANS Q
 I $L(ACDANS)>LEN W $E(ACDANS,1,LEN) Q
 E  D  Q
 .N JUST,STUFF,I,REM,CAL
 .S JUST=$P(FILL,","),STUFF=$P(FILL,",",2)
 .S REM=LEN-$L(ACDANS)
 .I JUST="R" W ACDANS
 .F I=1:1:REM W @STUFF
 .I JUST="L" W ACDANS
 Q
XFILL ;Truncate or pad xml fields
 I $L(ACDANS)=LEN Q
 I $L(ACDANS)>LEN S ACDANS=$E(ACDANS,1,LEN) Q
 E  D  Q
 .N JUST,STUFF,I,REM,CAL,LACDANS
 .S LACDANS=""
 .S JUST=$P(FILL,","),STUFF=$P(FILL,",",2),STUFF=$P(STUFF,"^")
 .Q:STUFF="BLANK"
 .S:STUFF="ZERO" STUFF=0
 .S:STUFF="NINE" STUFF=9
 .S REM=LEN-$L(ACDANS)
 .F I=1:1:REM S:JUST="R" ACDANS=ACDANS_STUFF S:JUST="L" LACDANS=LACDANS_STUFF
 .I JUST="L" S ACDANS=LACDANS_ACDANS
 Q
STRIP ;replace special characters
 N AA,BB,X1
 S BB=""
 F I=1:1:($L(ACDANS)) Q:I'>0  D
 .S (AA,X1)=$E(ACDANS,I)
 .S:X1="&" AA=" and "
 .S:X1=">" AA=" GT "
 .S:X1="<" AA=" LT "
 .S:X1="$" AA=" "
 .S BB=BB_AA
 S ACDANS=BB
 Q
RCRS ;RCRS exeption rules
 I ($P(TPG,3,4)=44),((MPGH>79999)&(MPGH<81109)) S VALID=0
 I (MPGH=80772),(($P(TPG,3,5)=619)!($P(TPG,3,5)=529)) S VALID=0
 I (MPGH=80772),(($P(TPG,3,4)=51)!($P(TPG,3,4)=21)!$P(TPG,3,4)=32) S VALID=0
 I (DATEDX>3220000),(($P(TPG,3,5)>159)&($P(TPG,3,5)<167)),((MPGH=82112)!(MPGHD=82612)!(MPGH=82632)) S VALID=0
 I (DATEDX>3220000),(($P(TPG,3,5)>167)&($P(TPG,3,5)<174)),((MPGH=82112)!(MPGHD=82612)!(MPGH=82632)) S VALID=0
 I (DATEDX>3220000),(($P(TPG,3,5)>177)&($P(TPG,3,5)<180)),((MPGH=82112)!(MPGHD=82612)!(MPGH=82632)) S VALID=0
 I (DATEDX>3220000),($P(TPG,3,5)=53),((MPGH=84832)!(MPGHD=84842)) S VALID=0
 Q
 ;
CLEANUP ;Cleanup
 K DATE,EDT,NCDB,SDT,STEXT