SDVSIT0 ;MJK/ALB,ESW,SCK - OE Processing ; 11/21/02 11:00am
;;5.3;Scheduling;**27,99,132,257,430**;AUG 13, 1993
;
ADD(SDT,SDVSIT) ; -- add/find outpatient encounter
; input SDT = visit date internal format
; SDVSIT = <see bottom of routine>
;
; returned = ien of 409.67
; *** search code to be written ***
; -- set up vars
S SDVSIT("VST")=""
; -- add a visit file entry
D VISIT(SDT,.SDVSIT)
; -- add opt encounter
Q $$NEW(SDT,.SDVSIT)
;
NEW(SDT,SDVSIT) ; -- create new outpatient encounter record
; input SDT = visit date internal format
; SDVSIT = <see bottom of routine>
;
; returned = ien of 409.67
;
N SDOE,X,DA,DR,DIE,DQ,DE,I
; -- creation hard set for performance
S I=$P(^SCE(0),U,3)
LOCK S I=I+1 L +^SCE(I):1 I '$T!$D(^SCE(I)) L -^SCE(I) G LOCK
S ^SCE(I,0)=SDT,^SCE("B",SDT,I)="",^SCE(0)=$P(^SCE(0),"^",1,2)_"^"_I_"^"_($P(^SCE(0),"^",4)+1),^DISV($S($D(DUZ)'[0:DUZ,1:0),"^SCE(")=I,Y=I
;K DD,DO S SDOE=0,X=SDT,DIC="^SCE(",DIC(0)="L" D FILE^DICN G NEWQ:'Y
S:'$G(SDVSIT("ELG")) SDVSIT("ELG")=$P($G(^DPT(SDVSIT("DFN"),.36)),U)
S SDVSIT("STA")=$$STATUS(+SDVSIT("DFN"),SDT,+$G(SDVSIT("LOC")),SDVSIT("ORG"),"KILL")
S (SDOE,DA)=+Y,DIE="^SCE(",DR="[SD ENCOUNTER ENTRY]" D ^DIE
D:$$REQ^SDM1A(SDT)'="CO" EN^SDCOM(SDOE,0,99999)
L -^SCE(SDOE)
NEWQ Q SDOE
;
VISIT(SDT,SDVSIT) ; -- add visit file entry
N VSIT,DFN,DIE,DIC,DR,DA,X,VSITPKG
; -- is visit tracking loaded
S X="VSITKIL" X ^%ZOSF("TEST") I '$T G VISITQ
; -- set up vars
;S VSIT(0)="ENMD0",VSIT=SDT,DFN=SDVSIT("DFN"),VSITPKG="SD"
S VSIT(0)="F",VSIT=SDT,DFN=SDVSIT("DFN"),VSITPKG="SD"
S VSIT("CLN")=$G(SDVSIT("CLN")),VSIT("SVC")=$S($G(SDVSIT("SVC"))]"":SDVSIT("SVC"),$$INP^SDAM2(DFN,SDT)="I":"I",1:"A")
;S VSIT("INS")=$P($G(^DG(40.8,+$G(SDVSIT("DIV")),0)),U,7)
S VSIT("ELG")=$S($G(SDVSIT("ELG")):SDVSIT("ELG"),1:+$G(^DPT(DFN,.36)))
I $G(SDVSIT("LOC")) S VSIT("LOC")=SDVSIT("LOC")
I $G(SDVSIT("PAR")) S X=$G(^SCE(SDVSIT("PAR"),0)) I X]"" S VSIT=+X I $P(X,U,5) S VSIT("LNK")=$P(X,U,5)
S VSIT("ACT")=$$GETARN^SDPFSS2(SDT,DFN,$G(SDVSIT("LOC")))
I $G(VSIT("LNK")) D ;PX/96 - accept passed INSTITUTION
.N DR,DIC,DA,DIQ,INST,DIC1
.S DR=".06",DIC=9000010,DIC1=DIC,DA=VSIT("LNK"),DIQ="INST",DIQ(0)="I" D EN^DIQ1
.S VSIT("INS")=+$G(INST(DIC1,DA,DR,"I"))
.I VSIT("INS")'>0 S VSIT("INS")=$P($G(^DG(40.8,+$G(SDVSIT("DIV")),0)),U,7)
.Q
;
I '$G(SDVSIT("PAR")) D
. S VSIT("PRI")="P"
E D
. I SDVSIT("ORG")=4 D
.. S VSIT("PRI")="C",VSIT("SVC")=$S($$INP^SDAM2(DFN,SDT)="I":"D",1:"X")
. E D
.. S VSIT("PRI")="S"
;
; -- changes for database conversion to pass in source and service
I $D(SCCVT) D
. I $G(SCCVT("SOR"))'="" S VSIT("SOR")=$$SOURCE^PXAPI(SCCVT("SOR"))
. I $G(SCCVT("SVC"))'="" S VSIT("SVC")=SCCVT("SVC")
. I $G(SCCVT("LOC"))'="" S VSIT("LOC")=SCCVT("LOC")
;
; -- do checks
I 'VSIT,'DFN,'VSIT("ELG")!('VSIT("INS"))!('VSIT("CLN")) G VISITQ
;
; -- add/find visit
;-- change call if orinating process is a disposition.
I SDVSIT("ORG")=3 D DISPVSIT^PXAPI
I SDVSIT("ORG")'=3 D ^VSIT
IF +$G(VSIT("IEN"))>0 S SDVSIT("VST")=+VSIT("IEN")
VISITQ Q
;
STATUS(DFN,SDT,SDCL,SDORG,SDACT) ; -- 409.68;.07 x-ref
N Y S Y=0
I $$INP^SDAM2(DFN,SDT)="I" S Y=8
I 'Y,$P($G(^SC(+SDCL,0)),U,17)="Y" S Y=12
I 'Y S Y=$S(SDACT="SET":2,$$REQ^SDM1A(SDT)="CO":14,1:2)
Q Y
;
;
; Additional input/output variable documentation
;
; SDVSIT("LOC") = file # 44 ien (location)
; ("ELG") = file # 8 ien (eligibility)
; ("CLN") = file # 40.7 ien (clinic stop code)
; ("DIV") = file # 40.8 ien (med ctr div)
; ("DFN") = file # 2 ien (patient)
; ("STA") = file #409.63 ien (appt status)
; ("ORG") = orginating process
; 1 - appt
; 2 - add/edit
; 3 - disposition
; ("TYP") = file #409.1 ien (appt type)
; ("VST") = file #9000010 ien (visit)
; ("LNK") = file #9000010 ien (parent visit)
; ("REF") = extended reference
; appt - ^SC(<clinic>,"S",<date/time>,1,<ext ref>,0)
; disp - ^DPT(<dfn>,"DIS",<ext ref>,0)
; ("PAR") = file #409.68 ien (outpatient encounter)
; - parent encounter ien
; SDVIEN = passed in Visit file ien
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDVSIT0 4437 printed Oct 16, 2024@19:02:26 Page 2
SDVSIT0 ;MJK/ALB,ESW,SCK - OE Processing ; 11/21/02 11:00am
+1 ;;5.3;Scheduling;**27,99,132,257,430**;AUG 13, 1993
+2 ;
ADD(SDT,SDVSIT) ; -- add/find outpatient encounter
+1 ; input SDT = visit date internal format
+2 ; SDVSIT = <see bottom of routine>
+3 ;
+4 ; returned = ien of 409.67
+5 ; *** search code to be written ***
+6 ; -- set up vars
+7 SET SDVSIT("VST")=""
+8 ; -- add a visit file entry
+9 DO VISIT(SDT,.SDVSIT)
+10 ; -- add opt encounter
+11 QUIT $$NEW(SDT,.SDVSIT)
+12 ;
NEW(SDT,SDVSIT) ; -- create new outpatient encounter record
+1 ; input SDT = visit date internal format
+2 ; SDVSIT = <see bottom of routine>
+3 ;
+4 ; returned = ien of 409.67
+5 ;
+6 NEW SDOE,X,DA,DR,DIE,DQ,DE,I
+7 ; -- creation hard set for performance
+8 SET I=$PIECE(^SCE(0),U,3)
LOCK SET I=I+1
LOCK +^SCE(I):1
IF '$TEST!$DATA(^SCE(I))
LOCK -^SCE(I)
GOTO LOCK
+1 SET ^SCE(I,0)=SDT
SET ^SCE("B",SDT,I)=""
SET ^SCE(0)=$PIECE(^SCE(0),"^",1,2)_"^"_I_"^"_($PIECE(^SCE(0),"^",4)+1)
SET ^DISV($SELECT($DATA(DUZ)'[0:DUZ,1:0),"^SCE(")=I
SET Y=I
+2 ;K DD,DO S SDOE=0,X=SDT,DIC="^SCE(",DIC(0)="L" D FILE^DICN G NEWQ:'Y
+3 if '$GET(SDVSIT("ELG"))
SET SDVSIT("ELG")=$PIECE($GET(^DPT(SDVSIT("DFN"),.36)),U)
+4 SET SDVSIT("STA")=$$STATUS(+SDVSIT("DFN"),SDT,+$GET(SDVSIT("LOC")),SDVSIT("ORG"),"KILL")
+5 SET (SDOE,DA)=+Y
SET DIE="^SCE("
SET DR="[SD ENCOUNTER ENTRY]"
DO ^DIE
+6 if $$REQ^SDM1A(SDT)'="CO"
DO EN^SDCOM(SDOE,0,99999)
+7 LOCK -^SCE(SDOE)
NEWQ QUIT SDOE
+1 ;
VISIT(SDT,SDVSIT) ; -- add visit file entry
+1 NEW VSIT,DFN,DIE,DIC,DR,DA,X,VSITPKG
+2 ; -- is visit tracking loaded
+3 SET X="VSITKIL"
XECUTE ^%ZOSF("TEST")
IF '$TEST
GOTO VISITQ
+4 ; -- set up vars
+5 ;S VSIT(0)="ENMD0",VSIT=SDT,DFN=SDVSIT("DFN"),VSITPKG="SD"
+6 SET VSIT(0)="F"
SET VSIT=SDT
SET DFN=SDVSIT("DFN")
SET VSITPKG="SD"
+7 SET VSIT("CLN")=$GET(SDVSIT("CLN"))
SET VSIT("SVC")=$SELECT($GET(SDVSIT("SVC"))]"":SDVSIT("SVC"),$$INP^SDAM2(DFN,SDT)="I":"I",1:"A")
+8 ;S VSIT("INS")=$P($G(^DG(40.8,+$G(SDVSIT("DIV")),0)),U,7)
+9 SET VSIT("ELG")=$SELECT($GET(SDVSIT("ELG")):SDVSIT("ELG"),1:+$GET(^DPT(DFN,.36)))
+10 IF $GET(SDVSIT("LOC"))
SET VSIT("LOC")=SDVSIT("LOC")
+11 IF $GET(SDVSIT("PAR"))
SET X=$GET(^SCE(SDVSIT("PAR"),0))
IF X]""
SET VSIT=+X
IF $PIECE(X,U,5)
SET VSIT("LNK")=$PIECE(X,U,5)
+12 SET VSIT("ACT")=$$GETARN^SDPFSS2(SDT,DFN,$GET(SDVSIT("LOC")))
+13 ;PX/96 - accept passed INSTITUTION
IF $GET(VSIT("LNK"))
Begin DoDot:1
+14 NEW DR,DIC,DA,DIQ,INST,DIC1
+15 SET DR=".06"
SET DIC=9000010
SET DIC1=DIC
SET DA=VSIT("LNK")
SET DIQ="INST"
SET DIQ(0)="I"
DO EN^DIQ1
+16 SET VSIT("INS")=+$GET(INST(DIC1,DA,DR,"I"))
+17 IF VSIT("INS")'>0
SET VSIT("INS")=$PIECE($GET(^DG(40.8,+$GET(SDVSIT("DIV")),0)),U,7)
+18 QUIT
End DoDot:1
+19 ;
+20 IF '$GET(SDVSIT("PAR"))
Begin DoDot:1
+21 SET VSIT("PRI")="P"
End DoDot:1
+22 IF '$TEST
Begin DoDot:1
+23 IF SDVSIT("ORG")=4
Begin DoDot:2
+24 SET VSIT("PRI")="C"
SET VSIT("SVC")=$SELECT($$INP^SDAM2(DFN,SDT)="I":"D",1:"X")
End DoDot:2
+25 IF '$TEST
Begin DoDot:2
+26 SET VSIT("PRI")="S"
End DoDot:2
End DoDot:1
+27 ;
+28 ; -- changes for database conversion to pass in source and service
+29 IF $DATA(SCCVT)
Begin DoDot:1
+30 IF $GET(SCCVT("SOR"))'=""
SET VSIT("SOR")=$$SOURCE^PXAPI(SCCVT("SOR"))
+31 IF $GET(SCCVT("SVC"))'=""
SET VSIT("SVC")=SCCVT("SVC")
+32 IF $GET(SCCVT("LOC"))'=""
SET VSIT("LOC")=SCCVT("LOC")
End DoDot:1
+33 ;
+34 ; -- do checks
+35 IF 'VSIT
IF 'DFN
IF 'VSIT("ELG")!('VSIT("INS"))!('VSIT("CLN"))
GOTO VISITQ
+36 ;
+37 ; -- add/find visit
+38 ;-- change call if orinating process is a disposition.
+39 IF SDVSIT("ORG")=3
DO DISPVSIT^PXAPI
+40 IF SDVSIT("ORG")'=3
DO ^VSIT
+41 IF +$GET(VSIT("IEN"))>0
SET SDVSIT("VST")=+VSIT("IEN")
VISITQ QUIT
+1 ;
STATUS(DFN,SDT,SDCL,SDORG,SDACT) ; -- 409.68;.07 x-ref
+1 NEW Y
SET Y=0
+2 IF $$INP^SDAM2(DFN,SDT)="I"
SET Y=8
+3 IF 'Y
IF $PIECE($GET(^SC(+SDCL,0)),U,17)="Y"
SET Y=12
+4 IF 'Y
SET Y=$SELECT(SDACT="SET":2,$$REQ^SDM1A(SDT)="CO":14,1:2)
+5 QUIT Y
+6 ;
+7 ;
+8 ; Additional input/output variable documentation
+9 ;
+10 ; SDVSIT("LOC") = file # 44 ien (location)
+11 ; ("ELG") = file # 8 ien (eligibility)
+12 ; ("CLN") = file # 40.7 ien (clinic stop code)
+13 ; ("DIV") = file # 40.8 ien (med ctr div)
+14 ; ("DFN") = file # 2 ien (patient)
+15 ; ("STA") = file #409.63 ien (appt status)
+16 ; ("ORG") = orginating process
+17 ; 1 - appt
+18 ; 2 - add/edit
+19 ; 3 - disposition
+20 ; ("TYP") = file #409.1 ien (appt type)
+21 ; ("VST") = file #9000010 ien (visit)
+22 ; ("LNK") = file #9000010 ien (parent visit)
+23 ; ("REF") = extended reference
+24 ; appt - ^SC(<clinic>,"S",<date/time>,1,<ext ref>,0)
+25 ; disp - ^DPT(<dfn>,"DIS",<ext ref>,0)
+26 ; ("PAR") = file #409.68 ien (outpatient encounter)
+27 ; - parent encounter ien
+28 ; SDVIEN = passed in Visit file ien
+29 ;