LROSPLG ;B'HAM ISC/ADM - MOVE SP DATA FROM SURGICAL RECORD ;4/12/94 08:54
;;3.0; Surgery ;**28**;24 Jun 93
Q:$P(^LR(LRDFN,0),"^",2)'=2 D END
S:'$D(DFN) DFN=$P(^LR(LRDFN,0),"^",3) D DEM^VADPT S PNM=VADM(1),SSN=VA("PID")
S X1=DT,X2=-7 D C^%DTC S SREND=9999999.999999-X D NOW^%DTC S SRDT=9999999.999999-%
W !!,"Checking surgical record for this patient...",!
S CNT=0 F S SRDT=$O(^SRF("ADT",DFN,SRDT)) Q:'SRDT!(SRDT>SREND) S SROP=0 F S SROP=$O(^SRF("ADT",DFN,SRDT,SROP)) Q:'SROP!$D(SRTN) D LIST
I CNT=0 W !,"No operations on record in the past 7 days for this patient.",! D END Q
I CNT=1 K DIR W ! S DIR("A",1)="Only one operation on record in the past 7 days.",DIR("A")="Is this the correct operation for the specimen(s) (Y/N)",DIR(0)="Y" D ^DIR I $D(DTOUT)!$D(DUOUT)!'Y D NOOP Q
I CNT=1,Y=1 S SRTN=+SRCASE(1) D DOC Q
OPT K DIR S DIR("?",1)="Enter the number of the operation associated with the specimen(s)",DIR("?")="or press RETURN to bypass operation selection."
W ! S DIR("A")="Select operation associated with the specimen(s)",DIR(0)="NO^1:"_CNT
D ^DIR I $D(DTOUT)!$D(DUOUT)
I +Y S SRTN=+SRCASE(+Y),CNT=+Y
NOOP I '$D(SRTN) W !!,"No operation selected.",! D END Q
DOC S SRDOC=$S($P($G(^SRF(SRTN,"NON")),"^")="Y":$P(^("NON"),"^",6),1:$P($G(^SRF(SRTN,.1)),"^",4)) Q
DISP I $D(SRTN) S SROP=SRTN,SRSDATE=$P(^SRF(SRTN,0),"^",9) D ^SROSPLG2
END K CNT,DIR,DR,I,J,K,LOOP,M,MM,MMM,SR,SRABORT,SRCASE,SRD,SRDOC,SRDT,SREND,SRJ,SRK,SRLONG,SRN,SROP,SROPER,SROPERS,SROPS,SROTHER,SRSCAN,SRSDATE,SRSTAT,SRSTATUS,SRTN,VA,VADM,VAERR,X,%
Q
LIST ; list cases
S SRSCAN=1 I $P($G(^SRF(SROP,.2)),"^",10)!$P($G(^SRF(SROP,.2)),"^",12)!($P($G(^SRF(SROP,"NON")),"^")="Y") K SRSCAN
I $D(SRSCAN),$D(^SRF(SROP,30)),$P(^(30),"^") Q
I $D(SRSCAN),$D(^SRF(SROP,31)),$P(^(31),"^",8) Q
I $D(^SRF(SROP,37)),$P(^(37),"^") Q
S CNT=CNT+1,SRSDATE=$P(^SRF(SROP,0),"^",9) W !,CNT_". "
CASE W $E(SRSDATE,4,5)_"-"_$E(SRSDATE,6,7)_"-"_$E(SRSDATE,2,3)
S SROPER=$P(^SRF(SROP,"OP"),"^") I $O(^SRF(SROP,13,0)) S SROTHER=0 F I=0:0 S SROTHER=$O(^SRF(SROP,13,SROTHER)) Q:'SROTHER D OTHER
S SROPER="Case #"_SROP_" >> "_SROPER D ^SROSPLG1 K SROPS,MM,MMM S:$L(SROPER)<65 SROPS(1)=SROPER I $L(SROPER)>64 S SROPER=SROPER_" " F M=1:1 D LOOP Q:MMM=""
W ?14,SROPS(1) I $D(SROPS(2)) W !,?14,SROPS(2) I $D(SROPS(3)) W !,?14,SROPS(3) W:$D(SROPS(4)) !,?14,SROPS(4)
S SRCASE(CNT)=SROP_"^"_SRDT
Q
OTHER ; other operations
S SRLONG=1 I $L(SROPER)+$L($P(^SRF(SROP,13,SROTHER,0),"^"))>235 S SRLONG=0,SROTHER=999,SROPERS=" ..."
I SRLONG S SROPERS=$P(^SRF(SROP,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)'<65 S SROPS(M)=SROPS(M)_MM_" ",SROPER=MMM
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLROSPLG 2816 printed Dec 13, 2024@02:19:02 Page 2
LROSPLG ;B'HAM ISC/ADM - MOVE SP DATA FROM SURGICAL RECORD ;4/12/94 08:54
+1 ;;3.0; Surgery ;**28**;24 Jun 93
+2 if $PIECE(^LR(LRDFN,0),"^",2)'=2
QUIT
DO END
+3 if '$DATA(DFN)
SET DFN=$PIECE(^LR(LRDFN,0),"^",3)
DO DEM^VADPT
SET PNM=VADM(1)
SET SSN=VA("PID")
+4 SET X1=DT
SET X2=-7
DO C^%DTC
SET SREND=9999999.999999-X
DO NOW^%DTC
SET SRDT=9999999.999999-%
+5 WRITE !!,"Checking surgical record for this patient...",!
+6 SET CNT=0
FOR
SET SRDT=$ORDER(^SRF("ADT",DFN,SRDT))
if 'SRDT!(SRDT>SREND)
QUIT
SET SROP=0
FOR
SET SROP=$ORDER(^SRF("ADT",DFN,SRDT,SROP))
if 'SROP!$DATA(SRTN)
QUIT
DO LIST
+7 IF CNT=0
WRITE !,"No operations on record in the past 7 days for this patient.",!
DO END
QUIT
+8 IF CNT=1
KILL DIR
WRITE !
SET DIR("A",1)="Only one operation on record in the past 7 days."
SET DIR("A")="Is this the correct operation for the specimen(s) (Y/N)"
SET DIR(0)="Y"
DO ^DIR
IF $DATA(DTOUT)!$DATA(DUOUT)!'Y
DO NOOP
QUIT
+9 IF CNT=1
IF Y=1
SET SRTN=+SRCASE(1)
DO DOC
QUIT
OPT KILL DIR
SET DIR("?",1)="Enter the number of the operation associated with the specimen(s)"
SET DIR("?")="or press RETURN to bypass operation selection."
+1 WRITE !
SET DIR("A")="Select operation associated with the specimen(s)"
SET DIR(0)="NO^1:"_CNT
+2 DO ^DIR
IF $DATA(DTOUT)!$DATA(DUOUT)
+3 IF +Y
SET SRTN=+SRCASE(+Y)
SET CNT=+Y
NOOP IF '$DATA(SRTN)
WRITE !!,"No operation selected.",!
DO END
QUIT
DOC SET SRDOC=$SELECT($PIECE($GET(^SRF(SRTN,"NON")),"^")="Y":$PIECE(^("NON"),"^",6),1:$PIECE($GET(^SRF(SRTN,.1)),"^",4))
QUIT
DISP IF $DATA(SRTN)
SET SROP=SRTN
SET SRSDATE=$PIECE(^SRF(SRTN,0),"^",9)
DO ^SROSPLG2
END KILL CNT,DIR,DR,I,J,K,LOOP,M,MM,MMM,SR,SRABORT,SRCASE,SRD,SRDOC,SRDT,SREND,SRJ,SRK,SRLONG,SRN,SROP,SROPER,SROPERS,SROPS,SROTHER,SRSCAN,SRSDATE,SRSTAT,SRSTATUS,SRTN,VA,VADM,VAERR,X,%
+1 QUIT
LIST ; list cases
+1 SET SRSCAN=1
IF $PIECE($GET(^SRF(SROP,.2)),"^",10)!$PIECE($GET(^SRF(SROP,.2)),"^",12)!($PIECE($GET(^SRF(SROP,"NON")),"^")="Y")
KILL SRSCAN
+2 IF $DATA(SRSCAN)
IF $DATA(^SRF(SROP,30))
IF $PIECE(^(30),"^")
QUIT
+3 IF $DATA(SRSCAN)
IF $DATA(^SRF(SROP,31))
IF $PIECE(^(31),"^",8)
QUIT
+4 IF $DATA(^SRF(SROP,37))
IF $PIECE(^(37),"^")
QUIT
+5 SET CNT=CNT+1
SET SRSDATE=$PIECE(^SRF(SROP,0),"^",9)
WRITE !,CNT_". "
CASE WRITE $EXTRACT(SRSDATE,4,5)_"-"_$EXTRACT(SRSDATE,6,7)_"-"_$EXTRACT(SRSDATE,2,3)
+1 SET SROPER=$PIECE(^SRF(SROP,"OP"),"^")
IF $ORDER(^SRF(SROP,13,0))
SET SROTHER=0
FOR I=0:0
SET SROTHER=$ORDER(^SRF(SROP,13,SROTHER))
if 'SROTHER
QUIT
DO OTHER
+2 SET SROPER="Case #"_SROP_" >> "_SROPER
DO ^SROSPLG1
KILL SROPS,MM,MMM
if $LENGTH(SROPER)<65
SET SROPS(1)=SROPER
IF $LENGTH(SROPER)>64
SET SROPER=SROPER_" "
FOR M=1:1
DO LOOP
if MMM=""
QUIT
+3 WRITE ?14,SROPS(1)
IF $DATA(SROPS(2))
WRITE !,?14,SROPS(2)
IF $DATA(SROPS(3))
WRITE !,?14,SROPS(3)
if $DATA(SROPS(4))
WRITE !,?14,SROPS(4)
+4 SET SRCASE(CNT)=SROP_"^"_SRDT
+5 QUIT
OTHER ; other operations
+1 SET SRLONG=1
IF $LENGTH(SROPER)+$LENGTH($PIECE(^SRF(SROP,13,SROTHER,0),"^"))>235
SET SRLONG=0
SET SROTHER=999
SET SROPERS=" ..."
+2 IF SRLONG
SET SROPERS=$PIECE(^SRF(SROP,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)'<65
QUIT
SET SROPS(M)=SROPS(M)_MM_" "
SET SROPER=MMM
+2 QUIT