SCCVEAE1 ;ALB/RMO,TMP - Add/Edit Conversion cont.; [ 04/05/95 8:46 AM ]
;;5.3;Scheduling;**211**;Aug 13, 1993
;
CON(SCCVEVT,SCDTM,SCVALDT,SCDA) ;Should conversion event be processed for add/edit
; Input -- SCCVEVT Conversion event
; SCDTM Visit date/time
; SCVALDT Valid converted Visit date/time (SCDTM)
; SCDA Clinic stop code sub-file IEN
; Output -- 1=Yes and 0=No
;
N SC0,SCECSTAT,Y,SCOE,SCSTOP,SCLN,DFN
S DFN=+$P($G(^SDV(SCDTM,0)),U,2)
S SC0=$G(^SDV(SCDTM,"CS",SCDA,0))
S SCSTOP=+SC0
S SCLN=+$P(SC0,U,3)
S SCOE=+$P(SC0,U,8)
S SCECSTAT=$P(SC0,U,9)
;
; -- do checks
S Y=1
IF Y,$P(SCVALDT,".")>SCCVACRP S Y=0 ; Greater than ACRP date
IF Y,SCCVEVT=1,SCECSTAT S Y=0 ; Convert/already converted
IF Y,SCCVEVT=2,'SCECSTAT S Y=0 ; Re-convert/never converted
IF Y,'SCCVEVT,SCECSTAT S Y=0 ; Estimate/already converted
;
; -- if check out required then must have a co completion date/time
IF Y,$$REQ^SDM1A(SCDTM)="CO",'$P($G(^SCE(SCOE,0)),U,7) S Y=0
;
; -- if a/e for 900 stop, same clinic, no enounter
; and lower "CS" ien then current then don't convert
IF Y,SCCV900=SCSTOP,SCLN D
. N SCS,SCS0
. S SCS=0
. F S SCS=$O(^SDV(SCDTM,"CS",SCS)) Q:'SCS!(SCS=SCDA) S SCS0=$G(^(SCS,0)) IF +SCS0=SCCV900,+$P(SCS0,U,3)=SCLN,'$P(SCS0,U,8) S Y=0 Q
;
; -- if not a 900, did stop get added via appts? if so, don't convert.
IF Y,SCCV900'=SCSTOP D
. N SCAP,SCAP0,SCEND
. S SCAP=$P(SCDTM,"."),SCEND=SCAP+.24
. F S SCAP=$O(^DPT(DFN,"S",SCAP)) Q:'SCAP!(SCAP>SCEND) S SCAP0=$G(^(SCAP,0)) D Q:'Y
. . ; -- must be valid made appt
. . IF $P(SCAP0,U,2)'="",$P(SCAP0,U,2)'="I" Q
. . ; -- if clinic specified then appt must be for same clinic
. . IF SCLN,SCLN'=+SCAP0 Q
. . ; -- if enc exists & c/o, compare enc stop code with sdv stop code
. . IF $P(SCAP0,U,20) D Q
. . . IF $P($G(^SCE($P(SCAP0,U,20),0)),U,3)=SCSTOP,$P($G(^SCE($P(SCAP0,U,20),0)),U,7) S Y=0
. . ; -- compare clinic's stop code with sdv stop code
. . IF $P($G(^SC(+SCAP0,0)),U,7)=SCSTOP S Y=0 Q
;
Q +$G(Y)
;
EN(SCCVEVT,SCDTM,SCDA,SCOEP,SCLOG) ; Entry point to convert an add/edit
; Input -- SCCVEVT Conversion event
; 0=Estimate 1=Convert 2=Re-convert
; SCDTM ien of SDV entry (~Visit date/time)
; SCDA Clinic stop code sub-file IEN
; SCOEP Parent outpatient encounter IEN [optional]
; SCLOG Scheduling conversion log IEN [optional]
N SCCV,SCOE,SCDATA,SCCONS,SCEST,Z,SCVALDT
;
; -- make sure sdv d/t is valid
S SCVALDT=$$DATECHCK^SDVSIT(SCDTM)
;
S SCCONS("SRCE")="SD TO PCE DB CONV"
S SCCONS("PKG")=$O(^DIC(9.4,"C","SD",0))
;
; Check if add/edit should be processed
IF '$$CON(SCCVEVT,SCDTM,SCVALDT,SCDA) G ENQ
;
; Set-up conversion array and variables
D SET^SCCVEAE3(SCCVEVT,+$G(SCLOG),SCDTM,SCVALDT,SCDA,.SCOEP,.SCOE,.SCCV)
;
I 'SCCVEVT,$G(SCCV("ERR")) G ENQ
;
; Skip if no new enctr or visit needed & no error to log
I '$G(SCCV("NEW")),'$D(SCCV("ERR")) G ENQ
;
; Increment number of add/edits found (estimating only)
I 'SCCVEVT D EN^SCCVZZ("AE-1",SCOE,SCDTM,SCDA,+$P($G(SCCV("OE",0)),U,6),+$P($G(SCCV("OE",0)),U,2)) D INCRTOT^SCCVEGU1(.SCTOT,1,1)
;
; Log error if no encounter or no visit, exit if no encounter
I SCCVEVT,$S('$G(SCOE):1,1:'$P($G(SCCV("OE",0)),U,5)) D G:'$G(SCOE) ENQ
. N SCERRIP,Y,SCE
. S Y=SCDTM D D^DIQ S SCERRIP(1)=Y
. S SCERRIP(2)=SCDA
. S SCERRIP(5)=$$OTHERR^SCCVU2($G(SCCV("ERR")))
. S SCERRIP(4)=$S('$G(SCOE):"Outpatient encounter",1:"Visit")
. S SCE("DFN")=$P($G(^SDV(SCDTM,0)),U,2),SCE("ENC")=$G(SCOE),SCE("VSIT")="",SCE("DATE")=SCDTM
. D GETERR^SCCVLOG1(4049005.001,.SCE,.SCERRIP,$G(SCLOG),0,.SCERRMSG)
. S SCTOT(2.06)=$G(SCTOT(2.06))+1
. S:$G(SCOE) ^XTMP("SCCV-ERR-"_+$G(SCLOG),"NO-VIS",SCOE)=""
;
G:$G(SCCV("ERR")) ENQ
;
; Invoke DATA-TO-PCE call, store any errors
S SCEST=""
I $S('SCCVEVT:1,1:$P($G(^SCE(SCOE,0)),U,5)) D DATA2PCE^SCCVPCE(SCOE,.SCCONS,SCCVEVT,$S(SCCVEVT:$G(SCOEP),1:$P($G(^SCE(SCOE,0)),U,6)),SCDTM,SCDA,.SCEST)
;
I 'SCCVEVT D G ENQ ;Estimate exits here
.F Z=1:1:3 I $P(SCEST,U,Z) D INCRTOT^SCCVEGU1(.SCTOT,Z+8,$P(SCEST,U,Z)) D EN^SCCVZZ("AE-"_(Z+8),SCOE,SCDTM,SCDA,+$G(SCOEP),$P(SCEST,U,Z))
;
; Convert additional add/edit data
D ENC(SCOE,.SCCV)
;
; Update add/edit as converted
D DONE(SCDTM,SCDA,1)
;
; Update last entry and number of records
I $G(SCLOG),'$G(SCOEP) D UPDREC^SCCVLOG(SCLOG,SCOE,"CST")
I '$G(SCLOG),$G(SCTOT("A/E")) S SCTOT("OK")=1
ENQ Q
;
ENC(SCOE,SCCV) ; Convert additional add/edit data for encounter
; Input -- SCOE Outpatient encounter IEN
; SCCV Conversion array
; Output -- None
N SCDATA
I $G(SCCV("VST")),'$P($G(^SCE(SCOE,0)),U,5) S SCDATA(.05)=SCCV("VST") ; visit file entry
I SCCV("NEW")=1 D ;Only if conversion adds the encounter
. I $P($G(SCCV("CS",0)),U,6)'="" S SCDATA(202)=$P(SCCV("CS",0),U,6)
. I $P($G(SCCV("CS",0)),U,2)'="" S SCDATA(101)=$P(SCCV("CS",0),U,2)
. I $P($G(SCCV("CS",1)),U)'="" S SCDATA(201)=$P(SCCV("CS",1),U)
. I $P($G(SCCV("CS",0)),U,7)'="" S SCDATA(902)=$P(SCCV("CS",0),U,7)
. S SCDATA(901)=1 ; created by conversion
I $G(SCCV("VST")) D ENCCNV^SCCVEAP1(.SCDATA)
I $D(SCDATA) D UPD^SCCVDBU(409.68,SCOE,.SCDATA)
ENCQ Q
;
DONE(SCDTM,SCDA,SCECSTAT) ; Update add/edit encounter conversion status
; Input -- SCDTM Visit date/time
; SCDA Clinic stop code sub-file IEN
; SCECSTAT Encounter conversion status
; Output -- None
N SCDATA,SCIENS
S SCIENS=SCDA_","_SCDTM
S:'$P($G(^SDV(SCDTM,"CS",SCDA,0)),U,9) SCDATA(9)=SCECSTAT ; encounter conversion status
I $D(SCDATA) D UPD^SCCVDBU(409.51,SCIENS,.SCDATA)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCCVEAE1 5804 printed Oct 16, 2024@18:39:18 Page 2
SCCVEAE1 ;ALB/RMO,TMP - Add/Edit Conversion cont.; [ 04/05/95 8:46 AM ]
+1 ;;5.3;Scheduling;**211**;Aug 13, 1993
+2 ;
CON(SCCVEVT,SCDTM,SCVALDT,SCDA) ;Should conversion event be processed for add/edit
+1 ; Input -- SCCVEVT Conversion event
+2 ; SCDTM Visit date/time
+3 ; SCVALDT Valid converted Visit date/time (SCDTM)
+4 ; SCDA Clinic stop code sub-file IEN
+5 ; Output -- 1=Yes and 0=No
+6 ;
+7 NEW SC0,SCECSTAT,Y,SCOE,SCSTOP,SCLN,DFN
+8 SET DFN=+$PIECE($GET(^SDV(SCDTM,0)),U,2)
+9 SET SC0=$GET(^SDV(SCDTM,"CS",SCDA,0))
+10 SET SCSTOP=+SC0
+11 SET SCLN=+$PIECE(SC0,U,3)
+12 SET SCOE=+$PIECE(SC0,U,8)
+13 SET SCECSTAT=$PIECE(SC0,U,9)
+14 ;
+15 ; -- do checks
+16 SET Y=1
+17 ; Greater than ACRP date
IF Y
IF $PIECE(SCVALDT,".")>SCCVACRP
SET Y=0
+18 ; Convert/already converted
IF Y
IF SCCVEVT=1
IF SCECSTAT
SET Y=0
+19 ; Re-convert/never converted
IF Y
IF SCCVEVT=2
IF 'SCECSTAT
SET Y=0
+20 ; Estimate/already converted
IF Y
IF 'SCCVEVT
IF SCECSTAT
SET Y=0
+21 ;
+22 ; -- if check out required then must have a co completion date/time
+23 IF Y
IF $$REQ^SDM1A(SCDTM)="CO"
IF '$PIECE($GET(^SCE(SCOE,0)),U,7)
SET Y=0
+24 ;
+25 ; -- if a/e for 900 stop, same clinic, no enounter
+26 ; and lower "CS" ien then current then don't convert
+27 IF Y
IF SCCV900=SCSTOP
IF SCLN
Begin DoDot:1
+28 NEW SCS,SCS0
+29 SET SCS=0
+30 FOR
SET SCS=$ORDER(^SDV(SCDTM,"CS",SCS))
if 'SCS!(SCS=SCDA)
QUIT
SET SCS0=$GET(^(SCS,0))
IF +SCS0=SCCV900
IF +$PIECE(SCS0,U,3)=SCLN
IF '$PIECE(SCS0,U,8)
SET Y=0
QUIT
End DoDot:1
+31 ;
+32 ; -- if not a 900, did stop get added via appts? if so, don't convert.
+33 IF Y
IF SCCV900'=SCSTOP
Begin DoDot:1
+34 NEW SCAP,SCAP0,SCEND
+35 SET SCAP=$PIECE(SCDTM,".")
SET SCEND=SCAP+.24
+36 FOR
SET SCAP=$ORDER(^DPT(DFN,"S",SCAP))
if 'SCAP!(SCAP>SCEND)
QUIT
SET SCAP0=$GET(^(SCAP,0))
Begin DoDot:2
+37 ; -- must be valid made appt
+38 IF $PIECE(SCAP0,U,2)'=""
IF $PIECE(SCAP0,U,2)'="I"
QUIT
+39 ; -- if clinic specified then appt must be for same clinic
+40 IF SCLN
IF SCLN'=+SCAP0
QUIT
+41 ; -- if enc exists & c/o, compare enc stop code with sdv stop code
+42 IF $PIECE(SCAP0,U,20)
Begin DoDot:3
+43 IF $PIECE($GET(^SCE($PIECE(SCAP0,U,20),0)),U,3)=SCSTOP
IF $PIECE($GET(^SCE($PIECE(SCAP0,U,20),0)),U,7)
SET Y=0
End DoDot:3
QUIT
+44 ; -- compare clinic's stop code with sdv stop code
+45 IF $PIECE($GET(^SC(+SCAP0,0)),U,7)=SCSTOP
SET Y=0
QUIT
End DoDot:2
if 'Y
QUIT
End DoDot:1
+46 ;
+47 QUIT +$GET(Y)
+48 ;
EN(SCCVEVT,SCDTM,SCDA,SCOEP,SCLOG) ; Entry point to convert an add/edit
+1 ; Input -- SCCVEVT Conversion event
+2 ; 0=Estimate 1=Convert 2=Re-convert
+3 ; SCDTM ien of SDV entry (~Visit date/time)
+4 ; SCDA Clinic stop code sub-file IEN
+5 ; SCOEP Parent outpatient encounter IEN [optional]
+6 ; SCLOG Scheduling conversion log IEN [optional]
+7 NEW SCCV,SCOE,SCDATA,SCCONS,SCEST,Z,SCVALDT
+8 ;
+9 ; -- make sure sdv d/t is valid
+10 SET SCVALDT=$$DATECHCK^SDVSIT(SCDTM)
+11 ;
+12 SET SCCONS("SRCE")="SD TO PCE DB CONV"
+13 SET SCCONS("PKG")=$ORDER(^DIC(9.4,"C","SD",0))
+14 ;
+15 ; Check if add/edit should be processed
+16 IF '$$CON(SCCVEVT,SCDTM,SCVALDT,SCDA)
GOTO ENQ
+17 ;
+18 ; Set-up conversion array and variables
+19 DO SET^SCCVEAE3(SCCVEVT,+$GET(SCLOG),SCDTM,SCVALDT,SCDA,.SCOEP,.SCOE,.SCCV)
+20 ;
+21 IF 'SCCVEVT
IF $GET(SCCV("ERR"))
GOTO ENQ
+22 ;
+23 ; Skip if no new enctr or visit needed & no error to log
+24 IF '$GET(SCCV("NEW"))
IF '$DATA(SCCV("ERR"))
GOTO ENQ
+25 ;
+26 ; Increment number of add/edits found (estimating only)
+27 IF 'SCCVEVT
DO EN^SCCVZZ("AE-1",SCOE,SCDTM,SCDA,+$PIECE($GET(SCCV("OE",0)),U,6),+$PIECE($GET(SCCV("OE",0)),U,2))
DO INCRTOT^SCCVEGU1(.SCTOT,1,1)
+28 ;
+29 ; Log error if no encounter or no visit, exit if no encounter
+30 IF SCCVEVT
IF $SELECT('$GET(SCOE):1,1:'$PIECE($GET(SCCV("OE",0)),U,5))
Begin DoDot:1
+31 NEW SCERRIP,Y,SCE
+32 SET Y=SCDTM
DO D^DIQ
SET SCERRIP(1)=Y
+33 SET SCERRIP(2)=SCDA
+34 SET SCERRIP(5)=$$OTHERR^SCCVU2($GET(SCCV("ERR")))
+35 SET SCERRIP(4)=$SELECT('$GET(SCOE):"Outpatient encounter",1:"Visit")
+36 SET SCE("DFN")=$PIECE($GET(^SDV(SCDTM,0)),U,2)
SET SCE("ENC")=$GET(SCOE)
SET SCE("VSIT")=""
SET SCE("DATE")=SCDTM
+37 DO GETERR^SCCVLOG1(4049005.001,.SCE,.SCERRIP,$GET(SCLOG),0,.SCERRMSG)
+38 SET SCTOT(2.06)=$GET(SCTOT(2.06))+1
+39 if $GET(SCOE)
SET ^XTMP("SCCV-ERR-"_+$GET(SCLOG),"NO-VIS",SCOE)=""
End DoDot:1
if '$GET(SCOE)
GOTO ENQ
+40 ;
+41 if $GET(SCCV("ERR"))
GOTO ENQ
+42 ;
+43 ; Invoke DATA-TO-PCE call, store any errors
+44 SET SCEST=""
+45 IF $SELECT('SCCVEVT:1,1:$PIECE($GET(^SCE(SCOE,0)),U,5))
DO DATA2PCE^SCCVPCE(SCOE,.SCCONS,SCCVEVT,$SELECT(SCCVEVT:$GET(SCOEP),1:$PIECE($GET(^SCE(SCOE,0)),U,6)),SCDTM,SCDA,.SCEST)
+46 ;
+47 ;Estimate exits here
IF 'SCCVEVT
Begin DoDot:1
+48 FOR Z=1:1:3
IF $PIECE(SCEST,U,Z)
DO INCRTOT^SCCVEGU1(.SCTOT,Z+8,$PIECE(SCEST,U,Z))
DO EN^SCCVZZ("AE-"_(Z+8),SCOE,SCDTM,SCDA,+$GET(SCOEP),$PIECE(SCEST,U,Z))
End DoDot:1
GOTO ENQ
+49 ;
+50 ; Convert additional add/edit data
+51 DO ENC(SCOE,.SCCV)
+52 ;
+53 ; Update add/edit as converted
+54 DO DONE(SCDTM,SCDA,1)
+55 ;
+56 ; Update last entry and number of records
+57 IF $GET(SCLOG)
IF '$GET(SCOEP)
DO UPDREC^SCCVLOG(SCLOG,SCOE,"CST")
+58 IF '$GET(SCLOG)
IF $GET(SCTOT("A/E"))
SET SCTOT("OK")=1
ENQ QUIT
+1 ;
ENC(SCOE,SCCV) ; Convert additional add/edit data for encounter
+1 ; Input -- SCOE Outpatient encounter IEN
+2 ; SCCV Conversion array
+3 ; Output -- None
+4 NEW SCDATA
+5 ; visit file entry
IF $GET(SCCV("VST"))
IF '$PIECE($GET(^SCE(SCOE,0)),U,5)
SET SCDATA(.05)=SCCV("VST")
+6 ;Only if conversion adds the encounter
IF SCCV("NEW")=1
Begin DoDot:1
+7 IF $PIECE($GET(SCCV("CS",0)),U,6)'=""
SET SCDATA(202)=$PIECE(SCCV("CS",0),U,6)
+8 IF $PIECE($GET(SCCV("CS",0)),U,2)'=""
SET SCDATA(101)=$PIECE(SCCV("CS",0),U,2)
+9 IF $PIECE($GET(SCCV("CS",1)),U)'=""
SET SCDATA(201)=$PIECE(SCCV("CS",1),U)
+10 IF $PIECE($GET(SCCV("CS",0)),U,7)'=""
SET SCDATA(902)=$PIECE(SCCV("CS",0),U,7)
+11 ; created by conversion
SET SCDATA(901)=1
End DoDot:1
+12 IF $GET(SCCV("VST"))
DO ENCCNV^SCCVEAP1(.SCDATA)
+13 IF $DATA(SCDATA)
DO UPD^SCCVDBU(409.68,SCOE,.SCDATA)
ENCQ QUIT
+1 ;
DONE(SCDTM,SCDA,SCECSTAT) ; Update add/edit encounter conversion status
+1 ; Input -- SCDTM Visit date/time
+2 ; SCDA Clinic stop code sub-file IEN
+3 ; SCECSTAT Encounter conversion status
+4 ; Output -- None
+5 NEW SCDATA,SCIENS
+6 SET SCIENS=SCDA_","_SCDTM
+7 ; encounter conversion status
if '$PIECE($GET(^SDV(SCDTM,"CS",SCDA,0)),U,9)
SET SCDATA(9)=SCECSTAT
+8 IF $DATA(SCDATA)
DO UPD^SCCVDBU(409.51,SCIENS,.SCDATA)
+9 QUIT
+10 ;