Пример #1
0
        private void IhiSeachOrValidateQuery()
        {
            // ------------------------------------------------------------------------------
            // Set up
            // ------------------------------------------------------------------------------

            // Set up the request
            searchIHI request = new searchIHI();

            SetRequestDataForQuery(IhiSearchValidateOutcome, request);

            // Obtain the certificate by serial number
            string           CertSerial = RemoveWhitespace(IhiSearchValidateConfig.CertificateSerialNumber);
            X509Certificate2 tlsCert    = GetCertificate(
                IhiSearchValidateConfig.CertificateSerialNumber, //The serial number is commonly seen with spaces "06 3c 23' yet we don't want then in this call.
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.LocalMachine,
                true
                );

            //Test that we found a certificate, there will be a error message write for return if it was not found
            if (tlsCert != null)
            {
                // The same certificate is used for signing the request.
                // This certificate will be different to TLS cert for some operations.
                X509Certificate2 signingCert = tlsCert;

                // Set up client product information (PCIN)
                // Values below should be provided by Medicare
                Pyro.ADHA.mcaR3.ConsumerSearchIHI.ProductType product = new Pyro.ADHA.mcaR3.ConsumerSearchIHI.ProductType()
                {
                    platform       = System.Environment.OSVersion.ToString(), // Can be any value
                    productName    = IhiSearchValidateConfig.ProductName,     // Provided by Medicare
                    productVersion = IhiSearchValidateConfig.ProductVersion,  // Provided by Medicare
                    vendor         = new Pyro.ADHA.mcaR3.ConsumerSearchIHI.QualifiedId()
                    {
                        id        = IhiSearchValidateConfig.VendorId,         // Provided by Medicare
                        qualifier = IhiSearchValidateConfig.VendorIdQualifier // Provided by Medicare
                    }
                };


                // Set up user identifier details
                Pyro.ADHA.mcaR3.ConsumerSearchIHI.QualifiedId user = new Pyro.ADHA.mcaR3.ConsumerSearchIHI.QualifiedId()
                {
                    id        = IhiSearchValidateOutcome.RequestData.UserId,         // User ID internal to your system
                    qualifier = IhiSearchValidateOutcome.RequestData.UserIdQualifier // Eg: http://ns.yourcompany.com.au/id/yoursoftware/userid/1.0
                };

                // Set up user HPI-O identifier
                //The HPI-O is optional and only required if you are setup and using a CSP certificate, in this case you must pass the HPI-O
                //of the orginisation you are making the call for.
                Pyro.ADHA.mcaR3.ConsumerSearchIHI.QualifiedId hpio = new Pyro.ADHA.mcaR3.ConsumerSearchIHI.QualifiedId()
                {
                    id        = "9344699237",                                      // HPIO internal to your system
                    qualifier = "http://ns.electronichealth.net.au/id/hi/hpio/1.0" // Eg: http://ns.yourcompany.com.au/id/yoursoftware/userid/1.0
                };

                // ------------------------------------------------------------------------------
                // Client instantiation and invocation
                // ------------------------------------------------------------------------------

                // Instantiate the client
                ConsumerSearchIHIClient client = new ConsumerSearchIHIClient(
                    new Uri(IhiSearchValidateConfig.HiServiceEndpoint),
                    product,
                    user,
                    null,
                    signingCert,
                    tlsCert);

                searchIHIResponse ihiResponse = null;
                try
                {
                    // Invokes the query based on type
                    if (RequestHasIHINumber || (RequestHasDvaNumber && RequestHasMedicareNumber))
                    {
                        ihiResponse = client.BasicSearch(request);
                    }

                    if (RequestHasMedicareNumber)
                    {
                        ihiResponse = client.BasicMedicareSearch(request);
                    }

                    if (RequestHasDvaNumber)
                    {
                        ihiResponse = client.BasicDvaSearch(request);
                    }

                    SetResponseDataToReturnData(IhiSearchValidateOutcome, ihiResponse);
                    SetSoapRequestAndResponseData(IhiSearchValidateOutcome, client, ihiResponse);
                    IhiSearchValidateOutcome.SuccessfulQuery = true;
                }
                catch (FaultException fex)
                {
                    IhiSearchValidateOutcome.SuccessfulQuery = false;

                    MessageFault fault = fex.CreateMessageFault();
                    if (fault.HasDetail)
                    {
                        Pyro.ADHA.mcaR3.ConsumerSearchIHI.ServiceMessagesType error = fault.GetDetail <Pyro.ADHA.mcaR3.ConsumerSearchIHI.ServiceMessagesType>();
                        // Look at error details in here
                        if (error.serviceMessage.Length > 0)
                        {
                            string returnMessage = error.serviceMessage[0].code + ": " + error.serviceMessage[0].reason;
                            IhiSearchValidateOutcome.QueryMetadata.ErrorMessge = returnMessage;
                        }
                    }
                }
                catch (Exception Exec)
                {
                    IhiSearchValidateOutcome.SuccessfulQuery = false;
                    // If an error is encountered, client.LastSoapResponse often provides a more
                    // detailed description of the error.
                    IhiSearchValidateOutcome.QueryMetadata.ErrorMessge = Exec.Message;
                    SetSoapRequestAndResponseData(IhiSearchValidateOutcome, client, ihiResponse);
                }
                finally
                {
                    // Clean up
                    client.Dispose();
                }
            }
        }
