[613] | 1 | VSITSTAT ;ISL/PKR - Visit Tracking in/out patient Update Protocol for ADT ;4/23/97
|
---|
| 2 | ;;1.0;PCE PATIENT CARE ENCOUNTER;**76**;Aug 12, 1996
|
---|
| 3 | ; Patch PX*1*76 changes the 2nd line of all VSIT* routines to reflect
|
---|
| 4 | ; the incorporation of the module into PCE. For historical reference,
|
---|
| 5 | ; the old (VISIT TRACKING) 2nd line is included below to reference VSIT
|
---|
| 6 | ; patches.
|
---|
| 7 | ;
|
---|
| 8 | ;;2.0;VISIT TRACKING;**2**;Aug 12, 1996
|
---|
| 9 | ;
|
---|
| 10 | EN ;Main entry point called by ADT event driver, process adm and d/c only.
|
---|
| 11 | I '$D(^UTILITY("DGPM",$J,1))&'$D(^UTILITY("DGPM",$J,3)) G ENQ
|
---|
| 12 | W:'$G(DGQUIET) !!,"Updating visit status..."
|
---|
| 13 | ;
|
---|
| 14 | N MAXDATE,TOFFSET
|
---|
| 15 | S MAXDATE=9999999
|
---|
| 16 | S TOFFSET=.0000001
|
---|
| 17 | ;
|
---|
| 18 | ;Build a time ordered list of visits for this patient.
|
---|
| 19 | N DATE,TIME,VDT,VIEN
|
---|
| 20 | S VDT=""
|
---|
| 21 | F S VDT=$O(^AUPNVSIT("AA",DFN,VDT)) Q:'VDT D
|
---|
| 22 | . S VIEN="",VIEN=$O(^AUPNVSIT("AA",DFN,VDT,VIEN))
|
---|
| 23 | . S DATE=$P(VDT,".",1)
|
---|
| 24 | . S TIME=VDT-DATE
|
---|
| 25 | . S DATE=MAXDATE-DATE+TIME
|
---|
| 26 | . S ^TMP("VSITSTAT",$J,DFN,DATE,VIEN)=""
|
---|
| 27 | ;
|
---|
| 28 | ;Try to get information for the complete movement.
|
---|
| 29 | S VAIP("E")=DGPMDA
|
---|
| 30 | D IN5^VADPT
|
---|
| 31 | ;
|
---|
| 32 | ;Setup the admission information.
|
---|
| 33 | N ADMA,ADMIT
|
---|
| 34 | S ADMIT=$$ADMISSIO(.ADMA)
|
---|
| 35 | ;
|
---|
| 36 | ;Setup the discharge information.
|
---|
| 37 | N DISA,DISCHG
|
---|
| 38 | S DISCHG=$$DISCHARG(.DISA)
|
---|
| 39 | ;
|
---|
| 40 | ;We must have a value either for the admission after or previous.
|
---|
| 41 | I (ADMA("A")="")&(ADMA("P")="") D Q
|
---|
| 42 | . W !,"VSITSTAT FATAL ERROR -- NO ADMISSION TIME"
|
---|
| 43 | ;
|
---|
| 44 | N IN,INOUT,OUT,SDBEG,SDEND
|
---|
| 45 | S IN=1,OUT=0
|
---|
| 46 | ;
|
---|
| 47 | ;General, this handles admission add and parts of admission change
|
---|
| 48 | ;delete change.
|
---|
| 49 | I (+ADMA("A")>0)&(ADMA("A")'=ADMA("P")) D
|
---|
| 50 | . S SDBEG=ADMA("A")-TOFFSET
|
---|
| 51 | . I DISCHG S SDEND=DISA("A")
|
---|
| 52 | . E S SDEND=MAXDATE
|
---|
| 53 | . S INOUT=IN
|
---|
| 54 | . D SCANUPD(SDBEG,SDEND,INOUT)
|
---|
| 55 | ;
|
---|
| 56 | ;Admission change. We only need to worry about a latter time. The
|
---|
| 57 | ;earlier case is entirely handled above.
|
---|
| 58 | I (+ADMA("P")>0)&(+ADMA("P")<+ADMA("A")) D
|
---|
| 59 | . S SDBEG=ADMA("P")
|
---|
| 60 | . S SDEND=ADMA("A")-TOFFSET
|
---|
| 61 | . S INOUT=OUT
|
---|
| 62 | . D SCANUPD(SDBEG,SDEND,INOUT)
|
---|
| 63 | ;
|
---|
| 64 | ;Admission delete.
|
---|
| 65 | I (+ADMA("P")>0)&(ADMA("A")="") D
|
---|
| 66 | . S SDBEG=ADMA("P")-TOFFSET
|
---|
| 67 | . I +DISA("P")>0 S SDEND=DISA("P")
|
---|
| 68 | . E S SDEND=MAXDATE
|
---|
| 69 | . S INOUT=OUT
|
---|
| 70 | . D SCANUPD(SDBEG,SDEND,INOUT)
|
---|
| 71 | ;
|
---|
| 72 | ;Discharge add.
|
---|
| 73 | I (ADMA("A")=ADMA("P"))&(+DISA("A")>0) D
|
---|
| 74 | . S SDBEG=DISA("A")+TOFFSET
|
---|
| 75 | . S SDEND=MAXDATE
|
---|
| 76 | . S INOUT=OUT
|
---|
| 77 | . D SCANUPD(SDBEG,SDEND,INOUT)
|
---|
| 78 | ;
|
---|
| 79 | ;Discharge change. We only need to worry about an earlier discharge
|
---|
| 80 | ;time.
|
---|
| 81 | I (+DISA("A")>0)&(+DISA("A")<+DISA("P")) D
|
---|
| 82 | . S SDBEG=DISA("A")+TOFFSET
|
---|
| 83 | . S SDEND=DISA("P")
|
---|
| 84 | . S INOUT=OUT
|
---|
| 85 | . D SCANUPD(SDBEG,SDEND,INOUT)
|
---|
| 86 | ;
|
---|
| 87 | ;Discharge delete.
|
---|
| 88 | I (ADMA("A")=ADMA("P"))&(+DISA("P")>0)&(DISA("A")="") D
|
---|
| 89 | . S SDBEG=ADMA("A")-TOFFSET
|
---|
| 90 | . S SDEND=DISA("P")
|
---|
| 91 | . S INOUT=IN
|
---|
| 92 | . D SCANUPD(SDBEG,SDEND,INOUT)
|
---|
| 93 | ;
|
---|
| 94 | W:'$G(DGQUIET) "completed."
|
---|
| 95 | ;
|
---|
| 96 | ENQ ;
|
---|
| 97 | K ^TMP("VSITSTAT",$J,DFN)
|
---|
| 98 | D KVA^VADPT
|
---|
| 99 | Q
|
---|
| 100 | ;
|
---|
| 101 | ;=======================================================================
|
---|
| 102 | ADMISSIO(ADMA) ;Return true if there is an admission.
|
---|
| 103 | ;
|
---|
| 104 | ;If the movement is just a change in discharge time UTILITY(...1,...)
|
---|
| 105 | ;will not exist.
|
---|
| 106 | N MVMNT
|
---|
| 107 | S MVMNT="",MVMNT=$O(^UTILITY("DGPM",$J,1,MVMNT))
|
---|
| 108 | I MVMNT D
|
---|
| 109 | . S ADMA("A")=$P($G(^UTILITY("DGPM",$J,1,MVMNT,"A")),U,1)
|
---|
| 110 | . S ADMA("P")=$P($G(^UTILITY("DGPM",$J,1,MVMNT,"P")),U,1)
|
---|
| 111 | E D
|
---|
| 112 | . S ADMA("A")=$P(VAIP(13,1),U,1)
|
---|
| 113 | . I VAIP(13)=DGPMDA S ADMA("P")=$P(DGPMP,U,1)
|
---|
| 114 | . E S ADMA("P")=""
|
---|
| 115 | Q 1
|
---|
| 116 | ;
|
---|
| 117 | ;=======================================================================
|
---|
| 118 | DISCHARG(DISA) ;Return true if there is a discharge.
|
---|
| 119 | N MVMNT,RETVAL
|
---|
| 120 | S MVMNT="",MVMNT=$O(^UTILITY("DGPM",$J,3,MVMNT))
|
---|
| 121 | I MVMNT D
|
---|
| 122 | . S DISA("A")=$P($G(^UTILITY("DGPM",$J,3,MVMNT,"A")),U,1)
|
---|
| 123 | . S DISA("P")=$P($G(^UTILITY("DGPM",$J,3,MVMNT,"P")),U,1)
|
---|
| 124 | E D
|
---|
| 125 | . S DISA("A")=$P(VAIP(17,1),U,1)
|
---|
| 126 | . I VAIP(17)=DGPMDA S DISA("P")=$P(DGPMP,U,1)
|
---|
| 127 | . E S DISA("P")=""
|
---|
| 128 | I DISA("A")>0 S RETVAL=1
|
---|
| 129 | E S RETVAL=0
|
---|
| 130 | Q RETVAL
|
---|
| 131 | ;
|
---|
| 132 | ;=======================================================================
|
---|
| 133 | SCANUPD(VSITBEG,VSITEND,INOUT) ;Scan range of visits and update
|
---|
| 134 | ; input:
|
---|
| 135 | ; VSITBEG := begin date
|
---|
| 136 | ; VSITEND := end date
|
---|
| 137 | ; INOUT := visit status
|
---|
| 138 | ;
|
---|
| 139 | N VSIT,VSITDT,VSITIEN
|
---|
| 140 | S VSITDT=VSITBEG
|
---|
| 141 | F S VSITDT=$O(^TMP("VSITSTAT",$J,DFN,VSITDT)) Q:('VSITDT)!(VSITDT>VSITEND) D
|
---|
| 142 | . S VSITIEN="",VSITIEN=$O(^TMP("VSITSTAT",$J,DFN,VSITDT,VSITIEN))
|
---|
| 143 | . S VSIT("IEN")=VSITIEN
|
---|
| 144 | . S VSIT("IO")=INOUT
|
---|
| 145 | . S VSIT("SVC")=$$UPDSCAT(VSITIEN,INOUT)
|
---|
| 146 | . D UPD^VSIT
|
---|
| 147 | ;
|
---|
| 148 | Q
|
---|
| 149 | ;=======================================================================
|
---|
| 150 | UPDSCAT(VSITIEN,INOUT) ;Set the Service Category for in or outpatient.
|
---|
| 151 | N CSC,NSC
|
---|
| 152 | S (CSC,NSC)=$P($G(^AUPNVSIT(VSITIEN,0)),U,7)
|
---|
| 153 | I (CSC="A")!(CSC="I") D
|
---|
| 154 | . I INOUT S NSC="I"
|
---|
| 155 | . E S NSC="A"
|
---|
| 156 | ;
|
---|
| 157 | I (CSC="D")!(CSC="X") D
|
---|
| 158 | . I INOUT S NSC="D"
|
---|
| 159 | . E S NSC="X"
|
---|
| 160 | ;
|
---|
| 161 | ;If the current Service Category was not A, I, D, or X return the original.
|
---|
| 162 | Q NSC
|
---|
| 163 | ;
|
---|