Esempio n. 1
0
        public void EV_1089SETParseTest()
        {
            PRPA_IN201305UV02 test = new PRPA_IN201305UV02();

            test.Sender           = new RMIM.UV.NE2010.MCCI_MT100200UV01.Sender();
            test.Sender.Device    = new RMIM.UV.NE2010.MCCI_MT100200UV01.Device();
            test.Sender.Device.Id = new SET <II>()
            {
                NullFlavor = NullFlavor.NoInformation
            };

            XmlIts1Formatter fmtr = new XmlIts1Formatter();

            fmtr.GraphAides.Add(new DatatypeFormatter());

            var            sw     = new StringWriter();
            XmlStateWriter writer = new XmlStateWriter(XmlWriter.Create(sw));

            fmtr.Graph(writer, test);
            writer.Flush();
            String xmlString = sw.ToString();

            StringReader   sr     = new StringReader(xmlString);
            XmlStateReader rdr    = new XmlStateReader(XmlReader.Create(sr));
            var            result = fmtr.Parse(rdr);

            Assert.IsNotNull(result.Structure as PRPA_IN201305UV02);
            Assert.IsNotNull((result.Structure as PRPA_IN201305UV02).Sender.Device.Id);
            //Assert.AreEqual(test, result.Structure);
        }
        public PRPA_IN201306UV02 PRPA_IN201305UV02(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, PATIENT p)
        {
            PRPA_IN201306UV02 objReturn = null;

            try
            {
                PRPA_MT201306UV02ParameterList patientParameters = GetDemographicParameters(p);
                if (patientParameters == null)
                {
                    return(null);
                }
                QUQI_MT021001UV01DataEnterer[] currentUser = GetDataEnterer(CURRENT_USER, CURRENT_REGISTRY_ID);

                if (rsMain == null)
                {
                    InitProxy();
                }

                string createDateTime = DateTime.Now.ToString("yyyyMMddhhmmss");

                PRPA_IN201305UV02 PRPA_IN201305UV021 = new PRPA_IN201305UV02()
                {
                    id = new II()
                    {
                        root = vaRoot, extension = string.Format("{0}-{1}", "MCID", createDateTime)
                    },
                    creationTime = new TS()
                    {
                        value = createDateTime
                    },
                    versionCode = new CS()
                    {
                        code = verCode
                    },
                    interactionId = new II()
                    {
                        extension = "PRPA_IN201305UV02", root = iiRoot
                    },
                    processingCode = new CS()
                    {
                        code = prcCode
                    },
                    processingModeCode = new CS()
                    {
                        code = "T"
                    },
                    acceptAckCode = new CS()
                    {
                        code = "AL"
                    },

                    receiver = new MCCI_MT000100UV01Receiver[]
                    {
                        new MCCI_MT000100UV01Receiver()
                        {
                            typeCode = CommunicationFunctionType.RCV,
                            device   = new MCCI_MT000100UV01Device()
                            {
                                determinerCode = "INSTANCE",
                                classCode      = EntityClassDevice.DEV,
                                id             = new II[] { new II()
                                                            {
                                                                root = vaRoot
                                                            } }
                            }
                        }
                    },

                    sender = new MCCI_MT000100UV01Sender()
                    {
                        typeCode = CommunicationFunctionType.SND,
                        device   = new MCCI_MT000100UV01Device()
                        {
                            determinerCode = "INSTANCE",
                            classCode      = EntityClassDevice.DEV,
                            id             = new II[] { new II()
                                                        {
                                                            root = vaRoot, extension = "200CRSE"
                                                        } }
                        }
                    },

                    controlActProcess = new PRPA_IN201305UV02QUQI_MT021001UV01ControlActProcess()
                    {
                        dataEnterer = currentUser,
                        classCode   = ActClassControlAct.CACT,
                        moodCode    = x_ActMoodIntentEvent.EVN,
                        code        = new CD()
                        {
                            code = "PRPA_TE201305UV02", codeSystem = iiRoot
                        },

                        queryByParameter = new PRPA_MT201306UV02QueryByParameter()
                        {
                            queryId = new II()
                            {
                                root = vaRoot, extension = createDateTime
                            },
                            statusCode = new CS()
                            {
                                code = "new"
                            },
                            modifyCode = new CS()
                            {
                                code = "MVI.COMP1"
                            },
                            initialQuantity = new INT()
                            {
                                value = "1"
                            },
                            parameterList = patientParameters
                        },
                    }
                };

                ////Used for debugging request
                //SoapEnvelope envelope = new SoapEnvelope();
                //envelope.body = new Body();
                //envelope.body.PRPA_IN201305UV02 = PRPA_IN201305UV021;

                //XmlSerializer ser = new XmlSerializer(typeof(SoapEnvelope));
                //TextWriter writer = new StreamWriter("C:\\temp\\PRPA_IN201305UV02.xml");
                //ser.Serialize(writer, envelope);
                //writer.Close();

                LogDetails logDetails = new LogDetails(String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                objReturn = rsMain.PRPA_IN201305UV02(PRPA_IN201305UV021);
                LogManager.LogTiming(logDetails);

                ////Used for debugging response
                //if (objReturn != null)
                //{
                //    envelope = new SoapEnvelope();
                //    envelope.body = new Body();
                //    envelope.body.PRPA_IN201306UV02 = objReturn;

                //    ser = new XmlSerializer(typeof(SoapEnvelope));
                //    writer = new StreamWriter("C:\\temp\\PRPA_IN201306UV02.xml");
                //    ser.Serialize(writer, envelope);
                //    writer.Close();
                //}
            }
            catch (WebException ex)
            {
                LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                throw ex;
            }
            catch (Exception ex)
            {
                LogManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), CURRENT_USER, CURRENT_REGISTRY_ID);
                throw ex;
            }

            return(objReturn);
        }
        /// <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 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>
        /// Search for a patient based on name
        /// </summary>
        public void Search(String patientName)
        {
            // Attempt to split the name
            string firstName = String.Empty, lastName = String.Empty;
            Regex  re    = new Regex(@"^(.*?)[,](.*?)$");
            var    match = re.Match(patientName + ",");

            if (!match.Success)
            {
                return;
            }

            // Next, get the parts
            if (match.Groups.Count > 1)
            {
                lastName = match.Groups[1].Value.Replace(",", "");
            }
            if (match.Groups.Count > 2)
            {
                firstName = match.Groups[2].Value.Replace(",", "");
            }

            // Now search
            PRPA_IN201305UV02 pdQuery = new PRPA_IN201305UV02(
                Guid.NewGuid(),
                DateTime.Now,
                PRPA_IN201305UV02.GetInteractionId(),
                ProcessingID.Production,
                "I",
                AcknowledgementCondition.Always,
                new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Receiver(
                    new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                        SET <II> .CreateSET(new II("1.3.6.1.4.1.33349.3.1.1.20.4", "CR-FAKE"))
                        )
                    ),
                new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Sender(
                    new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                        SET <II> .CreateSET(new II("1.2.3.4.5.4", "Sample"))
                        )
                    ),
                new MARC.Everest.RMIM.UV.NE2008.QUQI_MT021001UV01.ControlActProcess <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter>(
                    "EVN"
                    )
            {
                Id               = SET <II> .CreateSET(Guid.NewGuid()),
                EffectiveTime    = new IVL <TS>(DateTime.Now),
                Code             = Util.Convert <CD <String> >(PRPA_IN201305UV02.GetTriggerEvent()),
                queryByParameter = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter(
                    Guid.NewGuid(),
                    "New",
                    new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.ParameterList()
                    )
            }
                );

            // Build name
            EN searchName = new EN(EntityNameUse.Search, new ENXP[] {});

            foreach (var s in lastName.Split(' '))
            {
                searchName.Part.Add(new ENXP(s, EntityNamePartType.Family));
            }
            if (!String.IsNullOrEmpty(firstName))
            {
                foreach (var s in firstName.Split(' '))
                {
                    searchName.Part.Add(new ENXP(s, EntityNamePartType.Given));
                }
            }

            // Query parameters
            pdQuery.controlActProcess.queryByParameter.ParameterList.LivingSubjectName.Add(new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.LivingSubjectName(
                                                                                               SET <EN> .CreateSET(searchName),
                                                                                               "livingSubject.Name"
                                                                                               ));

            // Send
            if (!this.m_clientConnector.IsOpen())
            {
                this.m_clientConnector.Open();
            }

            this.m_clientConnector.BeginSend(pdQuery, this.OnBeginSend, null);
        }
