source: WorldVistAEHR/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/XUOAAHL7.m@ 738

Last change on this file since 738 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 6.6 KB
Line 
1XUOAAHL7 ;OAKCIOFO/JLG - Clinical Trainee HL7 Msg Routine;8:06 AM 22 Mar 2005
2 ;;8.0;KERNEL;**251,324,344**;Jul 10, 1995
3 ;
4OAA ; entry point for the scheduled option [XUOAA SEND HL7 MESSAGE]
5 ; This routine generates an HL7 PMU message, Update Personnel Record,
6 ; based on data pointed by the ^VA(200,"ATR",ien) cross-reference.
7 ; The type of message is PMU~B02 with the following structure:
8 ; MSH,EVN,STF,PRA,ORG,EDU
9 ; The data generated for the STF,PRA,ORG, and EDU are not repeating.
10 ;
11 ; Input:
12 ; MSGID (required) Pass by reference
13 ; ERROR (required) Pass by reference
14 ;
15 ; Output:
16 ; MSGID The message id assigned to the message when the call
17 ; succeeds; null when call does not succeed.
18 ; ERROR 0 if call succeeds.
19 ; "1^description of error" if call fails
20 ;
21 ; Pre-conditions:
22 ; - ^VA(200,"ATR") exists
23 ; - XUOAA PMU event protocol and XUOAA ACK subscriber protocols are
24 ; active.
25 ; Postcondition:
26 ; - An HL7 PMU-B02 message is queued for transmission.
27 ; - the ^VA(200,"ATR") x-reference is killed when queueing is
28 ; successful; otherwise, it is left intact for next attempt.
29 ;
30 N CNT,CS,ERROR,FS,INDX,RESULT,SS,TOTAL,XUCNT,XUHLDT,XUHLDT1,XUHLMID
31 N XUMTIEN,XUOAA,XUOAAHL
32 S TOTAL=0
33LOOP1 ; Generate batch messages of 100 messages long
34 I '$D(^VA(200,"ATR")) D MAIL Q ;No "ATR" xref
35 K ^TMP("HLS",$J),XUOAA
36 S (INDX,XUOAA,CNT,ERROR)=0
37 D INIT Q:ERROR
38 D STUB Q:ERROR ; create msg stub (batch)
39 ; iterate over list of entries (100 max) and build batch message
40 F S INDX=$O(^VA(200,"ATR",INDX)) Q:'INDX!(XUOAA>99) D
41 . L +^VA(200,INDX):30 Q:'$T
42 . S XUOAA=XUOAA+1 ; message count in batch
43 . ; temporary array to keep track of entries
44 . S XUOAA(INDX)=$G(^VA(200,"ATR",INDX)) ; date/time recorded
45 . D BLDMSG(INDX) ; build message for this entry
46 . K ^VA(200,"ATR",INDX)
47 . S TOTAL=TOTAL+1
48 . L -^VA(200,INDX)
49 D SEND
50 I ERROR D RESTORE,STORENV Q
51 I XUOAA>99 G LOOP1 ; more than 100 entries, create another batch
52 K ^TMP("HLS",$J),XUOAA
53 D MAIL
54 Q
55 ;
56INIT ; initialize HL variables
57 ; "XUOAA PMU"=event protocol, XUOAAHL=hl variables
58 ; checks for valid event protocol
59 D INIT^HLFNC2("XUOAA PMU",.XUOAAHL)
60 I $G(XUOAAHL) S ERROR="1^"_$P(XUOAAHL,U,2) Q
61 S FS=$G(XUOAAHL("FS")) ;field separator
62 S CS=$E(XUOAAHL("ECH"),1) ;component separator
63 S SS=$E(XUOAAHL("ECH"),4) ;sub-component separator
64 Q
65 ;
66STUB ; create msg stub for batch msg
67 ; XUHLMID=batch msg id, XUMTIEN=file 772 ien
68 ; XUHLDT=FM date/time, XUHLDT1=HL7 date/time
69 D CREATE^HLTF(.XUHLMID,.XUMTIEN,.XUHLDT,.XUHLDT1)
70 I 'XUHLMID S ERROR="1^could not create msg stub" Q
71 Q
72 ;
73BLDMSG(IEN) ;
74 N ADDR,CITY,DEGLEV,DOB,EMAIL,ENTERDT,FACILITY,GEOLOC,IFN
75 N LASTYR,MSGHDR,NAME,PROGSTD,RECORDT,SERVICE,SSN,STATE,STREET,TERMDT
76 N TITLE,ZIP,XUNAME,VHATF,X,Y
77 Q:'IEN
78 ; extract data from Fileman and transform to HL7 datatype
79 S XUNAME("FILE")=200,XUNAME("FIELD")=.01,XUNAME("IENS")=IEN
80 S NAME=$$HLNAME^XLFNAME(.XUNAME,"S",CS)
81 S STREET=$$GET1^DIQ(200,IEN,"STREET ADDRESS 1")
82 S STREET=STREET_U_$$GET1^DIQ(200,IEN,"STREET ADDRESS 2")
83 S STREET=STREET_U_$$GET1^DIQ(200,IEN,"STREET ADDRESS 3")
84 S CITY=$$GET1^DIQ(200,IEN,"CITY")
85 S STATE=$$GET1^DIQ(200,IEN,"STATE","I")
86 S ZIP=$$GET1^DIQ(200,IEN,"ZIP CODE")
87 S GEOLOC=CITY_U_STATE_U_ZIP_U_"USA"
88 S ADDR=$$HLADDR^HLFNC(STREET,GEOLOC)
89 S SSN=$$GET1^DIQ(200,IEN,"SSN")
90 S SSN=SSN_CS_CS_CS_"USSSA"_CS_"SS"
91 S EMAIL=$$GET1^DIQ(200,IEN,"EMAIL ADDRESS")
92 S DEGLEV=$$GET1^DIQ(200,IEN,"CURRENT DEGREE LEVEL:ABBREVIATION")
93 S PROGSTD=$$GET1^DIQ(200,IEN,"PROGRAM OF STUDY")
94 S LASTYR=$$GET1^DIQ(200,IEN,"LAST TRAINING MONTH & YEAR")
95 D
96 . N %DT
97 . S X=LASTYR,%DT="M"
98 . D ^%DT
99 . Q
100 S LASTYR=$$FMTHL7^XLFDT(Y)
101 S SERVICE=$$GET1^DIQ(200,IEN,"SERVICE/SECTION")
102 S SERVICE=SERVICE_CS_CS_"SERVICE/SECTION"
103 S TERMDT=$$GET1^DIQ(200,IEN,"DATE NO LONGER TRAINEE","I")
104 S TERMDT=$$FMTHL7^XLFDT(TERMDT)
105 S:'TERMDT TERMDT=""
106 S TITLE=$$GET1^DIQ(200,IEN,"TITLE")
107 S ENTERDT=$$GET1^DIQ(200,IEN,"START OF TRAINING","I")
108 S ENTERDT=$$FMTHL7^XLFDT(ENTERDT)
109 S:'ENTERDT ENTERDT=""
110 ; date recorded
111 S RECORDT=$$FMTHL7^XLFDT($G(XUOAA(IEN)))
112 S FACILITY=$$NS^XUAF4($$KSP^XUPARAM("INST"))
113 S FACILITY=$P(FACILITY,U,2)_CS_$P(FACILITY,U)
114 D
115 . S VHATF=+$$GET1^DIQ(200,IEN,"VHA TRAINING FACILITY","I")
116 . I VHATF<1 S VHATF="^" Q ;Both pieces Null
117 . I VHATF>0 S VHATF=$$NS^XUAF4(VHATF)
118 . Q
119 S VHATF=$P(VHATF,U,2)_CS_$P(VHATF,U)
120 ; IFN= internal file number
121 S IFN=IEN_CS_"IEN"_CS_"NEW PERSON"
122 S DOB=$$GET1^DIQ(200,IEN,"DOB","I")
123 S DOB=$$FMTHL7^XLFDT(DOB)
124 ; create msg header per entry
125 ; XUOAAHL=hl array from INIT, XUHLMID=batch msg id from STUB
126 ; XUOAA=message count, MSGHDR=message header
127 D MSH^HLFNC2(.XUOAAHL,XUHLMID_"-"_XUOAA,.MSGHDR)
128 ; build temporary MSG TEXT array
129 S CNT=CNT+1
130 S ^TMP("HLS",$J,CNT)=MSGHDR
131 S CNT=CNT+1
132 S ^TMP("HLS",$J,CNT)="EVN"_FS_XUOAAHL("ETN")_FS_RECORDT_FS_FS_FS_FS_FS_FACILITY
133 S CNT=CNT+1
134 S ^TMP("HLS",$J,CNT)="STF"_FS_IFN_FS_SSN_FS_NAME_FS_FS_FS_DOB_FS_FS_FS_SERVICE_FS_FS_ADDR_FS_FS_FS_FS_EMAIL_FS_FS_FS_TITLE
135 S CNT=CNT+1
136 S ^TMP("HLS",$J,CNT)="PRA"_FS_FS_FS_"OAA"_FS_FS_PROGSTD_CS_CS_CS_CS_LASTYR
137 S CNT=CNT+1
138 S ^TMP("HLS",$J,CNT)="ORG"_FS_1_FS_VHATF_FS_SERVICE_FS_FS_FS_FS_FS_CS_PROGSTD_CS_"PROGRAM OF STUDY"_FS_ENTERDT_CS_TERMDT
139 S CNT=CNT+1
140 S ^TMP("HLS",$J,CNT)="EDU"_FS_"1"_FS_DEGLEV
141 D
142 . ; Update Trainee's Date Transmitted to OAA
143 . N DIERR,ZERR,FDA
144 . S FDA(200,$S(IEN[",":IEN,1:IEN_","),12.5)=DT
145 . D FILE^DIE("I","FDA","ZERR")
146 Q
147 ;
148SEND ; send complete batch message
149 ; "XUOAA PMU"=event protocol, LB=batch array type
150 ; RESULT="msgid^error code^error msg" , XUMTIEN=file 772 ien from STUB
151 D GENERATE^HLMA("XUOAA PMU","GB",1,.RESULT,XUMTIEN)
152 I +$P(RESULT,U,2) D Q
153 . S ERROR="1^"_$P(RESULT,U,3)
154 S MSGID=+RESULT
155 Q
156 ;
157RESTORE ; message could not be sent, restore x-ref
158 S INDX=0 F S INDX=$O(XUOAA(INDX)) Q:'INDX D
159 . S ^VA(200,"ATR",INDX)=$G(XUOAA(INDX))
160 Q
161 ;
162RECACK ; receive application acknoledgement from HL7
163 I $G(HL("ACKCD"))'="AA" D
164 . D STORENV("RECACK")
165 Q
166 ;
167STORENV ; store environmental variables for logging purposes
168 N APP,XTMP,X
169 S APP="Clinical Trainee Core Dataset",XTMP="XUOAA"_DT
170 S ^XTMP(XTMP,0)=$$FMADD^XLFDT(DT,14)_U_$$NOW^XLFDT_U_APP
171 S X="^XTMP("""_XTMP_""","
172 D DOLRO^%ZOSV
173 Q
174 ;
175MAIL ;Send mail message to G.XUOAA CLIN TRAINEE TRANS
176 N LN,MSGTXT,MSGSBJ
177 S LN=1
178 S MSGSBJ="Clinical Trainee Transmission Count"
179 S MSGTXT=""
180 S MSGTXT(LN)=" ",LN=LN+1
181 S MSGTXT(LN)="Number of trainees transmitted to OAA: "_TOTAL
182 ;Check to see if Mail Group has members
183 I '$$GOTLOCAL^XMXAPIG("XUOAA CLIN TRAINEE TRANS") D SENDMSG^XMXAPI(DUZ,MSGSBJ,"MTEXT",DUZ) Q
184 ; Mail Group Has Memebers so send the message
185 D SENDMSG^XMXAPI(DUZ,MSGSBJ,"MSGTXT","G.XUOAA CLIN TRAINEE TRANS")
186 Q
Note: See TracBrowser for help on using the repository browser.