| 1 | SCCVU ;ALB/RMO,TMP - Encounter Conversion Utilities; [ 08/02/95  10:15 AM ]
 | 
|---|
| 2 |  ;;5.3;Scheduling;**211**;Aug 13, 1993
 | 
|---|
| 3 |  ;
 | 
|---|
| 4 | INACT(SCDT) ; -- Check if encounter is "inactive"
 | 
|---|
| 5 |  ;An inactive encounter is "an encounter which occurred prior
 | 
|---|
| 6 |  ;to the beginning of the last fiscal year" 
 | 
|---|
| 7 |  ; Input  -- SCDT     Date
 | 
|---|
| 8 |  ; Output -- 1=Yes and 0=No
 | 
|---|
| 9 |  N X,X1,X2
 | 
|---|
| 10 |  S X1=($E(DT,1,3)-$S($E(DT,4,5)>9:1,1:2))_"1001",X2=-1 D C^%DTC
 | 
|---|
| 11 |  Q $S(SCDT>X:0,1:1)
 | 
|---|
| 12 |  ;
 | 
|---|
| 13 | CON(SCOE) ; -- Check if encounter has already been converted
 | 
|---|
| 14 |  ; Input  -- SCOE     Outpatient encounter IEN
 | 
|---|
| 15 |  ; Output -- 1=Yes and 0=No
 | 
|---|
| 16 |  N SCOE0,SCORG,Y
 | 
|---|
| 17 |  S SCOE0=$G(^SCE(+SCOE,0)),SCORG=+$P(SCOE0,U,8)
 | 
|---|
| 18 |  I SCORG=1 D  ;appointment
 | 
|---|
| 19 |  . S Y=+$P($G(^DPT(+$P(SCOE0,U,2),"S",+SCOE0,0)),U,23)
 | 
|---|
| 20 |  I SCORG=2 D  ;add/edit
 | 
|---|
| 21 |  . S Y=+$P($G(^SDV($$SDVIEN(+$P(SCOE0,U,2),+SCOE0),"CS",+$P(SCOE0,U,9),0)),U,9)
 | 
|---|
| 22 |  I SCORG=3 D  ;disposition
 | 
|---|
| 23 |  . S Y=+$P($G(^DPT(+$P(SCOE0,U,2),"DIS",9999999-SCOE0,0)),U,19)
 | 
|---|
| 24 |  Q +$G(Y)
 | 
|---|
| 25 |  ;
 | 
|---|
| 26 | PAUSE ;
 | 
|---|
| 27 |  N DIR
 | 
|---|
| 28 |  W ! S DIR(0)="E",DIR("A")="Press Return to Continue" D ^DIR K DIR W !
 | 
|---|
| 29 |  Q
 | 
|---|
| 30 |  ;
 | 
|---|
| 31 | CCREATE(SCOE) ; Check if encounter or its visit was created by the conversion
 | 
|---|
| 32 |  ;  routines
 | 
|---|
| 33 |  ; SCOE = ien of the encounter
 | 
|---|
| 34 |  ; RETURNS: 
 | 
|---|
| 35 |  ;     0 if neither the encounter nor the visit were created by the
 | 
|---|
| 36 |  ;       conversion
 | 
|---|
| 37 |  ;     1 if the encounter and visit were created by the conversion
 | 
|---|
| 38 |  ;     2 if the visit only was created by the conversion
 | 
|---|
| 39 |  ;
 | 
|---|
| 40 |  N SCCVNV,STAT
 | 
|---|
| 41 |  ;
 | 
|---|
| 42 |  S STAT=0
 | 
|---|
| 43 |  ; In encounter, if conversion completed flag is set, the visit had to
 | 
|---|
| 44 |  ;  have been created by the conversion routines
 | 
|---|
| 45 |  S SCCVNV=$G(^SCE(SCOE,"CNV"))
 | 
|---|
| 46 |  I +SCCVNV,$P(SCCVNV,U,4) S STAT=1 ; encounter created and completed
 | 
|---|
| 47 |  I 'SCCVNV,$P(SCCVNV,U,4) S STAT=2 ; encounter not created, but completed
 | 
|---|
| 48 |  Q STAT
 | 
|---|
| 49 |  ;
 | 
|---|
| 50 | OK(SCMODE) ; -- is it ok to allow conversion and re-conversion (for testing)
 | 
|---|
| 51 |  ;  input:      SCMODE := 1 - interactive | 0 - silent
 | 
|---|
| 52 |  ;
 | 
|---|
| 53 |  N SCOK
 | 
|---|
| 54 |  S SCOK=1  ; <<-- set this flag to 1 allow all functionality, 0 otherwise
 | 
|---|
| 55 |  IF SCMODE,SCOK=0 D
 | 
|---|
| 56 |  . W !!,"Conversion functionality is disabled." D PAUSE
 | 
|---|
| 57 |  Q +$G(SCOK)
 | 
|---|
| 58 |  ;
 | 
|---|
| 59 | SDVIEN(DFN,DATE) ; -- get sdv ien for patient/date-time
 | 
|---|
| 60 |  Q +$G(^SDV("ADT",+DFN,+$P(DATE,".")))
 | 
|---|
| 61 |  ;
 | 
|---|
| 62 | ENDDATE() ; -- conversion end date
 | 
|---|
| 63 |  N Y
 | 
|---|
| 64 |  S Y=$$FMDATE^SCDXUTL()
 | 
|---|
| 65 |  IF Y S Y=$$FMADD^XLFDT(Y,-1)
 | 
|---|
| 66 |  IF 'Y S Y=2960930
 | 
|---|
| 67 |  Q Y
 | 
|---|
| 68 |  ;
 | 
|---|