Пример #2
0
        private void SetResponseDataToReturnData(IhiSearchValidateOutcome IhiSearchValidateOutcome, searchIHIResponse ihiResponse)
        {
            if (ihiResponse.searchIHIResult != null)
            {
                if (!String.IsNullOrWhiteSpace(ihiResponse.searchIHIResult.familyName))
                {
                    IhiSearchValidateOutcome.ResponseData.Family = ihiResponse.searchIHIResult.familyName;
                }

                if (!String.IsNullOrWhiteSpace(ihiResponse.searchIHIResult.givenName))
                {
                    IhiSearchValidateOutcome.ResponseData.Given = ihiResponse.searchIHIResult.givenName;
                }

                if (ihiResponse.searchIHIResult.dateOfBirth != null)
                {
                    IhiSearchValidateOutcome.ResponseData.Dob = ihiResponse.searchIHIResult.dateOfBirth;
                }

                IhiSearchValidateOutcome.ResponseData.SexChar = GetSexCharBySexType(ihiResponse.searchIHIResult.sex);

                if (!String.IsNullOrWhiteSpace(ihiResponse.searchIHIResult.ihiNumber))
                {
                    if (ihiResponse.searchIHIResult.ihiNumber.StartsWith(IhiNamespace) && ihiResponse.searchIHIResult.ihiNumber.Length == (IhiNamespace.Length + 16))
                    {
                        //Strip off the namespace and only return the 16 digit IHI number
                        string IHIValue = ihiResponse.searchIHIResult.ihiNumber;
                        IhiSearchValidateOutcome.ResponseData.IHINumber = IHIValue.Substring(IHIValue.Length - 16, 16);
                    }
                    else
                    {
                        //For some reason the retuned value does not conform to the namespave and 16 digit IHI default, so just return what we got.
                        IhiSearchValidateOutcome.ResponseData.IHINumber = ihiResponse.searchIHIResult.ihiNumber;
                    }
                }

                if (ihiResponse.searchIHIResult.ihiRecordStatusSpecified)
                {
                    IhiSearchValidateOutcome.ResponseData.IHIRecordStatus = ihiResponse.searchIHIResult.ihiRecordStatus.ToString();
                }

                if (ihiResponse.searchIHIResult.ihiStatusSpecified)
                {
                    IhiSearchValidateOutcome.ResponseData.IHIStatus = ihiResponse.searchIHIResult.ihiStatus.ToString();
                }

                if (!String.IsNullOrWhiteSpace(ihiResponse.searchIHIResult.medicareCardNumber))
                {
                    IhiSearchValidateOutcome.ResponseData.MedicareNumber = ihiResponse.searchIHIResult.medicareCardNumber;
                }

                if (!String.IsNullOrWhiteSpace(ihiResponse.searchIHIResult.medicareIRN))
                {
                    IhiSearchValidateOutcome.ResponseData.MedicareIRN = ihiResponse.searchIHIResult.medicareIRN;
                }

                if (!String.IsNullOrWhiteSpace(ihiResponse.searchIHIResult.dvaFileNumber))
                {
                    IhiSearchValidateOutcome.ResponseData.DVANumber = ihiResponse.searchIHIResult.dvaFileNumber;
                }
            }
        }
