/// <summary> /// Creates filter data from the request /// </summary> public RegistryQueryRequest CreateFilterData(MARC.Everest.Interfaces.IInteraction request, List <MARC.Everest.Connectors.IResultDetail> dtls) { ILocalizationService locale = Context.GetService(typeof(ILocalizationService)) as ILocalizationService; // Componentize the message into the data model CaComponentUtil compUtil = new CaComponentUtil(); compUtil.Context = this.Context; PRPA_IN101103CA rqst = request as PRPA_IN101103CA; List <DomainIdentifier> ids = new List <DomainIdentifier>(); var queryData = compUtil.CreateQueryMatch(rqst.controlActEvent, dtls, ref ids); if (ids == null || queryData == null) { throw new MessageValidationException(locale.GetString("MSGE00A"), request); } var filter = MessageUtil.CreateQueryData(rqst.controlActEvent.QueryByParameter, String.Format("{1}^^^&{0}&ISO", rqst.Sender.Device.Id.Root, rqst.Sender.Device.Id.Extension) ); filter.OriginalMessageQueryId = String.Format("{1}^^^&{0}&ISO", request.Id.Root, request.Id.Extension); filter.QueryRequest = queryData; filter.TargetDomain = ids; filter.IsSummary = true; return(filter); }
/// <summary> /// Create filter data /// </summary> public RegistryQueryRequest CreateFilterData(MARC.Everest.Interfaces.IInteraction request, List <MARC.Everest.Connectors.IResultDetail> dtls) { ILocalizationService locale = Context.GetService(typeof(ILocalizationService)) as ILocalizationService; ISystemConfigurationService config = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService; // Componentize the message into the data model UvComponentUtil compUtil = new UvComponentUtil(); compUtil.Context = this.Context; PRPA_IN201309UV02 rqst = request as PRPA_IN201309UV02; List <DomainIdentifier> ids = new List <DomainIdentifier>(); var queryData = compUtil.CreateQueryMatch(rqst.controlActProcess, dtls, ref ids); if (ids == null || queryData == null) { throw new MessageValidationException(locale.GetString("MSGE00A"), request); } var filter = new RegistryQueryRequest() { QueryId = String.Format("{1}^^^&{0}&ISO", rqst.controlActProcess.queryByParameter.QueryId.Root, rqst.controlActProcess.queryByParameter.QueryId.Extension), Limit = 100, Originator = String.Format("{1}^^^&{0}&ISO", rqst.Sender.Device.Id.First.Root, rqst.Sender.Device.Id.First.Extension), QueryRequest = queryData, TargetDomain = ids, IsSummary = true, ResponseMessageType = this.CreateType.AssemblyQualifiedName }; // Ensure that the target domains are understood by this service if (filter.TargetDomain != null) { foreach (var id in filter.TargetDomain) { if (String.IsNullOrEmpty(id.Domain) || config.OidRegistrar.FindData(id.Domain) == null || !config.OidRegistrar.FindData(id.Domain).Attributes.Exists(p => p.Key.Equals("AssigningAuthorityName"))) { dtls.Add(new UnrecognizedTargetDomainResultDetail(locale, String.Format("//urn:hl7-org:v3#controlActProcess/urn:hl7-org:v3#queryByParameter/urn:hl7-org:v3#parameterList/urn:hl7-org:v3#patientIdentifier/urn:hl7-org:v3#value[@root='{0}']", id.Domain))); } } } return(filter); }
/// <summary> /// Create the response message /// </summary> public MARC.Everest.Interfaces.IInteraction Create(MARC.Everest.Interfaces.IInteraction request, RegistryQueryResult results, List <IResultDetail> dtls) { // GEt the config services ISystemConfigurationService configService = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService; ILocalizationService localeService = Context.GetService(typeof(ILocalizationService)) as ILocalizationService; var retHl7v3 = new List <MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject1 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object> >(results.Results.Count); UvDeComponentUtil dCompUtil = new UvDeComponentUtil(); dCompUtil.Context = this.Context; PRPA_IN201309UV02 rqst = request as PRPA_IN201309UV02; // Convert results to HL7v3 foreach (RegistrationEvent res in results.Results) { var retRec = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject1 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object>( false, dCompUtil.CreateRegistrationEventDetail(res, dtls) ); if (retRec.RegistrationEvent == null) { retRec = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject1 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object>( false, new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.RegistrationEvent <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object>() { NullFlavor = NullFlavor.NoInformation } ); } retHl7v3.Add(retRec); } if (retHl7v3.Count > 1) { dtls.Add(new InsufficientRepetitionsResultDetail(ResultDetailType.Warning, localeService.GetString("MSGE06E"), null)); } // Create the response PRPA_IN201310UV02 response = new PRPA_IN201310UV02 ( Guid.NewGuid(), DateTime.Now, PRPA_IN201310UV02.GetInteractionId(), ProcessingID.Production, "T", AcknowledgementCondition.Never, MessageUtil.CreateReceiver(rqst.Sender), MessageUtil.CreateSenderUv(new Uri(rqst.Receiver[0].Telecom.Value), configService), null ) { Acknowledgement = new List <MARC.Everest.RMIM.UV.NE2008.MCCI_MT100300UV01.Acknowledgement>() { new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100300UV01.Acknowledgement( dtls.Count(a => a.Type == ResultDetailType.Error) == 0 ? AcknowledgementType.ApplicationAcknowledgementAccept : AcknowledgementType.ApplicationAcknowledgementError, new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.TargetMessage(request.Id) ) } }; response.controlActProcess = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.ControlActProcess <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201307UV02.QueryByParameter, MARC.Everest.RMIM.UV.NE2008.PRPA_MT201304UV02.Patient, object>("EVN") { Id = SET <II> .CreateSET(new II(configService.Custodianship.Id.Domain, Guid.NewGuid().ToString())), Code = new CD <string>(PRPA_IN201310UV02.GetTriggerEvent().Code, PRPA_IN201310UV02.GetTriggerEvent().CodeSystem), QueryAck = new MARC.Everest.RMIM.UV.NE2008.QUQI_MT120001UV01.QueryAck( rqst.controlActProcess.queryByParameter.QueryId, "complete", (AcknowledgementType)response.Acknowledgement[0].TypeCode == AcknowledgementType.ApplicationAcknowledgementError ? QueryResponse.ApplicationError : results.TotalResults == 0 ? QueryResponse.NoDataFound : QueryResponse.DataFound, results.TotalResults, results.Results.Count, results.TotalResults - results.Results.Count - results.StartRecordNumber ), queryByParameter = rqst.controlActProcess.queryByParameter }; response.controlActProcess.LanguageCode = MessageUtil.GetDefaultLanguageCode(this.Context); if (retHl7v3.Count > 0) { response.controlActProcess.Subject.Add(retHl7v3[0]); } return(response); }
/// <summary> /// Create filter data /// </summary> public RegistryQueryRequest CreateFilterData(MARC.Everest.Interfaces.IInteraction request, List <MARC.Everest.Connectors.IResultDetail> dtls) { ILocalizationService locale = Context.GetService(typeof(ILocalizationService)) as ILocalizationService; ISystemConfigurationService config = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService; // Componentize the message into the data model UvComponentUtil compUtil = new UvComponentUtil(); compUtil.Context = this.Context; PRPA_IN201305UV02 rqst = request as PRPA_IN201305UV02; List <DomainIdentifier> ids = new List <DomainIdentifier>(); var queryData = compUtil.CreateQueryMatch(rqst.controlActProcess, dtls, ref ids); if (ids == null || queryData == null) { throw new MessageValidationException(locale.GetString("MSGE00A"), request); } var filter = new RegistryQueryRequest() { QueryId = String.Format("{1}^^^&{0}&ISO", rqst.controlActProcess.queryByParameter.QueryId.Root, rqst.controlActProcess.queryByParameter.QueryId.Extension), Limit = rqst.controlActProcess.queryByParameter.InitialQuantity == null ? 100 : (int)rqst.controlActProcess.queryByParameter.InitialQuantity, Originator = String.Format("{1}^^^&{0}&ISO", rqst.Sender.Device.Id.First.Root, rqst.Sender.Device.Id.First.Extension), ResponseMessageType = this.CreateType.AssemblyQualifiedName, QueryRequest = queryData, IsSummary = true, OriginalMessageQueryId = String.Format("{1}^^^&{0}&ISO", request.Id.Root, request.Id.Extension) }; // Filter parameters var qbp = rqst.controlActProcess.queryByParameter; if (qbp != null && qbp.MatchCriterionList != null && qbp.MatchCriterionList.NullFlavor == null) { if (qbp.MatchCriterionList.MatchAlgorithm != null && qbp.MatchCriterionList.MatchAlgorithm.NullFlavor == null && qbp.MatchCriterionList.MatchAlgorithm.Value is ST) { try { filter.MatchingAlgorithm = (MatchAlgorithm)Enum.Parse(typeof(MatchAlgorithm), qbp.MatchCriterionList.MatchAlgorithm.Value as ST); } catch { dtls.Add(new VocabularyIssueResultDetail(ResultDetailType.Warning, String.Format(locale.GetString("MSGE071"), qbp.MatchCriterionList.MatchAlgorithm.Value as ST), null)); } } else { filter.MatchingAlgorithm = MatchAlgorithm.Default; } // Match degree match if (qbp.MatchCriterionList.MinimumDegreeMatch != null && qbp.MatchCriterionList.MinimumDegreeMatch.NullFlavor == null && qbp.MatchCriterionList.MinimumDegreeMatch.Value != null && !qbp.MatchCriterionList.MinimumDegreeMatch.Value.IsNull) { var match = qbp.MatchCriterionList.MinimumDegreeMatch.Value as INT; if (match == null || match < 0 || match > 100) { dtls.Add(new NotSupportedChoiceResultDetail(ResultDetailType.Warning, locale.GetString("MSGE072"), null, null)); } else { filter.MinimumDegreeMatch = (float)((float)match / 100); } } } // Ensure that the target domains are understood by this service if (filter.TargetDomain != null) { foreach (var id in filter.TargetDomain) { if (String.IsNullOrEmpty(id.Domain) || config.OidRegistrar.FindData(id.Domain) == null || !config.OidRegistrar.FindData(id.Domain).Attributes.Exists(p => p.Key.Equals("AssigningAuthorityName"))) { dtls.Add(new UnrecognizedTargetDomainResultDetail(locale, String.Format("//urn:hl7-org:v3#controlActProcess/urn:hl7-org:v3#queryByParameter/urn:hl7-org:v3#parameterList/urn:hl7-org:v3#patientIdentifier/urn:hl7-org:v3#value[@root='{0}']", id.Domain))); } } } return(filter); }
/// <summary> /// Create the interaction type /// </summary> public MARC.Everest.Interfaces.IInteraction Create(MARC.Everest.Interfaces.IInteraction request, RegistryQueryResult results, List <IResultDetail> dtls) { // GEt the config services ISystemConfigurationService configService = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService; var retHl7v3 = new List <MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject1 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Patient, object> >(); //List<MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.Subject2<MARC.Everest.RMIM.CA.R020403.PRPA_MT101104CA.IdentifiedEntity>> retHl7v3 = new List<MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.Subject2<MARC.Everest.RMIM.CA.R020403.PRPA_MT101104CA.IdentifiedEntity>>(results.Results.Count()); UvDeComponentUtil dCompUtil = new UvDeComponentUtil(); dCompUtil.Context = this.Context; PRPA_IN201305UV02 rqst = request as PRPA_IN201305UV02; // Convert results to HL7v3 foreach (RegistrationEvent res in results.Results) { var retRec = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject1 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Patient, object>( true, dCompUtil.CreateRegistrationEvent(res, dtls) ); if (retRec.RegistrationEvent == null) { retRec = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.Subject1 <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Patient, object>( false, new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.RegistrationEvent <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Patient, object>() { NullFlavor = NullFlavor.NoInformation } ); } retHl7v3.Add(retRec); } // HACK: Sort by confidence score (if present) //retHl7v3.Sort((a, b) => // a != null && b != null && // a.RegistrationEvent != null && b.RegistrationEvent != null && // a.RegistrationEvent.Subject1 != null && b.RegistrationEvent.Subject1 != null && // a.RegistrationEvent.Subject1.registeredRole != null && b.RegistrationEvent.Subject1.registeredRole != null && // (a.RegistrationEvent.Subject1.registeredRole.SubjectOf1.Count > 0) && (b.RegistrationEvent.Subject1.registeredRole.SubjectOf1.Count > 0) ? // (b.RegistrationEvent.Subject1.registeredRole.SubjectOf1[0].QueryMatchObservation.Value as INT).CompareTo((a.RegistrationEvent.Subject1.registeredRole.SubjectOf1[0].QueryMatchObservation.Value as INT)) : 0); // Create the response PRPA_IN201306UV02 response = new PRPA_IN201306UV02 ( Guid.NewGuid(), DateTime.Now, PRPA_IN201306UV02.GetInteractionId(), ProcessingID.Production, "T", AcknowledgementCondition.Never, MessageUtil.CreateReceiver(rqst.Sender), MessageUtil.CreateSenderUv(new Uri(rqst.Receiver[0].Telecom.Value), configService), null ) { Acknowledgement = new List <MARC.Everest.RMIM.UV.NE2008.MCCI_MT100300UV01.Acknowledgement>() { new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100300UV01.Acknowledgement( dtls.Count(a => a.Type == ResultDetailType.Error) == 0 ? AcknowledgementType.ApplicationAcknowledgementAccept : AcknowledgementType.ApplicationAcknowledgementError, new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.TargetMessage(request.Id) ) } }; response.controlActProcess = new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700711UV01.ControlActProcess <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter, MARC.Everest.RMIM.UV.NE2008.PRPA_MT201310UV02.Patient, object>("EVN") { Id = SET <II> .CreateSET(new II(configService.Custodianship.Id.Domain, Guid.NewGuid().ToString())), Code = new CD <string>(PRPA_IN201306UV02.GetTriggerEvent().Code, PRPA_IN201306UV02.GetTriggerEvent().CodeSystem), QueryAck = new MARC.Everest.RMIM.UV.NE2008.QUQI_MT120001UV01.QueryAck( rqst.controlActProcess.queryByParameter.QueryId, "complete", (AcknowledgementType)response.Acknowledgement[0].TypeCode == AcknowledgementType.ApplicationAcknowledgementError ? QueryResponse.ApplicationError : results.TotalResults == 0 ? QueryResponse.NoDataFound : QueryResponse.DataFound, results.TotalResults, results.Results.Count, results.TotalResults - results.Results.Count - results.StartRecordNumber ), queryByParameter = rqst.controlActProcess.queryByParameter }; response.controlActProcess.LanguageCode = MessageUtil.GetDefaultLanguageCode(this.Context); if (retHl7v3.Count > 0) { response.controlActProcess.Subject.AddRange(retHl7v3); } return(response); }
/// <summary> /// Create the interaction /// </summary> public MARC.Everest.Interfaces.IInteraction Create(MARC.Everest.Interfaces.IInteraction request, RegistryQueryResult results, List <MARC.Everest.Connectors.IResultDetail> details) { // GEt the config services ISystemConfigurationService configService = Context.GetService(typeof(ISystemConfigurationService)) as ISystemConfigurationService; List <MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.Subject2 <MARC.Everest.RMIM.CA.R020403.PRPA_MT101104CA.IdentifiedEntity> > retHl7v3 = new List <MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.Subject2 <MARC.Everest.RMIM.CA.R020403.PRPA_MT101104CA.IdentifiedEntity> >(results.Results.Count()); CaDeComponentUtil dCompUtil = new CaDeComponentUtil(); dCompUtil.Context = this.Context; PRPA_IN101103CA rqst = request as PRPA_IN101103CA; // Convert results to HL7v3 foreach (RegistrationEvent res in results.Results) { var retRec = new MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.Subject2 <MARC.Everest.RMIM.CA.R020403.PRPA_MT101104CA.IdentifiedEntity>( dCompUtil.CreateRegistrationEvent(res, details) ); if (retRec.RegistrationEvent == null) { retRec = new MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.Subject2 <MARC.Everest.RMIM.CA.R020403.PRPA_MT101104CA.IdentifiedEntity>( new MARC.Everest.RMIM.CA.R020403.MFMI_MT700746CA.RegistrationEvent <MARC.Everest.RMIM.CA.R020403.PRPA_MT101104CA.IdentifiedEntity>() { NullFlavor = NullFlavor.NoInformation } ); } retHl7v3.Add(retRec); } // HACK: Sort by confidence score (if present) retHl7v3.Sort((a, b) => b.RegistrationEvent.Subject.registeredRole.SubjectOf.ObservationEvent.Value.CompareTo(a.RegistrationEvent.Subject.registeredRole.SubjectOf.ObservationEvent.Value)); // Create the response PRPA_IN101104CA response = new PRPA_IN101104CA ( Guid.NewGuid(), DateTime.Now, ResponseMode.Immediate, PRPA_IN101104CA.GetInteractionId(), PRPA_IN101104CA.GetProfileId(), ProcessingID.Production, AcknowledgementCondition.Never, MessageUtil.CreateReceiver(rqst.Sender), MessageUtil.CreateSender(rqst.Receiver.Telecom == null ? null : new Uri(rqst.Receiver.Telecom.Value), configService), new MARC.Everest.RMIM.CA.R020403.MCCI_MT002200CA.Acknowledgement( details.Count(a => a.Type == ResultDetailType.Error) == 0 ? AcknowledgementType.ApplicationAcknowledgementAccept : AcknowledgementType.ApplicationAcknowledgementError, new MARC.Everest.RMIM.CA.R020403.MCCI_MT002200CA.TargetMessage(request.Id) ) ); response.Acknowledgement.AcknowledgementDetail = MessageUtil.CreateAckDetails(details.ToArray()); response.controlActEvent = PRPA_IN101104CA.CreateControlActEvent( new II(configService.Custodianship.Id.Domain, Guid.NewGuid().ToString()), PRPA_IN101104CA.GetTriggerEvent(), new MARC.Everest.RMIM.CA.R020403.QUQI_MT120008CA.QueryAck( rqst.controlActEvent.QueryByParameter.QueryId, results.TotalResults == 0 ? QueryResponse.NoDataFound : (AcknowledgementType)response.Acknowledgement.TypeCode == AcknowledgementType.ApplicationAcknowledgementError ? QueryResponse.ApplicationError : QueryResponse.DataFound, results.TotalResults, results.Results.Count, results.TotalResults - results.Results.Count - results.StartRecordNumber ), rqst.controlActEvent.QueryByParameter ); response.controlActEvent.LanguageCode = MessageUtil.GetDefaultLanguageCode(this.Context); if (details.Count(o => o is DetectedIssueResultDetail) > 0) { response.controlActEvent.SubjectOf.AddRange(MessageUtil.CreateDetectedIssueEventsQuery(details.OfType <DetectedIssueResultDetail>().Select(o => o.Issue).ToList())); } response.controlActEvent.Subject.AddRange(retHl7v3); return(response); }