source: FOIAVistA/trunk/r/CLINICAL_PROCEDURES-MD/MDHL7B.m@ 1327

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

initial load of FOIAVistA 6/30/08 version

File size: 2.7 KB
Line 
1MDHL7B ; HOIFO/WAA -Bi-directional interface routine ;7/23/01 11:41
2 ;;1.0;CLINICAL PROCEDURES;;Apr 01, 2004
3 ;
4 ; This routine will take an entry from 702 and submit that data
5 ; to the instrument that was indicated by the user
6 ; SUB is a submit function
7 ; MDD702 is the IEN for the Entry from 702 that
8 ; needs to be sent.
9 ; The function will return -1^Submission failed and why
10 ; 0^Device not Bi-Directional
11 ; 1^Study submitted
12TMPSUB(MDD702) ; Process a submitted entry from user.
13 ; drp 16-JUL-2002 13:30:32
14 N DEVICE
15 S DEVICE=+$P(^MDD(702,MDD702,0),U,11) Q:'DEVICE "0^No Device - TEST"
16 I +$P($G(^MDS(702.09,DEVICE,.1)),U,3) Q "1^Study Submitted - TEST"
17 Q "0^No Bi Di Cap - TEST"
18 ;
19SUB(MDD702) ; Change to SUB when working
20 N MDORFLG,RESULT,MSG,MDERROR
21 S MDORFLG=1
22 D EN1
23 Q RESULT_U_MSG
24 ;
25CANCEL(MDD702) ; Cancel Orders
26 N MDORFLG,RESULT,MSG,MDERROR
27 S MDORFLG=0
28 D EN1
29 Q RESULT_U_MSG
30 ;
31EN1 ; The main entry point for the order to be processed.
32 N DEVIEN,WORKING,MDIORD
33 ; Get the device that will process this study
34 ; Build an HL7 Message based in the device.
35 ; After the device has processed the message this routine will
36 ; update the status with in 702.
37 S RESULT=1,MSG=$S(MDORFLG=1:"Study Submitted.",1:"Study Cancelled")
38 I '$D(^MDD(702,MDD702,0)) S MSG="There is no study in 702 for entry "_MDD702_".",RESULT=-1
39 I RESULT'=-1 D ;Get the device based on the CP def
40 . S DEF=$P(^MDD(702,MDD702,0),U,4) I DEF<1 S RESULT=-1,MSG="No CP DEFINITION for this entry in file 702.01."
41 . Q
42 I RESULT'=-1 D ; Check to see that there is a device entered for this procedure
43 . S DEVIEN=$P(^MDD(702,MDD702,0),U,11) I DEVIEN>0 Q
44 . S RESULT=0,MSG="No DEVICE is defined." Q
45 . Q
46 ;
47 ; DRP/16-MAY-2003 14:44:36 - Check for Loopback IP
48 I $$GET1^DIQ(702.09,DEVIEN_",",.14)="127.0.0.1" D Q
49 . D LOOPBACK^MDHL7XXX(MDD702,DEVIEN)
50 . S RESULT=+$$GET1^DIQ(702.09,DEVIEN_",",.13,"I"),MSG="OK"
51 . Q
52 ;
53 I RESULT>0 D ; Check to see that the device is a active and working
54 . S WORKING="" D INST^MDHL7U2(DEVIEN,.WORKING)
55 . Q:WORKING
56 . S RESULT=-1,MSG="There is a problem with the device entry in file 702.09."
57 . Q
58 I RESULT>0 D ; Check to see if the device is bi-directional
59 . N LINE
60 . S LINE=$G(^MDS(702.09,DEVIEN,.1))
61 . I $P(LINE,U,3)'=1 D Q ; The Device is not Bi-Directional
62 . . S RESULT=0,MSG="Device not Bi-Directional."
63 . . Q
64 . ; The device is Bi-Directional and we are getting an MDIORD number.
65 . S MDIORD=$$GETIORD^MDRPCOT1(MDD702) I MDIORD=-1 D
66 . . S RESULT=-1,MSG="Unable to create Instrument Order Number."
67 . . Q
68 . Q
69 I RESULT=1 D ; Process the message to be sent
70 . D EN1^MDHL7BH ; Build HL7 Message
71 . I $P(MDERROR,U,2) S RESULT="-1",MSG=$P(MDERROR,U,3)
72 . Q
73 Q
Note: See TracBrowser for help on using the repository browser.