source: WorldVistAEHR/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUHL7P3.m@ 1704

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

initial load of WorldVistAEHR

File size: 7.0 KB
Line 
1TIUHL7P3 ; SLC/AJB - TIUHL7 Msg Processing; March 23, 2005
2 ;;1.0;TEXT INTEGRATION UTILITIES;**200**;Jun 20, 1997
3 Q
4CONTINUE ;
5 ;
6 ; DOCUMENT TITLE & VISIT LIMITATION
7 I '+$$MEMBEROF^TIUHL7U1(TIU("TITLE"),"OPERATION REPORTS")!'+($$MEMBEROF^TIUHL7U1(TIU("TITLE"),"PROCEDURE REPORT (NON-O.R.)")) D TIUVISIT^TIUSRVA(.TIUTMP,TIU("TDA"),$G(DFN),$G(TIU("VSTR"))) I +TIUTMP D
8 . S TIUDA=+$$EXIST^TIUEDI3(+$G(DFN),+TIU("TDA"),$G(TIU("VSTR")),0,+TIU("AUDA")) I '+TIUDA D ERR^TIUHL7U1("TXA",16,"0000.00",TIU("TITLE")_" already exists for this visit; only one record of this type is allowed per visit.")
9 ;
10 ; get document parameters
11 D DOCPRM^TIUHL7U2(TIU("TDA"),.TIUDPRM)
12 ;
13 ; verify upload support for SURGICAL REPORT titles
14 I $$MEMBEROF^TIUHL7U1(TIU("TITLE"),"SURGICAL REPORTS") D
15 . I $$MEMBEROF^TIUHL7U1(TIU("TITLE"),"OPERATION REPORTS")!($$MEMBEROF^TIUHL7U1(TIU("TITLE"),"PROCEDURE REPORT (NON-O.R.)")) Q
16 . D ERR^TIUHL7U1("TXA",16,"0000.00","This SURGICAL REPORT ["_TIU("TITLE")_"] title is not a supported upload title.")
17 ;
18 ; send APPLICATION REJECT if any data element verification failed
19 I +TIU("EC") D ACK^TIUHL7U1("AR",TIUNAME,-1) Q
20 ;
21 ; validate and process OPERATION REPORTS or PROCEDURE REPORTS
22 I $$MEMBEROF^TIUHL7U1(TIU("TITLE"),"OPERATION REPORTS")!($$MEMBEROF^TIUHL7U1(TIU("TITLE"),"PROCEDURE REPORT (NON-O.R.)")) D Q
23 . N SUCCESS,TIUD0,TIUDA,TIUDAD,TIUSR0,TIUSRCN,TIUOPDT,TIUSTAT
24 . S TIUSRCN=+$G(TIU("SRCN")),TIUOPDT=+$P($G(TIU("EPDT")),"."),TIUDA=""
25 . I '+TIUSRCN,'+TIUOPDT D ERR^TIUHL7U1("TXA",12,"0000.000","HL7 message missing SURGICAL CASE # and OPERATION DATE.")
26 . I '+TIUSRCN,+TIUOPDT S TIUSRCN=$$FINDCASE^TIUPUTS($G(DFN),TIUOPDT) I '+TIUSRCN D ERR^TIUHL7U1("TXA",12,"0000.000","Unable to find a SURGICAL CASE # using the EPISODE BEGIN DATE ["_$$FMTE^XLFDT(TIUOPDT)_"].")
27 . I +TIUSRCN,$D(^SRF(TIUSRCN,"TIU")) S TIUDA=$$GETSDA^TIUPUTS(TIUSRCN) I '+TIUDA D ERR^TIUHL7U1("TXA",12,"0000.000","Unable to find "_TIU("TITLE")_" document stub for SURGICAL CASE #"_TIUSRCN_".")
28 . I +TIUSRCN'>0 D ERR^TIUHL7U1("TXA",12,"0000.000","SURGICAL CASE # cannot be determined.")
29 . I +TIUDA'>0 D ERR^TIUHL7U1("TXA",12,"0000.000","Unable to find "_TIU("TITLE")_" document stub for SURGICAL CASE #"_TIUSRCN_".")
30 . I '+TIU("EC") D
31 . . S TIUD0=$G(^TIU(8925,TIUDA,0)),TIUSR0=$G(^SRF(TIUSRCN,0))
32 . . I '+TIUOPDT S TIU("EPDT")=$P($P(TIUSR0,U,9),"."),TIUOPDT=TIU("EPDT")
33 . . I +TIUSR0'=$G(DFN) D ERR^TIUHL7U1("TXA",12,"0000.000","PATIENT mismatch between HL7 message ["_$$GET1^DIQ(2,$G(DFN),.01)_"] and SURGICAL CASE #"_TIUSRCN_" ["_$$GET1^DIQ(2,+TIUSR0,.01)_"].")
34 . . I +$P(TIUD0,U,2)'=$G(DFN) D ERR^TIUHL7U1("TXA",12,"0000.000","PATIENT mismatch between HL7 message ["_$$GET1^DIQ(2,$G(DFN),.01)_"] and "_TIU("TITLE")_" stub ["_$$GET1^DIQ(2,+$P(TIUD0,U,2),.01)_"].")
35 . . I TIUOPDT'=$P($P(TIUSR0,U,9),".") D ERR^TIUHL7U1("TXA",12,"0000.000","OPERATION DATE mismatch between HL7 message ["_$$FMTE^XLFDT(TIUOPDT)_"] and SURGICAL CASE #"_TIUSRCN_" ["_$$FMTE^XLFDT($P($P(TIUSR0,U,9),"."))_"].") Q
36 . . I +TIU("EC") Q
37 . . I +$G(TIUDA),'$$CANEDIT^TIUHL7U1(TIUDA),'+TIU("EC") G MAKEADD
38 . . S TIUZ("HDR")="1^1" D SETTEXT^TIUSRVPT(.SUCCESS,+TIUDA,.TIUZ)
39 . . I '+$G(SUCCESS) D ERR^TIUHL7U1("OBX",1,"0000.00","DOCUMENT TEXT failed to update.")
40 . I +TIU("EC") D ACK^TIUHL7U1("AR",TIUNAME,-1) Q
41 . D FOLLOWUP^TIUPUTS(+TIUDA)
42 . S $P(^TIU(8925,+TIUDA,13),U,2)=$S(+$G(TIU("EBDA")):TIU("EBDA"),1:TIU("AUDA"))
43 . D SIGNDOC^TIUHL7U1(+TIUDA) I +TIU("EC") D ACK^TIUHL7U1("AR",TIUNAME,-1) Q
44 . D ACK^TIUHL7U1("AA",TIUNAME,+TIUDA)
45 ;
46MAKEADD ;
47 ; validate CONSULT title
48 I $$MEMBEROF^TIUHL7U1(TIU("TITLE"),"CONSULTS") D
49 . I '+$G(TIU("CNCN")) D ERR^TIUHL7U1("TXA",12,"0000.00","HL7 message missing CONSULT #.") Q
50 . I '$$CPPAT^GMRCCP(TIU("CNCN"),$G(DFN)) D ERR^TIUHL7U1("TXA",12,"0000.00","PATIENT NAME ["_TIU("PTNAME")_"] mismatch between HL7 message and CONSULT ["_$$GET1^DIQ(123,TIU("CNCN"),.02)_"].") Q
51 . S TIUZ(1405)=TIU("CNCN")_";GMR(123,"
52 ;
53 I +TIU("EC") D ACK^TIUHL7U1("AR",TIUNAME,-1) Q
54 ;
55 ; set data fields
56 ; set appropriate DOCUMENT STATUS from document parameters
57 S DUZ=$G(TIU("AUDA")),DUZ(2)=$$GETDIV^TIUHL7U1(DUZ),TIU("DIVISION")=DUZ(2)
58 I $P(TIUDPRM(0),U,2)=1 S TIUZ(.05)=3
59 I '+$G(TIUZ(.05)),$P(TIUDPRM(0),U,3)>0,$P(TIUDPRM(0),U,3)'>2 S TIUZ(.05)=4
60 I '+$G(TIUZ(.05)) S TIUZ(.05)=5
61 ;
62 S TIUZ(.07)=$S(+$G(TIU("EPDT")):TIU("EPDT"),+$G(TIU("RFDT")):TIU("RFDT"),1:$$NOW^XLFDT)
63 S TIUZ(1201)=$$NOW^XLFDT
64 S TIUZ(1202)=$G(TIU("AUDA"))
65 S TIUZ(1204)=$G(TIU("AUDA"))
66 S TIUZ(1208)=$G(TIU("CSDA"))
67 S TIUZ(1212)=$G(TIU("DIVISION"))
68 S TIUZ(1301)=$G(TIU("RFDT"))
69 S TIUZ(1302)=$S(+$G(TIU("EBDA")):TIU("EBDA"),1:TIU("AUDA")),TIU("EBDA")=TIUZ(1302)
70 S TIUZ(1307)=$G(TIU("DICDT"))
71 S TIUZ(1701)=$G(TIU("SUB"))
72 ;
73 ; check if document was found and editable
74 ; if not editable, make addendum
75 I +$G(TIUDA),'$$CANEDIT^TIUHL7U1(TIUDA),'+TIU("EC") D Q
76 . N PERSON,SUCCESS
77 . S PERSON=$G(TIU("AUDA"))
78 . D MAKEADD^TIUHL7U2(.SUCCESS,TIUDA,.TIUZ,1)
79 . I '+SUCCESS D ERR^TIUHL7U1("TIU",1,"0000.000",$P(SUCCESS,U,2))
80 . I +TIU("EC") D ACK^TIUHL7U1("AR",TIUNAME,-1) Q
81 . S $P(^TIU(8925,+SUCCESS,13),U,3)="U",$P(^TIU(8925,+SUCCESS,13),U,2)=$S(+$G(TIU("EBDA")):TIU("EBDA"),1:TIU("AUDA"))
82 . D SIGNDOC^TIUHL7U1(+SUCCESS) I +TIU("EC") D ACK^TIUHL7U1("AR",TIUNAME,+SUCCESS) Q
83 . D ACK^TIUHL7U1("AA",TIUNAME,SUCCESS),SEND^TIUALRT(SUCCESS),SENDADD^TIUALRT(+TIUDA)
84 ;
85 ; if editable, make changes to document
86 I +$G(TIUDA),$$CANEDIT^TIUHL7U1(TIUDA),'+TIU("EC") D Q
87 . N SUCCESS
88 . D DELTEXT^TIUPUTPN(TIUDA)
89 . S TIUZ("HDR")="1^1" D SETTEXT^TIUSRVPT(.SUCCESS,+TIUDA,.TIUZ) K TIUZ("HDR"),TIUZ("TEXT")
90 . I '+SUCCESS D ERR^TIUHL7U1("TIU",1,"0000.000",$P(SUCCESS,U,2))
91 . D FILE^TIUSRVP(.SUCCESS,+TIUDA,.TIUZ)
92 . I '+SUCCESS D ERR^TIUHL7U1("TIU",1,"0000.000",$P(SUCCESS,U,2))
93 . I +TIU("EC") D ACK^TIUHL7U1("AR",TIUNAME,-1) Q
94 . S $P(^TIU(8925,+SUCCESS,13),U,3)="U",$P(^TIU(8925,+SUCCESS,13),U,2)=$S(+$G(TIU("EBDA")):TIU("EBDA"),1:TIU("AUDA"))
95 . D SIGNDOC^TIUHL7U1(+SUCCESS) I +TIU("EC") D ACK^TIUHL7U1("AR",TIUNAME,+SUCCESS) Q
96 . D ACK^TIUHL7U1("AA",TIUNAME,TIUDA),SEND^TIUALRT(TIUDA) Q
97 ;
98 I +TIU("EC") D ACK^TIUHL7U1("AR",TIUNAME,-1) Q
99 ;
100 ; document creation
101 N SDCNT,TIUDIV1,TIUFPRIV,TIUPRM0,TIUPRM1
102 D MAKE^TIUSRVP(.TIUDA,DFN,TIU("TDA"),,,,.TIUZ,TIU("VSTR"))
103 ;
104 ; verify creation & and set capture method to UPLOAD & ENTERED BY (if applicable)
105 I '+TIUDA D ERR^TIUHL7U1("TIU",1,"0000.00",$P(TIUDA,U,2)),ACK^TIUHL7U1("AR",TIUNAME,-1) Q
106 S $P(^TIU(8925,+TIUDA,13),U,3)="U",$P(^TIU(8925,+TIUDA,13),U,2)=$S(+$G(TIU("EBDA")):TIU("EBDA"),1:TIU("AUDA"))
107 S $P(^TIU(8925,+TIUDA,0),U,7)=$S(+$G(TIU("EPDT")):TIU("EPDT"),+$G(TIU("RFDT")):TIU("RFDT"),1:$$NOW^XLFDT)
108 ;
109 ; process signature/co-signature
110 D SIGNDOC^TIUHL7U1(+TIUDA) I +TIU("EC") D ACK^TIUHL7U1("AR",TIUNAME,+TIUDA) Q
111 ;
112 ; update the consult as necessary
113 I $$MEMBEROF^TIUHL7U1(TIU("TITLE"),"CONSULTS") D
114 . N TIUSTAT S TIUSTAT=$P($G(^TIU(8925,+TIUDA,0)),U,5)
115 . S TIUSTAT=$S(TIUSTAT>6:"COMPLETED",1:"INCOMPLETE")
116 . D GET^GMRCTIU(TIU("CNCN"),+TIUDA,TIUSTAT,TIU("AUDA"))
117 ;
118 D ACK^TIUHL7U1("AA",TIUNAME,+TIUDA)
119 D SEND^TIUALRT(+TIUDA)
120 D AUDIT^TIUHL7U1(+TIUDA,0,$$CHKSUM^TIULC("^TIU(8925,"_+TIUDA_",""TEXT"")"))
121 ;
122 Q
Note: See TracBrowser for help on using the repository browser.