public void Sample() { // Obtain the certificate for use with TLS and signing X509Certificate2 cert = X509CertificateUtil.GetCertificate( "06fba6", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true ); // Create the PCEHR header var pcehrHeader = PcehrHeaderHelper.CreateHeader(); // IHI is always 16 digits long starting 800360. pcehrHeader.IhiNumber = "8003608666885561"; // Instantiate the client // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/gainPCEHRAccess" // production endpoint is "https://services.ehealth.gov.au/gainPCEHRAccess" GainPCEHRAccessClient gainPcehrAccessClient = new GainPCEHRAccessClient(new Uri("https://b2b.ehealthvendortest.health.gov.au/gainPCEHRAccess"), cert, cert); // Add server certificate validation callback ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate; // Create the access request gainPCEHRAccessPCEHRRecord accessRequest = new gainPCEHRAccessPCEHRRecord(); // if gaining access without a code, authorisationDetails is not required // if gaining access with a code, include authorisationDetails, accessCode and accessType // if gaining emergency access, include authorisationDetails and set accessType to “EmergencyAccess” // Only include the below to pass an access code or gain emergency access accessRequest.authorisationDetails = new gainPCEHRAccessPCEHRRecordAuthorisationDetails(); // "patient access code" is not required if the patient has open access for there record accessRequest.authorisationDetails.accessCode = ""; accessRequest.authorisationDetails.accessType = gainPCEHRAccessPCEHRRecordAuthorisationDetailsAccessType.AccessCode; gainPCEHRAccessResponseIndividual individual = new gainPCEHRAccessResponseIndividual(); try { // Invoke the service responseStatusType responseStatus = gainPcehrAccessClient.GainPCEHRAccess(pcehrHeader, accessRequest, out individual); // Get the soap request and response string soapRequest = gainPcehrAccessClient.SoapMessages.SoapRequest; string soapResponse = gainPcehrAccessClient.SoapMessages.SoapResponse; } catch (FaultException fex) { // Handle any errors } }
/// <summary> /// Requests access to an individuals PCEHR. The IHI is specified within the PCEHR header. /// </summary> /// <param name="pcehrHeader">PCEHR header.</param> /// <param name="accessPcehrRecord">Access record.</param> /// <param name="individual">Matching individual.</param> /// <returns>Response.</returns> public responseStatusType GainPCEHRAccess(CommonPcehrHeader pcehrHeader, gainPCEHRAccessPCEHRRecord accessPcehrRecord, out gainPCEHRAccessResponseIndividual individual) { // PCEHRHeaderValidator.Validate(pcehrHeader); Validation.ValidateArgumentRequired("accessPcehrRecord", accessPcehrRecord); return(profileClient.GainPCEHRAccess(pcehrHeader.GetHeader <PCEHRHeader>(), accessPcehrRecord, out individual)); }
/// <summary> /// Gain access to an individual's PCEHR. /// </summary> /// <param name="pcehrHeader">PCEHR header.</param> /// <returns>Query response.</returns> internal responseStatusType GainPCEHRAccess(PCEHRHeader pcehrHeader, gainPCEHRAccessPCEHRRecord accessPcehrRecord, out gainPCEHRAccessResponseIndividual individual) { var timestamp = new timestampType() { created = DateTime.Now }; var signatureContainer = new signatureContainerType(); return(pcehrProfileClient.gainPCEHRAccess(timestamp, ref signatureContainer, pcehrHeader, accessPcehrRecord, out individual)); }
public void Run() { //Get Certificate and Header objects CertAndHeaderInfo CertAndHeaderInfo = Support.CertAndHeaderFactory.Get( certSerial: "06fba6", serialHPIO: "8003629900019338", patientType: Support.PatientType.CalebDerrington); // Obtain the certificate for use with TLS and signing X509Certificate2 cert = CertAndHeaderInfo.Certificate; // Create PCEHR header CommonPcehrHeader header = CertAndHeaderInfo.Header; // Instantiate the client // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/gainPCEHRAccess" // production endpoint is "https://services.ehealth.gov.au/gainPCEHRAccess" GainPCEHRAccessClient gainPcehrAccessClient = new GainPCEHRAccessClient(new Uri("https://b2b.ehealthvendortest.health.gov.au/gainPCEHRAccess"), cert, cert); // Add server certificate validation callback ServicePointManager.ServerCertificateValidationCallback += Support.CertificateHelper.ValidateServiceCertificate; // Create the access request gainPCEHRAccessPCEHRRecord accessRequest = new gainPCEHRAccessPCEHRRecord(); // if gaining access without a code, authorisationDetails is not required // if gaining access with a code, include authorisationDetails, accessCode and accessType // if gaining emergency access, include authorisationDetails and set accessType to “EmergencyAccess” // Only include the below to pass an access code or gain emergency access accessRequest.authorisationDetails = new gainPCEHRAccessPCEHRRecordAuthorisationDetails(); // "patient access code" is not required if the patient has open access for there record accessRequest.authorisationDetails.accessCode = ""; accessRequest.authorisationDetails.accessType = gainPCEHRAccessPCEHRRecordAuthorisationDetailsAccessType.AccessCode; gainPCEHRAccessResponseIndividual individual = new gainPCEHRAccessResponseIndividual(); try { // Invoke the service responseStatusType responseStatus = gainPcehrAccessClient.GainPCEHRAccess(header, accessRequest, out individual); // Get the soap request and response string soapRequest = gainPcehrAccessClient.SoapMessages.SoapRequest; string soapResponse = gainPcehrAccessClient.SoapMessages.SoapResponse; } catch (FaultException fex) { // Handle any errors } }