/// <summary> /// Create an Hl7 Client of the given type. /// </summary> /// <param name="hl7ClientType">Hl7 Client Type - enum.</param> /// <param name="fromActor">From Actor instance.</param> /// <param name="toActorName">To Actor Name.</param> /// <param name="commonConfig">Common Configuration.</param> /// <param name="config">HL7 Configuration.</param> /// <returns>Hl7 Client.</returns> public static Hl7Client CreateHl7Client(Hl7ClientTypeEnum hl7ClientType, BaseActor fromActor, ActorName toActorName, CommonConfig commonConfig, Hl7PeerToPeerConfig config) { Hl7Client hl7Client = null; switch (hl7ClientType) { case Hl7ClientTypeEnum.Hl7Client: hl7Client = new Hl7Client(fromActor, toActorName, commonConfig, config); break; case Hl7ClientTypeEnum.Unknown: default: break; } return(hl7Client); }
/// <summary> /// Create a Hl7 Server of the given type. /// </summary> /// <param name="hl7ServerType">Hl7 Server Type - enum.</param> /// <param name="toActor">To Actor instance.</param> /// <param name="fromActorName">From Actor Name.</param> /// <param name="commonConfig">Common Configuration.</param> /// <param name="config">HL7 Configuration.</param> /// <returns>Hl7 Server.</returns> public static Hl7Server CreateHl7Server(Hl7ServerTypeEnum hl7ServerType, BaseActor toActor, ActorName fromActorName, CommonConfig commonConfig, Hl7PeerToPeerConfig config) { Hl7Server hl7Server = null; switch (hl7ServerType) { case Hl7ServerTypeEnum.Hl7QueryServer: hl7Server = new Hl7QueryServer(toActor, fromActorName, commonConfig, config); break; case Hl7ServerTypeEnum.Hl7Server: hl7Server = new Hl7Server(toActor, fromActorName, commonConfig, config); break; case Hl7ServerTypeEnum.Unknown: default: break; } return(hl7Server); }
/// <summary> /// Load the Actor Configuration into the Integration Profile. /// </summary> /// <param name="configurationFilename">Configuration Filename</param> public void Load(System.String configurationFilename) { _actorConfigCollection = new ActorConfigCollection(); _peerToPeerConfigCollection = new BasePeerToPeerConfigCollection(); try { XmlTextReader reader = new XmlTextReader(configurationFilename); while (reader.EOF == false) { reader.ReadStartElement("IheIntegrationProfile"); _profileName = reader.ReadElementString("IntegrationProfileName"); _commonConfig.RootedBaseDirectory = reader.ReadElementString("RootedBaseDirectory"); _commonConfig.ResultsDirectory = reader.ReadElementString("ResultsDirectory"); // read OverwriteResults - added later - some config files may not contain this parameter reader.ReadString(); if (reader.Name == "OverwriteResults") { System.String overwriteResults = reader.ReadElementString("OverwriteResults"); if (overwriteResults == "True") { _commonConfig.OverwriteResults = true; } else { _commonConfig.OverwriteResults = false; } } _commonConfig.CredentialsFilename = reader.ReadElementString("CredentialsFilename"); _commonConfig.CertificateFilename = reader.ReadElementString("CertificateFilename"); _commonConfig.NistWebServiceUrl = reader.ReadElementString("NistWebServiceUrl"); _commonConfig.Hl7ProfileDirectory = reader.ReadElementString("Hl7ProfileDirectory"); _commonConfig.Hl7ProfileStoreName = reader.ReadElementString("Hl7ProfileStoreName"); _commonConfig.Hl7ValidationContextFilename = reader.ReadElementString("Hl7ValidationContextFilename"); System.String interactive = reader.ReadElementString("Interactive"); if (interactive == "True") { _commonConfig.Interactive = true; } else { _commonConfig.Interactive = false; } while ((reader.IsStartElement()) && (reader.Name == "ActorConfiguration")) { reader.ReadStartElement("ActorConfiguration"); reader.ReadStartElement("ActorName"); ActorTypeEnum actorType = ActorTypes.TypeEnum(reader.ReadElementString("ActorType")); System.String id = reader.ReadElementString("ActorId"); ActorName actorName = new ActorName(actorType, id); reader.ReadEndElement(); ActorConfigStateEnum configState = ActorConfigState.ConfigStateEnum(reader.ReadElementString("ConfigState")); ActorConfig actorConfig = new ActorConfig(actorName, configState); _actorConfigCollection.Add(actorConfig); reader.ReadEndElement(); } while ((reader.IsStartElement()) && ((reader.Name == "DicomPeerToPeerConfiguration") || (reader.Name == "Hl7PeerToPeerConfiguration"))) { if (reader.Name == "DicomPeerToPeerConfiguration") { DicomPeerToPeerConfig dicomPeerToPeerConfig = new DicomPeerToPeerConfig(); reader.ReadStartElement("DicomPeerToPeerConfiguration"); reader.ReadStartElement("FromActor"); reader.ReadStartElement("ActorName"); ActorTypeEnum actorType = ActorTypes.TypeEnum(reader.ReadElementString("ActorType")); System.String id = reader.ReadElementString("ActorId"); ActorName actorName = new ActorName(actorType, id); dicomPeerToPeerConfig.FromActorName = actorName; reader.ReadEndElement(); dicomPeerToPeerConfig.FromActorAeTitle = reader.ReadElementString("AeTitle"); reader.ReadEndElement(); reader.ReadStartElement("ToActor"); reader.ReadStartElement("ActorName"); actorType = ActorTypes.TypeEnum(reader.ReadElementString("ActorType")); id = reader.ReadElementString("ActorId"); actorName = new ActorName(actorType, id); dicomPeerToPeerConfig.ToActorName = actorName; reader.ReadEndElement(); dicomPeerToPeerConfig.ToActorAeTitle = reader.ReadElementString("AeTitle"); dicomPeerToPeerConfig.ToActorIpAddress = reader.ReadElementString("IpAddress"); reader.ReadEndElement(); dicomPeerToPeerConfig.PortNumber = UInt16.Parse(reader.ReadElementString("PortNumber")); System.String secureConnection = reader.ReadElementString("SecureConnection"); if (secureConnection == "True") { dicomPeerToPeerConfig.SecureConnection = true; } else { dicomPeerToPeerConfig.SecureConnection = false; } // read AutoValidate - added later - some config files may not contain this parameter reader.ReadString(); if (reader.Name == "AutoValidate") { System.String autoValidate = reader.ReadElementString("AutoValidate"); if (autoValidate == "True") { dicomPeerToPeerConfig.AutoValidate = true; } else { dicomPeerToPeerConfig.AutoValidate = false; } } dicomPeerToPeerConfig.ActorOption1 = reader.ReadElementString("ActorOption1"); dicomPeerToPeerConfig.ActorOption2 = reader.ReadElementString("ActorOption2"); dicomPeerToPeerConfig.ActorOption3 = reader.ReadElementString("ActorOption3"); dicomPeerToPeerConfig.SessionId = UInt16.Parse(reader.ReadElementString("SessionId")); dicomPeerToPeerConfig.SourceDataDirectory = reader.ReadElementString("SourceDataDirectory"); dicomPeerToPeerConfig.StoreDataDirectory = reader.ReadElementString("StoreDataDirectory"); System.String storeData = reader.ReadElementString("StoreData"); if (storeData == "True") { dicomPeerToPeerConfig.StoreData = true; } else { dicomPeerToPeerConfig.StoreData = false; } reader.ReadStartElement("DefinitionFiles"); bool readingDefinitionFiles = true; while (readingDefinitionFiles == true) { dicomPeerToPeerConfig.AddDefinitionFile(reader.ReadElementString("DefinitionFile")); reader.Read(); if ((reader.NodeType == XmlNodeType.EndElement) && (reader.Name == "DefinitionFiles")) { reader.Read(); readingDefinitionFiles = false; } } _peerToPeerConfigCollection.Add(dicomPeerToPeerConfig); reader.ReadEndElement(); } else { Hl7PeerToPeerConfig hl7PeerToPeerConfig = new Hl7PeerToPeerConfig(); reader.ReadStartElement("Hl7PeerToPeerConfiguration"); reader.ReadStartElement("FromActor"); reader.ReadStartElement("ActorName"); ActorTypeEnum actorType = ActorTypes.TypeEnum(reader.ReadElementString("ActorType")); System.String id = reader.ReadElementString("ActorId"); ActorName actorName = new ActorName(actorType, id); hl7PeerToPeerConfig.FromActorName = actorName; reader.ReadEndElement(); hl7PeerToPeerConfig.FromActorAeTitle = reader.ReadElementString("AeTitle"); reader.ReadEndElement(); reader.ReadStartElement("ToActor"); reader.ReadStartElement("ActorName"); actorType = ActorTypes.TypeEnum(reader.ReadElementString("ActorType")); id = reader.ReadElementString("ActorId"); actorName = new ActorName(actorType, id); hl7PeerToPeerConfig.ToActorName = actorName; reader.ReadEndElement(); hl7PeerToPeerConfig.ToActorAeTitle = reader.ReadElementString("AeTitle"); hl7PeerToPeerConfig.ToActorIpAddress = reader.ReadElementString("IpAddress"); reader.ReadEndElement(); hl7PeerToPeerConfig.PortNumber = UInt16.Parse(reader.ReadElementString("PortNumber")); hl7PeerToPeerConfig.MessageDelimiters.FromString(reader.ReadElementString("MessageDelimiters")); System.String secureConnection = reader.ReadElementString("SecureConnection"); if (secureConnection == "True") { hl7PeerToPeerConfig.SecureConnection = true; } else { hl7PeerToPeerConfig.SecureConnection = false; } // read AutoValidate - added later - some config files may not contain this parameter reader.ReadString(); if (reader.Name == "AutoValidate") { System.String autoValidate = reader.ReadElementString("AutoValidate"); if (autoValidate == "True") { hl7PeerToPeerConfig.AutoValidate = true; } else { hl7PeerToPeerConfig.AutoValidate = false; } } hl7PeerToPeerConfig.ActorOption1 = reader.ReadElementString("ActorOption1"); hl7PeerToPeerConfig.ActorOption2 = reader.ReadElementString("ActorOption2"); hl7PeerToPeerConfig.ActorOption3 = reader.ReadElementString("ActorOption3"); hl7PeerToPeerConfig.SessionId = UInt16.Parse(reader.ReadElementString("SessionId")); _peerToPeerConfigCollection.Add(hl7PeerToPeerConfig); reader.ReadEndElement(); } } reader.ReadEndElement(); } reader.Close(); } catch (System.Exception e) { System.String message = System.String.Format("Failed to read configuration file: \"{0}\". Error: \"{1}\"", configurationFilename, e.Message); throw new System.SystemException(message, e); } }