source: WorldVistAEHR/trunk/r/CLINICAL_PROCEDURES-MD/MDHL7BH.m@ 949

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

initial load of WorldVistAEHR

File size: 3.3 KB
Line 
1MDHL7BH ; HOIFO/WAA -Bi-directional interface (HL7) routine ;7/23/01 11:41
2 ;;1.0;CLINICAL PROCEDURES;;Apr 01, 2004
3 ;
4 ; This routine will build the HL7 Message and store that message.
5 ; After the message has been created then it will call the
6 ; The actual HL7package to start the processing of the message
7 ;
8 ; Reference DBIA #2161 [Supported] for HL7 calls.
9 ; Reference DBIA #2164 [Supported] for HL7 calls.
10 ; Reference DBIA #3065 [Supported] call to HLFNAME.
11 Q
12EN1 ;Main Entry point.
13 N MDMSG,MD101,CNT,HLA,LINE,MDHL,DFN,MDLINK
14 Q:RESULT<1 ; This tells the study is not a BDi
15 S MDLINK=$$GET1^DIQ(702.09,DEVIEN,.18,"E")
16 I MDLINK="" S RESULT=-1,MSG="No HL Logical Link has been defined." Q ; No no link has been defined
17 S MDERROR="0"
18 D INIT^HLFNC2("MCAR ORM SERVER",.MDMSG)
19 I +$G(MDMSG)>0 S RESULT=-1,MSG="Unable to produce a message." Q ; something is wrong and no MSH was created
20 S DFN=$$GET1^DIQ(702,MDD702,.01,"I")
21 S DEVNAME=$$GET1^DIQ(702.09,DEVIEN,.16,"I")
22 S CNT=0
23 D PID S CNT=CNT+1,HLA("HLS",CNT)=LINE
24 D PV1 S CNT=CNT+1,HLA("HLS",CNT)=LINE
25 D ORC S CNT=CNT+1,HLA("HLS",CNT)=LINE
26 D OBR I LINE'="" S CNT=CNT+1,HLA("HLS",CNT)=LINE
27 S HLP("SUBSCRIBER")="^^VISTA^^"_DEVNAME_"^M"
28 S HLL("LINKS",1)="MCAR ORM CLIENT"_"^"_MDLINK
29 D GENERATE^HLMA("MCAR ORM SERVER","LM",1,.MDHL,,.HLP)
30 I $P(MDHL,U,2) S MDERROR=MDHL
31 Q
32OBR ; Send the procedure to the correct device
33 S LINE="OBR|"
34 S DEVIEN=$$GET1^DIQ(702,MDD702,.11,"I")
35 S USC=$$GET1^DIQ(702.09,DEVIEN,.17,"I")
36 I USC="" S LINE="" Q
37 E S USC=$TR(USC,"=","^")
38 S $P(LINE,"|",5)=USC_"|"
39 Q
40PID ;get the patient information and build the PID
41 ;PID|||SSN||Last^First||DOB|SEX|||||||||||SSN
42 N MDSSN,NAME,DOB,ADDR,TMP
43 S LINE="PID|",$P(LINE,"|",21)=""
44 S MDSSN=$$GET1^DIQ(702,MDD702,.011) ; Get the ssn for the patient
45 S NAME=$$GET1^DIQ(702,MDD702,.01,"E") ; get the patient name
46 S NAME=$$HLNAME^XLFNAME($P(NAME,"^"),"",$E(HLECH,1))
47 I $P(NAME,$E(HLECH,1),7)'="L" S $P(NAME,$E(HLECH,1),7)="L"
48 S DOB=$$GET1^DIQ(2,DFN,.03,"I") S DOB=$$FTOHL7^MDHL7U2(DOB)
49 S ADDR=$$GET1^DIQ(2,DFN,.111,"E")_"^" ; Address 1
50 S TMP=$$GET1^DIQ(2,DFN,.112,"E") I TMP'="" S ADDR=ADDR_TMP ; Add 2
51 S TMP=$$GET1^DIQ(2,DFN,.113,"E") I TMP'="" S ADDR=ADDR_" "_TMP ; Add 3
52 S ADDR=ADDR_"^"_$$GET1^DIQ(2,DFN,.114,"E") ; City
53 S ADDR=ADDR_"^"_$$GET1^DIQ(5,$$GET1^DIQ(2,DFN,.115,"I"),1,"E") ; State
54 S ADDR=ADDR_"^"_$$GET1^DIQ(2,DFN,.116,"E") ; Zip
55 S $P(LINE,"|",2)="1"
56 S $P(LINE,"|",4)=MDSSN
57 S $P(LINE,"|",6)=NAME
58 S $P(LINE,"|",8)=DOB
59 S $P(LINE,"|",9)=$$GET1^DIQ(2,DFN,.02,"I")
60 S $P(LINE,"|",12)=ADDR
61 S $P(LINE,"|",20)=MDSSN
62 Q
63PV1 ;Get the ward location for PV1
64 ;PV1||In or out|Ward location
65 N WARD,INOUT,CONSULT,REF,NREF
66 S WARD=$$GET1^DIQ(2,DFN,.1,"E")
67 S INOUT=$S(WARD'="":"I",1:"O")
68 S:WARD'="" WARD=WARD_U_WARD
69 S LINE="PV1||"_INOUT_"|"_WARD
70 S CONSULT=$$GET123^MDHL7U2(MDD702) Q:CONSULT<1
71 S NREF=$$GETREF^MDHL7U2(CONSULT) Q:NREF="-1"
72 S $P(LINE,"|",9)=NREF
73 Q
74ORC ;get ORC onformation
75 ;ORC|NA|Order Number|||||||date/time ordered
76 N DATE,SDATE
77 S DATE=$$GET1^DIQ(702,MDD702,.02,"I")
78 S DATE=$$FTOHL7^MDHL7U2(DATE)
79 S SDATE=$$GET1^DIQ(702,MDD702,.07,"I")
80 I SDATE[";" S SDATE=$P(SDATE,";",2)
81 S SDATE=$$FTOHL7^MDHL7U2(SDATE)
82 S LINE="ORC|"_$S(MDORFLG=1:"NW",MDORFLG=0:"CA",1:"")_"|"_MDIORD
83 S $P(LINE,"|",6)=$S(MDORFLG=1:"NW",MDORFLG=0:"CA",1:"")
84 S $P(LINE,"|",10)=DATE,$P(LINE,"|",16)=SDATE
85 Q
Note: See TracBrowser for help on using the repository browser.