Пример #3
0
        private void SetSoapRequestAndResponseData(IhiSearchValidateOutcome IhiSearchValidateOutcome, ConsumerSearchIHIClient client, searchIHIResponse ihiResponse)
        {
            if (ihiResponse != null && ihiResponse.searchIHIResult != null && ihiResponse.searchIHIResult.serviceMessages != null)
            {
                ServiceMessagesType ServiceMessage = ihiResponse.searchIHIResult.serviceMessages;
                foreach (var Msg in ServiceMessage.serviceMessage)
                {
                    HiServiceMessage HiServiceMessage = new HiServiceMessage();
                    if (!String.IsNullOrWhiteSpace(Msg.code))
                    {
                        HiServiceMessage.Code = Msg.code;
                    }
                    if (!String.IsNullOrWhiteSpace(Msg.reason))
                    {
                        HiServiceMessage.Reason = Msg.reason;
                    }
                    HiServiceMessage.SeverityType = GetSeverityTypeString(Msg.severity);
                    IhiSearchValidateOutcome.QueryMetadata.ServiceMessage.Add(HiServiceMessage);
                }
            }

            if (client.SoapMessages != null)
            {
                if (!String.IsNullOrWhiteSpace(client.SoapMessages.SoapRequestMessageId))
                {
                    IhiSearchValidateOutcome.QueryMetadata.SoapRequestMessageId = client.SoapMessages.SoapRequestMessageId;
                }

                if (!String.IsNullOrWhiteSpace(client.SoapMessages.SoapResponseMessageId))
                {
                    IhiSearchValidateOutcome.QueryMetadata.SoapResponseMessageId = client.SoapMessages.SoapResponseMessageId;
                }

                if (IhiSearchValidateOutcome.RequestData.ReturnSoapRequestAndResponseData)
                {
                    if (!String.IsNullOrWhiteSpace(client.SoapMessages.SoapRequest))
                    {
                        IhiSearchValidateOutcome.QueryMetadata.SoapRequest = client.SoapMessages.SoapRequest;
                    }

                    if (!String.IsNullOrWhiteSpace(client.SoapMessages.SoapResponse))
                    {
                        IhiSearchValidateOutcome.QueryMetadata.SoapResponse = client.SoapMessages.SoapResponse;
                    }
                }
            }
        }
        public void Sample()
        {
            // ------------------------------------------------------------------------------
            // Set up
            // ------------------------------------------------------------------------------

            // Obtain the certificate by serial number
            X509Certificate2 tlsCert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // The same certificate is used for signing the request.
            // This certificate will be different to TLS cert for some operations.
            X509Certificate2 signingCert = tlsCert;

            // Set up client product information (PCIN)
            // Values below should be provided by Medicare
            ProductType product = new ProductType()
            {
                platform       = "Your system platform (Eg. Windows XP SP3)", // Can be any value
                productName    = "Product Name",                              // Provided by Medicare
                productVersion = "Product Version",                           // Provided by Medicare
                vendor         = new QualifiedId()
                {
                    id        = "Vendor Id",                                // Provided by Medicare
                    qualifier = "Vendor Qualifier"                          // Provided by Medicare
                }
            };

            // Set up user identifier details
            QualifiedId user = new QualifiedId()
            {
                id        = "User Id",                                      // User ID internal to your system
                qualifier = "http://<anything>/id/<anything>/userid/1.0"    // Eg: http://ns.yourcompany.com.au/id/yoursoftware/userid/1.0
            };

            // Set up user identifier details
            QualifiedId hpio = new QualifiedId()
            {
                id        = "HPIO",                                       // HPIO internal to your system
                qualifier = "http://<anything>/id/<anything>/hpio/1.0"    // Eg: http://ns.yourcompany.com.au/id/yoursoftware/userid/1.0
            };

            // ------------------------------------------------------------------------------
            // Client instantiation and invocation
            // ------------------------------------------------------------------------------

            // Instantiate the client
            ConsumerSearchIHIClient client = new ConsumerSearchIHIClient(
                new Uri("https://HIServiceEndpoint"),
                product,
                user,
                hpio,
                signingCert,
                tlsCert);

            // Set up the request
            searchIHI request = new searchIHI();

            request.ihiNumber   = "http://ns.electronichealth.net.au/id/hi/ihi/1.0/8003601240022579";
            request.dateOfBirth = DateTime.Parse("12 Dec 2002");
            request.givenName   = "Jessica";
            request.familyName  = "Wood";
            request.sex         = SexType.F;

            try
            {
                // Invokes a basic search
                searchIHIResponse ihiResponse = client.BasicSearch(request);
            }
            catch (Exception ex)
            {
                // If an error is encountered, client.LastSoapResponse often provides a more
                // detailed description of the error.
                string soapResponse = client.SoapMessages.SoapResponse;
            }
        }