SPNICD1 ;SAN/WDE/Report of PT's with particular ICD9's ;;2.0;Spinal Cord Dysfunction;**14**;01/02/1997 EN ;prompt user for ICD's that they want to look for K SPNICD S SPNEXIT=0 D REG I SPNEXIT=1 D ZAP Q D ASK I SPNEXIT=1 D ZAP Q I SPNANS=1 D RANGE I SPNEXIT=1 D ZAP Q I SPNANS=2 D SINGLE I SPNEXIT=1 D ZAP Q D DATE I SPNEXIT=1 D ZAP Q D DEV I SPNEXIT=1 D ZAP Q D BEG I SPNEXIT=1 D ZAP K SPNEXIT Q Q ;----------------------------------------------------------------- ASK ;see if they want a range.. W !,"Would you like to sort on a Range of ICD9 codes" S %=2 D YN^DICN I %[0 W !?10,"Enter Y or Yes if you want to sort on a range of ICD9 codes.",!?10,"Enter N or No if you want to look for specific ICD9 codes." G ASK I %<1 S SPNEXIT=1 Q S SPNANS=% Q ;----------------------------------------------------------------- REG W !!,"Do you want patients in the Registry only" S %=1 D YN^DICN I %[0 D G REG . W !?10,"Enter Y or Yes if you want just patients in the Registry," . W !?10,"Or enter N or No to include all Patients." I %<1 S SPNEXIT=1 Q S SPNIN=$S(%=1:"JUST",1:"ALL") Q ;------------------------------------------------------------------ RANGE ;tag allow user to input a range start and end icd's ;Note the set up of spnary its the value S DIC(0)="AEQMNZ",DIC("A")="Starting ICD9 Code: " S DIC="^ICD9(" D ^DIC I Y<1 S SPNEXIT=1 Q I Y>1 S SPNRAN1=$P(Y,U,2) S DIC("A")="Ending ICD9 code: " D ^DIC I Y<1 S SPNEXIT=1 Q I Y>1 S SPNRAN2=$P(Y,U,2) I SPNRAN2SPNEND S SPNCNT=SPNCNT+1 D .I $E(IOST,1)["C" I SPNCNT#10=0 W "." .S SPNPTF="",SPNPTF=$O(^DGPT("AF",SPNADDT,SPNPTF)) Q:SPNPTF="" .D TEST .Q D ^SPNICD2 D ZAP Q Q TEST ;test pt in 154 then icds S SPNDFN=$P($G(^DGPT(SPNPTF,0)),U,1) I SPNIN="JUST" Q:$D(^SPNL(154,SPNDFN,0))=0 ;NOT IN 154 S SPNDATA=$G(^DGPT(SPNPTF,70)) ;spnans=1 range spnasn=2 just the ones entered S SPNX=0 S SPNX=$G(^DGPT(SPNPTF,70)) Q:SPNX="" S SPNY=0 F A=10,16,17,18,19,20,21,22,23,24 S SPNY=$P(SPNDATA,U,A) I +SPNY D .S SPNZ=$P(^ICD9(SPNY,0),U,1) .I SPNANS=1 I (SPNZ>SPNRAN1) I (SPNZ