1 | VAFCCCAP ;ALB/CMM/PKE/PHH/EG/GAH OUTPATIENT CAPTURE TEST ; 5/5/05 9:04am
|
---|
2 | ;;5.3;Registration;**91,179,553,582,568,585,662,725,744**;Jun 06, 1996;Build 5
|
---|
3 | ;
|
---|
4 | ;
|
---|
5 | CAP ;Only fire if check-in,check-out, add/edit add, add/edit change
|
---|
6 | I ($G(SDAMEVT)<4)!($G(SDAMEVT)>7) Q
|
---|
7 | ;quit if no change
|
---|
8 | I +$G(SDATA("BEFORE","STATUS"))=3,+$G(SDATA("AFTER","STATUS"))=3
|
---|
9 | IF I $P($G(SDATA("AFTER","STATUS")),"^",3)'="ACTION REQ/CHECKED IN"
|
---|
10 | IF I $P($G(SDATA("BEFORE","STATUS")),"^",3)'="NO ACTION TAKEN/TODAY" Q
|
---|
11 | ;check to see if sending is on or off
|
---|
12 | I '$P($$SEND^VAFHUTL(),"^",2) Q
|
---|
13 | ;check if protocol disabled or no clients
|
---|
14 | I $$PROTOCHK("VAFC ADT-A08-SDAM SERVER") Q
|
---|
15 | ;Queue to run NOW, returns control back to outpatient event driver
|
---|
16 | S ZTRTN="EN^VAFCCCAP",ZTDESC="PIMS Outpatient HL7 v2.3 Capture"
|
---|
17 | S ZTSAVE("SDHDL")="",ZTSAVE("SDAMEVT")="",ZTSAVE("SDATA")="",ZTSAVE("^TMP(""SDEVT"",$J,")="",ZTIO="",ZTDTH=$H
|
---|
18 | D ^%ZTLOAD
|
---|
19 | ;W !?3,$G(ZTSK)
|
---|
20 | Q
|
---|
21 | ;
|
---|
22 | EN ;
|
---|
23 | N DFN,HLD,EVDT,CHK,ERR,SEND,NEW,EVENT,HOSP,THLD,PTR,REM,HPTR
|
---|
24 | ;
|
---|
25 | ;Appointments
|
---|
26 | ;
|
---|
27 | I SDAMEVT=4!(SDAMEVT=5) D
|
---|
28 | .S DFN=$P(SDATA,"^",2),EVDT=$P(SDATA,"^",3),PTR=$$GETPTR^VAFHCUTL(1),PTR=PTR_";SCE(",(CHK,UP,REM)=""
|
---|
29 | .I SDAMEVT=4 S PTR=DFN_";DPT(" ;check-in or unscheduled visit check-in
|
---|
30 | .;Need to check if deleting check-out
|
---|
31 | .;if deleting check-out and no pivot file entry exists don't send
|
---|
32 | .I +$G(SDATA("AFTER","STATUS"))=3&(+$G(SDATA("BEFORE","STATUS"))=2) S CHK=$$PIVCHK^VAFHPIVT(DFN,EVDT,2,PTR),PTR=$$UPPTR(DFN,EVDT) S:PTR="@" REM=1 S:+CHK>0 UP=$$UPDATE^VAFHUTL(+CHK,EVDT,PTR,REM) S:+CHK<0!(+UP<0) SEND="N"
|
---|
33 | .;set send to N if deleting and not in pivot file
|
---|
34 | .I '$D(SEND) D
|
---|
35 | ..S HLD=$$PIVCHK^VAFHPIVT(DFN,EVDT,2,PTR)
|
---|
36 | ..I +HLD=-1 S HPTR=DFN_";DPT(",HLD=$$PIVCHK^VAFHPIVT(DFN,EVDT,2,HPTR) I +HLD'=-1 S UP=$$UPDATE^VAFHUTL(+HLD,EVDT,PTR,"")
|
---|
37 | ..I +HLD=-1 S HLD=$$PIVNW^VAFHPIVT(DFN,EVDT,2,PTR)
|
---|
38 | ..;S EVENT=$P(HLD,":"),ERR=$$OA08^VAFHCA08(DFN,EVENT,EVDT,PTR,"2,3,4,5,6,7,8,9,11,12,13,14,16,19","2,3,4,5,6,7,8,9,10,11,12,13,14,15","A","A")
|
---|
39 | ..;set up call to vafcmsg for out-patient
|
---|
40 | ..I +HLD=-1 S ERR=HLD
|
---|
41 | ..S EVENT=$P(HLD,":")
|
---|
42 | ..I EVENT>0 D SETUP
|
---|
43 | ;
|
---|
44 | ;Stop codes, Add/Edits
|
---|
45 | I SDAMEVT=6!(SDAMEVT=7) D
|
---|
46 | .N HLD,STOP,THLD,REMOVE,UP
|
---|
47 | .S HLD="",STOP="N",ERR=""
|
---|
48 | .F K EVENT S REMOVE="N",HLD=$O(^TMP("SDEVT",$J,SDHDL,2,"SDOE",HLD)) Q:HLD=""!(STOP="Y") D
|
---|
49 | ..I ^TMP("SDEVT",$J,SDHDL,2,"SDOE",HLD,0,"AFTER")'=""&($P(^TMP("SDEVT",$J,SDHDL,2,"SDOE",HLD,0,"AFTER"),"^",6)'="") S STOP="Y" Q
|
---|
50 | ..;If STOP="Y" stop code was not stand alone
|
---|
51 | ..;If STOP="N" stop code is stand alone
|
---|
52 | ..I ^TMP("SDEVT",$J,SDHDL,2,"SDOE",HLD,0,"AFTER")="" D
|
---|
53 | ...S REMOVE="Y",DFN=$P(^TMP("SDEVT",$J,SDHDL,2,"SDOE",HLD,0,"BEFORE"),"^",2),EVDT=$P(^TMP("SDEVT",$J,SDHDL,2,"SDOE",HLD,0,"BEFORE"),"^"),PTR=HLD_";SCE("
|
---|
54 | ...S EVENT=$$PIVCHK^VAFHPIVT(DFN,EVDT,2,PTR)
|
---|
55 | ..I ^TMP("SDEVT",$J,SDHDL,2,"SDOE",HLD,0,"AFTER")'="" D
|
---|
56 | ...S DFN=$P(^TMP("SDEVT",$J,SDHDL,2,"SDOE",HLD,0,"AFTER"),"^",2),EVDT=$P(^TMP("SDEVT",$J,SDHDL,2,"SDOE",HLD,0,"AFTER"),"^"),PTR=HLD_";SCE("
|
---|
57 | ..I '$D(EVENT) S THLD=$$PIVNW^VAFHPIVT(DFN,EVDT,2,PTR),EVENT=$P(THLD,":")
|
---|
58 | ..I +$G(THLD)=-1 S ERR=THLD
|
---|
59 | ..I REMOVE="Y" S PTR="@",UP=$$UPDATE^VAFHUTL(+EVENT,EVDT,PTR,1)
|
---|
60 | ..;I +EVENT>0 S ERR=$$OA08^VAFHCA08(DFN,EVENT,EVDT,PTR,"2,3,4,5,6,7,8,9,11,12,13,14,16,19","2,3,4,5,6,7,8,9,10,11,12,13,14,15","A","A")
|
---|
61 | ..;set up call to vafcmsg for out-patient
|
---|
62 | ..I +EVENT>0 D SETUP
|
---|
63 | ;
|
---|
64 | EXIT ;
|
---|
65 | I $D(ZTQUEUED) S ZTREQ="@"
|
---|
66 | I +ERR<0 D ERROR(ERR,DFN)
|
---|
67 | D KILL^HLTRANS
|
---|
68 | Q
|
---|
69 | ;
|
---|
70 | ERROR(PNUM,DFN) ;
|
---|
71 | ;Error message unable to generate A08 Message
|
---|
72 | N GBL S GBL="^TMP($J,""ERR"")"
|
---|
73 | I +PNUM<0 S @GBL@(0)="ERROR",@GBL@(1)=$P(PNUM,"^",2)_", unable to generate A08 Message" D EBULL^VAFHUTL2(DFN,EVDT,"",$P(GBL,")")_",")
|
---|
74 | Q
|
---|
75 | ;
|
---|
76 | UPPTR(DFN,ADATE) ;
|
---|
77 | ;Have deleted checkout, update variable pointer
|
---|
78 | N PTR S PTR="@"
|
---|
79 | N DGARRAY,DGCOUNT,SDDATE
|
---|
80 | S DGARRAY(4)=DFN,DGARRAY(1)=ADATE_";"_ADATE,DGARRAY("FLDS")=3,DGARRAY("SORT")="P"
|
---|
81 | S DGCOUNT=$$SDAPI^SDAMA301(.DGARRAY)
|
---|
82 | ;
|
---|
83 | I DGCOUNT>0 D
|
---|
84 | .S SDDATE=0
|
---|
85 | .F S SDDATE=$O(^TMP($J,"SDAMA301",DFN,SDDATE)) Q:'SDDATE D
|
---|
86 | ..I SDDATE=ADATE S PTR=DFN_";DPT("
|
---|
87 | I DGCOUNT'=0 K ^TMP($J,"SDAMA301")
|
---|
88 | Q PTR
|
---|
89 | ;
|
---|
90 | SETUP ;
|
---|
91 | N PIVOTPTR
|
---|
92 | ;S EVENT=$P(HLD,":")
|
---|
93 | S EVNTINFO="^TMP(""VAFCMSG"",""EVNTINFO"","_$J_")"
|
---|
94 | K @EVNTINFO
|
---|
95 | S PIVOTPTR=+$O(^VAT(391.71,"D",+EVENT,0))
|
---|
96 | I ('PIVOTPTR) S ERR="-1^Unable to create entry in ADT/HL7 PIVOT FILE" Q
|
---|
97 | S @EVNTINFO@("PIVOT")=PIVOTPTR
|
---|
98 | S @EVNTINFO@("SERVER PROTOCOL")="VAFC ADT-A08-SDAM SERVER"
|
---|
99 | S @EVNTINFO@("VAR-PTR")=PTR
|
---|
100 | S @EVNTINFO@("EVENT-NUM")=EVENT
|
---|
101 | S ERR=$$BCSTADT^VAFCMSG0(DFN,"A08",EVDT,EVNTINFO)
|
---|
102 | K @EVNTINFO
|
---|
103 | Q
|
---|
104 | PROTOCHK(SPROTO) ;
|
---|
105 | ; input server protocol
|
---|
106 | ;output 1 if disabled or has no clients
|
---|
107 | N HL
|
---|
108 | D INIT^HLFNC2(SPROTO,.HL,1)
|
---|
109 | K HLQ,HLECH,HLFS
|
---|
110 | Q $D(HL)#2
|
---|