1 | VAFHCOPT ;ALB/CM/PKE/PHH/EG/GAH OUTPATIENT APPT (HL7 MESS) NIGHT JOB ; 10/18/06
|
---|
2 | ;;5.3;Registration;**91,568,585,725**;Aug 13, 1993;Build 12
|
---|
3 | ;
|
---|
4 | ;This routine will loop through the Hospital Location file "S" node
|
---|
5 | ;and generate an A08 message for all appointments for today
|
---|
6 | ;that have a status of "No action taken" or "Future"
|
---|
7 | ;
|
---|
8 | EN ;
|
---|
9 | ;Check to see if sending is on or off
|
---|
10 | N GO
|
---|
11 | S GO=$$SEND^VAFHUTL()
|
---|
12 | I GO=0 Q
|
---|
13 | ;
|
---|
14 | S ERRB="^TMP($J,""ADT-ERR""," K ^TMP($J,"ADT-ERR")
|
---|
15 | K HL D INIT^HLFNC2("VAFH A08",.HL)
|
---|
16 | I $D(HL)=1 S ERR="-1^"_HL QUIT
|
---|
17 | ;
|
---|
18 | N STAT,X1,X2
|
---|
19 | ;This job should be set to run after midnight daily.
|
---|
20 | D NOW^%DTC S START=X ;;;S START=2970101
|
---|
21 | S X1=START,X2=1 D C^%DTC S STOP=X K X1,X2,%H,X,%,%I
|
---|
22 | ;
|
---|
23 | S ENT=0,GBL="^TMP(""HLS"",$J)" K ^TMP("HLS",$J)
|
---|
24 | ;
|
---|
25 | N DGARRAY,DGCNT
|
---|
26 | F S ENT=$O(^SC(ENT)) Q:(ENT="")!(ENT'?.N) D
|
---|
27 | .S ENT1=START
|
---|
28 | .S DGARRAY(1)=START_";"_STOP,DGARRAY("FLDS")="1;3",DGARRAY(2)=ENT
|
---|
29 | .S DGCNT=$$SDAPI^SDAMA301(.DGARRAY)
|
---|
30 | .;
|
---|
31 | .I DGCNT>0 S DFN=0 F S DFN=$O(^TMP($J,"SDAMA301",ENT,DFN)) Q:DFN="" D
|
---|
32 | ..Q:'$D(^DPT(DFN,0))
|
---|
33 | ..S ENT1=0 F S ENT1=$O(^TMP($J,"SDAMA301",ENT,DFN,ENT1)) Q:ENT1=""!(ENT1'?.N1".".N) D
|
---|
34 | ...S STAT=$P($P(^TMP($J,"SDAMA301",ENT,DFN,ENT1),"^",3),";")
|
---|
35 | ...I STAT="NT" S ERR=$$CREATE() I +ERR>0 S VPTR=$P(ERR,"^",6) D GEN
|
---|
36 | ...I +$G(ERR)<0 S @ERRB@(1)=ERR D EBULL^VAFHUTL2("","","",ERRB)
|
---|
37 | .I DGCNT'=0 K ^TMP($J,"SDAMA301")
|
---|
38 | D EXIT
|
---|
39 | Q
|
---|
40 | ;
|
---|
41 | GEN ;
|
---|
42 | ;Generate the following segments:
|
---|
43 | ;MSH
|
---|
44 | ;
|
---|
45 | K HL D INIT^HLFNC2("VAFH A08",.HL)
|
---|
46 | I $D(HL)=1 S ERR="-1^"_HL Q
|
---|
47 | ;EVN
|
---|
48 | S EVN=$$EVN^VAFHLEVN("A08","05")
|
---|
49 | I +EVN=-1 S ERR="-1^Unable to generate EVN segment" Q
|
---|
50 | ;PID
|
---|
51 | S PID=$$EN^VAFHLPID(DFN,"2,3,4,5,6,7,8,9,11,12,13,14,16,19")
|
---|
52 | ;ZPD
|
---|
53 | S ZPD=$$EN^VAFHLZPD(DFN,"2,3,4,5,6,7,8,9,10,11,12,13,14,15")
|
---|
54 | ;PV1 (outpatient)
|
---|
55 | S PV1=$$OUT^VAFHLPV1(DFN,EVENT,EVDT,VPTR,"A")
|
---|
56 | I +PV1=-1 S ERR="-1^Unable to generate PV1 segment" Q
|
---|
57 | ;
|
---|
58 | ; no dg1 segment will be created. No diagnosis
|
---|
59 | ;information will be known at this stage.
|
---|
60 | ;
|
---|
61 | K ^TMP("HLS",$J)
|
---|
62 | S COUNT=1
|
---|
63 | ;
|
---|
64 | S @GBL@(COUNT)=EVN,COUNT=COUNT+1
|
---|
65 | S @GBL@(COUNT)=PID,COUNT=COUNT+1
|
---|
66 | S @GBL@(COUNT)=ZPD,COUNT=COUNT+1
|
---|
67 | S @GBL@(COUNT)=PV1
|
---|
68 | ;
|
---|
69 | ;
|
---|
70 | ;
|
---|
71 | D GENERATE^HLMA("VAFH A08","GM",1,.HLRST,"",.HL)
|
---|
72 | I HLRST,$P(HLRST,"^",2)=""
|
---|
73 | E S @ERRB@(1)=HLRST D EBULL^VAFHUTL2("","","",ERRB) K HLERR
|
---|
74 | Q
|
---|
75 | EXIT ;
|
---|
76 | D KILL^HLTRANS
|
---|
77 | K @GBL
|
---|
78 | K ZPD,DG1,PID,PV1,MSH,EVN,ENT,ENT1,ENT2,DFN,START,STOP,GBL,HLSDT
|
---|
79 | K EVDT,HLMTN,EVENT,COUNT,HLEVN,HLENTRY,ERR,VPTR,ERRB
|
---|
80 | Q
|
---|
81 | ;
|
---|
82 | CREATE() ;
|
---|
83 | ;creates new entry in pivot file
|
---|
84 | N NODE,VPTR
|
---|
85 | S EVDT=ENT1,VPTR=DFN_";DPT("
|
---|
86 | S NODE=$$PIVNW^VAFHPIVT(DFN,EVDT,2,VPTR)
|
---|
87 | I +NODE=-1 Q NODE
|
---|
88 | S EVENT=$P(NODE,":")
|
---|
89 | Q EVENT_"^"_NODE
|
---|