Esempio n. 6
0
        public void EV_1089SETParseTest()
        {
            PRPA_IN201305UV02 test = new PRPA_IN201305UV02();
            test.Sender = new RMIM.UV.NE2010.MCCI_MT100200UV01.Sender();
            test.Sender.Device = new RMIM.UV.NE2010.MCCI_MT100200UV01.Device();
            test.Sender.Device.Id = new SET<II>() { NullFlavor = NullFlavor.NoInformation };

            XmlIts1Formatter fmtr = new XmlIts1Formatter();
            fmtr.GraphAides.Add(new DatatypeFormatter());

            var sw = new StringWriter();
            XmlStateWriter writer = new XmlStateWriter(XmlWriter.Create(sw));
            fmtr.Graph(writer, test);
            writer.Flush();
            String xmlString = sw.ToString();

            StringReader sr = new StringReader(xmlString);
            XmlStateReader rdr = new XmlStateReader(XmlReader.Create(sr));
            var result = fmtr.Parse(rdr);
            Assert.IsNotNull(result.Structure as PRPA_IN201305UV02);
            Assert.IsNotNull((result.Structure as PRPA_IN201305UV02).Sender.Device.Id);
            //Assert.AreEqual(test, result.Structure);
        }
        /// <summary>
        /// Search for a patient based on name
        /// </summary>
        public void Search(String patientName)
        {
            // Attempt to split the name
            string firstName = String.Empty, lastName = String.Empty;
            Regex re = new Regex(@"^(.*?)[,](.*?)$");
            var match = re.Match(patientName + ",");
            if (!match.Success) return;
            
            // Next, get the parts
            if (match.Groups.Count > 1)
                lastName = match.Groups[1].Value.Replace(",", "");
            if(match.Groups.Count > 2)
                firstName = match.Groups[2].Value.Replace(",", "");
            
            // Now search
            PRPA_IN201305UV02 pdQuery = new PRPA_IN201305UV02(
                Guid.NewGuid(),
                DateTime.Now,
                PRPA_IN201305UV02.GetInteractionId(),
                ProcessingID.Production,
                "I",
                AcknowledgementCondition.Always,
                new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Receiver(
                    new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                        SET<II>.CreateSET(new II("1.3.6.1.4.1.33349.3.1.1.20.4", "CR-FAKE"))
                    )
                ),
                new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Sender(
                    new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                        SET<II>.CreateSET(new II("1.2.3.4.5.4", "Sample"))
                    )
                ),
                new MARC.Everest.RMIM.UV.NE2008.QUQI_MT021001UV01.ControlActProcess<MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter>(
                    "EVN"
                )
                {
                    Id = SET<II>.CreateSET(Guid.NewGuid()),
                    EffectiveTime = new IVL<TS>(DateTime.Now),
                    Code = Util.Convert<CD<String>>(PRPA_IN201305UV02.GetTriggerEvent()),
                    queryByParameter = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter(
                        Guid.NewGuid(),
                        "New",
                        new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.ParameterList()
                    )
                }
            );
          
            // Build name
            EN searchName = new EN(EntityNameUse.Search, new ENXP[]{});
            foreach(var s in lastName.Split(' '))
                searchName.Part.Add(new ENXP(s, EntityNamePartType.Family));
            if(!String.IsNullOrEmpty(firstName))
                foreach(var s in firstName.Split(' '))
                    searchName.Part.Add(new ENXP(s, EntityNamePartType.Given));

            // Query parameters
            pdQuery.controlActProcess.queryByParameter.ParameterList.LivingSubjectName.Add(new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.LivingSubjectName(
                SET<EN>.CreateSET(searchName),
                "livingSubject.Name"
            ));

            // Send
            if(!this.m_clientConnector.IsOpen())
                this.m_clientConnector.Open();

            this.m_clientConnector.BeginSend(pdQuery, this.OnBeginSend, null);
        }
