PXKCO ;ISL/JVS,ESW - Provider-Dx-CPT-VSIT at check-out ; 01/27/2021
;;1.0;PCE PATIENT CARE ENCOUNTER;**28,41,96,211**;Aug 12, 1996;Build 454
;Routine-set varibles-Check-out
; VARIABLE LIST
;
; PXKAFT = After picture of the encounter provider entry
; PXKBEF = Before picture of the encounter provider entry
; PXKDFN = The DFN of the patient(IEN in file 2 or 9000001)
; PXKNODA,PXKNODB = Before and After Enounter NODE
; PXKPR,PXKAPR,PXKBPR = PROVIDER IEN in VA(200
; PXKREF = Reference to the temp global
; PXKSOR = Source of data(CO,EF,WS,DE)
; PXKOE = outpatient encounter IEN in SCE
; PXKOA = Operating/attending(e.g "O" or "A")
; PXKORG = Orginating process
; PXKPRI = IFN of OUTPATIENT PROVIDER (#409.44) file entry
; PXKPS,PXKAPS = primary/secondary(e.g. "P" or "S")
; PXKVDT = Visit date and time in fileman format
; PXKVST = Encounter equavalent visit IEN in VISIT file
;
W !,"This is NOT an entry point!!" Q
;
EN1 ;Pims Check-out entry point
N VSIT
I '$D(SDHDL) Q
;
EN ;---ENTRY POINT
N PXKREF,PXKORG,STOP,PXKOE
S PXKREF="^TMP(""SDEVT"",$J,SDHDL)",STOP=0
;
; -- SDHDL is the current process
; It's always defined.
;
S PXKORG=0
F S PXKORG=$O(@PXKREF@(PXKORG)) S:"1234"'[PXKORG STOP=1 Q:STOP=1 Q:'PXKORG D
.Q:STOP=1
.N PXKNODB,PXKNODA
.S PXKOE=0 F S PXKOE=$O(@PXKREF@(PXKORG,"SDOE",PXKOE)) Q:'PXKOE D
..K VSIT
..N NODE,NODE0,PXKDIV
..S PXKNODB=$G(@PXKREF@(PXKORG,"SDOE",PXKOE,0,"BEFORE"))
..S PXKNODA=$G(@PXKREF@(PXKORG,"SDOE",PXKOE,0,"AFTER"))
..S VSIT("IENB")=$P(PXKNODB,"^",5) ;BEFORE IEN
..S VSIT("IEN")=$P(PXKNODA,"^",5) ;VISIT IEN
..Q:$G(VSIT("IEN"))<1
..;
..S NODE0=$G(^AUPNVSIT(VSIT("IEN"),0))
..S NODE=$G(^AUPNVSIT(VSIT("IEN"),150))
..Q:NODE0=""
..;
..;gathering the changed data elements
..I $P(NODE0,U,21)'=$P(PXKNODA,U,13) S VSIT("ELG")=$P(PXKNODA,"^",13) ;ELIGIBILITY
..I $P(PXKNODB,U,3)'=$P(PXKNODA,U,3) S VSIT("DSS")=$P(PXKNODA,"^",3) ;CLINIC STOP CODE
..I $P(PXKNODB,U,11)'=$P(PXKNODA,U,11) S PXKDIV=$P($G(PXKNODA),"^",11) ;DIVISION
..I $D(PXKDIV) S VSIT("INS")=$S(+$P(NODE0,U,6)>0:$P(NODE0,U,6),+PXKDIV>0:$P($G(^DG(40.8,+PXKDIV,0)),"^",7),1:"") ;INSTITUTION; PX/96 - accept INSTITUTION if passed to PCE.
..;
..I '$D(VSIT("ELG")),'$D(VSIT("DSS")),'$D(VSIT("INS")) Q
..;
..;check for necessary changes to SVC and PRI
..I ($D(VSIT("DSS"))),($P(PXKNODA,U,8)'=4),(NODE]"") DO
...S VSIT("SVC")=$$SVC("A",VSIT("DSS"),$P(NODE,U,2),$P(PXKNODA,U,4))
...S VSIT("PRI")=$$PRI($P(NODE,U,3),VSIT("DSS"))
..;
..D UPD^VSIT
..K VSIT
Q
;
SVC(SVC,DSS,PXKIO,LOC) ;
;This tag performs the same tests for the Service Catagory that are in
;the visit tracking routine VSITDEF. This has been added as part of
;patch SD*5.3*66
;INPUTS SVC - The service category to start with.
; DSS - The Clinic stop code or DSS Identifier.
; PXKIO - The Patient status.
; LOC - The location of the visit.
;
;OUTPUT SVC - The service category need based upon DSS and PXKIO
;
I SVC="E" G SVCQ
I $P(^DIC(40.7,+DSS,0),"^",1)["TELE" S SVC="T" G SVCQ ;any TELEphone
I $O(^VSIT(150.1,"B",$P(^DIC(40.7,+DSS,0),"^",2),0)) S SVC="X"
I SVC="",+DSS=$P($G(^SC(+LOC,0)),"^",7) S SVC="A"
;Default changes from "X" to "A" in PX*1.0*211.
I SVC="" S SVC="A"
I PXKIO S SVC=$S(SVC="A":"I",SVC="X":"D",1:SVC)
E S SVC=$S(SVC="I":"A",SVC="D":"X",1:SVC)
SVCQ Q SVC
;
PRI(PRI,DSS) ;
;This tag performs the same checks for the encounter type as in VSITDEF
;It has been added as part of SD*5.3*66
;INPUT PRI - Encounter type
; DSS - The Clinic stop code or DSS ID.
;
;OUTPUT PRI - The Encounter type based upon DSS
;
I PRI="P",$O(^VSIT(150.1,"B",+$P($G(^DIC(40.7,+DSS,0)),"^",2),0)) S PRI="O"
E I PRI="O",'$O(^VSIT(150.1,"B",+$P($G(^DIC(40.7,+DSS,0)),"^",2),0)) S PRI="P"
Q PRI
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXKCO 3888 printed Oct 16, 2024@18:29:45 Page 2
PXKCO ;ISL/JVS,ESW - Provider-Dx-CPT-VSIT at check-out ; 01/27/2021
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**28,41,96,211**;Aug 12, 1996;Build 454
+2 ;Routine-set varibles-Check-out
+3 ; VARIABLE LIST
+4 ;
+5 ; PXKAFT = After picture of the encounter provider entry
+6 ; PXKBEF = Before picture of the encounter provider entry
+7 ; PXKDFN = The DFN of the patient(IEN in file 2 or 9000001)
+8 ; PXKNODA,PXKNODB = Before and After Enounter NODE
+9 ; PXKPR,PXKAPR,PXKBPR = PROVIDER IEN in VA(200
+10 ; PXKREF = Reference to the temp global
+11 ; PXKSOR = Source of data(CO,EF,WS,DE)
+12 ; PXKOE = outpatient encounter IEN in SCE
+13 ; PXKOA = Operating/attending(e.g "O" or "A")
+14 ; PXKORG = Orginating process
+15 ; PXKPRI = IFN of OUTPATIENT PROVIDER (#409.44) file entry
+16 ; PXKPS,PXKAPS = primary/secondary(e.g. "P" or "S")
+17 ; PXKVDT = Visit date and time in fileman format
+18 ; PXKVST = Encounter equavalent visit IEN in VISIT file
+19 ;
+20 WRITE !,"This is NOT an entry point!!"
QUIT
+21 ;
EN1 ;Pims Check-out entry point
+1 NEW VSIT
+2 IF '$DATA(SDHDL)
QUIT
+3 ;
EN ;---ENTRY POINT
+1 NEW PXKREF,PXKORG,STOP,PXKOE
+2 SET PXKREF="^TMP(""SDEVT"",$J,SDHDL)"
SET STOP=0
+3 ;
+4 ; -- SDHDL is the current process
+5 ; It's always defined.
+6 ;
+7 SET PXKORG=0
+8 FOR
SET PXKORG=$ORDER(@PXKREF@(PXKORG))
if "1234"'[PXKORG
SET STOP=1
if STOP=1
QUIT
if 'PXKORG
QUIT
Begin DoDot:1
+9 if STOP=1
QUIT
+10 NEW PXKNODB,PXKNODA
+11 SET PXKOE=0
FOR
SET PXKOE=$ORDER(@PXKREF@(PXKORG,"SDOE",PXKOE))
if 'PXKOE
QUIT
Begin DoDot:2
+12 KILL VSIT
+13 NEW NODE,NODE0,PXKDIV
+14 SET PXKNODB=$GET(@PXKREF@(PXKORG,"SDOE",PXKOE,0,"BEFORE"))
+15 SET PXKNODA=$GET(@PXKREF@(PXKORG,"SDOE",PXKOE,0,"AFTER"))
+16 ;BEFORE IEN
SET VSIT("IENB")=$PIECE(PXKNODB,"^",5)
+17 ;VISIT IEN
SET VSIT("IEN")=$PIECE(PXKNODA,"^",5)
+18 if $GET(VSIT("IEN"))<1
QUIT
+19 ;
+20 SET NODE0=$GET(^AUPNVSIT(VSIT("IEN"),0))
+21 SET NODE=$GET(^AUPNVSIT(VSIT("IEN"),150))
+22 if NODE0=""
QUIT
+23 ;
+24 ;gathering the changed data elements
+25 ;ELIGIBILITY
IF $PIECE(NODE0,U,21)'=$PIECE(PXKNODA,U,13)
SET VSIT("ELG")=$PIECE(PXKNODA,"^",13)
+26 ;CLINIC STOP CODE
IF $PIECE(PXKNODB,U,3)'=$PIECE(PXKNODA,U,3)
SET VSIT("DSS")=$PIECE(PXKNODA,"^",3)
+27 ;DIVISION
IF $PIECE(PXKNODB,U,11)'=$PIECE(PXKNODA,U,11)
SET PXKDIV=$PIECE($GET(PXKNODA),"^",11)
+28 ;INSTITUTION; PX/96 - accept INSTITUTION if passed to PCE.
IF $DATA(PXKDIV)
SET VSIT("INS")=$SELECT(+$PIECE(NODE0,U,6)>0:$PIECE(NODE0,U,6),+PXKDIV>0:$PIECE($GET(^DG(40.8,+PXKDIV,0)),"^",7),1:"")
+29 ;
+30 IF '$DATA(VSIT("ELG"))
IF '$DATA(VSIT("DSS"))
IF '$DATA(VSIT("INS"))
QUIT
+31 ;
+32 ;check for necessary changes to SVC and PRI
+33 IF ($DATA(VSIT("DSS")))
IF ($PIECE(PXKNODA,U,8)'=4)
IF (NODE]"")
Begin DoDot:3
+34 SET VSIT("SVC")=$$SVC("A",VSIT("DSS"),$PIECE(NODE,U,2),$PIECE(PXKNODA,U,4))
+35 SET VSIT("PRI")=$$PRI($PIECE(NODE,U,3),VSIT("DSS"))
End DoDot:3
+36 ;
+37 DO UPD^VSIT
+38 KILL VSIT
End DoDot:2
End DoDot:1
+39 QUIT
+40 ;
SVC(SVC,DSS,PXKIO,LOC) ;
+1 ;This tag performs the same tests for the Service Catagory that are in
+2 ;the visit tracking routine VSITDEF. This has been added as part of
+3 ;patch SD*5.3*66
+4 ;INPUTS SVC - The service category to start with.
+5 ; DSS - The Clinic stop code or DSS Identifier.
+6 ; PXKIO - The Patient status.
+7 ; LOC - The location of the visit.
+8 ;
+9 ;OUTPUT SVC - The service category need based upon DSS and PXKIO
+10 ;
+11 IF SVC="E"
GOTO SVCQ
+12 ;any TELEphone
IF $PIECE(^DIC(40.7,+DSS,0),"^",1)["TELE"
SET SVC="T"
GOTO SVCQ
+13 IF $ORDER(^VSIT(150.1,"B",$PIECE(^DIC(40.7,+DSS,0),"^",2),0))
SET SVC="X"
+14 IF SVC=""
IF +DSS=$PIECE($GET(^SC(+LOC,0)),"^",7)
SET SVC="A"
+15 ;Default changes from "X" to "A" in PX*1.0*211.
+16 IF SVC=""
SET SVC="A"
+17 IF PXKIO
SET SVC=$SELECT(SVC="A":"I",SVC="X":"D",1:SVC)
+18 IF '$TEST
SET SVC=$SELECT(SVC="I":"A",SVC="D":"X",1:SVC)
SVCQ QUIT SVC
+1 ;
PRI(PRI,DSS) ;
+1 ;This tag performs the same checks for the encounter type as in VSITDEF
+2 ;It has been added as part of SD*5.3*66
+3 ;INPUT PRI - Encounter type
+4 ; DSS - The Clinic stop code or DSS ID.
+5 ;
+6 ;OUTPUT PRI - The Encounter type based upon DSS
+7 ;
+8 IF PRI="P"
IF $ORDER(^VSIT(150.1,"B",+$PIECE($GET(^DIC(40.7,+DSS,0)),"^",2),0))
SET PRI="O"
+9 IF '$TEST
IF PRI="O"
IF '$ORDER(^VSIT(150.1,"B",+$PIECE($GET(^DIC(40.7,+DSS,0)),"^",2),0))
SET PRI="P"
+10 QUIT PRI