コード例 #1
0
        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
            }
        }
コード例 #2
0
        public void SampleForDIXmlResponses()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Override this value to the current patient's IHI.
            header.IhiNumber = "IHI";

            // Instantiate the client
            // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/getView"
            // production endpoint is "https://services.ehealth.gov.au/getView"
            GetViewClient getViewClient = new GetViewClient(new Uri("https://GetViewEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            try
            {
                getView request = new getView()
                {
                    // Creates a diagnosticImagingReportView
                    view = new diagnosticImagingReportView()
                    {
                        fromDate = DateTime.Now.AddDays(-10),
                        toDate   = DateTime.Now,
                        // versionNumber can be found in the "PCEHR View Service - Technical Service Specification" via
                        // https://digitalhealth.gov.au/implementation-resources/national-infrastructure/EP-2109-2015
                        // If the specification doesn't specify the version number then it is 1.0
                        versionNumber = "Version number here"
                    }
                };

                var responseStatus = getViewClient.GetView(header, request);

                // Convert XML response into Class for diagnosticImagingReportView
                XmlDocument xml = new XmlDocument();
                xml.PreserveWhitespace = true;
                xml.LoadXml(Encoding.Default.GetString(responseStatus.view.data));
                diagnosticImagingReportViewResponse data = new diagnosticImagingReportViewResponse();
                data = (diagnosticImagingReportViewResponse)DeserialiseElementToClass(xml.DocumentElement, data);

                // Get the soap request and response
                string soapRequest  = getViewClient.SoapMessages.SoapRequest;
                string soapResponse = getViewClient.SoapMessages.SoapResponse;
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
コード例 #3
0
        public void CreateCDAPackage()
        {
            // ------------------------------------------------------------------------------
            // Set up signing certificate and identifiers
            // ------------------------------------------------------------------------------

            // Load certificate used to sign the CDA document
            X509Certificate2 signingCert = X509CertificateUtil.GetCertificate(
                "Signing Certificate Find Value",
                X509FindType.FindBySubjectName,
                StoreName.My,
                StoreLocation.CurrentUser,
                true);

            // ------------------------------------------------------------------------------
            // Create CDAPackage
            // ------------------------------------------------------------------------------

            // Create an approver
            var approver = new Approver()
            {
                PersonId         = new Uri("http://ns.electronichealth.net.au/id/hi/hpii/1.0/8003610000000000"),
                PersonFamilyName = "Jacobs",
                PersonGivenNames = new List <string> {
                    "Adam", "Barry"
                },
                PersonNameSuffixes = new List <string> {
                    "MD", "JR"
                },
                PersonTitles = new List <string> {
                    "MR", "DR"
                }
            };

            // Create a CDAPackage instance
            var package = new CDAPackage(approver);

            // Create the CDA root document for the CDA package
            package.CreateRootDocument(File.ReadAllBytes("CdaDocumentXmlFile.xml"));

            // Add an image attachment
            package.AddDocumentAttachment(
                "ImageAttachment1.jpg",
                File.ReadAllBytes("ImageAttachment1.jpg")
                );

            // Add another image attachment
            package.AddDocumentAttachment(
                "ImageAttachment2.png",
                File.ReadAllBytes("ImageAttachment2.png")
                );

            // Create the CDA package zip
            CDAPackageUtility.CreateZip(package, "CdaPackageOutputFilePath.zip", signingCert);
        }
        public void Sample()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Override this value to the current patient's IHI.
            header.IhiNumber = "IHI";

            // Create the client
            UploadDocumentMetadataClient uploadDocumentMetadataClient = new UploadDocumentMetadataClient(
                new Uri("https://UploadDocumentEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            byte[] packageBytes = File.ReadAllBytes("CdaPackage.zip"); // Create a package

            // Create a request from an existing package
            // Format codes and format code names are not fixed, and it is recommended for them to be configurable.
            SubmitObjectsRequest request = uploadDocumentMetadataClient.CreateRequestForNewDocument(
                packageBytes,
                "unique repository ID",
                "formatCode",
                "formatCodeName",
                HealthcareFacilityTypeCodes.GeneralPractice,
                PracticeSettingTypes.GeneralPracticeMedicalClinicService
                );



            try
            {
                // Invoke the service
                RegistryResponseType registryResponse = uploadDocumentMetadataClient.UploadDocumentMetadata(header, request);

                // Get the soap request and response
                string soapRequest  = uploadDocumentMetadataClient.SoapMessages.SoapRequest;
                string soapResponse = uploadDocumentMetadataClient.SoapMessages.SoapResponse;
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
コード例 #5
0
        //Sonic's Cert
        //public static string CertificateSerialNumber = "07248d";
        public static X509Certificate2 GetCertificate()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                CertificateSerialNumber,
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.LocalMachine,
                true
                );

            return(cert);
        }
コード例 #6
0
        public static X509Certificate2 GetCertificate(string certSerial)
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                certSerial,
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            return(cert);
        }
コード例 #7
0
        public void Sample()
        {
            // Payload
            XmlDocument payload = new XmlDocument();

            payload.LoadXml("<data>Sample data to deliver.</data>");

            // TLS certificate used to authenticate the client to the SMD service during TLS connection.
            X509Certificate2 tlsCert = X509CertificateUtil.GetCertificate("TlsCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Certificate used to sign the payload.
            X509Certificate2 signingCert = X509CertificateUtil.GetCertificate("SigningCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Certificate used to encrypt the payload.
            X509Certificate2 payloadEncryptionCert = X509CertificateUtil.GetCertificate("EncryptionCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Instantiate the client.
            SealedMessageDeliveryClient client = new SealedMessageDeliveryClient(tlsCert);

            // Set up metadata
            MessageMetadataType metadata = new MessageMetadataType();

            metadata.creationTime         = DateTime.Now.ToUniversalTime();
            metadata.expiryTime           = DateTime.Now.AddDays(30).ToUniversalTime();
            metadata.expiryTimeSpecified  = true;
            metadata.invocationId         = new UniqueId().ToString();
            metadata.receiverIndividual   = HIQualifiers.HPIIQualifier + "16 digit receiver HPII";
            metadata.receiverOrganisation = HIQualifiers.HPIOQualifier + "16 digit receiver organisation HPIO";
            metadata.senderIndividual     = HIQualifiers.HPIIQualifier + "16 digit sender HPII";
            metadata.senderOrganisation   = HIQualifiers.HPIOQualifier + "16 digit sender organisation HPIO";
            metadata.serviceCategory      = "ServiceCategory";
            metadata.serviceInterface     = ServiceInterfaces.SmdServiceInterface;

            // Set up route record. Route records are used to indicate where transport responses
            // are to be sent to.
            metadata.routeRecord    = new RouteRecordEntryType[1];
            metadata.routeRecord[0] = new RouteRecordEntryType();
            metadata.routeRecord[0].sendIntermediateResponses = false;
            metadata.routeRecord[0].interaction                  = new InteractionType();
            metadata.routeRecord[0].interaction.target           = HIQualifiers.HPIOQualifier + "16 digit HPIO of the transport response target";
            metadata.routeRecord[0].interaction.serviceCategory  = "ServiceCategory";
            metadata.routeRecord[0].interaction.serviceEndpoint  = "https://TransportResponseDeliveryEndpoint";
            metadata.routeRecord[0].interaction.serviceInterface = ServiceInterfaces.TrdServiceInterface;
            metadata.routeRecord[0].interaction.serviceProvider  = HIQualifiers.HPIOQualifier + "16 digit HPIO of the TRD service provider";

            // Obtain a SealedMessageType instance.
            SealedMessageType sealedMessage = SealedMessageDeliveryClient.GetSealedMessage(payload, metadata, signingCert, payloadEncryptionCert);

            // Invoke the Deliver operation on the client.
            deliverResponse response = client.Deliver(sealedMessage, new Uri("https://SMDServiceEndpoint"));
        }
コード例 #8
0
        public void Sample()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Override this value to the current patient's IHI.
            header.IhiNumber = "IHI";

            // Create the client
            // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/removeDocument"
            // production endpoint is "https://services.ehealth.gov.au:443/removeDocument"
            RemoveDocumentClient removeDocumentClient = new RemoveDocumentClient(
                new Uri("https://RemoveDocumentEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            try
            {
                var request = new removeDocument()
                {
                    // this should be the value of the ExternalIdentifier "XDSDocumentEntry.uniqueId" in the GetDocumentList response
                    documentID = "document ID",
                    // reasonForRemoval should be one of:
                    // removeDocumentReasonForRemoval.IncorrectIdentity
                    // removeDocumentReasonForRemoval.ElectToRemove
                    // removeDocumentReasonForRemoval.Withdrawn
                    reasonForRemoval = removeDocumentReasonForRemoval.Withdrawn
                };

                // Invoke the service
                var responseStatus = removeDocumentClient.RemoveDocument(header, request);

                // Get the soap request and response
                string soapRequest  = removeDocumentClient.SoapMessages.SoapRequest;
                string soapResponse = removeDocumentClient.SoapMessages.SoapResponse;
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
コード例 #9
0
        public void Sample()
        {
            // NASH certificate should be used here, NOT the HI/Medicare certificates
            // The NASH certificate can be found in the NASH PKI Test Kit
            // To receive the Test Kit fill the application to request a National Authentication Service
            // for Health(NASH) Public Key Infrastructure(PKI) test certificate kit form
            // https://myhealthrecorddeveloper.digitalhealth.gov.au/resources/prepare/my-health-record-system-pre-requisites#step-2
            // Insure the certificate is installed in  Current User -> Personal -> Certificates
            // (run MMC and add the certificates add - on to view)
            // The "Issue To" field of a NASH certificate looks like general(or something different)."HPI-O".electronichealth.net.au
            // "Serial Number" can be found in the details once the certificate is installed.
            // Type the Serial number, don't copy and paste it, remove the spaces and use uppercase.

            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "06fba6",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Override this value to the current patient's IHI.
            header.IhiNumber = "IHI";

            // Instantiate the client
            // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/doesPCEHRExist"
            // Production endpoint is "https://services.ehealth.gov.au/doesPCEHRExist"
            DoesPCEHRExistClient doesPcehrExistClient = new DoesPCEHRExistClient(new Uri("https://b2b.ehealthvendortest.health.gov.au/doesPCEHRExist"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            try
            {
                // Invoke the service
                doesPCEHRExistResponse response = doesPcehrExistClient.DoesPCEHRExist(header);

                // Get the soap request and response
                string soapRequest  = doesPcehrExistClient.SoapMessages.SoapRequest;
                string soapResponse = doesPcehrExistClient.SoapMessages.SoapResponse;
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
コード例 #10
0
        public void Sample()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Interface requires this to be blank
            header.IhiNumber = null;

            // Create the client
            GetTemplateClient templateClient = new GetTemplateClient(new Uri("https://GetTemplateEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            // Specify the objects that will hold the output
            getTemplateResponseTemplate responseTemplate;
            DateTime cacheExpiry = new DateTime();

            try
            {
                var request = new getTemplate()
                {
                    serviceRequestorOption = ServiceRequestorOption.FullPackage.ToString(),
                    templateID             = "document unique ID"
                };

                // Invoke the service
                var responseStatusType = templateClient.GetTemplate(
                    header,
                    request);

                // Get the soap request and response
                string soapRequest  = templateClient.SoapMessages.SoapRequest;
                string soapResponse = templateClient.SoapMessages.SoapResponse;
            }
            catch (FaultException e)
            {
                // Handle any errors
            }
        }
コード例 #11
0
        public void Sample()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Override this value to the current patient's IHI.
            header.IhiNumber = "IHI";

            // Instantiate the client
            // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/getAuditView"
            // production endpoint is "https://services.ehealth.gov.au/getAuditView"
            GetAuditViewClient getAuditViewClient = new GetAuditViewClient(new Uri("https://GetAuditViewEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            try
            {
                // Invoke the service
                getAuditViewResponseEventTrail[] eventTrails;

                // Set up the dates
                var dates = new getAuditView()
                {
                    dateFrom = DateTime.Parse("from date/time"),
                    dateTo   = DateTime.Parse("to date/time")
                };

                var responseStatus = getAuditViewClient.GetAuditView(header, dates);

                // Get the soap request and response
                string soapRequest  = getAuditViewClient.SoapMessages.SoapRequest;
                string soapResponse = getAuditViewClient.SoapMessages.SoapResponse;
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
コード例 #12
0
        public void Sample()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header  (See PcehrHeaderHelper.cs)
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Override this value to the current patient's IHI.
            header.IhiNumber = "IHI";

            // Create the client
            // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/getDocument"
            // production endpoint is "https://services.ehealth.gov.au/getDocument"
            GetDocumentClient getDocumentClient = new GetDocumentClient(new Uri("https://GetDocumentEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            // Create a request
            List <RetrieveDocumentSetRequestTypeDocumentRequest> request =
                new List <RetrieveDocumentSetRequestTypeDocumentRequest>();

            // Set the details of the document to retrieve
            request.Add(new RetrieveDocumentSetRequestTypeDocumentRequest()
            {
                // This should be the value of the ExternalIdentifier "XDSDocumentEntry.uniqueId" in the GetDocumentList response
                DocumentUniqueId = "document unique id",
                // This should be the value of "repositoryUniqueId" in the GetDocumentList response
                RepositoryUniqueId = "repository unique id"
            });

            try
            {
                // Invoke the service
                RetrieveDocumentSetResponseType response = getDocumentClient.GetDocument(header, request.ToArray());
            }
            catch (FaultException e)
            {
                // Handle any errors
            }
        }
コード例 #13
0
        public void Sample()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Interface requires this to be blank
            header.IhiNumber = null;

            // Create the client
            SearchTemplateClient searchTemplateClient = new SearchTemplateClient(new Uri("https://SearchTemplateEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            // Specify the objects that will hold the output
            searchTemplateResponseTemplate[] responseTemplates;

            try
            {
                // Invoke the service
                searchTemplateResponse responseStatus = searchTemplateClient.SearchTemplate(header,
                                                                                            new searchTemplate()
                {
                    templateID       = "template ID",
                    templateMetadata = null
                });

                // Get the soap request and response
                string soapRequest  = searchTemplateClient.SoapMessages.SoapRequest;
                string soapResponse = searchTemplateClient.SoapMessages.SoapResponse;
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
コード例 #14
0
        public void Sample()
        {
            // NASH certificate should be used here, NOT the HI certificate
            // the NASH certificate can be found in the NASH PKI Test Kit
            // certificate needs to be installed in the right place
            // the "Issue To" field of a NASH certificate looks like general(or something different)."HPI-O".electronichealth.net.au
            // "Serial Number" can be found in the details once the certificate is installed. e.g. in Windows, certificates can be found in Certs.msc

            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Override this value to the current patient's IHI.
            header.IhiNumber = "IHI";

            // Create the client
            // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/getRepresentativeList"
            // production endpoint is "https://services.ehealth.gov.au/getRepresentativeList"
            GetIndividualDetailsViewClient getIndividualDetailsClient = new GetIndividualDetailsViewClient(
                new Uri("https://GetIndividualDetailsViewClientEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            object request = (string)"";

            try
            {
                // Invoke the service
                getIndividualDetailsViewResponse response = getIndividualDetailsClient.GetIndividualDetailsView(header, request);
            }
            catch (FaultException e)
            {
                // Handle any errors
            }
        }
        public void Sample()
        {
            // This example shows a Transport Response Delivery (TRD) message creation after a message
            // is received via Sealed Message Delivery (SMD). A static helper method is provided on
            // the client to help generate a TransportResponseType instance from a SealedMessageType
            // instance received via SMD, SIMD, or SMR.

            // TLS certificate used to authenticate the client to the TRD service during TLS connection.
            X509Certificate2 tlsCert = X509CertificateUtil.GetCertificate("TlsCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Certificate used to decrypt a received SealedMessageType payload.
            X509Certificate2 payloadDecryptionCert = X509CertificateUtil.GetCertificate("PayloadDecryptionCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Set up client.
            TransportResponseDeliveryClient trdClient = new TransportResponseDeliveryClient(tlsCert);

            // The SealedMessageType instance to generate a Transport Response for.
            // Typically, this would be available after an SMD, SIMD or SMR service invocation.
            Nehta.SMD2010.SMD.SealedMessageType sealedMessage = new Nehta.SMD2010.SMD.SealedMessageType();

            // Generate the Transport Response for the Sealed Message.
            TransportResponseType transportResponse = TransportResponseDeliveryClient.GetTransportResponse(
                new CommonSealedMessageType(sealedMessage),
                HIQualifiers.HPIOQualifier + "16 digit HPIO of sender organisation",
                ResponseClassType.Success,
                "DeliveryResponseCode",
                "DeliveryResponseMessage",
                DateTime.Now.ToUniversalTime(),
                new UniqueId().ToString(),
                true,
                null,
                payloadDecryptionCert
                );

            // Add the generated Transport Response to a list.
            List <TransportResponseType> transportResponses = new List <TransportResponseType>();

            transportResponses.Add(transportResponse);

            // Invoke the Deliver operation on the client, passing in the list of Transport Responses.
            deliverResponse response = trdClient.Deliver(transportResponses, new Uri("https://TRDServiceEndpoint"));
        }
        public void Sample()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Override this value to the current patient's IHI.
            header.IhiNumber = "IHI";

            // Instantiate the client
            // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/getChangeHistoryView"
            // production endpoint is "https://services.ehealth.gov.au/getChangeHistoryView"
            GetChangeHistoryViewClient changeHistoryViewClient = new GetChangeHistoryViewClient(new Uri("https://GetChangeHistoryViewEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            try
            {
                // Invoke the service
                // if you run GetDocumentList first, you will get a list of document ids in the response
                // the "value" attribute in the <ns3:ExternalIdentifier> element provides the unique document id
                var changeHistoryView = changeHistoryViewClient.GetChangeHistoryView(
                    header, new getChangeHistoryView()
                {
                    documentID = "document unique id"
                }
                    );
            }
            catch (FaultException e)
            {
                // Handle any errors
            }
        }
コード例 #17
0
        public RetrieveDocumentSetResponseType GetDocument(string documentId, string repositoryId)
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Create the client
            GetDocumentClient getDocumentClient = new GetDocumentClient(new Uri("https://GetDocumentEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            // Create a request
            List <RetrieveDocumentSetRequestTypeDocumentRequest> request = new List <RetrieveDocumentSetRequestTypeDocumentRequest>();

            // Set the details of the document to retrieve
            request.Add(new RetrieveDocumentSetRequestTypeDocumentRequest()
            {
                DocumentUniqueId   = documentId,
                RepositoryUniqueId = repositoryId
            });

            try
            {
                // Invoke the service
                RetrieveDocumentSetResponseType response = getDocumentClient.GetDocument(header, request.ToArray());
                return(response);
            }
            catch (FaultException e)
            {
                // Handle any errors
                return(null);
            }
        }
コード例 #18
0
        public void Sample()
        {
            // TLS certificate used to authenticate the client to the TRR service during TLS connection.
            X509Certificate2 tlsCert = X509CertificateUtil.GetCertificate("TlsCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Instantiate client
            TransportResponseRetrievalClient client = new TransportResponseRetrievalClient(tlsCert);

            // ------------------------------------------------------------------------------
            // Retrieve
            // ------------------------------------------------------------------------------

            // Set up request
            retrieve retrieveRequest = new retrieve()
            {
                allAvailable = true,
                limit        = 0,
                organisation = HIQualifiers.HPIOQualifier + "16 digit HPIO of receiver organisation"
            };

            // Invoke the Retrieve operation
            TransportResponseListType responseList = client.Retrieve(retrieveRequest, new Uri("https://TRREndpointUri"));

            // ------------------------------------------------------------------------------
            // Remove
            // ------------------------------------------------------------------------------

            // Build list of retrieved transport response IDs
            string[] responseIds = responseList.response.Select(r => r.metadata.responseId).ToArray();

            // Set up request
            remove removeRequest = new remove()
            {
                force        = true,
                organisation = HIQualifiers.HPIOQualifier + "16 digit HPIO of receiver organisation",
                responseId   = responseIds
            };

            // Invoke the Remove operation
            RemoveResultType[] removeResults = client.Remove(removeRequest, new Uri("https://TRREndpointUri"));
        }
        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
            };

            // ------------------------------------------------------------------------------
            // Call the read interface
            // ------------------------------------------------------------------------------

            // Read the existing values from HI
            ProviderDirectoryOrganisationEntryRecord providerDetails = null;

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

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

            // Create the request
            var directoryEntry = new manageProviderDirectoryEntry();

            // Set the items to the published based on the IDs used from the 'read' operation
            var organisationEntryRecord = new ProviderDirectoryOrganisationEntryRecord();

            organisationEntryRecord.externalIdentifier          = (providerDetails != null ? providerDetails.externalIdentifier : 0);
            organisationEntryRecord.externalIdentifierSpecified = (providerDetails != null ? true : false);
            organisationEntryRecord.displayPrivateDetails       = (providerDetails != null ? providerDetails.displayPrivateDetails : false);;
            organisationEntryRecord.priorityNumber = (providerDetails != null ? providerDetails.priorityNumber : 1);
            organisationEntryRecord.display        = true;
            organisationEntryRecord.electronicCommunicationExternalId = (providerDetails != null ? providerDetails.electronicCommunicationExternalId : null);
            organisationEntryRecord.organisationServiceExternalId     = (providerDetails != null ? providerDetails.organisationServiceExternalId : null);

            organisationEntryRecord.nameExternalId    = providerDetails.nameExternalId;
            organisationEntryRecord.addressExternalId = providerDetails.addressExternalId;
            organisationEntryRecord.endpointLocatorServiceExternalId = providerDetails.endpointLocatorServiceExternalId;

            directoryEntry.organisationEntry = new[] { organisationEntryRecord };


            // Submit the request
            try
            {
                manageProviderDirectoryEntryResponse response = client.ManageProviderDirectoryEntry(directoryEntry);
            }
            catch (Exception ex)
            {
                // If an error is encountered, client.LastSoapResponse often provides a more
                // detailed description of the error.
                string soapResponse = client.SoapMessages.SoapResponse;
            }
        }
コード例 #20
0
        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
            // ------------------------------------------------------------------------------

            // Create the request
            var directoryEntry = new manageProviderOrganisation()
            {
                hpioNumber = "http://<anything>/id/<anything>/hpio/1.0/HPIO",
                endpointLocatorServiceRecord = new[]
                {
                    new EndpointLocatorServiceRecord()
                    {
                        serviceIdentity = "<yourserviceidentity>",
                        serviceAddress  = "<yourserviceaddress>",
                    },
                }
            };

            // Instantiate the client
            using (var client = new ProviderManageProviderOrganisationClient(new Uri("https://HIServiceEndpoint"), product, user, hpio, signingCert, tlsCert))
            {
                // Submit the request
                try
                {
                    manageProviderOrganisationResult response = client.ManageProviderOrganisation(directoryEntry);
                }
                catch (Exception ex)
                {
                    // If an error is encountered, client.LastSoapResponse often provides a more
                    // detailed description of the error.
                    string soapResponse = client.SoapMessages.SoapResponse;
                }
            }
        }
コード例 #21
0
        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 ID 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
            ProviderReadReferenceDataClient client = new ProviderReadReferenceDataClient(
                new Uri("https://HIServiceEndpoint"),
                product,
                user,
                hpio,
                signingCert,
                tlsCert);

            try
            {
                // Invokes the read operation
                readReferenceDataResponse readReferenceDataResponse =
                    client.ReadReferenceData(new string[]
                {
                    "providerTypeCode",
                    "providerSpecialty",
                    "providerSpecialisation",
                    "organisationTypeCode",
                    "organisationService",
                    "organisationServiceUnit",
                });
            }
            catch (FaultException fex)
            {
                string       returnError = "";
                MessageFault fault       = fex.CreateMessageFault();
                if (fault.HasDetail)
                {
                    ServiceMessagesType error = fault.GetDetail <ServiceMessagesType>();
                    // Look at error details in here
                    if (error.serviceMessage.Length > 0)
                    {
                        returnError = error.serviceMessage[0].code + ": " + error.serviceMessage[0].reason;
                    }
                }

                // If an error is encountered, client.LastSoapResponse often provides a more
                // detailed description of the error.
                string soapResponse = client.SoapMessages.SoapResponse;
            }
            catch (Exception ex)
            {
                // If an error is encountered, client.LastSoapResponse often provides a more
                // detailed description of the error.
                string 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
            ConsumerCreateVerifiedIHIClient client = new ConsumerCreateVerifiedIHIClient(
                new Uri("https://HIServiceEndpoint"),
                product,
                user,
                hpio,
                signingCert,
                tlsCert);

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

            request.dateOfBirth = DateTime.Parse("01 Dec 2014");
            request.dateOfBirthAccuracyIndicator = DateAccuracyIndicatorType.AAA;
            request.familyName = "Wood";
            request.givenName  = new [] { "Jessica" };
            request.sex        = SexType.F;
            request.usage      = IndividualNameUsageType.L;
            request.address    = new AddressType();
            request.address.australianStreetAddress = new AustralianStreetAddressType();
            request.address.australianStreetAddress.streetNumber        = "10";
            request.address.australianStreetAddress.streetName          = "Browning Street";
            request.address.australianStreetAddress.streetType          = StreetType.ST;
            request.address.australianStreetAddress.streetTypeSpecified = true;
            request.address.australianStreetAddress.suburb   = "West End";
            request.address.australianStreetAddress.postcode = "4101";
            request.address.australianStreetAddress.state    = StateType.QLD;
            request.address.purpose     = AddressPurposeType.R;
            request.address.preferred   = TrueFalseType.T;
            request.privacyNotification = true;

            try
            {
                // Invokes a basic search
                createVerifiedIHIResponse ihiResponse = client.CreateVerifiedIhi(request);
            }
            catch (FaultException fex)
            {
                string       returnError = "";
                MessageFault fault       = fex.CreateMessageFault();
                if (fault.HasDetail)
                {
                    ServiceMessagesType error = fault.GetDetail <ServiceMessagesType>();
                    // Look at error details in here
                    if (error.serviceMessage.Length > 0)
                    {
                        returnError = error.serviceMessage[0].code + ": " + error.serviceMessage[0].reason;
                    }
                }

                // If an error is encountered, client.LastSoapResponse often provides a more
                // detailed description of the error.
                string soapResponse = client.SoapMessages.SoapResponse;
            }
            catch (Exception ex)
            {
                // If an error is encountered, client.LastSoapResponse often provides a more
                // detailed description of the error.
                string soapResponse = client.SoapMessages.SoapResponse;
            }
        }
コード例 #23
0
        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;
            }
        }
        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        = "OMO", // The OMO of the certificate
                qualifier = "http://<anything>/id/<anything>/userid/1.0"
                                   // Eg: http://ns.medicareaustralia.gov.au/id/hi/distinguishedname/1.0
            };


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

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

            // Create the request
            var directoryEntry = new readProviderOrganisation
            {
                hpioNumber     = "http://ns.electronichealth.net.au/id/hi/hpio/1.0/" + "HPIO Number Here",
                linkSearchType = "link Search Type Here"
            };

            // Submit the request
            try
            {
                var response = client.ReadProviderOrganisation(directoryEntry);
            }
            catch (Exception ex)
            {
                // If an error is encountered, client.LastSoapResponse often provides a more
                // detailed description of the error.
                string 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
            var client = new ProviderBatchAsyncSearchForProviderOrganisationClient(
                new Uri("https://HIServiceEndpoint"),
                product,
                user,
                hpio,
                signingCert,
                tlsCert);

            // Create the search request
            var search1 = new BatchSearchForProviderOrganisationCriteriaType()
            {
                requestIdentifier             = Guid.NewGuid().ToString(),
                searchForProviderOrganisation = new searchForProviderOrganisation()
                {
                    hpioNumber = HIQualifiers.HPIOQualifier + "HPIO TO SEARCH",
                }
            };

            // Submit the batch search request
            var submitResponse =
                client.BatchSubmitProviderOrganisations(new BatchSearchForProviderOrganisationCriteriaType[]
            {
                search1
            });

            // Retrieve the batch result
            var retrieveResponse = client.BatchRetrieveProviderOrganisations(new retrieveSearchForProviderOrganisation()
            {
                batchIdentifier = submitResponse.submitSearchForProviderOrganisationResult.batchIdentifier
            });
        }
        public void Sample()
        {
            // TLS certificate used to authenticate the client to the SMR service during TLS connection.
            X509Certificate2 tlsCert = X509CertificateUtil.GetCertificate("TlsCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Certificate used to sign the payload.
            X509Certificate2 signingCert = X509CertificateUtil.GetCertificate("SigningCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Certificate used to encrypt the payload.
            X509Certificate2 payloadDecryptionCert = X509CertificateUtil.GetCertificate("DecryptionCertificateSerialNumber", X509FindType.FindBySerialNumber, StoreName.My, StoreLocation.CurrentUser, true);

            // Instantiate client
            SealedMessageRetrievalClient client = new SealedMessageRetrievalClient(tlsCert);

            // ------------------------------------------------------------------------------
            // List
            // ------------------------------------------------------------------------------

            // Set up request
            list listRequest = new list()
            {
                allAvailable         = true,
                limit                = 0,
                receiverOrganisation = HIQualifiers.HPIOQualifier + "16 digit HPIO of receiver organisation"
            };

            // Invoke the List operation
            MessageListType messageList = client.List(listRequest, new Uri("https://SMRServiceEndpointUri"));

            // ------------------------------------------------------------------------------
            // Retrieve
            // ------------------------------------------------------------------------------

            // Get list of invocation IDs obtained from List operation
            string[] invocationIds = messageList.retrievalRecord.Select(r => r.metadata.invocationId).ToArray();

            // Set up request
            retrieve retrieveRequest = new retrieve()
            {
                invocationId         = invocationIds,
                receiverOrganisation = HIQualifiers.HPIOQualifier + "16 digit HPIO of receiver organisation"
            };

            // Invoke the Retrieve operation
            SealedMessageType[] sealedMessages = client.Retrieve(retrieveRequest, new Uri("https://SMRServiceEndpointUri"));

            // ------------------------------------------------------------------------------
            // Obtaining the payload from the Sealed Messages
            // ------------------------------------------------------------------------------

            // Obtain the first Sealed Message to decrypt
            SealedMessageType sealedMessage = sealedMessages[0];

            // Serialize the encrypted payload
            XmlDocument encryptedPayload = sealedMessage.encryptedPayload.SerializeToXml("encryptedPayload");

            // Decrypt the payload, obtaining the signed payload
            XmlDocument decryptedPayload = encryptedPayload.XspDecrypt(payloadDecryptionCert);

            // Obtain the original payload from the signed payload
            XmlDocument originalPayload = decryptedPayload.XspGetPayloadFromSignedDocument();
        }
コード例 #27
0
        // Sample code for these CDA response getViews

        // Nehta.VendorLibrary.PCEHR.PrescriptionAndDispenseView.prescriptionAndDispenseView
        // Nehta.VendorLibrary.PCEHR.MedicareOverview.medicareOverview
        // Nehta.VendorLibrary.PCEHR.HealthCheckScheduleView.healthCheckScheduleView
        // Nehta.VendorLibrary.PCEHR.ObservationView.observationView

        public void SampleForCdaDocumentResponses()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Instantiate the client
            // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/getView"
            // production endpoint is "https://services.ehealth.gov.au/getView"
            GetViewClient getViewClient = new GetViewClient(new Uri("https://GetViewEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            try
            {
                getView request = new getView()
                {
                    // For PrescriptionAndDispenseView
                    view = new prescriptionAndDispenseView()
                    {
                        fromDate = DateTime.Now.AddDays(-10),
                        toDate   = DateTime.Now,
                        // versionNumber can be found in the "PCEHR View Service - Technical Service Specification" via
                        // https://digitalhealth.gov.au/implementation-resources/national-infrastructure/EP-2109-2015
                        // If the specification doesn't specify the version number then it is 1.0
                        versionNumber = "Version number here"
                    }

                    // For MedicareOverview
                    //view = new medicareOverview()
                    //{
                    //    fromDate = DateTime.Now.AddDays(-10),
                    //    toDate = DateTime.Now,
                    // versionNumber can be found in the "PCEHR View Service - Technical Service Specification" via
                    // https://digitalhealth.gov.au/implementation-resources/national-infrastructure/EP-2109-2015
                    // If the specification doesn't specify the version number then it is 1.0
                    //    versionNumber = "Version number here"
                    //}

                    // For HealthCheckScheduleView
                    //view = new healthCheckScheduleView()
                    //{
                    //    jurisdiction = healthCheckScheduleViewJurisdiction.NSW,
                    // versionNumber can be found in the "PCEHR View Service - Technical Service Specification" via
                    // https://digitalhealth.gov.au/implementation-resources/national-infrastructure/EP-2109-2015
                    // If the specification doesn't specify the version number then it is 1.0
                    //    versionNumber = "Version number here"
                    //}

                    // For ObservationView
                    //view = new observationView()
                    //{
                    //    fromDate = DateTime.Now.AddDays(-10),
                    //    toDate = DateTime.Now,
                    // versionNumber can be found in the "PCEHR View Service - Technical Service Specification" via
                    // https://digitalhealth.gov.au/implementation-resources/national-infrastructure/EP-2109-2015
                    // If the specification doesn't specify the version number then it is 1.0
                    //    versionNumber = "Version number here"
                    //    documentSource = observationViewDocumentSource.ALL,
                    //    observationType = observationViewObservationType.WEIGHT,
                    //    referenceData = observationViewReferenceData.CDC
                    //}
                };

                var responseStatus = getViewClient.GetView(header, request);

                // Treat response like a getDocument - unzip package
                if (responseStatus.view != null)
                {
                    var zipfile = responseStatus.view.data;
                    // and Unzip
                }

                // Get the soap request and response
                string soapRequest  = getViewClient.SoapMessages.SoapRequest;
                string soapResponse = getViewClient.SoapMessages.SoapResponse;
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
        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
            ProviderSearchHIProviderDirectoryForOrganisationClient client = new ProviderSearchHIProviderDirectoryForOrganisationClient(
                new Uri("https://HIServiceEndpoint"),
                product,
                user,
                hpio,
                signingCert,
                tlsCert);

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

            request.hpioNumber = HIQualifiers.HPIOQualifier + "8003624166667003";

            try
            {
                // Invokes an identifier search
                searchHIProviderDirectoryForOrganisationResponse response = client.IdentifierSearch(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;
            }
        }
        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
            ConsumerSearchIHIBatchSyncClient client = new ConsumerSearchIHIBatchSyncClient(
                new Uri("https://HIServiceEndpoint"),
                product,
                user,
                hpio,
                signingCert,
                tlsCert);

            // Create a list of search requests
            var searches = new List <CommonSearchIHIRequestType>();

            // Add a basic search
            searches.AddBasicSearch(Guid.NewGuid().ToString(), new CommonSearchIHI()
            {
                ihiNumber   = HIQualifiers.IHIQualifier + "8003601240022579",
                dateOfBirth = DateTime.Parse("12 Dec 2002"),
                givenName   = "Jessica",
                familyName  = "Wood",
                sex         = CommonSexType.F
            });

            // Add a basic Medicare search
            searches.AddBasicMedicareSearch(Guid.NewGuid().ToString(), new CommonSearchIHI()
            {
                medicareCardNumber = "2950141861",
                medicareIRN        = "1",
                dateOfBirth        = DateTime.Parse("12 Dec 2002"),
                givenName          = "Jessica",
                familyName         = "Wood",
                sex = CommonSexType.F
            });

            // Add a basic DVA search
            searches.AddBasicDvaSearch(Guid.NewGuid().ToString(), new CommonSearchIHI()
            {
                dvaFileNumber = "N 908030C",
                dateOfBirth   = DateTime.Parse("12 Dec 1970"),
                givenName     = "Luke",
                familyName    = "Lawson",
                sex           = CommonSexType.M
            });

            // Add an Australian street address search
            searches.AddAustralianStreetAddressSearch(Guid.NewGuid().ToString(), new CommonSearchIHI()
            {
                dateOfBirth             = DateTime.Parse("12 Dec 2002"),
                givenName               = "Jessica",
                familyName              = "Wood",
                sex                     = CommonSexType.F,
                australianStreetAddress = new CommonAustralianStreetAddressType()
                {
                    streetNumber        = "21",
                    streetName          = "Ross",
                    streetType          = CommonStreetType.RD,
                    streetTypeSpecified = true,
                    suburb   = "Queanbeyan",
                    state    = CommonStateType.NSW,
                    postcode = "2620"
                }
            });

            try
            {
                // Invokes the batch search
                searchIHIBatchResponse ihiResponse = client.SearchIHIBatchSync(searches);
            }
            catch (FaultException fex)
            {
                string       returnError = "";
                MessageFault fault       = fex.CreateMessageFault();
                if (fault.HasDetail)
                {
                    ServiceMessagesType error = fault.GetDetail <ServiceMessagesType>();
                    // Look at error details in here
                    if (error.serviceMessage.Length > 0)
                    {
                        returnError = error.serviceMessage[0].code + ": " + error.serviceMessage[0].reason;
                    }
                }

                // If an error is encountered, client.LastSoapResponse often provides a more
                // detailed description of the error.
                string soapResponse = client.SoapMessages.SoapResponse;
            }
            catch (Exception ex)
            {
                // If an error is encountered, client.LastSoapResponse often provides a more
                // detailed description of the error.
                string soapResponse = client.SoapMessages.SoapResponse;
            }
        }
コード例 #30
0
        public void Sample()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Override this value to the current patient's IHI.
            header.IhiNumber = "IHI";

            // Create the client
            // SVT endpoint is https://b2b.ehealthvendortest.health.gov.au/uploadDocument
            // production endpoint is https://services.ehealth.gov.au/uploadDocument
            UploadDocumentClient uploadDocumentClient = new UploadDocumentClient(
                new Uri("https://UploadDocumentEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            byte[] packageBytes = File.ReadAllBytes("CdaPackage.zip"); // Create a package

            // Create a request to register a new document on the PCEHR.
            // Create a request to register a new document on the PCEHR.
            // Format codes and format code names are not fixed, and it is recommended for them to be configurable.
            // formatCode is the Template Package ID for each clinical document, formatCodeName is the Document type
            // please find specific details for each clinical document type on https://digitalhealth.gov.au/implementation-resources/clinical-documents
            // formatCodeName can be read in Table 3 of the Document Exchange Service Technical Service Specification
            // For example (formateCodeName - formatCode):
            // "eHealth Dispense Record" - 1.2.36.1.2001.1006.1.171.5
            // "Pathology Report" - 1.2.36.1.2001.1006.1.220.4
            // "Diagnostic Imaging Report" - 1.2.36.1.2001.1006.1.222.4
            ProvideAndRegisterDocumentSetRequestType request = uploadDocumentClient.CreateRequestForNewDocument(
                packageBytes,
                "formatCode",
                "formatCodeName",
                HealthcareFacilityTypeCodes.GeneralPractice,                // Update to relevant code
                PracticeSettingTypes.GeneralPracticeMedicalClinicService    // Update to relevant code
                );

            // To supercede / amend an existing document, the same UploadDocument call is used. However, the request is
            // prepared using the CreateRequestForReplacement function.

            // Note that the new document must have a different UUID/GUID to the one it is replacing.
            // the uuidOfDocumentToReplace must be converted to OID format and include the repository OID.
            // (i.e. a document being replaced in the My Health Record repository is)

            // ProvideAndRegisterDocumentSetRequestType request = uploadDocumentClient.CreateRequestForReplacement(
            //    packageBytes,
            //    "formatCode",
            //    "formatCodeName",
            //    HealthcareFacilityTypeCodes.GeneralPractice,
            //    PracticeSettingTypes.GeneralPracticeMedicalClinicService,
            //    "uuidOfDocumentToReplace"
            //    );

            // When uploading to the NPDR where the repository unique ID, document size and hash may need to be included
            // in the metadata, use the utility function below.

            // uploadDocumentClient.AddRepositoryIdAndCalculateHashAndSize(request, "REPOSITORY_UNIQUE_ID");

            try
            {
                // Invoke the service
                RegistryResponseType registryResponse = uploadDocumentClient.UploadDocument(header, request);

                // Get the soap request and response
                string soapRequest  = uploadDocumentClient.SoapMessages.SoapRequest;
                string soapResponse = uploadDocumentClient.SoapMessages.SoapResponse;
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }