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(); } } }
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; } }