/// <summary> /// Validate the message /// </summary> internal static void Validate(IMessage message, ISystemConfigurationService config, List <IResultDetail> dtls, IServiceProvider context) { // Structure validation PipeParser pp = new PipeParser() { ValidationContext = new DefaultValidation() }; try { pp.Encode(message); } catch (Exception e) { dtls.Add(new ValidationResultDetail(ResultDetailType.Error, e.Message, e)); } // Validation of sending application try { Terser msgTerser = new Terser(message); object obj = msgTerser.getSegment("MSH") as NHapi.Model.V25.Segment.MSH; if (obj != null) { var msh = obj as NHapi.Model.V25.Segment.MSH; var domainId = new ComponentUtility() { Context = context }.CreateDomainIdentifier(msh.SendingApplication, dtls); if (!config.IsRegisteredDevice(domainId)) { dtls.Add(new UnrecognizedSenderResultDetail(domainId)); } } else { obj = msgTerser.getSegment("MSH") as NHapi.Model.V231.Segment.MSH; if (obj != null) { var msh = obj as NHapi.Model.V231.Segment.MSH; var domainId = new ComponentUtility() { Context = context }.CreateDomainIdentifier(msh.SendingApplication, dtls); if (!config.IsRegisteredDevice(domainId)) { dtls.Add(new UnrecognizedSenderResultDetail(domainId)); } } else { dtls.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, "Missing MSH", "MSH")); } } } catch (Exception e) { dtls.Add(new ResultDetail(ResultDetailType.Error, e.Message, e)); } }
/// <summary> /// Create a domain identifier list /// </summary> //internal static List<DomainIdentifier> CreateDomainIdentifierList(List<MARC.Everest.RMIM.CA.R020403.REPC_MT500006CA.RecordId> list) //{ // List<DomainIdentifier> retVal = new List<DomainIdentifier>(); // foreach (var recId in list) // retVal.Add(new DomainIdentifier() // { // Domain = recId.Value.Root, // Identifier = recId.Value.Extension // }); // return retVal; //} /// <summary> /// Validates common transport wrapper flags /// </summary> public static void ValidateTransportWrapper(IInteraction interaction, ISystemConfigurationService config, List <IResultDetail> dtls) { // Check the response mode code string rspMode = Util.ToWireFormat((interaction as IImplementsResponseModeCode <ResponseMode>).ResponseModeCode); string procMode = Util.ToWireFormat((interaction as IImplementsProcessingCode <ProcessingID>).ProcessingCode); var profile = interaction as IImplementsProfileId; // Check response mode if (rspMode != "I") { dtls.Add(new UnsupportedResponseModeResultDetail(rspMode)); } //// Check processing id //if (procMode != "P" && procMode != "D") // dtls.Add(new UnsupportedProcessingModeResultDetail(procMode)); // Check version identifier if (!interaction.VersionCode.CodeValue.Equals("V3-2008N")) { dtls.Add(new UnsupportedVersionResultDetail(String.Format("Version '{0}' is not supported by this endpoint", interaction.VersionCode))); } else if (profile == null || profile.ProfileId.Count(o => II.Comparator(o, MCCI_IN000002CA.GetProfileId()[0]) == 0) == 0) { dtls.Add(new UnsupportedVersionResultDetail(String.Format("Supplied profile identifier does not match any profile identifier this endpoint can reliably process"))); } Sender sndr = interaction.GetType().GetProperty("Sender").GetValue(interaction, null) as Sender; if (sndr == null || sndr.NullFlavor != null || sndr.Device == null || sndr.Device.NullFlavor != null || sndr.Device.Id == null || sndr.Device.Id.IsNull) { dtls.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, "Sender information is missing from message", null)); } else { var sndrId = new DomainIdentifier() { Domain = sndr.Device.Id.Root, Identifier = sndr.Device.Id.Extension }; if (!config.IsRegisteredDevice(sndrId)) { dtls.Add(new UnrecognizedSenderResultDetail(sndrId)); } } }
/// <summary> /// Generate altnerative ack detilas for the MCCI message set /// </summary> //public static IEnumerable<AcknowledgementDetail> CreateGenAckDetails(IResultDetail[] details) //{ // List<AcknowledgementDetail> retVal = new List<AcknowledgementDetail>(10); // foreach (var item in MessageUtil.CreateAckDetails(details)) // retVal.Add(new AcknowledgementDetail( // item.TypeCode, item.Code, item.Text, item.Location)); // return retVal; //} /// <summary> /// Create a domain identifier list /// </summary> //internal static List<DomainIdentifier> CreateDomainIdentifierList(List<MARC.Everest.RMIM.CA.R020403.REPC_MT500006CA.RecordId> list) //{ // List<DomainIdentifier> retVal = new List<DomainIdentifier>(); // foreach (var recId in list) // retVal.Add(new DomainIdentifier() // { // Domain = recId.Value.Root, // Identifier = recId.Value.Extension // }); // return retVal; //} /// <summary> /// Validates common transport wrapper flags /// </summary> public static void ValidateTransportWrapperUv(IInteraction interaction, ISystemConfigurationService config, List <IResultDetail> dtls) { // Check the response mode code string procMode = Util.ToWireFormat((interaction as IImplementsProcessingCode <ProcessingID>).ProcessingCode); var profile = interaction as IImplementsProfileId; // Check processing id //if (procMode != "P" && procMode != "D") // dtls.Add(new UnsupportedProcessingModeResultDetail(procMode)); // Check version identifier if (interaction.VersionCode != null && !interaction.VersionCode.CodeValue.Equals(HL7StandardVersionCode.Version3_Prerelease1)) { dtls.Add(new UnsupportedVersionResultDetail(String.Format("Version '{0}' is not supported by this endpoint", interaction.VersionCode))); } //if(profile == null) // dtls.Add(new FixedValueMisMatchedResultDetail(String.Empty, String.Format("{1}^^^&{0}&ISO", MCCI_IN000002UV01.GetProfileId()[0].Root, MCCI_IN000002UV01.GetProfileId()[0].Extension), false, "//urn:hl7-org:v3#profileId")); //else if (profile == null || profile.ProfileId.Count(o => II.Comparator(o, MCCI_IN000002UV01.GetProfileId()[0]) == 0) == 0) // dtls.Add(new UnsupportedVersionResultDetail(String.Format("Supplied profile identifier does not match any profile identifier this endpoint can reliably process"))); Sender sndr = interaction.GetType().GetProperty("Sender").GetValue(interaction, null) as Sender; if (sndr == null || sndr.NullFlavor != null || sndr.Device == null || sndr.Device.NullFlavor != null || sndr.Device.Id == null || sndr.Device.Id.IsNull) { dtls.Add(new MandatoryElementMissingResultDetail(ResultDetailType.Error, "Sender information is missing from message", null)); } else { var sndrId = sndr.Device.Id.Find(o => !config.IsRegisteredDevice(new DomainIdentifier() { Domain = o.Root, Identifier = o.Extension })); if (sndrId != null) { dtls.Add(new UnrecognizedSenderResultDetail(new DomainIdentifier() { Domain = sndrId.Root, Identifier = sndrId.Extension })); } } }