SROALEC ;BIR/ADM - LIST OF ELIGIBLE CASES ;02/04/08
;;3.0; Surgery ;**160,166**;24 Jun 93;Build 6
S (GRAND,SRNEW,SRSOUT,TOT)=0,(SRHDR,SRPAGE)=1,SRTITLE="CASES ELIGIBLE FOR ASSESSMENT" K ^TMP("SRA",$J)
I SRFLG,SRASP S SRSPEC=$P(^SRO(137.45,SRASP,0),"^")
F S SRSD=$O(^SRF("AC",SRSD)) Q:'SRSD!(SRSD>SRED)!SRSOUT S SRTN=0 F S SRTN=$O(^SRF("AC",SRSD,SRTN)) Q:'SRTN!SRSOUT I $D(^SRF(SRTN,0)),$$MANDIV^SROUTL0(SRINSTP,SRTN) D UTL
I SRSP S SRSS="" F S SRSS=$O(^TMP("SRA",$J,SRSS)) Q:SRSS="" D SRSD Q:SRSOUT D:TOT TOT
I 'SRSP S SRNEW=1,(SRSD,TOT)=0 F S SRSD=$O(^TMP("SRA",$J,SRSD)) Q:'SRSD!SRSOUT S SRTN=0 F S SRTN=$O(^TMP("SRA",$J,SRSD,SRTN)) Q:'SRTN S SRA=^(SRTN) D CASE Q:SRSOUT
Q:SRSOUT I SRSP,'SRFLG,GRAND D GRAND
I SRFLG,'GRAND S SRSS=SRSPEC D HDR,GRAND
I SRSP,'SRFLG,'GRAND S SRSS="" D HDR,GRAND
I 'SRSP,'GRAND S SRSS="" D HDR,GRAND
I 'SRSP,GRAND S SRSS="" D GRAND
Q
UTL ; set up TMP global
N SRCPLT
I '$P($G(^SRF(SRTN,.2)),"^",3)&'$P($G(^SRF(SRTN,.2)),"^",12) Q
I $P($G(^SRF(SRTN,30)),"^") Q
I SRFLG,$P(^SRF(SRTN,0),"^",4)'=SRASP Q
S SRCPLT=$P($G(^SRO(136,SRTN,10)),"^") I SRCPLT,'$$XL^SROAX(SRTN) Q
S SRA=$G(^SRF(SRTN,"RA"))
I SRAST=1 Q:'($P(SRA,"^",2)="N"!($P(SRA,"^",2)="C"))!'($P(SRA,"^",6)="Y")
I SRAST=2 Q:'($P(SRA,"^",2)="N"!($P(SRA,"^",2)="C"))!'($P(SRA,"^",6)="N")
I SRAST=3 Q:$P(SRA,"^",2)'=""
I SRSP S SRSS=$P(^SRF(SRTN,0),"^",4),SRSS=$S(SRSS:$P(^SRO(137.45,SRSS,0),"^"),1:"SPECIALTY NOT ENTERED"),^TMP("SRA",$J,SRSS,SRSD,SRTN)=SRA Q
S ^TMP("SRA",$J,SRSD,SRTN)=SRA
Q
SRSD S SRNEW=1,(SRSD,TOT)=0 F S SRSD=$O(^TMP("SRA",$J,SRSS,SRSD)) Q:'SRSD!SRSOUT S SRTN=0 F S SRTN=$O(^TMP("SRA",$J,SRSS,SRSD,SRTN)) Q:'SRTN S SRA=^(SRTN) D CASE Q:SRSOUT
Q
CASE N SRA2 S SRA2=$P(SRA,"^",2) D
.I SRA2="" S SRATYPE="NOT LOGGED" Q
.I SRA2="N" D Q
.. I $P(SRA,"^",6)="N" S SRATYPE="EXCLUDED" Q
.. S SRATYPE="NON-CARDIAC"
.I SRA2="C" S SRATYPE="CARDIAC"
S TOT=TOT+1,GRAND=GRAND+1 D PRINT
Q
PRINT ; print case info
N SRDA,SRPROCS,SRSP1,SRY S SRPROCS=""
I $Y+8>IOSL!SRNEW D PAGE I SRSOUT Q
S SRA(0)=^SRF(SRTN,0),DFN=$P(SRA(0),"^") N I D DEM^VADPT S SRANM=VADM(1),SRASSN=VA("PID") K VADM
I $L(SRANM)>19 S SRANM=$P(SRANM,",")_","_$E($P(SRANM,",",2))_"."
S SRSP1="",X=$P(SRA(0),"^",4) S:X SRSP1=$P(^SRO(137.45,X,0),"^")
S SROPER=$P(^SRF(SRTN,"OP"),"^") I $O(^SRF(SRTN,13,0)) S SROTHER=0 F I=0:0 S SROTHER=$O(^SRF(SRTN,13,SROTHER)) Q:'SROTHER D OTHER
K SROPS,MM,MMM S:$L(SROPER)<63 SROPS(1)=SROPER I $L(SROPER)>62 S SROPER=SROPER_" " F M=1:1 D LOOP Q:MMM=""
S X=$P(SRA,"^"),SRSTATUS=$S(X="T":"TRANSMITTED",X="C":"COMPLETE",X="I":"INCOMPLETE",1:"NO ASSESSMENT"),Y=SRSD D D^DIQ S SRDT=$P(Y,"@")
I $Y+7>IOSL D PAGE I SRSOUT Q
W !,SRTN,?18,SRANM_" "_VA("PID"),?53,SRATYPE,?67,SRSTATUS,!,SRDT,?18,SROPS(1),! D
.I 'SRSP W $E(SRSP1,1,17) F I=2:1 W:$D(SROPS(I)) ?18,SROPS(I),! I '$D(SROPS(I)) W ! Q
.I SRSP F I=2:1 Q:'$D(SROPS(I)) W ?18,SROPS(I),!
S SRY=$P($G(^SRO(136,SRTN,0)),"^",2) I SRY D CPT S SRPROCS=SRCODE
S SRDA=0 F S SRDA=$O(^SRO(136,SRTN,3,SRDA)) Q:'SRDA S SRY=$P($G(^SRO(136,SRTN,3,SRDA,0)),"^") I SRY D CPT D
.S SRPROCS=SRPROCS_", "_SRCODE
I '$P($G(^SRO(136,SRTN,10)),"^"),$L(SRPROCS) W !,">>> Final CPT Coding is not complete."
S:SRPROCS="" SRPROCS="NOT ENTERED" W !,"CPT Codes: ",SRPROCS
I 'SRSOUT W ! F LINE=1:1:80 W "-"
Q
CPT ; check code for exclusion and get output value
N Y,SREX S (SRCODE,SREX)=""
S Y=$$CPT^ICPTCOD(SRY,$P(SRSD,".")),SRCODE=$P(Y,"^",2)
S SREX="" I '$D(^SRO(137,SRY,0)) S SREX="*"
S SRCODE=SREX_SRCODE
Q
OTHER ; other operations
S SRLONG=1 I $L(SROPER)+$L($P(^SRF(SRTN,13,SROTHER,0),"^"))>125 S SRLONG=0,SROTHER=999,SROPERS=" ..."
I SRLONG S SROPERS=$P(^SRF(SRTN,13,SROTHER,0),"^")
S SROPER=SROPER_$S(SROPERS'=" ...":", "_SROPERS,1:SROPERS)
Q
LOOP ; break procedures
S SROPS(M)="" F LOOP=1:1 S MM=$P(SROPER," "),MMM=$P(SROPER," ",2,200) Q:MMM="" Q:$L(SROPS(M))+$L(MM)'<63 S SROPS(M)=SROPS(M)_MM_" ",SROPER=MMM
Q
PAGE I $E(IOST)="P"!SRHDR G HDR
W !!,"Press <RET> to continue, or '^' to quit " R X:DTIME I '$T!(X["^") S SRSOUT=1 Q
I X["?" W !!,"If you want to continue the listing, press the 'Enter' key.",!,"Type '^' to return to the menu." G PAGE
HDR ; print heading
W @IOF,!,?(80-$L(SRTITLE)\2),SRTITLE,?70,$J("PAGE "_SRPAGE,9) W:$E(IOST)="P" !,?(80-$L(SRINST)\2),SRINST W !,?(80-$L(SRFRTO)\2),SRFRTO
W:$E(IOST)="P" !,?(80-$L(SRPRINT)\2),SRPRINT
W !!,?50,"'*' Denotes Eligible CPT Code" I SRSP,SRSS'="" W !,">>> "_SRSS
W !!,"CASE #",?18,"PATIENT",?53,"TYPE",?67,"STATUS",!,"OP DATE",?18,"OPERATION(S)",! W:'SRSP "SURG SPECIALTY",! F LINE=1:1:80 W "="
S SRHDR=0,SRNEW=0,SRPAGE=SRPAGE+1
Q
TOT W !!,"TOTAL FOR "_SRSS_": ",TOT
Q
GRAND I 'SRSP W !!,"TOTAL: ",GRAND Q
I SRSP,'SRFLG W !!,"TOTAL FOR ALL SPECIALTIES: ",GRAND Q
I SRSP,SRFLG S SRSS=SRSPEC D TOT
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSROALEC 4851 printed Dec 13, 2024@02:40:39 Page 2
SROALEC ;BIR/ADM - LIST OF ELIGIBLE CASES ;02/04/08
+1 ;;3.0; Surgery ;**160,166**;24 Jun 93;Build 6
+2 SET (GRAND,SRNEW,SRSOUT,TOT)=0
SET (SRHDR,SRPAGE)=1
SET SRTITLE="CASES ELIGIBLE FOR ASSESSMENT"
KILL ^TMP("SRA",$JOB)
+3 IF SRFLG
IF SRASP
SET SRSPEC=$PIECE(^SRO(137.45,SRASP,0),"^")
+4 FOR
SET SRSD=$ORDER(^SRF("AC",SRSD))
if 'SRSD!(SRSD>SRED)!SRSOUT
QUIT
SET SRTN=0
FOR
SET SRTN=$ORDER(^SRF("AC",SRSD,SRTN))
if 'SRTN!SRSOUT
QUIT
IF $DATA(^SRF(SRTN,0))
IF $$MANDIV^SROUTL0(SRINSTP,SRTN)
DO UTL
+5 IF SRSP
SET SRSS=""
FOR
SET SRSS=$ORDER(^TMP("SRA",$JOB,SRSS))
if SRSS=""
QUIT
DO SRSD
if SRSOUT
QUIT
if TOT
DO TOT
+6 IF 'SRSP
SET SRNEW=1
SET (SRSD,TOT)=0
FOR
SET SRSD=$ORDER(^TMP("SRA",$JOB,SRSD))
if 'SRSD!SRSOUT
QUIT
SET SRTN=0
FOR
SET SRTN=$ORDER(^TMP("SRA",$JOB,SRSD,SRTN))
if 'SRTN
QUIT
SET SRA=^(SRTN)
DO CASE
if SRSOUT
QUIT
+7 if SRSOUT
QUIT
IF SRSP
IF 'SRFLG
IF GRAND
DO GRAND
+8 IF SRFLG
IF 'GRAND
SET SRSS=SRSPEC
DO HDR
DO GRAND
+9 IF SRSP
IF 'SRFLG
IF 'GRAND
SET SRSS=""
DO HDR
DO GRAND
+10 IF 'SRSP
IF 'GRAND
SET SRSS=""
DO HDR
DO GRAND
+11 IF 'SRSP
IF GRAND
SET SRSS=""
DO GRAND
+12 QUIT
UTL ; set up TMP global
+1 NEW SRCPLT
+2 IF '$PIECE($GET(^SRF(SRTN,.2)),"^",3)&'$PIECE($GET(^SRF(SRTN,.2)),"^",12)
QUIT
+3 IF $PIECE($GET(^SRF(SRTN,30)),"^")
QUIT
+4 IF SRFLG
IF $PIECE(^SRF(SRTN,0),"^",4)'=SRASP
QUIT
+5 SET SRCPLT=$PIECE($GET(^SRO(136,SRTN,10)),"^")
IF SRCPLT
IF '$$XL^SROAX(SRTN)
QUIT
+6 SET SRA=$GET(^SRF(SRTN,"RA"))
+7 IF SRAST=1
if '($PIECE(SRA,"^",2)="N"!($PIECE(SRA,"^",2)="C"))!'($PIECE(SRA,"^",6)="Y")
QUIT
+8 IF SRAST=2
if '($PIECE(SRA,"^",2)="N"!($PIECE(SRA,"^",2)="C"))!'($PIECE(SRA,"^",6)="N")
QUIT
+9 IF SRAST=3
if $PIECE(SRA,"^",2)'=""
QUIT
+10 IF SRSP
SET SRSS=$PIECE(^SRF(SRTN,0),"^",4)
SET SRSS=$SELECT(SRSS:$PIECE(^SRO(137.45,SRSS,0),"^"),1:"SPECIALTY NOT ENTERED")
SET ^TMP("SRA",$JOB,SRSS,SRSD,SRTN)=SRA
QUIT
+11 SET ^TMP("SRA",$JOB,SRSD,SRTN)=SRA
+12 QUIT
SRSD SET SRNEW=1
SET (SRSD,TOT)=0
FOR
SET SRSD=$ORDER(^TMP("SRA",$JOB,SRSS,SRSD))
if 'SRSD!SRSOUT
QUIT
SET SRTN=0
FOR
SET SRTN=$ORDER(^TMP("SRA",$JOB,SRSS,SRSD,SRTN))
if 'SRTN
QUIT
SET SRA=^(SRTN)
DO CASE
if SRSOUT
QUIT
+1 QUIT
CASE NEW SRA2
SET SRA2=$PIECE(SRA,"^",2)
Begin DoDot:1
+1 IF SRA2=""
SET SRATYPE="NOT LOGGED"
QUIT
+2 IF SRA2="N"
Begin DoDot:2
+3 IF $PIECE(SRA,"^",6)="N"
SET SRATYPE="EXCLUDED"
QUIT
+4 SET SRATYPE="NON-CARDIAC"
End DoDot:2
QUIT
+5 IF SRA2="C"
SET SRATYPE="CARDIAC"
End DoDot:1
+6 SET TOT=TOT+1
SET GRAND=GRAND+1
DO PRINT
+7 QUIT
PRINT ; print case info
+1 NEW SRDA,SRPROCS,SRSP1,SRY
SET SRPROCS=""
+2 IF $Y+8>IOSL!SRNEW
DO PAGE
IF SRSOUT
QUIT
+3 SET SRA(0)=^SRF(SRTN,0)
SET DFN=$PIECE(SRA(0),"^")
NEW I
DO DEM^VADPT
SET SRANM=VADM(1)
SET SRASSN=VA("PID")
KILL VADM
+4 IF $LENGTH(SRANM)>19
SET SRANM=$PIECE(SRANM,",")_","_$EXTRACT($PIECE(SRANM,",",2))_"."
+5 SET SRSP1=""
SET X=$PIECE(SRA(0),"^",4)
if X
SET SRSP1=$PIECE(^SRO(137.45,X,0),"^")
+6 SET SROPER=$PIECE(^SRF(SRTN,"OP"),"^")
IF $ORDER(^SRF(SRTN,13,0))
SET SROTHER=0
FOR I=0:0
SET SROTHER=$ORDER(^SRF(SRTN,13,SROTHER))
if 'SROTHER
QUIT
DO OTHER
+7 KILL SROPS,MM,MMM
if $LENGTH(SROPER)<63
SET SROPS(1)=SROPER
IF $LENGTH(SROPER)>62
SET SROPER=SROPER_" "
FOR M=1:1
DO LOOP
if MMM=""
QUIT
+8 SET X=$PIECE(SRA,"^")
SET SRSTATUS=$SELECT(X="T":"TRANSMITTED",X="C":"COMPLETE",X="I":"INCOMPLETE",1:"NO ASSESSMENT")
SET Y=SRSD
DO D^DIQ
SET SRDT=$PIECE(Y,"@")
+9 IF $Y+7>IOSL
DO PAGE
IF SRSOUT
QUIT
+10 WRITE !,SRTN,?18,SRANM_" "_VA("PID"),?53,SRATYPE,?67,SRSTATUS,!,SRDT,?18,SROPS(1),!
Begin DoDot:1
+11 IF 'SRSP
WRITE $EXTRACT(SRSP1,1,17)
FOR I=2:1
if $DATA(SROPS(I))
WRITE ?18,SROPS(I),!
IF '$DATA(SROPS(I))
WRITE !
QUIT
+12 IF SRSP
FOR I=2:1
if '$DATA(SROPS(I))
QUIT
WRITE ?18,SROPS(I),!
End DoDot:1
+13 SET SRY=$PIECE($GET(^SRO(136,SRTN,0)),"^",2)
IF SRY
DO CPT
SET SRPROCS=SRCODE
+14 SET SRDA=0
FOR
SET SRDA=$ORDER(^SRO(136,SRTN,3,SRDA))
if 'SRDA
QUIT
SET SRY=$PIECE($GET(^SRO(136,SRTN,3,SRDA,0)),"^")
IF SRY
DO CPT
Begin DoDot:1
+15 SET SRPROCS=SRPROCS_", "_SRCODE
End DoDot:1
+16 IF '$PIECE($GET(^SRO(136,SRTN,10)),"^")
IF $LENGTH(SRPROCS)
WRITE !,">>> Final CPT Coding is not complete."
+17 if SRPROCS=""
SET SRPROCS="NOT ENTERED"
WRITE !,"CPT Codes: ",SRPROCS
+18 IF 'SRSOUT
WRITE !
FOR LINE=1:1:80
WRITE "-"
+19 QUIT
CPT ; check code for exclusion and get output value
+1 NEW Y,SREX
SET (SRCODE,SREX)=""
+2 SET Y=$$CPT^ICPTCOD(SRY,$PIECE(SRSD,"."))
SET SRCODE=$PIECE(Y,"^",2)
+3 SET SREX=""
IF '$DATA(^SRO(137,SRY,0))
SET SREX="*"
+4 SET SRCODE=SREX_SRCODE
+5 QUIT
OTHER ; other operations
+1 SET SRLONG=1
IF $LENGTH(SROPER)+$LENGTH($PIECE(^SRF(SRTN,13,SROTHER,0),"^"))>125
SET SRLONG=0
SET SROTHER=999
SET SROPERS=" ..."
+2 IF SRLONG
SET SROPERS=$PIECE(^SRF(SRTN,13,SROTHER,0),"^")
+3 SET SROPER=SROPER_$SELECT(SROPERS'=" ...":", "_SROPERS,1:SROPERS)
+4 QUIT
LOOP ; break procedures
+1 SET SROPS(M)=""
FOR LOOP=1:1
SET MM=$PIECE(SROPER," ")
SET MMM=$PIECE(SROPER," ",2,200)
if MMM=""
QUIT
if $LENGTH(SROPS(M))+$LENGTH(MM)'<63
QUIT
SET SROPS(M)=SROPS(M)_MM_" "
SET SROPER=MMM
+2 QUIT
PAGE IF $EXTRACT(IOST)="P"!SRHDR
GOTO HDR
+1 WRITE !!,"Press <RET> to continue, or '^' to quit "
READ X:DTIME
IF '$TEST!(X["^")
SET SRSOUT=1
QUIT
+2 IF X["?"
WRITE !!,"If you want to continue the listing, press the 'Enter' key.",!,"Type '^' to return to the menu."
GOTO PAGE
HDR ; print heading
+1 WRITE @IOF,!,?(80-$LENGTH(SRTITLE)\2),SRTITLE,?70,$JUSTIFY("PAGE "_SRPAGE,9)
if $EXTRACT(IOST)="P"
WRITE !,?(80-$LENGTH(SRINST)\2),SRINST
WRITE !,?(80-$LENGTH(SRFRTO)\2),SRFRTO
+2 if $EXTRACT(IOST)="P"
WRITE !,?(80-$LENGTH(SRPRINT)\2),SRPRINT
+3 WRITE !!,?50,"'*' Denotes Eligible CPT Code"
IF SRSP
IF SRSS'=""
WRITE !,">>> "_SRSS
+4 WRITE !!,"CASE #",?18,"PATIENT",?53,"TYPE",?67,"STATUS",!,"OP DATE",?18,"OPERATION(S)",!
if 'SRSP
WRITE "SURG SPECIALTY",!
FOR LINE=1:1:80
WRITE "="
+5 SET SRHDR=0
SET SRNEW=0
SET SRPAGE=SRPAGE+1
+6 QUIT
TOT WRITE !!,"TOTAL FOR "_SRSS_": ",TOT
+1 QUIT
GRAND IF 'SRSP
WRITE !!,"TOTAL: ",GRAND
QUIT
+1 IF SRSP
IF 'SRFLG
WRITE !!,"TOTAL FOR ALL SPECIALTIES: ",GRAND
QUIT
+2 IF SRSP
IF SRFLG
SET SRSS=SRSPEC
DO TOT
+3 QUIT