Esempio n. 8
0
        /// <summary>
        /// Generate PDQ Message
        /// </summary>
        /// <remarks>
        /// This will recreate the PDQ sample provided by IHE
        /// </remarks>
        private static void GeneratePDQ()
        {

            Console.WriteLine("\r\n\r\nGenerating PDQv3....\r\n\r\n");
            // Create the message structure
            PRPA_IN201305UV02 message = new PRPA_IN201305UV02(
                new II("1.2.840.114350.1.13.0.1.7.1.1", "35423"), // The identifier of the message
                DateTime.Now, // Identifies the time that the message was created
                PRPA_IN201305UV02.GetInteractionId(), // Identifies the interaction that is being executed
                ProcessingID.Training, // Identifies the processing code of the message (how the message is to be executed)
                "I", // Identifies the processing mode code 
                AcknowledgementCondition.Always, // Identifies under which conditions the message should be acknowledged
                null, // We'll fill this in later
                null, // We'll fill this in later
                new MARC.Everest.RMIM.UV.NE2008.QUQI_MT021001UV01.ControlActProcess<MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter>()
            );

            // The receiver node of the message identifies the system that is the intended recipient of the 
            // message
            message.Receiver.Clear();
            message.Receiver.Add(new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Receiver(
                new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                    new SET<II>(new II("1.2.840.114350.1.13.999.234")) // Identifies the device
                )
                { // We can use an initializer to populate variables that don't appear in the constructors
                    Telecom = new BAG<TEL>( // Telecom is a bag of telecommunications addresses
                        new TEL[] { "http://servicelocation/PDQuery" }
                     )
                }
            ));

            // The sender node identifies the system that is the sender of the message
            message.Sender = new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Sender(
                new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                    new SET<II>(new II("1.2.840.114350.1.13.999.567"))
                )
            );

            // The "controlActProcess" is the main query parameters
            var controlActProcess = message.controlActProcess; // do this to keep lines shorter
            // We need to tell the receiver what action we're executing
            controlActProcess.Code = new CD<string>(PRPA_IN201305UV02.GetTriggerEvent().Code);

            // Create the query object
            controlActProcess.queryByParameter = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter()
            { // Once again, using the initializer
                QueryId = new II("1.2.840.114350.1.13.28.1.18.5.999", "18204"),
                StatusCode = "new",
                InitialQuantity = 2
            };

            // Create the criterion list
            controlActProcess.queryByParameter.MatchCriterionList = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.MatchCriterionList()
            {
                MinimumDegreeMatch = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.MinimumDegreeMatch(
                    new INT(75),
                    "Degree of match requested"
                )
            };

            // Create the parameter list
            controlActProcess.queryByParameter.ParameterList = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.ParameterList();
            var parmList = controlActProcess.queryByParameter.ParameterList;

            // Query for Administrative Gender of Male
            parmList.LivingSubjectAdministrativeGender.Add(
                new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.LivingSubjectAdministrativeGender(
                    new SET<CE<AdministrativeGender>>(AdministrativeGender.Male),
                    "LivingSubject.administrativeGender"
                )
            );

            // Query for Birth Time of Aug 4, 1963
            parmList.LivingSubjectBirthTime.Add(
                new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.LivingSubjectBirthTime(
                    new SET<IVL<TS>>(
                        new IVL<TS>(new TS(
                                DateTime.Parse("August 04, 1963") // August 4, 1963
                            )
                        {
                            DateValuePrecision = DatePrecision.Day // Our date is precise to the day
                        }
                        )
                    ),
                    "LivingSubject.birthTime"
                )
            );

            // Query for Jimmy Jones
            parmList.LivingSubjectName.Add(
                new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.LivingSubjectName(
                    new SET<EN>(
                        new EN(EntityNameUse.Legal,
                            new ENXP[] { 
                                new ENXP("Jimmy", EntityNamePartType.Given),
                                new ENXP("Jones", EntityNamePartType.Family)
                            }
                        )
                    ),
                    "LivingSubject.name"
                )
            );

            // Retrieve alternate identifiers for the specified organization
            parmList.OtherIDsScopingOrganization.Add(
                new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.OtherIDsScopingOrganization(
                    new SET<II>(
                        new II("1.2.840.114350.1.13.99997.2.3412")
                    ),
                    "OtherIDs.scopingOrganization.id"
                )
            );

            // Retrieve alternate identifiers for the specified organization
            parmList.OtherIDsScopingOrganization.Add(
                new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.OtherIDsScopingOrganization(
                    new SET<II>(
                        new II("2.16.840.1.113883.4.1")
                    ),
                    "OtherIDs.scopingOrganization.id"
                )
            );


            FormatInstance(message);

        }
