SCCVCST2 ; ALB/TMP - SCHED VSTS RE-CONVERSION - DELETE ENCOUNTER; 25-NOV-97
;;5.3;Scheduling;**211**;Aug 13, 1993
;
DELE(SDOE) ;Delete Encounter on re-convert
; Input -- SDOE Outpatient Encounter file IEN
;
N DA,DFN,DE,DIE,DR,SDCL,SDDA,SDOE0,SDOEP,SDORG,SDT,SDVSAV,SDCNV
;
D SET(SDOE,.SDOE0,.SDT,.DFN,.SDCL,.SDORG,.SDDA,.SDCNV)
;
; Only delete encounter if created originally from conversion
G:'SDCNV DELEQ
;
D DELPTR(DFN,SDT,SDDA,SDORG,SDOE)
;
; -- delete child data for appts and dispos
I "^1^3^"[("^"_SDORG_"^") D CHLD(SDOE)
;
D OE(SDOE)
;
DELEQ Q
;
CHLD(SDOEP) ;Delete child encounters
; SDOEP := Parent encounter ien
;
N DFN,SDCL,SDDA,SDOE0,SDOEC,SDORG,SDT,SDCNV
S SDOEC=0
F S SDOEC=$O(^SCE("APAR",SDOEP,SDOEC)) Q:'SDOEC D
. D SET(SDOEC,.SDOE0,.SDT,.DFN,.SDCL,.SDORG,.SDDA,.SDCNV)
. Q:'SDCNV ;Only delete encounter if created by the conversion
. D DELPTR(DFN,SDT,SDDA,SDORG,SDOEC)
. D OE(SDOEC)
Q
;
SET(SDOE,SDOE0,SDT,DFN,SDCL,SDORG,SDDA,SDCNV) ;Set Variables
;
S SDOE0=$G(^SCE(+SDOE,0)),SDT=+SDOE0,DFN=+$P(SDOE0,"^",2),SDCL=+$P(SDOE0,"^",4),SDORG=+$P(SDOE0,"^",8),SDDA=$P(SDOE0,"^",9)
S SDCNV=$G(^SCE(+SDOE,"CNV"))
Q
;
DELPTR(DFN,SDT,SDDA,SDORG,SDOE) ; -- delete pointers to encounters in scheduling files
; DFN == patient ien
; SDT == encounter date/time
; SDDA == extended reference from encounter 9th piece
; SDORG == flag for origin of encounter
; SDOE == encounter ien
;
N DA,DIE,DR,SDI,SDCS,SDVIEN
IF SDORG=1,$P($G(^DPT(DFN,"S",SDT,0)),U,20)=SDOE D Q
.S DA(1)=DFN,DA=SDT,DIE="^DPT("_DFN_",""S"",",DR="21///@" D ^DIE
;
S SDVIEN=$$SDVIEN^SCCVU(DFN,SDT)
IF SDORG=2 F SDI=1:1:$L(SDDA,":") D Q
. S SDCS=+$P(SDDA,":",SDI)
. IF SDCS,$P($G(^SDV(SDVIEN,"CS",SDCS,0)),U,8)=SDOE D
. . S DA(1)=SDT,DA=SDCS,DIE="^SDV("_SDVIEN_",""CS"",",DR="8///@" D ^DIE
;
IF SDORG=3,$P($G(^DPT(DFN,"DIS",+SDDA,0)),U,18)=SDOE D Q
.S DA(1)=DFN,DA=+SDDA,DIE="^DPT("_DFN_",""DIS"",",DR="18///@" D ^DIE
;
Q
;
OE(SDOE) ;Delete Outpatient Encounter
; SDOE := Encounter ien
;
N DA,DIK
S DA=SDOE,DIK="^SCE(" D ^DIK
Q
;
DEL(SDOE,SDFL) ;Delete Classification - NOT NEEDED - no data existed for the
; periods allowed to be converted
; SDOE := Encounter ien
; SDFL := Internal file # of entry to delete
;
Q
N DA,DIK,SDI
S DIK="^SDD("_SDFL_",",SDI=0
F S SDI=$O(^SDD(SDFL,"AO",SDOE,SDI)) Q:'SDI S DA=+$O(^(SDI,0)) D ^DIK
Q
;
CO(SDOE) ;Delete Classification - NOT NEEDED - no data existed for the
; periods allowed to be converted
; SDOE := Encounter ien
;
G COQ
N DA,DIK,SDFL,SDI
I $P($G(^SCE(SDOE,0)),"^",6) G COQ
I $O(^SDD(409.42,"AO",SDOE,0))>0 D DEL(SDOE,409.42)
COQ Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCCVCST2 2750 printed Dec 13, 2024@02:38:30 Page 2
SCCVCST2 ; ALB/TMP - SCHED VSTS RE-CONVERSION - DELETE ENCOUNTER; 25-NOV-97
+1 ;;5.3;Scheduling;**211**;Aug 13, 1993
+2 ;
DELE(SDOE) ;Delete Encounter on re-convert
+1 ; Input -- SDOE Outpatient Encounter file IEN
+2 ;
+3 NEW DA,DFN,DE,DIE,DR,SDCL,SDDA,SDOE0,SDOEP,SDORG,SDT,SDVSAV,SDCNV
+4 ;
+5 DO SET(SDOE,.SDOE0,.SDT,.DFN,.SDCL,.SDORG,.SDDA,.SDCNV)
+6 ;
+7 ; Only delete encounter if created originally from conversion
+8 if 'SDCNV
GOTO DELEQ
+9 ;
+10 DO DELPTR(DFN,SDT,SDDA,SDORG,SDOE)
+11 ;
+12 ; -- delete child data for appts and dispos
+13 IF "^1^3^"[("^"_SDORG_"^")
DO CHLD(SDOE)
+14 ;
+15 DO OE(SDOE)
+16 ;
DELEQ QUIT
+1 ;
CHLD(SDOEP) ;Delete child encounters
+1 ; SDOEP := Parent encounter ien
+2 ;
+3 NEW DFN,SDCL,SDDA,SDOE0,SDOEC,SDORG,SDT,SDCNV
+4 SET SDOEC=0
+5 FOR
SET SDOEC=$ORDER(^SCE("APAR",SDOEP,SDOEC))
if 'SDOEC
QUIT
Begin DoDot:1
+6 DO SET(SDOEC,.SDOE0,.SDT,.DFN,.SDCL,.SDORG,.SDDA,.SDCNV)
+7 ;Only delete encounter if created by the conversion
if 'SDCNV
QUIT
+8 DO DELPTR(DFN,SDT,SDDA,SDORG,SDOEC)
+9 DO OE(SDOEC)
End DoDot:1
+10 QUIT
+11 ;
SET(SDOE,SDOE0,SDT,DFN,SDCL,SDORG,SDDA,SDCNV) ;Set Variables
+1 ;
+2 SET SDOE0=$GET(^SCE(+SDOE,0))
SET SDT=+SDOE0
SET DFN=+$PIECE(SDOE0,"^",2)
SET SDCL=+$PIECE(SDOE0,"^",4)
SET SDORG=+$PIECE(SDOE0,"^",8)
SET SDDA=$PIECE(SDOE0,"^",9)
+3 SET SDCNV=$GET(^SCE(+SDOE,"CNV"))
+4 QUIT
+5 ;
DELPTR(DFN,SDT,SDDA,SDORG,SDOE) ; -- delete pointers to encounters in scheduling files
+1 ; DFN == patient ien
+2 ; SDT == encounter date/time
+3 ; SDDA == extended reference from encounter 9th piece
+4 ; SDORG == flag for origin of encounter
+5 ; SDOE == encounter ien
+6 ;
+7 NEW DA,DIE,DR,SDI,SDCS,SDVIEN
+8 IF SDORG=1
IF $PIECE($GET(^DPT(DFN,"S",SDT,0)),U,20)=SDOE
Begin DoDot:1
+9 SET DA(1)=DFN
SET DA=SDT
SET DIE="^DPT("_DFN_",""S"","
SET DR="21///@"
DO ^DIE
End DoDot:1
QUIT
+10 ;
+11 SET SDVIEN=$$SDVIEN^SCCVU(DFN,SDT)
+12 IF SDORG=2
FOR SDI=1:1:$LENGTH(SDDA,":")
Begin DoDot:1
+13 SET SDCS=+$PIECE(SDDA,":",SDI)
+14 IF SDCS
IF $PIECE($GET(^SDV(SDVIEN,"CS",SDCS,0)),U,8)=SDOE
Begin DoDot:2
+15 SET DA(1)=SDT
SET DA=SDCS
SET DIE="^SDV("_SDVIEN_",""CS"","
SET DR="8///@"
DO ^DIE
End DoDot:2
End DoDot:1
QUIT
+16 ;
+17 IF SDORG=3
IF $PIECE($GET(^DPT(DFN,"DIS",+SDDA,0)),U,18)=SDOE
Begin DoDot:1
+18 SET DA(1)=DFN
SET DA=+SDDA
SET DIE="^DPT("_DFN_",""DIS"","
SET DR="18///@"
DO ^DIE
End DoDot:1
QUIT
+19 ;
+20 QUIT
+21 ;
OE(SDOE) ;Delete Outpatient Encounter
+1 ; SDOE := Encounter ien
+2 ;
+3 NEW DA,DIK
+4 SET DA=SDOE
SET DIK="^SCE("
DO ^DIK
+5 QUIT
+6 ;
DEL(SDOE,SDFL) ;Delete Classification - NOT NEEDED - no data existed for the
+1 ; periods allowed to be converted
+2 ; SDOE := Encounter ien
+3 ; SDFL := Internal file # of entry to delete
+4 ;
+5 QUIT
+6 NEW DA,DIK,SDI
+7 SET DIK="^SDD("_SDFL_","
SET SDI=0
+8 FOR
SET SDI=$ORDER(^SDD(SDFL,"AO",SDOE,SDI))
if 'SDI
QUIT
SET DA=+$ORDER(^(SDI,0))
DO ^DIK
+9 QUIT
+10 ;
CO(SDOE) ;Delete Classification - NOT NEEDED - no data existed for the
+1 ; periods allowed to be converted
+2 ; SDOE := Encounter ien
+3 ;
+4 GOTO COQ
+5 NEW DA,DIK,SDFL,SDI
+6 IF $PIECE($GET(^SCE(SDOE,0)),"^",6)
GOTO COQ
+7 IF $ORDER(^SDD(409.42,"AO",SDOE,0))>0
DO DEL(SDOE,409.42)
COQ QUIT
+1 ;