SROALSSP ;BIR/ADM - ASSESSMENTS BY SPECIALTY (PRINTER) ;01/18/07
;;3.0; Surgery ;**32,47,50,100,142,153,160**;24 Jun 93;Build 7
START S SRSOUT=0 K ^TMP("SRA",$J)
F S SRSD=$O(^SRF("AC",SRSD)) Q:'SRSD!(SRSD>SRED) S SRTN=0 F S SRTN=$O(^SRF("AC",SRSD,SRTN)) Q:'SRTN I $D(^SRF(SRTN,0)),$$MANDIV^SROUTL0(SRINSTP,SRTN) D UTL
D PRINT Q
UTL ; write to ^TMP("SRA,$J)
S SRA(0)=^SRF(SRTN,0)
S CAN=$P($G(^SRF(SRTN,30)),"^") I CAN Q
S CAN=$P($G(^SRF(SRTN,31)),"^",8) I CAN'="" Q
S X=$P($G(^SRF(SRTN,.2)),"^",12) I 'X Q
I SRFLG,$P(^SRF(SRTN,0),"^",4)'=SRASP Q
S SRSS=$P(^SRF(SRTN,0),"^",4),SRSS=$S(SRSS:$P(^SRO(137.45,SRSS,0),"^"),1:"SPECIALTY NOT ENTERED")
S TYPE=$P($G(^SRF(SRTN,"RA")),"^",2) I SRSS="SPECIALTY NOT ENTERED",TYPE="C" S SRSS="N/A"
S ^TMP("SRA",$J,SRSS,SRTN)=""
Q
SET ; set variables
K SRCPTT S SRCPTT="NOT ENTERED"
S SRA("RA")=$G(^SRF(SRTN,"RA")),X=$P(SRA("RA"),"^"),STATUS=$S(X="I":"INCOMPLETE",X="C":"COMPLETED",X="T":"TRANSMITTED",1:"EXCLUSION")
S (SREXCL,Y)=$P(SRA("RA"),"^",7),C=$P(^DD(130,102,0),"^",2) D Y^DIQ S SREXCL=Y
I SREXCL="",STATUS="EXCLUSION" S STATUS="NO ASSESSMENT"
S SRA(0)=^SRF(SRTN,0),DFN=$P(SRA(0),"^") N I D DEM^VADPT S SRANM=VADM(1),SRASSN=VA("PID") K VADM
S X=^SRF(SRTN,"OP"),SROPER=$P(X,"^")
I $O(^SRF(SRTN,13,0)) S SROTHER=0 F I=0:0 S SROTHER=$O(^SRF(SRTN,13,SROTHER)) Q:'SROTHER D OTHER
S X=$P($G(^SRF(SRTN,"RA")),"^",2) I X="C" S SROPER="* "_SROPER
K SROPS,MM,MMM S:$L(SROPER)<34 SROPS(1)=SROPER I $L(SROPER)>33 S SROPER=SROPER_" " F M=1:1 D LOOP Q:MMM=""
S SRSS=$P(SRA(0),"^",4),SRSS=$S(SRSS:$P(^SRO(137.45,SRSS,0),"^"),1:"SPECIALTY NOT ENTERED")
D TECH^SROPRIN
S Y=$P(SRA(0),"^",9) D D^DIQ S SRDT=$P(Y,"@")
S (SRDOC,Y)=$P($G(^SRF(SRTN,.1)),"^",4),C=$P(^DD(130,.14,0),"^",2) D:Y'="" Y^DIQ I $L(Y)>23 S Z=$P(Y,",")_","_$E($P(Y,",",2))_".",Y=Z
S SRDOC=Y
Q
PRINT ;
U IO S SRSS="",(SRTC,SRPAGE)=0 D HDR Q:SRSOUT
F S SRSS=$O(^TMP("SRA",$J,SRSS)) Q:SRSS=""!SRSOUT S SRC=0 D SS S SRTN=0 F S SRTN=$O(^TMP("SRA",$J,SRSS,SRTN)) D:'SRTN SSCT Q:'SRTN!SRSOUT D SET,CASE
Q:SRFLG I $Y+5>IOSL D HDR Q:SRSOUT
W !!,"TOTAL MAJOR CASES FOR ALL SPECIALTIES: ",SRTC
Q
CASE ; print a case
S SRC=SRC+1,SRTC=SRTC+1
I $Y+5>IOSL D HDR Q:SRSOUT W !!,"SURGICAL SPECIALTY: ",SRSS,!
W !,SRTN,?20,SRANM_" "_VA("PID"),?67,STATUS,?107,SRTECH,!,SRDT,?20,SROPS(1),?67,SREXCL W ?107,SRDOC
I $D(SROPS(2)) W !,?20,SROPS(2) I $D(SROPS(3)) W !,?20,SROPS(3) I $D(SROPS(4)) W !,?20,SROPS(4)
N I,SRPROC,SRL S SRL=100 D CPTS^SROAUTL0 W !,?20,"CPT Codes: "
F I=1:1 Q:'$D(SRPROC(I)) W:I=1 ?31,SRPROC(I) W:I'=1 !,?31,SRPROC(I)
W ! F LINE=1:1:132 W "-"
Q
SS ; print surgical specialty
I $Y+5>IOSL D HDR Q:SRSOUT
W !!,"SURGICAL SPECIALTY: ",SRSS,! Q
HDR ; print heading
I $D(ZTQUEUED) D ^SROSTOP I SRHALT S SRSOUT=1 Q
S SRHD="ALL SURGICAL CASES BY SURGICAL SPECIALTY",SRPAGE=SRPAGE+1
W:$Y @IOF W !,?(132-$L(SRHD)\2),SRHD,?120,"PAGE "_SRPAGE,!,?(132-$L(SRINST)\2),SRINST,!,?58,"SURGERY SERVICE",?100,"DATE REVIEWED:"
W !,?(132-$L(SRFRTO)\2),SRFRTO,?100,"REVIEWED BY:"
W !!,"CASE #",?20,"PATIENT",?67,"ASSESSMENT STATUS",?107,"ANESTHESIA TECHNIQUE",!,"OPERATION DATE",?20,"PRINCIPAL OPERATIVE PROCEDURE",?67,"EXCLUSION CRITERIA",?107,"SURGEON",! F L=1:1:132 W "="
Q
OTHER ; other operations
S SRLONG=1 I $L(SROPER)+$L($P(^SRF(SRTN,13,SROTHER,0),"^"))>165 S SRLONG=0,OPER=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)'<44 S SROPS(M)=SROPS(M)_MM_" ",SROPER=MMM
Q
SSCT ; write specialty count
I $Y+5>IOSL D HDR Q:SRSOUT
W !!,"TOTAL ",SRSS,": ",SRC,! F L=1:1:132 W "-"
Q
SROALSSP ;BIR/ADM - ASSESSMENTS BY SPECIALTY (PRINTER) ;01/18/07
+1 ;;3.0; Surgery ;**32,47,50,100,142,153,160**;24 Jun 93;Build 7
START SET SRSOUT=0
KILL ^TMP("SRA",$JOB)
+1 FOR
SET SRSD=$ORDER(^SRF("AC",SRSD))
IF 'SRSD!(SRSD>SRED)
QUIT
SET SRTN=0
FOR
SET SRTN=$ORDER(^SRF("AC",SRSD,SRTN))
IF 'SRTN
QUIT
IF $DATA(^SRF(SRTN,0))
IF $$MANDIV^SROUTL0(SRINSTP,SRTN)
DO UTL
+2 DO PRINT
QUIT
UTL ; write to ^TMP("SRA,$J)
+1 SET SRA(0)=^SRF(SRTN,0)
+2 SET CAN=$PIECE($GET(^SRF(SRTN,30)),"^")
IF CAN
QUIT
+3 SET CAN=$PIECE($GET(^SRF(SRTN,31)),"^",8)
IF CAN'=""
QUIT
+4 SET X=$PIECE($GET(^SRF(SRTN,.2)),"^",12)
IF 'X
QUIT
+5 IF SRFLG
IF $PIECE(^SRF(SRTN,0),"^",4)'=SRASP
QUIT
+6 SET SRSS=$PIECE(^SRF(SRTN,0),"^",4)
SET SRSS=$SELECT(SRSS:$PIECE(^SRO(137.45,SRSS,0),"^"),1:"SPECIALTY NOT ENTERED")
+7 SET TYPE=$PIECE($GET(^SRF(SRTN,"RA")),"^",2)
IF SRSS="SPECIALTY NOT ENTERED"
IF TYPE="C"
SET SRSS="N/A"
+8 SET ^TMP("SRA",$JOB,SRSS,SRTN)=""
+9 QUIT
SET ; set variables
+1 KILL SRCPTT
SET SRCPTT="NOT ENTERED"
+2 SET SRA("RA")=$GET(^SRF(SRTN,"RA"))
SET X=$PIECE(SRA("RA"),"^")
SET STATUS=$SELECT(X="I":"INCOMPLETE",X="C":"COMPLETED",X="T":"TRANSMITTED",1:"EXCLUSION")
+3 SET (SREXCL,Y)=$PIECE(SRA("RA"),"^",7)
SET C=$PIECE(^DD(130,102,0),"^",2)
DO Y^DIQ
SET SREXCL=Y
+4 IF SREXCL=""
IF STATUS="EXCLUSION"
SET STATUS="NO ASSESSMENT"
+5 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
+6 SET X=^SRF(SRTN,"OP")
SET SROPER=$PIECE(X,"^")
+7 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
+8 SET X=$PIECE($GET(^SRF(SRTN,"RA")),"^",2)
IF X="C"
SET SROPER="* "_SROPER
+9 KILL SROPS,MM,MMM
IF $LENGTH(SROPER)<34
SET SROPS(1)=SROPER
IF $LENGTH(SROPER)>33
SET SROPER=SROPER_" "
FOR M=1:1
DO LOOP
IF MMM=""
QUIT
+10 SET SRSS=$PIECE(SRA(0),"^",4)
SET SRSS=$SELECT(SRSS:$PIECE(^SRO(137.45,SRSS,0),"^"),1:"SPECIALTY NOT ENTERED")
+11 DO TECH^SROPRIN
+12 SET Y=$PIECE(SRA(0),"^",9)
DO D^DIQ
SET SRDT=$PIECE(Y,"@")
+13 SET (SRDOC,Y)=$PIECE($GET(^SRF(SRTN,.1)),"^",4)
SET C=$PIECE(^DD(130,.14,0),"^",2)
IF Y'=""
DO Y^DIQ
IF $LENGTH(Y)>23
SET Z=$PIECE(Y,",")_","_$EXTRACT($PIECE(Y,",",2))_"."
SET Y=Z
+14 SET SRDOC=Y
+15 QUIT
PRINT ;
+1 USE IO
SET SRSS=""
SET (SRTC,SRPAGE)=0
DO HDR
IF SRSOUT
QUIT
+2 FOR
SET SRSS=$ORDER(^TMP("SRA",$JOB,SRSS))
IF SRSS=""!SRSOUT
QUIT
SET SRC=0
DO SS
SET SRTN=0
FOR
SET SRTN=$ORDER(^TMP("SRA",$JOB,SRSS,SRTN))
IF 'SRTN
DO SSCT
IF 'SRTN!SRSOUT
QUIT
DO SET
DO CASE
+3 IF SRFLG
QUIT
IF $Y+5>IOSL
DO HDR
IF SRSOUT
QUIT
+4 WRITE !!,"TOTAL MAJOR CASES FOR ALL SPECIALTIES: ",SRTC
+5 QUIT
CASE ; print a case
+1 SET SRC=SRC+1
SET SRTC=SRTC+1
+2 IF $Y+5>IOSL
DO HDR
IF SRSOUT
QUIT
WRITE !!,"SURGICAL SPECIALTY: ",SRSS,!
+3 WRITE !,SRTN,?20,SRANM_" "_VA("PID"),?67,STATUS,?107,SRTECH,!,SRDT,?20,SROPS(1),?67,SREXCL
WRITE ?107,SRDOC
+4 IF $DATA(SROPS(2))
WRITE !,?20,SROPS(2)
IF $DATA(SROPS(3))
WRITE !,?20,SROPS(3)
IF $DATA(SROPS(4))
WRITE !,?20,SROPS(4)
+5 NEW I,SRPROC,SRL
SET SRL=100
DO CPTS^SROAUTL0
WRITE !,?20,"CPT Codes: "
+6 FOR I=1:1
IF '$DATA(SRPROC(I))
QUIT
IF I=1
WRITE ?31,SRPROC(I)
IF I'=1
WRITE !,?31,SRPROC(I)
+7 WRITE !
FOR LINE=1:1:132
WRITE "-"
+8 QUIT
SS ; print surgical specialty
+1 IF $Y+5>IOSL
DO HDR
IF SRSOUT
QUIT
+2 WRITE !!,"SURGICAL SPECIALTY: ",SRSS,!
QUIT
HDR ; print heading
+1 IF $DATA(ZTQUEUED)
DO ^SROSTOP
IF SRHALT
SET SRSOUT=1
QUIT
+2 SET SRHD="ALL SURGICAL CASES BY SURGICAL SPECIALTY"
SET SRPAGE=SRPAGE+1
+3 IF $Y
WRITE @IOF
WRITE !,?(132-$LENGTH(SRHD)\2),SRHD,?120,"PAGE "_SRPAGE,!,?(132-$LENGTH(SRINST)\2),SRINST,!,?58,"SURGERY SERVICE",?100,"DATE REVIEWED:"
+4 WRITE !,?(132-$LENGTH(SRFRTO)\2),SRFRTO,?100,"REVIEWED BY:"
+5 WRITE !!,"CASE #",?20,"PATIENT",?67,"ASSESSMENT STATUS",?107,"ANESTHESIA TECHNIQUE",!,"OPERATION DATE",?20,"PRINCIPAL OPERATIVE PROCEDURE",?67,"EXCLUSION CRITERIA",?107,"SURGEON",!
FOR L=1:1:132
WRITE "="
+6 QUIT
OTHER ; other operations
+1 SET SRLONG=1
IF $LENGTH(SROPER)+$LENGTH($PIECE(^SRF(SRTN,13,SROTHER,0),"^"))>165
SET SRLONG=0
SET OPER=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)'<44
QUIT
SET SROPS(M)=SROPS(M)_MM_" "
SET SROPER=MMM
+2 QUIT
SSCT ; write specialty count
+1 IF $Y+5>IOSL
DO HDR
IF SRSOUT
QUIT
+2 WRITE !!,"TOTAL ",SRSS,": ",SRC,!
FOR L=1:1:132
WRITE "-"
+3 QUIT