Esempio n. 9
0
        /// <summary>
        /// Generate PDQ Message
        /// </summary>
        /// <remarks>
        /// This will recreate the PDQ sample provided by IHE
        /// </remarks>
        private static void GeneratePDQ()
        {
            Console.WriteLine("\r\n\r\nGenerating PDQv3....\r\n\r\n");
            // Create the message structure
            PRPA_IN201305UV02 message = new PRPA_IN201305UV02(
                new II("1.2.840.114350.1.13.0.1.7.1.1", "35423"), // The identifier of the message
                DateTime.Now,                                     // Identifies the time that the message was created
                PRPA_IN201305UV02.GetInteractionId(),             // Identifies the interaction that is being executed
                ProcessingID.Training,                            // Identifies the processing code of the message (how the message is to be executed)
                "I",                                              // Identifies the processing mode code
                AcknowledgementCondition.Always,                  // Identifies under which conditions the message should be acknowledged
                null,                                             // We'll fill this in later
                null,                                             // We'll fill this in later
                new MARC.Everest.RMIM.UV.NE2008.QUQI_MT021001UV01.ControlActProcess <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter>()
                );

            // The receiver node of the message identifies the system that is the intended recipient of the
            // message
            message.Receiver.Clear();
            message.Receiver.Add(new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Receiver(
                                     new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                                         new SET <II>(new II("1.2.840.114350.1.13.999.234")) // Identifies the device
                                         )
            {                                                                                // We can use an initializer to populate variables that don't appear in the constructors
                Telecom = new BAG <TEL>(                                                     // Telecom is a bag of telecommunications addresses
                    new TEL[] { "http://servicelocation/PDQuery" }
                    )
            }
                                     ));

            // The sender node identifies the system that is the sender of the message
            message.Sender = new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Sender(
                new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                    new SET <II>(new II("1.2.840.114350.1.13.999.567"))
                    )
                );

            // The "controlActProcess" is the main query parameters
            var controlActProcess = message.controlActProcess; // do this to keep lines shorter

            // We need to tell the receiver what action we're executing
            controlActProcess.Code = new CD <string>(PRPA_IN201305UV02.GetTriggerEvent().Code);

            // Create the query object
            controlActProcess.queryByParameter = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter()
            { // Once again, using the initializer
                QueryId         = new II("1.2.840.114350.1.13.28.1.18.5.999", "18204"),
                StatusCode      = "new",
                InitialQuantity = 2
            };

            // Create the criterion list
            controlActProcess.queryByParameter.MatchCriterionList = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.MatchCriterionList()
            {
                MinimumDegreeMatch = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.MinimumDegreeMatch(
                    new INT(75),
                    "Degree of match requested"
                    )
            };

            // Create the parameter list
            controlActProcess.queryByParameter.ParameterList = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.ParameterList();
            var parmList = controlActProcess.queryByParameter.ParameterList;

            // Query for Administrative Gender of Male
            parmList.LivingSubjectAdministrativeGender.Add(
                new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.LivingSubjectAdministrativeGender(
                    new SET <CE <AdministrativeGender> >(AdministrativeGender.Male),
                    "LivingSubject.administrativeGender"
                    )
                );

            // Query for Birth Time of Aug 4, 1963
            parmList.LivingSubjectBirthTime.Add(
                new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.LivingSubjectBirthTime(
                    new SET <IVL <TS> >(
                        new IVL <TS>(new TS(
                                         DateTime.Parse("August 04, 1963") // August 4, 1963
                                         )
            {
                DateValuePrecision = DatePrecision.Day             // Our date is precise to the day
            }
                                     )
                        ),
                    "LivingSubject.birthTime"
                    )
                );

            // Query for Jimmy Jones
            parmList.LivingSubjectName.Add(
                new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.LivingSubjectName(
                    new SET <EN>(
                        new EN(EntityNameUse.Legal,
                               new ENXP[] {
                new ENXP("Jimmy", EntityNamePartType.Given),
                new ENXP("Jones", EntityNamePartType.Family)
            }
                               )
                        ),
                    "LivingSubject.name"
                    )
                );

            // Retrieve alternate identifiers for the specified organization
            parmList.OtherIDsScopingOrganization.Add(
                new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.OtherIDsScopingOrganization(
                    new SET <II>(
                        new II("1.2.840.114350.1.13.99997.2.3412")
                        ),
                    "OtherIDs.scopingOrganization.id"
                    )
                );

            // Retrieve alternate identifiers for the specified organization
            parmList.OtherIDsScopingOrganization.Add(
                new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.OtherIDsScopingOrganization(
                    new SET <II>(
                        new II("2.16.840.1.113883.4.1")
                        ),
                    "OtherIDs.scopingOrganization.id"
                    )
                );


            FormatInstance(message);
        }
