source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCMCHLRI.m@ 1226

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

initial load of WorldVistAEHR

File size: 4.8 KB
RevLine 
[613]1SCMCHLRI ;BP/DJB - PCMM HL7 Rejects - Identify & Store Msg ; 2/28/00 12:10pm
2 ;;5.3;Scheduling;**210**;AUG 13, 1993
3 ;
4ACK ;Identify an acknowledgment message
5 ;
6 ;HL7 Message:
7 ; ACK Code..........: Segment MSA, fld 1
8 ; Msg ID............: Segment MSA, fld 2
9 ; Segment code......: Segment ERR, fld 2, component 1
10 ; Sequence..........: Segment ERR, fld 2, component 2
11 ; Field Position....: Segment ERR, fld 2, component 3
12 ; Error code........: Segment ERR, fld 2, component 4
13 ;
14 NEW ARRAY,CS,FS,RS
15 ;
16 S CS=$E(HL("ECH"),1) ;..Component separator
17 S RS=$E(HL("ECH"),2) ;..Repetition separator
18 S FS=HL("FS") ;.........Field separator
19 ;
20 D PARSE ;Build array
21 Q:'$D(ARRAY)
22 D UPDATE ;Update PCMM HL7 TRANSISSION LOG file
23 Q
24 ;
25PARSE ;Parse ACK message.
26 ;Build array:
27 ; ARRAY("MSA","MSGID")........= Message ID
28 ; ARRAY("MSA","ACKCODE")......= ACK code
29 ; ARRAY("ERR",counter,"SEG")..= Segment ID
30 ; ARRAY("ERR",counter,"SEQ")..= Sequence #
31 ; ARRAY("ERR",counter,"FLD")..= Field Position
32 ; ARRAY("ERR",counter,"CODE").= Error code
33 ;
34 NEW CNTERR,MSGID,SEG,TXTFLD,TXTREP
35 ;
36 F X HLNEXT Q:(HLQUIT'>0) D ;
37 . S SEG=$P(HLNODE,FS,1) ;..Segment name
38 . ;
39 . ;-> MSA segment
40 . I SEG="MSA" D Q
41 .. S ARRAY("MSA","ACKCODE")=$P(HLNODE,FS,2)
42 .. S ARRAY("MSA","MSGID")=$P(HLNODE,FS,3)
43 . ;
44 . ;-> ERR segment
45 . I SEG="ERR" D Q
46 .. S TXTFLD=$P(HLNODE,FS,2) ;..Repeating field
47 .. F CNTERR=1:1 S TXTREP=$P(TXTFLD,RS,CNTERR) Q:TXTREP="" D ;
48 ... S ARRAY("ERR",CNTERR,"SEG")=$P(TXTREP,CS,1)
49 ... ;Get Sequence # and strip off any leading zeros
50 ... S SEQ=$P(TXTREP,CS,2)
51 ... F Q:($E(SEQ,1)'=0) S SEQ=$E(SEQ,2,$L(SEQ))
52 ... S ARRAY("ERR",CNTERR,"SEQ")=SEQ
53 ... S ARRAY("ERR",CNTERR,"FLD")=$P(TXTREP,CS,3)
54 ... S ARRAY("ERR",CNTERR,"CODE")=$P(TXTREP,CS,4)
55 Q
56 ;
57UPDATE ;Update entry in PCMM HL7 TRANSMISSION LOG file
58 NEW ACKCODE,ERRORI,MSGID,TRANI
59 S MSGID=ARRAY("MSA","MSGID")
60 S TRANI=$O(^SCPT(404.471,"B",MSGID,""))
61 Q:'$G(TRANI)
62 Q:'$D(^SCPT(404.471,TRANI))
63 S ACKCODE=ARRAY("MSA","ACKCODE")
64 ;
65 ;Message processed.
66 I ACKCODE="AA" D STATUS(TRANI,"A") Q ;Msg accepted
67 ;
68 ;Rejected for reasons unrelated to content.
69 I ACKCODE="AR" D STATUS(TRANI,"M") Q ;Msg marked for re-transmit
70 ;
71 ;Rejected - error information provided.
72 I ACKCODE="AE" D Q
73 . D STATUS(TRANI,"RJ") ;Msg rejected
74 . D STORE(TRANI)
75 Q
76 ;
77STATUS(TRANI,STATUS) ;Update STATUS field in PCMM HL7 TRANSMISSION LOG file.
78 ; Input: TRANI - IEN of PCM HL7 TRANSMISSION LOG file
79 ; STATUS - A=Accepted, M=Marked for re-transmit, RJ=Rejected
80 ;
81 NEW SCERR,SCFDA,SCIENS
82 Q:'$G(TRANI)
83 Q:",A,M,RJ,"'[(","_$G(STATUS)_",")
84 S SCIENS=TRANI_","
85 S SCFDA(404.471,SCIENS,.04)=STATUS ;.........Status
86 S SCFDA(404.471,SCIENS,.05)=$$NOW^XLFDT() ;..ACK received date
87 D FILE^DIE("I","SCFDA","SCERR")
88 Q
89 ;
90STORE(TRANI) ;Store data from "ERR" and "ZER" arrays
91 ;
92 ; Input: TRANI - IEN of PCMM HL7 TRANSMISSION LOG file
93 ;Output: None
94 ;
95 NEW SCERR,SCIEN,SCIENS,SCIENS1,SCFDA
96 NEW CNT,ERRORI,FLD,SEG,SEQ,ZPCID
97 ;
98 S CNT=0
99 F S CNT=$O(ARRAY("ERR",CNT)) Q:'CNT D ;
100 . ;
101 . ;Create entry in ERROR CODE multiple field
102 . S ERRORI=$$CREATE(ARRAY("ERR",CNT,"CODE"),CNT,TRANI)
103 . Q:+ERRORI<0
104 . ;
105 . S SEG=$G(ARRAY("ERR",CNT,"SEG")) ;..Segment
106 . S SEQ=$G(ARRAY("ERR",CNT,"SEQ")) ;..Sequence number
107 . S FLD=$G(ARRAY("ERR",CNT,"FLD")) ;..Field Position
108 . S ZPCID=""
109 . I SEG="ZPC" D ;..ZPC ID
110 .. Q:'SEQ
111 .. S SEQI=$O(^SCPT(404.471,TRANI,"ZPC","B",SEQ,""))
112 .. Q:'SEQI
113 .. S ZPCID=$P($G(^SCPT(404.471,TRANI,"ZPC",SEQI,0)),"^",2)
114 . ;
115 . S SCIENS=ERRORI_","_TRANI_","
116 . S SCFDA(404.47142,SCIENS,.02)=SEG
117 . S SCFDA(404.47142,SCIENS,.03)=SEQ
118 . S SCFDA(404.47142,SCIENS,.04)=FLD
119 . S SCFDA(404.47142,SCIENS,.05)=ZPCID
120 . S SCFDA(404.47142,SCIENS,.06)=1
121 . D FILE^DIE("I","SCFDA","SCERR")
122 . KILL SCFDA,SCERR
123 Q
124 ;
125CREATE(ERRORCD,CNT,TRANI) ;Create an entry in the ERROR CODE multiiple field
126 ; Input: ERRORCD - Error code
127 ; CNT - Counter for multiple entries
128 ;Output: IEN to entry created
129 ; -1^Error - Unable to create entry
130 ;
131 NEW IENS,SCERR,SCFDA,SCIEN
132 S:'$G(CNT) CNT=1
133 S IENS="+"_CNT_","_TRANI_","
134 S SCFDA(404.47142,IENS,.01)=ERRORCD
135 D UPDATE^DIE("E","SCFDA","SCIEN","SCERR")
136 I $D(SCERR) Q "-1^Unable to create entry in ERROR CODE field"
137 Q SCIEN(CNT)
138 ;
139CONVERT(ID) ;If ID is from an integrated site, convert it to local ID.
140 ;Input: ID="Site#-404.49 IEN" (Example: 642-3456)
141 ;
142 I $D(^SCPT(404.49,"C",ID)) D ;....See if ID is an Integration ID
143 . S ID=$O(^SCPT(404.49,"C",ID,"")) ;..If so, convert it to local ID
144 E S ID=$P(ID,"-",2)
145 Q ID
146 ;
147 ;==================================================================
148 ;
149HL7SAMP ;Sample code to view HL7 message
150 NEW I,J
151 F I=1:1 X HLNEXT Q:HLQUIT'>0 D ;
152 . S ^TMP("DJB",$J,I)=HLNODE
153 . S J=0
154 . ;Get segments greater than 245 characters
155 . F S J=$O(HLNODE(J)) Q:'J S ^TMP("DJB",$J,I,J)=HLNODE(J)
156 Q
Note: See TracBrowser for help on using the repository browser.