PXCECCLS ;WASH/BDB,PKR - UPDATE ENCOUNTER SC/EI FROM DX SC/EI ;Aug 04, 2025@11:50:49
;;1.0;PCE PATIENT CARE ENCOUNTER;**124,174,168,211,234,244**;Feb 12, 2004;Build 37
Q
;
VST(PXVIEN) ;
; PXVIEN Pointer to the Visit (#9000010)
;
;Loop over the V POV Service Connected and Environmental Indicator
;(SC/EI) fields and auto-populate the encounter level SC/EI based
;on the following rules:
;
;If the SC/EI for at least one ICD diagnosis is "Yes", the
;Encounter Level SC/EI will automatically be set to "Yes"
;regardless if the Encounter Level SC (or EI) was previously
;populated ("Yes", "No" or Null). Note: This presumes that a
;single ICD diagnosis with SC/EI determination of "Yes" makes the
;Encounter SC/EI determination "Yes".
;
;If the SC/EI for all ICD diagnosis are "No" the Encounter Level
;SC/EI will automatically be set to "No" regardless if the
;Encounter Level SC/EI was previously populated ("Yes", "No" or
;Null). Note: This presumes that an Encounter SC/EI cannot be
;"Yes" if all ICD diagnosis have an SC/EI determination of "No".
;
;If at least one ICD diagnosis is missing SC/EI determination and
;none of the other ICD diagnosis SC/EI determination is "Yes" do
;not change the SC/EI determination of the Encounter level. Note:
;This presumes that if one or more ICD diagnosis do not have an
;SC/EI determination then no inference can be made upon the
;Encounter Level SC determination. In addition if another package
;populates SC/EI directly do not overwrite that value in the case
;of incomplete data. In other words do not set the Encounter Level
;to Null.
;
;VARIABLE LIST TO AUTO POPULATE THE ENCOUNTER LEVEL SC/EI
;For each SC/EI in the PXSCEINW string:
; = 1 SC/EI Classification determined by the DX's is found to be "Yes"
; = 0 SC/EI Classification determined by the DX's is found to be "NO"
; =-1 SC/EI cannot be determined by the DX's =""
;
;Do not ask the SC/EI questions Edit flag for SC: SCEF, AO: AOEF,
;IR: IREF, EC:ECEF, MST: MSTEF , HNC: HNCEF , CV: CVEF,
;SHAD:SHADEF Used in Visit File Filing - See example below:
; VSIT("SCEF")=1 SC/EI
; Classification determined by the DX's - do not ask SC/EI
; VSIT("SCEF")=0
; SC/EI Classification undetermined by the DX's - ask SC/EI etc.
;
;====================
;If the Visit is missing the patient quit.
I $P($G(^AUPNVSIT(PXVIEN,0)),U,5)="" Q
N CIDX,CODE,DONOTUPD,FINAL,IDX,VSIT,NODE,PXPOV,PXPOV800,PXSAS,SAS,UPDATE,X
S VSIT("IEN")=PXVIEN
I '$D(^AUPNVPOV("AD",PXVIEN)) D UPD^VSIT Q
;Initialize the SC/EI variables. The variables ending in A0 will be
;true if all if all the diagnosis entries are 0 for that variable.
;Loop over all V POV entries for the Visit.
S PXPOV=0,UPDATE=0
F S PXPOV=+$O(^AUPNVPOV("AD",PXVIEN,PXPOV)) Q:PXPOV=0 D
. D GETSAFORVPOVDET^PXSPECAUTH(.SAS,.PXPOV800,PXPOV)
. S IDX=0 F S IDX=$O(SAS(IDX)) Q:IDX'>0 D
.. S NODE=SAS(IDX,0),CODE=$$GETCODE^PXSPECAUTH($P(NODE,U))
.. I $P(NODE,U,2)=1 S FINAL(CODE)=NODE Q
.. I $P(NODE,U,2)=0 D Q
... I $G(FINAL(CODE))="" S FINAL(CODE)=NODE Q
... I $P(FINAL(CODE),U,2)=0!($P(FINAL(CODE),U,2)=1) Q
... S FINAL(CODE)=-1
.. I $P(NODE,U,2)=-1 D
... I $P($G(FINAL(CODE)),U,2)=1 Q
... S FINAL(CODE)=-1
K SAS
S VSIT(900)=""
S CODE="",IDX=0 F S CODE=$O(FINAL(CODE)) Q:CODE="" D
.S NODE=FINAL(CODE) I NODE=-1 Q
.S IDX=IDX+1,SAS(IDX,0)=$$FINDBYCODE^PXSPECAUTH(CODE)_U_$P(NODE,U,2)
I $D(SAS) M VSIT(900)=SAS S VSIT(900)=IDX
D UPD^VSIT
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXCECCLS 3536 printed Jul 11, 2026@02:24:13 Page 2
PXCECCLS ;WASH/BDB,PKR - UPDATE ENCOUNTER SC/EI FROM DX SC/EI ;Aug 04, 2025@11:50:49
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**124,174,168,211,234,244**;Feb 12, 2004;Build 37
+2 QUIT
+3 ;
VST(PXVIEN) ;
+1 ; PXVIEN Pointer to the Visit (#9000010)
+2 ;
+3 ;Loop over the V POV Service Connected and Environmental Indicator
+4 ;(SC/EI) fields and auto-populate the encounter level SC/EI based
+5 ;on the following rules:
+6 ;
+7 ;If the SC/EI for at least one ICD diagnosis is "Yes", the
+8 ;Encounter Level SC/EI will automatically be set to "Yes"
+9 ;regardless if the Encounter Level SC (or EI) was previously
+10 ;populated ("Yes", "No" or Null). Note: This presumes that a
+11 ;single ICD diagnosis with SC/EI determination of "Yes" makes the
+12 ;Encounter SC/EI determination "Yes".
+13 ;
+14 ;If the SC/EI for all ICD diagnosis are "No" the Encounter Level
+15 ;SC/EI will automatically be set to "No" regardless if the
+16 ;Encounter Level SC/EI was previously populated ("Yes", "No" or
+17 ;Null). Note: This presumes that an Encounter SC/EI cannot be
+18 ;"Yes" if all ICD diagnosis have an SC/EI determination of "No".
+19 ;
+20 ;If at least one ICD diagnosis is missing SC/EI determination and
+21 ;none of the other ICD diagnosis SC/EI determination is "Yes" do
+22 ;not change the SC/EI determination of the Encounter level. Note:
+23 ;This presumes that if one or more ICD diagnosis do not have an
+24 ;SC/EI determination then no inference can be made upon the
+25 ;Encounter Level SC determination. In addition if another package
+26 ;populates SC/EI directly do not overwrite that value in the case
+27 ;of incomplete data. In other words do not set the Encounter Level
+28 ;to Null.
+29 ;
+30 ;VARIABLE LIST TO AUTO POPULATE THE ENCOUNTER LEVEL SC/EI
+31 ;For each SC/EI in the PXSCEINW string:
+32 ; = 1 SC/EI Classification determined by the DX's is found to be "Yes"
+33 ; = 0 SC/EI Classification determined by the DX's is found to be "NO"
+34 ; =-1 SC/EI cannot be determined by the DX's =""
+35 ;
+36 ;Do not ask the SC/EI questions Edit flag for SC: SCEF, AO: AOEF,
+37 ;IR: IREF, EC:ECEF, MST: MSTEF , HNC: HNCEF , CV: CVEF,
+38 ;SHAD:SHADEF Used in Visit File Filing - See example below:
+39 ; VSIT("SCEF")=1 SC/EI
+40 ; Classification determined by the DX's - do not ask SC/EI
+41 ; VSIT("SCEF")=0
+42 ; SC/EI Classification undetermined by the DX's - ask SC/EI etc.
+43 ;
+44 ;====================
+45 ;If the Visit is missing the patient quit.
+46 IF $PIECE($GET(^AUPNVSIT(PXVIEN,0)),U,5)=""
QUIT
+47 NEW CIDX,CODE,DONOTUPD,FINAL,IDX,VSIT,NODE,PXPOV,PXPOV800,PXSAS,SAS,UPDATE,X
+48 SET VSIT("IEN")=PXVIEN
+49 IF '$DATA(^AUPNVPOV("AD",PXVIEN))
DO UPD^VSIT
QUIT
+50 ;Initialize the SC/EI variables. The variables ending in A0 will be
+51 ;true if all if all the diagnosis entries are 0 for that variable.
+52 ;Loop over all V POV entries for the Visit.
+53 SET PXPOV=0
SET UPDATE=0
+54 FOR
SET PXPOV=+$ORDER(^AUPNVPOV("AD",PXVIEN,PXPOV))
if PXPOV=0
QUIT
Begin DoDot:1
+55 DO GETSAFORVPOVDET^PXSPECAUTH(.SAS,.PXPOV800,PXPOV)
+56 SET IDX=0
FOR
SET IDX=$ORDER(SAS(IDX))
if IDX'>0
QUIT
Begin DoDot:2
+57 SET NODE=SAS(IDX,0)
SET CODE=$$GETCODE^PXSPECAUTH($PIECE(NODE,U))
+58 IF $PIECE(NODE,U,2)=1
SET FINAL(CODE)=NODE
QUIT
+59 IF $PIECE(NODE,U,2)=0
Begin DoDot:3
+60 IF $GET(FINAL(CODE))=""
SET FINAL(CODE)=NODE
QUIT
+61 IF $PIECE(FINAL(CODE),U,2)=0!($PIECE(FINAL(CODE),U,2)=1)
QUIT
+62 SET FINAL(CODE)=-1
End DoDot:3
QUIT
+63 IF $PIECE(NODE,U,2)=-1
Begin DoDot:3
+64 IF $PIECE($GET(FINAL(CODE)),U,2)=1
QUIT
+65 SET FINAL(CODE)=-1
End DoDot:3
End DoDot:2
End DoDot:1
+66 KILL SAS
+67 SET VSIT(900)=""
+68 SET CODE=""
SET IDX=0
FOR
SET CODE=$ORDER(FINAL(CODE))
if CODE=""
QUIT
Begin DoDot:1
+69 SET NODE=FINAL(CODE)
IF NODE=-1
QUIT
+70 SET IDX=IDX+1
SET SAS(IDX,0)=$$FINDBYCODE^PXSPECAUTH(CODE)_U_$PIECE(NODE,U,2)
End DoDot:1
+71 IF $DATA(SAS)
MERGE VSIT(900)=SAS
SET VSIT(900)=IDX
+72 DO UPD^VSIT
+73 QUIT
+74 ;