Esempio n. 10
0
        /// <summary>
        /// Generate the auto complete data
        /// </summary>
        public String[] Filter(WcfClientConnector connector, string filter)
        {
            List <String> retVal = new List <String>();

            // Create the instance
            PRPA_IN201305UV02 instance = new PRPA_IN201305UV02(
                Guid.NewGuid(),
                DateTime.Now,
                PRPA_IN201305UV02.GetInteractionId(),
                ProcessingID.Production,
                "T",
                AcknowledgementCondition.Always,
                new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Receiver()
            {
                Telecom = new TEL("http://cr.marc-hi.ca:8080/pdqsupplier"),
                Device  = new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                    SET <II> .CreateSET(new II("1.3.6.1.4.1.33349.3.1.1.20.4", "CR"))
                    )
            },
                new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Sender()
            {
                Telecom = new TEL()
                {
                    NullFlavor = NullFlavor.NoInformation
                },
                Device = new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                    SET <II> .CreateSET(new II("1.2.3.4.5.4", "Sample"))
                    )
            },
                new MARC.Everest.RMIM.UV.NE2008.QUQI_MT021001UV01.ControlActProcess <MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter>("EVN")
            {
                Id   = SET <II> .CreateSET(Guid.NewGuid()),
                Code = CD <String> .Parse(PRPA_IN201305UV02.GetTriggerEvent()),
                AuthorOrPerformer = new List <MARC.Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.AuthorOrPerformer>(),
                queryByParameter  = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter(
                    Guid.NewGuid(),
                    "new",
                    new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.ParameterList()

                    )
                {
                    InitialQuantity = 10
                }
            }
                );

            instance.controlActProcess.EffectiveTime = new IVL <TS>(DateTime.Now);

            // Set the author
            instance.controlActProcess.AuthorOrPerformer.Add(new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.AuthorOrPerformer());
            instance.controlActProcess.AuthorOrPerformer[0].SetParticipationChoice(new MARC.Everest.RMIM.UV.NE2008.COCT_MT090300UV01.AssignedDevice(
                                                                                       SET <II> .CreateSET(new II("1.2.3.4.5.4", "Sample")),
                                                                                       "DEV"
                                                                                       )
                                                                                   );

            // Set the filter for given then family
            foreach (var enpt in new EntityNamePartType[] { EntityNamePartType.Given, EntityNamePartType.Family })
            {
                instance.Id = Guid.NewGuid();
                instance.controlActProcess.queryByParameter.QueryId = Guid.NewGuid();

                // Set the name
                instance.controlActProcess.queryByParameter.ParameterList.LivingSubjectName.Clear();
                instance.controlActProcess.queryByParameter.ParameterList.LivingSubjectName.Add(
                    new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.LivingSubjectName(
                        SET <EN> .CreateSET(new EN(EntityNameUse.Search, new ENXP[] {
                    new ENXP(filter, enpt)
                })),
                        "livingSubject.name"
                        )
                    );

                // Make the query
                PRPA_IN201306UV02 response = this.SendReceive(connector, instance) as PRPA_IN201306UV02;

                // Interpret the response code
                if (response.Acknowledgement[0].TypeCode != AcknowledgementType.ApplicationAcknowledgementAccept ||
                    response.controlActProcess == null)
                {
                    continue;
                }
                foreach (var subj in response.controlActProcess.Subject)
                {
                    // Ensure that the relationships exist
                    if (subj.RegistrationEvent == null ||
                        subj.RegistrationEvent.Subject1 == null ||
                        subj.RegistrationEvent.Subject1.registeredRole == null ||
                        subj.RegistrationEvent.Subject1.registeredRole.GetPatientEntityChoiceSubjectAsPRPA_MT201310UV02Person() == null ||
                        subj.RegistrationEvent.Subject1.registeredRole.GetPatientEntityChoiceSubjectAsPRPA_MT201310UV02Person().Name == null ||
                        subj.RegistrationEvent.Subject1.registeredRole.GetPatientEntityChoiceSubjectAsPRPA_MT201310UV02Person().Name.IsEmpty)
                    {
                        continue;
                    }

                    // Add the formatted name
                    var legalName = subj.RegistrationEvent.Subject1.registeredRole.GetPatientEntityChoiceSubjectAsPRPA_MT201310UV02Person().Name.Find(o => o.Use != null && o.Use.Contains(EntityNameUse.Legal));
                    if (legalName == null)
                    {
                        legalName = subj.RegistrationEvent.Subject1.registeredRole.GetPatientEntityChoiceSubjectAsPRPA_MT201310UV02Person().Name[0];
                    }
                    retVal.Add(String.Format("{0}@{1} - {2}",
                                             subj.RegistrationEvent.Subject1.registeredRole.Id[0].Root,
                                             subj.RegistrationEvent.Subject1.registeredRole.Id[0].Extension,
                                             legalName.ToString("{FAM}, {GIV}")));
                }
            }

            // Now return results
            return(retVal.ToArray());
        }
