Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: MDHL7B

MDHL7B.m

Go to the documentation of this file.
  1. MDHL7B ; HOIFO/WAA -Bi-directional interface routine ;7/23/01 11:41
  1. ;;1.0;CLINICAL PROCEDURES;**41**;Apr 01, 2004;Build 3
  1. ;
  1. ; IA# 5844 [Supported] Calls to XLFIPV
  1. ; This routine will take an entry from 702 and submit that data
  1. ; to the instrument that was indicated by the user
  1. ; SUB is a submit function
  1. ; MDD702 is the IEN for the Entry from 702 that
  1. ; needs to be sent.
  1. ; The function will return -1^Submission failed and why
  1. ; 0^Device not Bi-Directional
  1. ; 1^Study submitted
  1. ;
  1. ; 09/25/15 KAM Remedy ticket 1095728 patch MD*1*41 IPv6 modifications
  1. ;
  1. TMPSUB(MDD702) ; Process a submitted entry from user.
  1. ; drp 16-JUL-2002 13:30:32
  1. N DEVICE
  1. S DEVICE=+$P(^MDD(702,MDD702,0),U,11) Q:'DEVICE "0^No Device - TEST"
  1. I +$P($G(^MDS(702.09,DEVICE,.1)),U,3) Q "1^Study Submitted - TEST"
  1. Q "0^No Bi Di Cap - TEST"
  1. ;
  1. SUB(MDD702) ; Change to SUB when working
  1. N MDORFLG,RESULT,MSG,MDERROR
  1. S MDORFLG=1
  1. D EN1
  1. Q RESULT_U_MSG
  1. ;
  1. CANCEL(MDD702) ; Cancel Orders
  1. N MDORFLG,RESULT,MSG,MDERROR
  1. S MDORFLG=0
  1. D EN1
  1. Q RESULT_U_MSG
  1. ;
  1. EN1 ; The main entry point for the order to be processed.
  1. N DEVIEN,WORKING,MDIORD
  1. ; Get the device that will process this study
  1. ; Build an HL7 Message based in the device.
  1. ; After the device has processed the message this routine will
  1. ; update the status with in 702.
  1. S RESULT=1,MSG=$S(MDORFLG=1:"Study Submitted.",1:"Study Cancelled")
  1. I '$D(^MDD(702,MDD702,0)) S MSG="There is no study in 702 for entry "_MDD702_".",RESULT=-1
  1. I RESULT'=-1 D ;Get the device based on the CP def
  1. . 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."
  1. . Q
  1. I RESULT'=-1 D ; Check to see that there is a device entered for this procedure
  1. . S DEVIEN=$P(^MDD(702,MDD702,0),U,11) I DEVIEN>0 Q
  1. . S RESULT=0,MSG="No DEVICE is defined." Q
  1. . Q
  1. ;
  1. ; DRP/16-MAY-2003 14:44:36 - Check for Loopback IP
  1. ; 09/25/15 KAM Remedy ticket 1095728 patch MD*1*41 IPv6 modifications
  1. ; Changed next line to use new IPv6 API
  1. ;
  1. ;I $$GET1^DIQ(702.09,DEVIEN_",",.14)="127.0.0.1" D Q
  1. I $$CONVERT^XLFIPV($$GET1^DIQ(702.09,DEVIEN_",",.14))=$$CONVERT^XLFIPV("127.0.0.1") D Q
  1. . D LOOPBACK^MDHL7XXX(MDD702,DEVIEN)
  1. . S RESULT=+$$GET1^DIQ(702.09,DEVIEN_",",.13,"I"),MSG="OK"
  1. . Q
  1. ;
  1. I RESULT>0 D ; Check to see that the device is a active and working
  1. . S WORKING="" D INST^MDHL7U2(DEVIEN,.WORKING)
  1. . Q:WORKING
  1. . S RESULT=-1,MSG="There is a problem with the device entry in file 702.09."
  1. . Q
  1. I RESULT>0 D ; Check to see if the device is bi-directional
  1. . N LINE
  1. . S LINE=$G(^MDS(702.09,DEVIEN,.1))
  1. . I $P(LINE,U,3)'=1 D Q ; The Device is not Bi-Directional
  1. . . S RESULT=0,MSG="Device not Bi-Directional."
  1. . . Q
  1. . ; The device is Bi-Directional and we are getting an MDIORD number.
  1. . S MDIORD=$$GETIORD^MDRPCOT1(MDD702) I MDIORD=-1 D
  1. . . S RESULT=-1,MSG="Unable to create Instrument Order Number."
  1. . . Q
  1. . Q
  1. I RESULT=1 D ; Process the message to be sent
  1. . D EN1^MDHL7BH ; Build HL7 Message
  1. . I $P(MDERROR,U,2) S RESULT="-1",MSG=$P(MDERROR,U,3)
  1. . Q
  1. Q