SRTPNEW ;BIR/SJA - CREATE NEW RISK ASSESSMENT ;02/14/08
;;3.0; Surgery ;**167**;24 Jun 93;Build 27
D NEW G:SRSOUT END I SRVA="N" D ADD Q
START W @IOF,!,?1,VADM(1)_" "_VA("PID")
W !!! S (SRDT,CNT)=0 F I=0:0 S SRDT=$O(^SRF("ADT",DFN,SRDT)) Q:'SRDT!(SRSOUT) S SRASS=0 F I=0:0 S SRASS=$O(^SRF("ADT",DFN,SRDT,SRASS)) Q:'SRASS!($D(SRTN))!(SRSOUT) D LIST I $D(SRTN) G ASK
I 'CNT W "No operations exist for this patient. Assessment cannot be entered.",!!,"Press RETURN to continue... " R X:DTIME G END
OPT W !!,"Select Operation: " R X:DTIME I '$T!("^"[X) S SRSOUT=1 G END
I '$D(SRCASE(X)) W !!,"Enter the number of the desired operation" W $S('$D(SRNEWOP):".",1:", or '"_CNT_"' to enter a new case.") G OPT
S SRTN=+SRCASE(X)
ASK W !!,"Sure you want "_$S($D(SRCHG):"to assign this Surgical case to the Transplant Assessment? YES//",1:"to create a Transplant Assessment for this surgical case? YES//") R SRYN:DTIME I '$T!(SRYN["^") K SRTN S SRSOUT=1 Q
S SRYN=$E(SRYN) I "YyNn"'[SRYN W !!,"Enter 'YES' to create an assessment for this surgical case, or 'NO' to quit",!,"this option." G ASK
I "Yy"'[SRYN K SRTN S SRSOUT=1 Q
S:SRVA="V" SRTPDT=$P($P(^SRF(SRTN,0),"^",9),".")
I '$D(SRCHG) D VACO Q:SRSOUT D ADD
Q
LIST ; list assessments
I $P($G(^SRF(SRASS,"NON")),"^")="Y" Q
S SRSCAN=1 I $D(^SRF(SRASS,.2)),$P(^(.2),"^",12)'="" K SRSCAN
I $D(SRSCAN),$P($G(^SRF(SRASS,30)),"^") Q
I $D(SRSCAN),$P($G(^SRF(SRASS,31)),"^",8) Q
I $D(^SRF(SRASS,37)),$P(^(37),"^") Q
I '$P($G(^SRF(SRASS,.2)),"^",12) Q
I $Y+5>IOSL S SRBACK=0 D SEL Q:$D(SRTN)!(SRSOUT) I SRBACK S CNT=0,SRASS=SRCASE(1)-1,SRDT=$P(SRCASE(1),"^",2) W @IOF,!,?1,VADM(1)_" "_VA("PID"),! Q
S CNT=CNT+1,SRSDATE=$P(^SRF(SRASS,0),"^",9)
DISP S SROPER=$P(^SRF(SRASS,"OP"),"^") I $O(^SRF(SRASS,13,0)) S SROTHER=0 F I=0:0 S SROTHER=$O(^SRF(SRASS,13,SROTHER)) Q:'SROTHER D OTHER
S SROP=SRASS D ^SROP1
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=""
I '$D(SRTN) W CNT_". "
CASE W $E(SRSDATE,4,5)_"-"_$E(SRSDATE,6,7)_"-"_$E(SRSDATE,2,3),?14,SROPS(1) I $D(SROPS(2)) W !,?14,SROPS(2) I $D(SROPS(3)) W !,?14,SROPS(3)
I $D(SROPS(4)) W !,?14,SROPS(4)
I $D(SRTN) Q
W !! S SRCASE(CNT)=SRASS_"^"_SRDT
Q
OTHER ; other operations
S SRLONG=1 I $L(SROPER)+$L($P(^SRF(SRASS,13,SROTHER,0),"^"))>235 S SRLONG=0,SROTHER=999,SROPERS=" ..."
I SRLONG S SROPERS=$P(^SRF(SRASS,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
SEL ; select case
W !!!,"Select Operation, or enter <RET> to continue listing Procedures: " R X:DTIME I '$T!(X["^") S SRSOUT=1 Q
I X="" W @IOF,!,?1,VADM(1)_" "_VA("PID"),!! Q
I '$D(SRCASE(X)) W !!,"Please enter the number corresponding to the Surgical Case you want to edit.",!,"If the case desired does not appear, enter <RET> to continue listing",!,"additional cases."
I '$D(SRCASE(X)) W !!,"Press <RET> to continue " R X:DTIME S:'$T SRSOUT=1 S SRBACK=1 Q
S SRTN=+SRCASE(X)
Q
END D ^SRSKILL W @IOF
Q
NEW K SRL,SRCNT
S SRCNT=0 I '$P($G(^SRO(133,SRSITE,0)),"^",21) S YY=$G(^SRO(133,SRSITE,8)) D
.F I=1:1:$L(YY,"^") I $P(YY,"^",I)="Y" S SRCNT=SRCNT+1 D
..S SRL(SRCNT)=$S(I=1:"Kidney;1",I=2:"Liver;2",I=3:"Lung;3",I=4:"Heart;4",1:"")
I SRCNT=1 S Y=1 W !!,"Creating a New "_$P(SRL(1),";")_" Transplant Assessment..." G T1
W ! S II=0 F S II=$O(SRL(II)) Q:'II W !,II,". ",$P(SRL(II),";")
W ! K DIR S DIR(0)="N^1:"_SRCNT,DIR("A")="Select Type of Transplant" D ^DIR K DIR I $D(DTOUT)!$D(DUOUT) K SRTN,SRTPP S SRSOUT=1 Q
T1 S XX=$P(SRL(Y),";",2),SRTTYPE=$S(XX=1:"K",XX=2:"LI",XX=3:"LU",XX=4:"H",1:"")
; VA or Non-VA Indicator
VA K DIR W ! S DIR(0)="139.5,185",DIR("A")="Is this a VA or a Non-VA Transplant (V or N)" D ^DIR K DIR I $D(DTOUT)!(X="^") K SRTN,SRTPP S SRSOUT=1 Q
S SRVA=Y
DATE ; Date of Transplant
I SRVA'="N" Q
K DIR W ! S DIR(0)="139.5,1",DIR("A")="Date of Transplant" D ^DIR K DIR I $D(DTOUT)!$D(DUOUT) S SRSOUT=1 Q
S SRTPDT=Y
VACO ; VACO ID
K SRVACO,DIR W ! S DIR(0)="139.5,3",DIR("A")="VACO ID" D ^DIR K DIR I $D(DTOUT)!(X="^") S SRSOUT=1 Q
S SRVACO=Y
Q
ADD K DA,DIC,DD,DO S X=DFN,DIC="^SRT(",DIC(0)="L",DLAYGO=139.5 D FILE^DICN K DD,DO,DIC,DLAYGO S SRTPP=+Y
K DIE,DR,DA S DA=SRTPP,DIE=139.5,DR="1////"_SRTPDT_$S(SRVA="V":";2////"_SRTN,1:"")_";3////"_SRVACO_";182////"_SRTTYPE_";Q;181////I;185////"_SRVA
; if kidney transplant, defualt Pancreas fields to "N/NS"
I SRTTYPE="K" N SRPAN S SRPAN="134;135;136;137;138;139;140;141;142" F II=1:1:$L(SRPAN,";") S DR=DR_";"_$P(SRPAN,";",II)_"////"_$S($P(SRPAN,";",II)=134:"N",1:"NS")
D ^DIE K DR,DIE,DA
S ^SRT(SRTPP,8)=$S(SRVA="N":SRSITE("DIV"),SRVA="V":$P($G(^SRF(SRTN,8)),"^"),1:"")
Q
CHK ; VACO ID check
Q:'$O(^SRT("AE",X,0)) N SRDFN,SRDFN1,SRNODE0,SRC
I $D(DA) S SRNODE0=$G(^SRT(DA,0))
S SRDFN1=$S($D(DFN):DFN,1:$P(SRNODE0,"^"))
S SRDFN=0 F S SRDFN=$O(^SRT("AE",X,SRDFN)) Q:'SRDFN I SRDFN'=SRDFN1 D K X Q
.S SRC(1)="This VACO ID has already been assigned to another patient.",SRC(1,"F")="!!?5"
.S SRC(2)="VACO ID is a unique identifier provided centrally for each patient",SRC(2,"F")="!?5"
.S SRC(3)="undergoing a transplant.",SRC(3,"F")="!?5"
.D EN^DDIOL(.SRC)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSRTPNEW 5386 printed Sep 15, 2024@22:12:39 Page 2
SRTPNEW ;BIR/SJA - CREATE NEW RISK ASSESSMENT ;02/14/08
+1 ;;3.0; Surgery ;**167**;24 Jun 93;Build 27
+2 DO NEW
if SRSOUT
GOTO END
IF SRVA="N"
DO ADD
QUIT
START WRITE @IOF,!,?1,VADM(1)_" "_VA("PID")
+1 WRITE !!!
SET (SRDT,CNT)=0
FOR I=0:0
SET SRDT=$ORDER(^SRF("ADT",DFN,SRDT))
if 'SRDT!(SRSOUT)
QUIT
SET SRASS=0
FOR I=0:0
SET SRASS=$ORDER(^SRF("ADT",DFN,SRDT,SRASS))
if 'SRASS!($DATA(SRTN))!(SRSOUT)
QUIT
DO LIST
IF $DATA(SRTN)
GOTO ASK
+2 IF 'CNT
WRITE "No operations exist for this patient. Assessment cannot be entered.",!!,"Press RETURN to continue... "
READ X:DTIME
GOTO END
OPT WRITE !!,"Select Operation: "
READ X:DTIME
IF '$TEST!("^"[X)
SET SRSOUT=1
GOTO END
+1 IF '$DATA(SRCASE(X))
WRITE !!,"Enter the number of the desired operation"
WRITE $SELECT('$DATA(SRNEWOP):".",1:", or '"_CNT_"' to enter a new case.")
GOTO OPT
+2 SET SRTN=+SRCASE(X)
ASK WRITE !!,"Sure you want "_$SELECT($DATA(SRCHG):"to assign this Surgical case to the Transplant Assessment? YES//",1:"to create a Transplant Assessment for this surgical case? YES//")
READ SRYN:DTIME
IF '$TEST!(SRYN["^")
KILL SRTN
SET SRSOUT=1
QUIT
+1 SET SRYN=$EXTRACT(SRYN)
IF "YyNn"'[SRYN
WRITE !!,"Enter 'YES' to create an assessment for this surgical case, or 'NO' to quit",!,"this option."
GOTO ASK
+2 IF "Yy"'[SRYN
KILL SRTN
SET SRSOUT=1
QUIT
+3 if SRVA="V"
SET SRTPDT=$PIECE($PIECE(^SRF(SRTN,0),"^",9),".")
+4 IF '$DATA(SRCHG)
DO VACO
if SRSOUT
QUIT
DO ADD
+5 QUIT
LIST ; list assessments
+1 IF $PIECE($GET(^SRF(SRASS,"NON")),"^")="Y"
QUIT
+2 SET SRSCAN=1
IF $DATA(^SRF(SRASS,.2))
IF $PIECE(^(.2),"^",12)'=""
KILL SRSCAN
+3 IF $DATA(SRSCAN)
IF $PIECE($GET(^SRF(SRASS,30)),"^")
QUIT
+4 IF $DATA(SRSCAN)
IF $PIECE($GET(^SRF(SRASS,31)),"^",8)
QUIT
+5 IF $DATA(^SRF(SRASS,37))
IF $PIECE(^(37),"^")
QUIT
+6 IF '$PIECE($GET(^SRF(SRASS,.2)),"^",12)
QUIT
+7 IF $Y+5>IOSL
SET SRBACK=0
DO SEL
if $DATA(SRTN)!(SRSOUT)
QUIT
IF SRBACK
SET CNT=0
SET SRASS=SRCASE(1)-1
SET SRDT=$PIECE(SRCASE(1),"^",2)
WRITE @IOF,!,?1,VADM(1)_" "_VA("PID"),!
QUIT
+8 SET CNT=CNT+1
SET SRSDATE=$PIECE(^SRF(SRASS,0),"^",9)
DISP SET SROPER=$PIECE(^SRF(SRASS,"OP"),"^")
IF $ORDER(^SRF(SRASS,13,0))
SET SROTHER=0
FOR I=0:0
SET SROTHER=$ORDER(^SRF(SRASS,13,SROTHER))
if 'SROTHER
QUIT
DO OTHER
+1 SET SROP=SRASS
DO ^SROP1
+2 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 IF '$DATA(SRTN)
WRITE CNT_". "
CASE WRITE $EXTRACT(SRSDATE,4,5)_"-"_$EXTRACT(SRSDATE,6,7)_"-"_$EXTRACT(SRSDATE,2,3),?14,SROPS(1)
IF $DATA(SROPS(2))
WRITE !,?14,SROPS(2)
IF $DATA(SROPS(3))
WRITE !,?14,SROPS(3)
+1 IF $DATA(SROPS(4))
WRITE !,?14,SROPS(4)
+2 IF $DATA(SRTN)
QUIT
+3 WRITE !!
SET SRCASE(CNT)=SRASS_"^"_SRDT
+4 QUIT
OTHER ; other operations
+1 SET SRLONG=1
IF $LENGTH(SROPER)+$LENGTH($PIECE(^SRF(SRASS,13,SROTHER,0),"^"))>235
SET SRLONG=0
SET SROTHER=999
SET SROPERS=" ..."
+2 IF SRLONG
SET SROPERS=$PIECE(^SRF(SRASS,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
SEL ; select case
+1 WRITE !!!,"Select Operation, or enter <RET> to continue listing Procedures: "
READ X:DTIME
IF '$TEST!(X["^")
SET SRSOUT=1
QUIT
+2 IF X=""
WRITE @IOF,!,?1,VADM(1)_" "_VA("PID"),!!
QUIT
+3 IF '$DATA(SRCASE(X))
WRITE !!,"Please enter the number corresponding to the Surgical Case you want to edit.",!,"If the case desired does not appear, enter <RET> to continue listing",!,"additional cases."
+4 IF '$DATA(SRCASE(X))
WRITE !!,"Press <RET> to continue "
READ X:DTIME
if '$TEST
SET SRSOUT=1
SET SRBACK=1
QUIT
+5 SET SRTN=+SRCASE(X)
+6 QUIT
END DO ^SRSKILL
WRITE @IOF
+1 QUIT
NEW KILL SRL,SRCNT
+1 SET SRCNT=0
IF '$PIECE($GET(^SRO(133,SRSITE,0)),"^",21)
SET YY=$GET(^SRO(133,SRSITE,8))
Begin DoDot:1
+2 FOR I=1:1:$LENGTH(YY,"^")
IF $PIECE(YY,"^",I)="Y"
SET SRCNT=SRCNT+1
Begin DoDot:2
+3 SET SRL(SRCNT)=$SELECT(I=1:"Kidney;1",I=2:"Liver;2",I=3:"Lung;3",I=4:"Heart;4",1:"")
End DoDot:2
End DoDot:1
+4 IF SRCNT=1
SET Y=1
WRITE !!,"Creating a New "_$PIECE(SRL(1),";")_" Transplant Assessment..."
GOTO T1
+5 WRITE !
SET II=0
FOR
SET II=$ORDER(SRL(II))
if 'II
QUIT
WRITE !,II,". ",$PIECE(SRL(II),";")
+6 WRITE !
KILL DIR
SET DIR(0)="N^1:"_SRCNT
SET DIR("A")="Select Type of Transplant"
DO ^DIR
KILL DIR
IF $DATA(DTOUT)!$DATA(DUOUT)
KILL SRTN,SRTPP
SET SRSOUT=1
QUIT
T1 SET XX=$PIECE(SRL(Y),";",2)
SET SRTTYPE=$SELECT(XX=1:"K",XX=2:"LI",XX=3:"LU",XX=4:"H",1:"")
+1 ; VA or Non-VA Indicator
VA KILL DIR
WRITE !
SET DIR(0)="139.5,185"
SET DIR("A")="Is this a VA or a Non-VA Transplant (V or N)"
DO ^DIR
KILL DIR
IF $DATA(DTOUT)!(X="^")
KILL SRTN,SRTPP
SET SRSOUT=1
QUIT
+1 SET SRVA=Y
DATE ; Date of Transplant
+1 IF SRVA'="N"
QUIT
+2 KILL DIR
WRITE !
SET DIR(0)="139.5,1"
SET DIR("A")="Date of Transplant"
DO ^DIR
KILL DIR
IF $DATA(DTOUT)!$DATA(DUOUT)
SET SRSOUT=1
QUIT
+3 SET SRTPDT=Y
VACO ; VACO ID
+1 KILL SRVACO,DIR
WRITE !
SET DIR(0)="139.5,3"
SET DIR("A")="VACO ID"
DO ^DIR
KILL DIR
IF $DATA(DTOUT)!(X="^")
SET SRSOUT=1
QUIT
+2 SET SRVACO=Y
+3 QUIT
ADD KILL DA,DIC,DD,DO
SET X=DFN
SET DIC="^SRT("
SET DIC(0)="L"
SET DLAYGO=139.5
DO FILE^DICN
KILL DD,DO,DIC,DLAYGO
SET SRTPP=+Y
+1 KILL DIE,DR,DA
SET DA=SRTPP
SET DIE=139.5
SET DR="1////"_SRTPDT_$SELECT(SRVA="V":";2////"_SRTN,1:"")_";3////"_SRVACO_";182////"_SRTTYPE_";Q;181////I;185////"_SRVA
+2 ; if kidney transplant, defualt Pancreas fields to "N/NS"
+3 IF SRTTYPE="K"
NEW SRPAN
SET SRPAN="134;135;136;137;138;139;140;141;142"
FOR II=1:1:$LENGTH(SRPAN,";")
SET DR=DR_";"_$PIECE(SRPAN,";",II)_"////"_$SELECT($PIECE(SRPAN,";",II)=134:"N",1:"NS")
+4 DO ^DIE
KILL DR,DIE,DA
+5 SET ^SRT(SRTPP,8)=$SELECT(SRVA="N":SRSITE("DIV"),SRVA="V":$PIECE($GET(^SRF(SRTN,8)),"^"),1:"")
+6 QUIT
CHK ; VACO ID check
+1 if '$ORDER(^SRT("AE",X,0))
QUIT
NEW SRDFN,SRDFN1,SRNODE0,SRC
+2 IF $DATA(DA)
SET SRNODE0=$GET(^SRT(DA,0))
+3 SET SRDFN1=$SELECT($DATA(DFN):DFN,1:$PIECE(SRNODE0,"^"))
+4 SET SRDFN=0
FOR
SET SRDFN=$ORDER(^SRT("AE",X,SRDFN))
if 'SRDFN
QUIT
IF SRDFN'=SRDFN1
Begin DoDot:1
+5 SET SRC(1)="This VACO ID has already been assigned to another patient."
SET SRC(1,"F")="!!?5"
+6 SET SRC(2)="VACO ID is a unique identifier provided centrally for each patient"
SET SRC(2,"F")="!?5"
+7 SET SRC(3)="undergoing a transplant."
SET SRC(3,"F")="!?5"
+8 DO EN^DDIOL(.SRC)
End DoDot:1
KILL X
QUIT
+9 QUIT