Esempio n. 11
0
        /// <summary>
        /// Generate the auto complete data
        /// </summary>
        public String[] Filter(WcfClientConnector connector, string filter)
        {

            List<String> retVal = new List<String>();

            // Create the instance
            PRPA_IN201305UV02 instance = new PRPA_IN201305UV02(
                  Guid.NewGuid(),
                  DateTime.Now,
                  PRPA_IN201305UV02.GetInteractionId(),
                  ProcessingID.Production,
                  "T",
                  AcknowledgementCondition.Always,
                  new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Receiver()
                  {
                      Telecom = new TEL("http://cr.marc-hi.ca:8080/pdqsupplier"),
                      Device = new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                        SET<II>.CreateSET(new II("1.3.6.1.4.1.33349.3.1.1.20.4", "CR"))
                      )
                  },
                  new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Sender()
                  {
                      Telecom = new TEL() { NullFlavor = NullFlavor.NoInformation },
                      Device = new MARC.Everest.RMIM.UV.NE2008.MCCI_MT100200UV01.Device(
                        SET<II>.CreateSET(new II("1.2.3.4.5.4", "Sample"))
                      )
                  },
                  new MARC.Everest.RMIM.UV.NE2008.QUQI_MT021001UV01.ControlActProcess<MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter>("EVN")
                  {
                      Id = SET<II>.CreateSET(Guid.NewGuid()),
                      Code = CD<String>.Parse(PRPA_IN201305UV02.GetTriggerEvent()),
                      AuthorOrPerformer = new List<MARC.Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.AuthorOrPerformer>(),
                      queryByParameter = new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.QueryByParameter(
                          Guid.NewGuid(),
                          "new",
                          new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.ParameterList()

                    )
                    {
                        InitialQuantity = 10
                    }
                  }
                );

            instance.controlActProcess.EffectiveTime = new IVL<TS>(DateTime.Now);

            // Set the author
            instance.controlActProcess.AuthorOrPerformer.Add(new MARC.Everest.RMIM.UV.NE2008.MFMI_MT700701UV01.AuthorOrPerformer());
            instance.controlActProcess.AuthorOrPerformer[0].SetParticipationChoice(new MARC.Everest.RMIM.UV.NE2008.COCT_MT090300UV01.AssignedDevice(
                SET<II>.CreateSET(new II("1.2.3.4.5.4", "Sample")),
                "DEV"
              )
            );

            // Set the filter for given then family
            foreach (var enpt in new EntityNamePartType[] { EntityNamePartType.Given, EntityNamePartType.Family })
            {
                instance.Id = Guid.NewGuid();
                instance.controlActProcess.queryByParameter.QueryId = Guid.NewGuid();

                // Set the name
                instance.controlActProcess.queryByParameter.ParameterList.LivingSubjectName.Clear();
                instance.controlActProcess.queryByParameter.ParameterList.LivingSubjectName.Add(
                    new MARC.Everest.RMIM.UV.NE2008.PRPA_MT201306UV02.LivingSubjectName(
                        SET<EN>.CreateSET(new EN(EntityNameUse.Search, new ENXP[] {
                        new ENXP(filter, enpt)
                        })),
                        "livingSubject.name"
                    )
                );

                // Make the query
                PRPA_IN201306UV02 response = this.SendReceive(connector, instance) as PRPA_IN201306UV02;

                // Interpret the response code
                if (response.Acknowledgement[0].TypeCode != AcknowledgementType.ApplicationAcknowledgementAccept ||
                    response.controlActProcess == null)
                    continue;
                foreach (var subj in response.controlActProcess.Subject)
                {
                    // Ensure that the relationships exist
                    if (subj.RegistrationEvent == null ||
                        subj.RegistrationEvent.Subject1 == null ||
                        subj.RegistrationEvent.Subject1.registeredRole == null ||
                        subj.RegistrationEvent.Subject1.registeredRole.GetPatientEntityChoiceSubjectAsPRPA_MT201310UV02Person() == null ||
                        subj.RegistrationEvent.Subject1.registeredRole.GetPatientEntityChoiceSubjectAsPRPA_MT201310UV02Person().Name == null ||
                        subj.RegistrationEvent.Subject1.registeredRole.GetPatientEntityChoiceSubjectAsPRPA_MT201310UV02Person().Name.IsEmpty)
                        continue;

                    // Add the formatted name
                    var legalName = subj.RegistrationEvent.Subject1.registeredRole.GetPatientEntityChoiceSubjectAsPRPA_MT201310UV02Person().Name.Find(o => o.Use != null && o.Use.Contains(EntityNameUse.Legal));
                    if (legalName == null)
                        legalName = subj.RegistrationEvent.Subject1.registeredRole.GetPatientEntityChoiceSubjectAsPRPA_MT201310UV02Person().Name[0];
                    retVal.Add(String.Format("{0}@{1} - {2}",
                        subj.RegistrationEvent.Subject1.registeredRole.Id[0].Root,
                        subj.RegistrationEvent.Subject1.registeredRole.Id[0].Extension,
                        legalName.ToString("{FAM}, {GIV}")));
                }
                

            }

            // Now return results
            return retVal.ToArray();

        }