Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SCCVEAP2

SCCVEAP2.m

Go to the documentation of this file.
  1. SCCVEAP2 ;ALB/RMO,TMP - Appointment Conversion cont.; [ 04/05/95 10:19 AM ]
  1. ;;5.3;Scheduling;**211**;Aug 13, 1993
  1. ;
  1. VISIT(SCDTM,SCCV) ;Create visit when encounter already exists
  1. ; Input -- SCDTM Appointment date/time
  1. ; SCCV Conversion array
  1. ; Output -- Visit file IEN
  1. N SCVSIT,SCDATA,SCCVT,SCOE
  1. IF '$G(SCCV("OE",0)) G VISITQ
  1. S SCOE=$G(SCCV("OE"))
  1. S SCVSIT("DFN")=$P(SCCV("OE",0),U,2)
  1. IF 'SCVSIT("DFN") G VISITQ
  1. ;
  1. S SCVSIT("CLN")=$S('$G(SCCV("CSC")):$P(SCCV("OE",0),U,3),1:SCCV("CSC"))
  1. ;
  1. S SCVSIT("DIV")=$P(SCCV("OE",0),U,11)
  1. S SCVSIT("ELG")=$P(SCCV("OE",0),U,13)
  1. S SCVSIT("LOC")=$P(SCCV("OE",0),U,4)
  1. S SCVSIT("TYP")=$P(SCCV("OE",0),U,10)
  1. S SCVSIT("STA")=$P(SCCV("OE",0),U,12)
  1. S SCVSIT("ORG")=$G(SCCV("ORG"))
  1. ;
  1. D SETSCCVT(.SCCVT,.SCCONS)
  1. IF $G(SCCV("PAR")) S SCVSIT("PAR")=SCCV("PAR")
  1. ;
  1. ; -- use parent's visit if a/e, location same, clinic stop same
  1. IF $G(SCVSIT("PAR")),SCVSIT("ORG")=2 D
  1. . N SCOEP0
  1. . S SCOEP0=$G(^SCE(SCVSIT("PAR"),0))
  1. . IF $P(SCOEP0,U,5),SCVSIT("LOC")=$P(SCOEP0,U,4),SCVSIT("CLN")=$P(SCOEP0,U,3) S SCVSIT("VST")=$P(SCOEP0,U,5)
  1. ;
  1. IF '$G(SCVSIT("VST")) D VISIT^SDVSIT0(SCDTM,.SCVSIT)
  1. ;
  1. IF $G(SCVSIT("VST")) S SCTOT(1.02)=$G(SCTOT(1.02))+1
  1. ;
  1. IF $G(SCVSIT("VST")),'$P(SCCV("OE",0),U,5) D
  1. . ; -- fix invalid date/time of a/e to sync w/visit
  1. . IF SCVSIT("ORG")=2,+SCCV("OE",0)'=SCDTM S SCDATA(.01)=SCDTM
  1. . S SCDATA(.05)=SCVSIT("VST")
  1. . D UPD^SCCVDBU(409.68,SCOE,.SCDATA)
  1. ;
  1. S SCCV("OE",0)=$G(^SCE(SCOE,0))
  1. S SCCV("VST")=$G(SCVSIT("VST"))
  1. ;
  1. VISITQ Q $G(SCVSIT("VST"))
  1. ;
  1. ANC(SCOEP,DFN,SCDTM,SCCLN,SCCV,SCLOG) ;Create stp code enctr/visit for ancillary tests
  1. ; Input -- SCOEP Parent encounter (if known)
  1. ; DFN Patient IEN
  1. ; SCDTM Appointment date/time
  1. ; SCCLN Clinic IEN
  1. ; SCCV Conversion array
  1. ; SCLOG Scheduling conversion log IEN [optional]
  1. ; Output -- None
  1. N SCANC,SCOE,SCSCD,SCSCDI,SCVSIT,SCT,SCADD
  1. I $G(SCCV("PT",0))=""!$S(SCCV("EVT"):$G(SCCV("OE",0))="",1:0) G ANCQ
  1. I $P(SCCV("PT",0),U,3)'="" S SCANC(108)=$P(SCCV("PT",0),U,3) ; lab
  1. I $P(SCCV("PT",0),U,4)'="" S SCANC(105)=$P(SCCV("PT",0),U,4) ; x-ray
  1. I $P(SCCV("PT",0),U,5)'="" S SCANC(107)=$P(SCCV("PT",0),U,5) ; ekg
  1. S SCSCD=""
  1. F S SCSCD=$O(SCANC(SCSCD)) Q:'SCSCD D
  1. . S SCSCDI=+$O(^DIC(40.7,"C",SCSCD,0))
  1. . ;
  1. . S SCADD=$$CHK(DFN,SCDTM,SCCLN,.SCCV,SCSCDI,.SCOE)
  1. . I SCADD D
  1. . . ;Increment number of ancillaries found (estimating only)
  1. . . S SCVSIT("DFN")=DFN
  1. . . I 'SCCVEVT D Q
  1. . . . F SCT=2,SCADD+6 D
  1. . . . . N DFN
  1. . . . . D INCRTOT^SCCVEGU1(.SCTOT,SCT,1),EN^SCCVZZ("AE-"_SCT,SCOE,SCANC(SCSCD),$P($G(SCCV("PT",0)),U),+$G(SCOEP),SCVSIT("DFN"))
  1. . . ;
  1. . . I SCADD=1 D
  1. . . . S SCVSIT("CLN")=SCSCDI
  1. . . . S SCVSIT("DIV")=$P(SCCV("OE",0),U,11)
  1. . . . S SCVSIT("ELG")=$P(SCCV("OE",0),U,13)
  1. . . . S SCVSIT("LOC")=SCCLN
  1. . . . S SCVSIT("TYP")=$P(SCCV("OE",0),U,10)
  1. . . . S SCVSIT("PAR")=$G(SCOEP)
  1. . . . S SCVSIT("ORG")=2,SCVSIT("REF")=""
  1. . . . D SETSCCVT(.SCCVT,.SCCONS)
  1. . . . S SCOE=$$SDOE^SDVSIT(SCANC(SCSCD),.SCVSIT,"",$G(SCOEP))
  1. . . . I '$G(SCVSIT("VST")) D Q
  1. . . . . D CREATERR^SCCVLOG1(DFN,SCDTM,SCOE,2,SCCLN,SCSCD,$G(SCLOG))
  1. . . . . S:$G(SCOE) ^XTMP("SCCV-ERR-"_+SCLOG,"NO-VIS",SCOE)=""
  1. . . . . S SCTOT(2.06)=$G(SCTOT(2.06))+1
  1. . . . Q:'SCOE
  1. . . . S SCTOT(1.02)=$G(SCTOT(1.02))+1
  1. . . . N SCCVX
  1. . . . S SCCVX("HIST")=0
  1. . . . S SCCVX("NEW")=1
  1. . . . D ENC^SCCVEAP1(SCOE,.SCCVX)
  1. . . ;
  1. . . I SCADD=2,SCOE D
  1. . . . N SCCVX,SCCVY
  1. . . . S SCCVY("OE")=SCOE
  1. . . . S SCCVY("OE",0)=$G(^SCE(SCOE,0))
  1. . . . S SCCVY("PAR")=$P(SCCVY("OE",0),U,6)
  1. . . . S SCCVY("ORG")=2
  1. . . . S SCVSIT("VST")=$$VISIT(+SCCVY("OE",0),.SCCVY) ; create visit
  1. . . . I 'SCVSIT("VST") D Q
  1. . . . . D CREATERR^SCCVLOG1(DFN,+SCCVY("OE",0),SCOE,2,$P(SCCVY("OE",0),U,4),SCSCD,$G(SCLOG))
  1. . . . . S ^XTMP("SCCV-ERR-"_+SCLOG,"NO-VIS",SCOE)=""
  1. . . . . S SCTOT(2.06)=$G(SCTOT(2.06))+1
  1. . . . N SCCVX
  1. . . . S SCCVX("VST")=SCVSIT("VST") D ENC^SCCVEAP1(SCOE,.SCCVX)
  1. ;
  1. ANCQ Q
  1. ;
  1. CHK(DFN,SCDTM,SCCLN,SCCV,SCSCDI,SCOE) ;Check if stop code should be added for ancillary test
  1. ; Input -- DFN Patient IEN
  1. ; SCDTM Appointment date/time
  1. ; SCCLN Clinic IEN
  1. ; SCCV Conversion array
  1. ; SCSCDI Clinic Stop Code IEN
  1. ; Output -- 1=Add enctr and visit 2=Add only visit and 0=No,don't add
  1. ; SCOE IEN of the encounter for the anc test
  1. N Y,SCAEDTM,SCDA,SCOEC,SCOE00,SDQ
  1. S Y=1,SCOE=""
  1. ;
  1. I $P($G(^SC(SCCLN,0)),U,17)="Y" S Y=0 G CHKQ ; non-count clinic
  1. ;
  1. ; The following line is commented out because although it would be a valid check, it is much too tight and thus inconsistent with the rest of the conversion
  1. ;I $$REQ^SDM1A(SCDTM)="CO",'$P($G(SCCV("PT",0)),U,7) S Y=0 G CHKQ ; check out required but no checkout date, don't process
  1. ;
  1. S (SCOEC,SDQ)=0
  1. F S SCOEC=$O(^SCE("APAR",+$G(SCOEP),SCOEC)) Q:'SCOEC D Q:SDQ
  1. . S SCOE00=$G(^SCE(SCOEC,0))
  1. . I $P(SCOE00,U,3)=SCSCDI D
  1. . . S SDQ=1
  1. . . I 'SCCVEVT,$P(SCOE00,U,8)=2 S Y=0 Q ;Will be counted with add/edits
  1. . . I SCCVEVT<2 D Q ;Estimate/convert
  1. . . . I $P(SCOE00,U,5) S Y=0 Q ;Already added
  1. . . . S Y=2,SCOE=SCOEC ;Add visit only
  1. . . I SCCVEVT=2 D Q ;Re-convert
  1. . . . D RECNVT^SCCVEAP3(SCOEC,SCOE00,.SCCONS)
  1. . . . I $D(^SCE(SCOEC,0)) S Y=2,SCOE=SCOEC Q ;Re-add visit only
  1. . . . S Y=1 ;Re-add visit and encounter
  1. ;
  1. CHKQ Q $G(Y)
  1. ;
  1. CHLD(SCOEP,SCCV,SCLOG) ;Convert children
  1. ; Input -- SCOEP Parent outpatient encounter IEN
  1. ; SCCV Conversion array
  1. ; SCLOG Scheduling conversion log IEN [optional]
  1. ; Output -- None
  1. N SCERRMSG,SCOE0,SCOEC,SCX,SDVIEN
  1. S SCOEC=0
  1. F S SCOEC=$O(^SCE("APAR",SCOEP,SCOEC)) Q:'SCOEC D
  1. . S SCOE0=$G(^SCE(SCOEC,0))
  1. . S SDVIEN=$$SDVIEN^SCCVU(+$P(SCOE0,U,2),+SCOE0)
  1. . I 'SCCV("EVT"),$P(SCOE0,U,9) D Q:'SCX
  1. . . F SCX=1:1:$L($P(SCOE0,U,9),":") I $P($G(^SDV(SDVIEN,"CS",+$P($P(SCOE0,U,9),":",SCX),0)),U,8)=SCOEC S SCX=0 Q ;When estimating, these should be counted in the add/edit loop
  1. . I $P(SCOE0,U,8)=2,$P(SCOE0,U,9),'$P(SCOE0,U,5) D ;convert child add/edit
  1. . . ;There should be only 1 ":" piece before 10/1/96, but this was
  1. . . ; included in the case of bad data
  1. . . F SCX=1:1:$L($P(SCOE0,U,9),":") D EN^SCCVEAE1(SCCV("EVT"),SDVIEN,+$P($P(SCOE0,U,9),":",SCX),SCOEP,$G(SCLOG))
  1. Q
  1. ;
  1. SETSCCVT(SCCVT,SCCONS) ; Set the SCCVT array for source and service type
  1. S SCCVT("SOR")=SCCONS("SRCE")
  1. S SCCVT("SVC")="E"
  1. I $G(SCCV("ORG"))=3,$G(SCCV("LOC")) S SCCVT("LOC")=SCCV("LOC")
  1. Q
  1. ;