SCCVEDI1 ;ALB/RMO,TMP - Disposition Conversion cont.; [ 04/05/95 8:12 AM ]
;;5.3;Scheduling;**211,1015**;Aug 13, 1993;Build 21
;
CON(SCCVEVT,DFN,SCDTM,SCCVDIS) ; Should conversion event be processed for disposition
; Input -- SCCVEVT Conversion event
; DFN Patient IEN
; SCDTM Visit date/time
; SCCVDIS Array of disposition clinics
;
; Output -- 1=Yes and 0=No
;
N SCECSTAT,Y,SCOE,SCDIS0,SCTYPE,SCDIV
S SCDIS0=$G(^DPT(DFN,"DIS",9999999-SCDTM,0))
S SCTYPE=$P(SCDIS0,U,2)
S SCDIV=+$P(SCDIS0,U,4)
S SCOE=+$P(SCDIS0,U,18)
S SCECSTAT=$P(SCDIS0,U,19)
;
; -- do checks
S Y=1
; -- don't use if date is greater than ACRP date
IF Y,$P(SCDTM,".")>SCCVACRP S Y=0
; -- don't use if application w/o exam
IF Y,SCTYPE=2 S Y=0
; -- don't use if no dispo clinic division & > 1 defined for site
IF Y,'$G(SCCVDIS(SCDIV)),'$G(SCCVDIS(0)) S Y=0
; -- don't use if convert and already converted
IF Y,SCCVEVT=1,SCECSTAT S Y=0
; -- don't use if re-convert and not converted
IF Y,SCCVEVT=2,'SCECSTAT S Y=0
; -- don't use if estimate and converted
IF Y,'SCCVEVT,SCECSTAT S Y=0
; -- 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
Q +$G(Y)
;
EN(SCCVEVT,DFN,SCDTM,SCLOG) ; Entry point to convert a disposition
; Input -- SCCVEVT Conversion event
; 0=Estimate 1=Convert 2=Re-convert
; DFN Patient IEN
; SCDTM Visit date/time
; SCLOG Scheduling conversion log IEN [optional]
N SCCV,SCOE,SCCONS,SCEST
;
S SCCONS("SRCE")="SD TO PCE DB CONV"
S SCCONS("PKG")=$O(^DIC(9.4,"C","SD",0))
;
;Set up the array for extracting a default disp clinic for the division
I '$D(SCCVDIS) D
. N SCCL,SCDIV,Z
. S Z=0 F S Z=$O(^PX(815,1,"DHL",Z)) Q:'Z S SCCL=+$G(^(Z,0)),SCDIV=$P($G(^SC(SCCL,0)),U,15) I SCDIV,'$D(SCCVDIS(SCDIV)) S SCCVDIS(SCDIV)=SCCL
. ; Default (0) is used if division does not have a valid disp clinic
. S SCCVDIS(0)=+$P($G(^SD(404.91,1,"CNV")),U,2)
;
; Check if disposition should be processed
IF '$$CON(SCCVEVT,DFN,SCDTM,.SCCVDIS) G ENQ
;
; Set-up conversion array and variables
D SET^SCCVEDI3(SCCVEVT,+$G(SCLOG),DFN,.SCOE,.SCCV)
;
I 'SCCVEVT,$G(SCCV("ERR")) G ENQ
;
; Don't process no new enctr or visit needed & no error to log
I '$G(SCCV("NEW")),'$D(SCCV("ERR")) G ENQ
;
; Increment number of dispositions found (estimating only)
I 'SCCVEVT D INCRTOT^SCCVEGU1(.SCTOT,5,1),EN^SCCVZZ("DIS-5",SCOE,SCDTM)
;
; 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 SCE,SCERRIP,Y
. S SCERRIP(1)=$P($G(^DPT(DFN,0)),U)
. S Y=SCDTM D D^DIQ S SCERRIP(2)=Y
. S SCERRIP(5)=$$OTHERR^SCCVU2($G(SCCV("ERR")))
. S SCERRIP(4)=$S('$G(SCOE):"Outpatient encounter",1:"Visit")
. S SCE("DFN")=DFN,SCE("ENC")=$G(SCOE),SCE("VSIT")="",SCE("DATE")=SCDTM
. D GETERR^SCCVLOG1(4049005.003,.SCE,.SCERRIP,$G(SCLOG),0,.SCERRMSG)
. S:$G(SCOE) ^XTMP("SCCV-ERR-"_+SCLOG,"NO-VIS",SCOE)=""
. S SCTOT(2.06)=$G(SCTOT(2.06))+1
;
G:$G(SCCV("ERR")) ENQ
;
; Convert additional disposition data
I SCCVEVT D ENC(SCOE,.SCCV)
;
; Convert children
D CHLD^SCCVEAP2(SCOE,.SCCV,$G(SCLOG))
;
; Invoke DATA-TO-PCE call, store any errors
I $S('SCCVEVT:1,1:$P($G(^SCE(SCOE,0)),U,5)) D DATA2PCE^SCCVPCE(SCOE,.SCCONS,SCCVEVT,$G(SCOEP),"","",.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("DIS-"_(Z+8),SCOE,SCDTM,"","",$P(SCEST,U,Z))
;
; Update disposition as converted
D DONE(DFN,SCDTM,1)
;
; Update last entry and number of records
I $G(SCLOG) D UPDREC^SCCVLOG(SCLOG,SCOE,"CST")
I '$G(SCLOG) S SCTOT("OK")=1
;
ENQ Q
;
ENC(SCOE,SCCV) ; Convert additional disposition data for the encounter
; $$GETDISP^SDVIST2 creates the encounter and seeds it with disp data
; 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
S:$G(SCCV("NEW"))=1 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(DFN,SCDTM,SCECSTAT) ; Update disposition encounter conversion status
; Input -- DFN Patient IEN
; SCDTM Visit date/time
; SCECSTAT Encounter conversion status
; Output -- None
N SCDATA,SCIENS
S SCIENS=(9999999-SCDTM)_","_DFN
S:'$P($G(^DPT(DFN,"DIS",+SCIENS,0)),U,19) SCDATA(19)=SCECSTAT ; encounter conversion status
I $D(SCDATA) D UPD^SCCVDBU(2.101,SCIENS,.SCDATA)
Q
;
SCCVEDI1 ;ALB/RMO,TMP - Disposition Conversion cont.; [ 04/05/95 8:12 AM ]
+1 ;;5.3;Scheduling;**211,1015**;Aug 13, 1993;Build 21
+2 ;
CON(SCCVEVT,DFN,SCDTM,SCCVDIS) ; Should conversion event be processed for disposition
+1 ; Input -- SCCVEVT Conversion event
+2 ; DFN Patient IEN
+3 ; SCDTM Visit date/time
+4 ; SCCVDIS Array of disposition clinics
+5 ;
+6 ; Output -- 1=Yes and 0=No
+7 ;
+8 NEW SCECSTAT,Y,SCOE,SCDIS0,SCTYPE,SCDIV
+9 SET SCDIS0=$GET(^DPT(DFN,"DIS",9999999-SCDTM,0))
+10 SET SCTYPE=$PIECE(SCDIS0,U,2)
+11 SET SCDIV=+$PIECE(SCDIS0,U,4)
+12 SET SCOE=+$PIECE(SCDIS0,U,18)
+13 SET SCECSTAT=$PIECE(SCDIS0,U,19)
+14 ;
+15 ; -- do checks
+16 SET Y=1
+17 ; -- don't use if date is greater than ACRP date
+18 IF Y
IF $PIECE(SCDTM,".")>SCCVACRP
SET Y=0
+19 ; -- don't use if application w/o exam
+20 IF Y
IF SCTYPE=2
SET Y=0
+21 ; -- don't use if no dispo clinic division & > 1 defined for site
+22 IF Y
IF '$GET(SCCVDIS(SCDIV))
IF '$GET(SCCVDIS(0))
SET Y=0
+23 ; -- don't use if convert and already converted
+24 IF Y
IF SCCVEVT=1
IF SCECSTAT
SET Y=0
+25 ; -- don't use if re-convert and not converted
+26 IF Y
IF SCCVEVT=2
IF 'SCECSTAT
SET Y=0
+27 ; -- don't use if estimate and converted
+28 IF Y
IF 'SCCVEVT
IF SCECSTAT
SET Y=0
+29 ; -- if check out required then must have a co completion date/time
+30 IF Y
IF $$REQ^SDM1A(SCDTM)="CO"
IF '$PIECE($GET(^SCE(SCOE,0)),U,7)
SET Y=0
+31 QUIT +$GET(Y)
+32 ;
EN(SCCVEVT,DFN,SCDTM,SCLOG) ; Entry point to convert a disposition
+1 ; Input -- SCCVEVT Conversion event
+2 ; 0=Estimate 1=Convert 2=Re-convert
+3 ; DFN Patient IEN
+4 ; SCDTM Visit date/time
+5 ; SCLOG Scheduling conversion log IEN [optional]
+6 NEW SCCV,SCOE,SCCONS,SCEST
+7 ;
+8 SET SCCONS("SRCE")="SD TO PCE DB CONV"
+9 SET SCCONS("PKG")=$ORDER(^DIC(9.4,"C","SD",0))
+10 ;
+11 ;Set up the array for extracting a default disp clinic for the division
+12 IF '$DATA(SCCVDIS)
Begin DoDot:1
+13 NEW SCCL,SCDIV,Z
+14 SET Z=0
FOR
SET Z=$ORDER(^PX(815,1,"DHL",Z))
IF 'Z
QUIT
SET SCCL=+$GET(^(Z,0))
SET SCDIV=$PIECE($GET(^SC(SCCL,0)),U,15)
IF SCDIV
IF '$DATA(SCCVDIS(SCDIV))
SET SCCVDIS(SCDIV)=SCCL
+15 ; Default (0) is used if division does not have a valid disp clinic
+16 SET SCCVDIS(0)=+$PIECE($GET(^SD(404.91,1,"CNV")),U,2)
End DoDot:1
+17 ;
+18 ; Check if disposition should be processed
+19 IF '$$CON(SCCVEVT,DFN,SCDTM,.SCCVDIS)
GOTO ENQ
+20 ;
+21 ; Set-up conversion array and variables
+22 DO SET^SCCVEDI3(SCCVEVT,+$GET(SCLOG),DFN,.SCOE,.SCCV)
+23 ;
+24 IF 'SCCVEVT
IF $GET(SCCV("ERR"))
GOTO ENQ
+25 ;
+26 ; Don't process no new enctr or visit needed & no error to log
+27 IF '$GET(SCCV("NEW"))
IF '$DATA(SCCV("ERR"))
GOTO ENQ
+28 ;
+29 ; Increment number of dispositions found (estimating only)
+30 IF 'SCCVEVT
DO INCRTOT^SCCVEGU1(.SCTOT,5,1)
DO EN^SCCVZZ("DIS-5",SCOE,SCDTM)
+31 ;
+32 ; Log error if no encounter or no visit - exit if no encounter
+33 IF SCCVEVT
IF $SELECT('$GET(SCOE):1,1:'$PIECE($GET(SCCV("OE",0)),U,5))
Begin DoDot:1
+34 NEW SCE,SCERRIP,Y
+35 SET SCERRIP(1)=$PIECE($GET(^DPT(DFN,0)),U)
+36 SET Y=SCDTM
DO D^DIQ
SET SCERRIP(2)=Y
+37 SET SCERRIP(5)=$$OTHERR^SCCVU2($GET(SCCV("ERR")))
+38 SET SCERRIP(4)=$SELECT('$GET(SCOE):"Outpatient encounter",1:"Visit")
+39 SET SCE("DFN")=DFN
SET SCE("ENC")=$GET(SCOE)
SET SCE("VSIT")=""
SET SCE("DATE")=SCDTM
+40 DO GETERR^SCCVLOG1(4049005.003,.SCE,.SCERRIP,$GET(SCLOG),0,.SCERRMSG)
+41 IF $GET(SCOE)
SET ^XTMP("SCCV-ERR-"_+SCLOG,"NO-VIS",SCOE)=""
+42 SET SCTOT(2.06)=$GET(SCTOT(2.06))+1
End DoDot:1
IF '$GET(SCOE)
GOTO ENQ
+43 ;
+44 IF $GET(SCCV("ERR"))
GOTO ENQ
+45 ;
+46 ; Convert additional disposition data
+47 IF SCCVEVT
DO ENC(SCOE,.SCCV)
+48 ;
+49 ; Convert children
+50 DO CHLD^SCCVEAP2(SCOE,.SCCV,$GET(SCLOG))
+51 ;
+52 ; Invoke DATA-TO-PCE call, store any errors
+53 IF $SELECT('SCCVEVT:1,1:$PIECE($GET(^SCE(SCOE,0)),U,5))
DO DATA2PCE^SCCVPCE(SCOE,.SCCONS,SCCVEVT,$GET(SCOEP),"","",.SCEST)
+54 ;
+55 ;Estimate exits here
IF 'SCCVEVT
Begin DoDot:1
+56 FOR Z=1:1:3
IF $PIECE(SCEST,U,Z)
DO INCRTOT^SCCVEGU1(.SCTOT,Z+8,$PIECE(SCEST,U,Z))
DO EN^SCCVZZ("DIS-"_(Z+8),SCOE,SCDTM,"","",$PIECE(SCEST,U,Z))
End DoDot:1
GOTO ENQ
+57 ;
+58 ; Update disposition as converted
+59 DO DONE(DFN,SCDTM,1)
+60 ;
+61 ; Update last entry and number of records
+62 IF $GET(SCLOG)
DO UPDREC^SCCVLOG(SCLOG,SCOE,"CST")
+63 IF '$GET(SCLOG)
SET SCTOT("OK")=1
+64 ;
ENQ QUIT
+1 ;
ENC(SCOE,SCCV) ; Convert additional disposition data for the encounter
+1 ; $$GETDISP^SDVIST2 creates the encounter and seeds it with disp data
+2 ; Input -- SCOE Outpatient encounter IEN
+3 ; SCCV Conversion array
+4 ; Output -- None
+5 NEW SCDATA
+6 ; visit file entry
IF $GET(SCCV("VST"))
IF '$PIECE($GET(^SCE(SCOE,0)),U,5)
SET SCDATA(.05)=SCCV("VST")
+7 ; created by conversion
IF $GET(SCCV("NEW"))=1
SET SCDATA(901)=1
+8 IF $GET(SCCV("VST"))
DO ENCCNV^SCCVEAP1(.SCDATA)
+9 IF $DATA(SCDATA)
DO UPD^SCCVDBU(409.68,SCOE,.SCDATA)
+10 ;
ENCQ QUIT
+1 ;
DONE(DFN,SCDTM,SCECSTAT) ; Update disposition encounter conversion status
+1 ; Input -- DFN Patient IEN
+2 ; SCDTM Visit date/time
+3 ; SCECSTAT Encounter conversion status
+4 ; Output -- None
+5 NEW SCDATA,SCIENS
+6 SET SCIENS=(9999999-SCDTM)_","_DFN
+7 ; encounter conversion status
IF '$PIECE($GET(^DPT(DFN,"DIS",+SCIENS,0)),U,19)
SET SCDATA(19)=SCECSTAT
+8 IF $DATA(SCDATA)
DO UPD^SCCVDBU(2.101,SCIENS,.SCDATA)
+9 QUIT
+10 ;