Пример #1
0
        public static void Parse(HL7Message hl7Message, string hl7Input)
        {
            try
            {
                List <string> delimitedResult = hl7Input.Split(Convert.ToChar(CR)).ToList();

                foreach (string segment in delimitedResult)
                {
                    Segment s = new Segment();

                    s.Parse(segment);

                    hl7Message.segments.Add(s);
                }

                // get the message type after you've processed the message
                hl7Message.messageType = HL7MessageUtility.getMessageType(hl7Message, hl7Input);
            }
            catch (Exception e)
            {
                ErrorLogger.LogError(e, "HL7Message.Parse(HL7Message hl7Message, string hl7Input)", hl7Input);
            }
        }
Пример #2
0
        public static void handleProcessingForOutboundHandler(Configuration masterConfig, OutboundHandler outboundHandler)
        {
            // to control some basic CPU handling settings
            Config outboundConfig = new Config();

            // load each of the configurations into their own objects
            List <Application>           applications          = masterConfig.applications;
            List <Communication>         communications        = masterConfig.communications;
            List <WebserviceObject>      webserviceObjects     = masterConfig.webserviceObjects;
            List <WebserviceInstance>    webserviceInstances   = masterConfig.webserviceInstances;
            List <WebservicePropertySet> webserviceProperties  = masterConfig.webservicePropertySets;
            List <MessageGroup>          messageGroups         = masterConfig.messageGroups;
            List <MessageGroupInstance>  messageGroupInstances = masterConfig.messageGroupInstances;

            // continue to read the table
            while (true)
            {
                applications.ForEach(delegate(Application app)
                {
                    if (app.name == outboundHandler.getApplicationName())
                    {
                        // get the unprocessed message count for the application
                        List <MessageBucket> brokerInformation
                            = MessageBucketDAO.GetUnprocessedMessageHeaderInstancesByApplication(app);

                        // set the MOD from config file.
                        var options = new ParallelOptions {
                            MaxDegreeOfParallelism = outboundConfig.MaxDegreeOfParallelism
                        };
                        // parallel For each
                        Parallel.ForEach(brokerInformation, options, broker =>
                        {
                            // get the message header and message
                            MessageHeaderInstance messageHeaderInstance = broker.messageHeaderInstance;
                            Message message = broker.message;

                            // srub the input of bad stuff
                            string hl7Scrubbed = HL7MessageUtility.scrubHL7MessageForParse(message.hl7Raw);

                            // make the hl7 message
                            HL7Message hl7Message = HL7MessageDAO.getMessage(hl7Scrubbed);

                            // locally retrieve the communication object from memory
                            Communication communication
                                = ConfigurationUtility.GetIncomingWebserviceCommunication(app, communications);

                            // locally retrieve the webservice instance object from memory
                            WebserviceInstance webserviceInstance
                                = ConfigurationUtility.GetIncomingWebserviceInstance(communication, webserviceInstances);

                            // locally retrieve the web service objects from memory
                            List <WebserviceObject> wsObjects
                                = ConfigurationUtility.GetIncomingWebserviceObjects(webserviceInstance, webserviceObjects);

                            // determine the message type
                            Generic.MessageType messageType
                                = HL7MessageUtility.getMessageType(hl7Message, hl7Scrubbed);

                            switch (messageType)
                            {
                            // to handle a new message add message type then its own handler
                            case Generic.MessageType.ADT:
                                break;

                            case Generic.MessageType.ORM:
                                handleProcessingForORM(wsObjects,
                                                       webserviceProperties,
                                                       hl7Message,
                                                       messageGroupInstances,
                                                       messageGroups,
                                                       app,
                                                       message);
                                break;

                            case Generic.MessageType.ORU:
                                handleProcessingForORU(wsObjects,
                                                       webserviceProperties,
                                                       hl7Message,
                                                       messageGroupInstances,
                                                       messageGroups,
                                                       app,
                                                       message);
                                break;

                            case Generic.MessageType.SIU:
                                break;

                            case Generic.MessageType.UNKNOWN:
                                break;

                            default:
                                break;
                            }

                            // update the table to processed
                            MessageBucketDAO.UpdateProcessedFlagAndMessageLog(messageHeaderInstance, message, true);

                            // update broker stats
                            handleBrokerStatUpdate(message, communication);
                        });
                    }
                });

                // provide blocking if there is no data to process.
                Thread.Sleep(1000);
            }
        }