public static CommonPcehrHeader Common(CommonPcehrHeader CommonPcehrHeader, string uploadingHPIO)
        {
            //User ID should be a HPI-I if the user is HPI-I eligible (i.e. AHPRA registered)
            // If the user isn't HPI-I eligible (such as support staff and scientific staff) then set the user ID to a local ID and
            // Set pcehrHeader.UserIdType to PCEHRHeaderUserIDType.LocalSystemIdentifier;
            CommonPcehrHeader.UserId     = "AngusM";
            CommonPcehrHeader.UserIdType = CommonPcehrHeaderUserIDType.LocalSystemIdentifier;
            CommonPcehrHeader.UserName   = "******";

            // "organisation name" and "organisation HPIO" can be found in the NASH PKI Test Kit
            // HPI-O is always 16 digits long
            CommonPcehrHeader.OrganisationName = "AngusADHA";
            CommonPcehrHeader.OrganisationId   = uploadingHPIO;

            CommonPcehrHeader.ClientSystemType = CommonPcehrHeaderClientSystemType.CIS;

            // Below information can be found in the My Health Record Vendor Product Details Form
            // that you filled out and submitted
            CommonPcehrHeader.ProductPlatform = "Windows";
            CommonPcehrHeader.ProductName     = "NEHTA HIPS";
            CommonPcehrHeader.ProductVersion  = "6.1";
            CommonPcehrHeader.ProductVendor   = "HIPS0001";

            return(CommonPcehrHeader);
        }
        public static CommonPcehrHeader CreateHeader()
        {
            // Create the PCEHR header
            var pcehrHeader = new CommonPcehrHeader();

            // this is the patient's Individual Healthcare Identifier and is always 16 digits long
            //QLD: Star Patient: IHI 8003601090687190
            pcehrHeader.IhiNumber = "8003608666885561";

            //User ID should be a HPI-I if the user is HPI-I eligible (i.e. AHPRA registered)
            // If the user isn't HPI-I eligible (such as support staff and scientific staff) then set the user ID to a local ID and
            // Set pcehrHeader.UserIdType to PCEHRHeaderUserIDType.LocalSystemIdentifier;
            pcehrHeader.UserId     = "AngusM";
            pcehrHeader.UserIdType = CommonPcehrHeaderUserIDType.LocalSystemIdentifier;
            pcehrHeader.UserName   = "******";

            // "organisation name" and "organisation HPIO" can be found in the NASH PKI Test Kit
            // HPI-O is always 16 digits long
            pcehrHeader.OrganisationName = "AngusADHA";
            pcehrHeader.OrganisationId   = "8003629900019338";

            pcehrHeader.ClientSystemType = CommonPcehrHeaderClientSystemType.CIS;

            // Below information can be found in the My Health Record Vendor Product Details Form
            // that you filled out and submitted
            pcehrHeader.ProductPlatform = "Windows";
            pcehrHeader.ProductName     = "NEHTA HIPS";
            pcehrHeader.ProductVersion  = "6.1";
            pcehrHeader.ProductVendor   = "HIPS0001";

            return(pcehrHeader);
        }
        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
            }
        }
Esempio n. 4
0
        public void GetMedicareOverview()
        {
            //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/getView"
            // production endpoint is "https://services.ehealth.gov.au/getView"
            GetViewClient getViewClient = new GetViewClient(new Uri("https://b2b.ehealthvendortest.health.gov.au/getView"), cert, cert);

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

            try
            {
                getView request = new getView()
                {
                    // 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
                        //Currently 1.0 and 1.1
                        versionNumber = "1.1"
                    }
                };

                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 static string UploadingHPIO = "8003629900019338";

        public static CommonPcehrHeader CreateHeader(PatientType patientType, string uploadingHPIO)
        {
            var    pcehrHeader = new CommonPcehrHeader();
            string PatientName = string.Empty;

            switch (patientType)
            {
            case PatientType.FrankHarding:
                PatientName           = "Frank Harding";
                pcehrHeader.IhiNumber = "8003608666701594";
                break;

            case PatientType.CalebDerrington:
                PatientName           = "Caleb Derrington";
                pcehrHeader.IhiNumber = "8003608000045922";
                break;

            case PatientType.JackieHunt:
                PatientName           = "Jackie Hunt";
                pcehrHeader.IhiNumber = "8003608500179916";
                break;

            case PatientType.MaxwellThomas:
                PatientName           = "Maxwell Thomas";
                pcehrHeader.IhiNumber = "8003608666889084";
                break;

            case PatientType.LudwigHOBBS:
                PatientName           = "Ludwig HOBBS";
                pcehrHeader.IhiNumber = "8003608333345684";
                break;

            case PatientType.LarryBLAKE:
                PatientName           = "Larry BLAKE";
                pcehrHeader.IhiNumber = "8003608833499130";
                break;

            case PatientType.AliceLAMM:
                PatientName           = "Alice LAMM";
                pcehrHeader.IhiNumber = "8003608000166041";
                break;

            case PatientType.MarieVOSLOO:
                PatientName           = "Marie VOSLOO";
                pcehrHeader.IhiNumber = "8003608333357747";
                break;

            default:
                break;
            }

            Console.WriteLine($"-Patient--------------------------------------------------------------");
            Console.WriteLine($"Name: {PatientName}");
            Console.WriteLine($"IHI: {pcehrHeader.IhiNumber}");
            Console.WriteLine($"----------------------------------------------------------------------");
            return(Common(pcehrHeader, uploadingHPIO));
        }
Esempio n. 6
0
        public void GetHealthRecordOverview()
        {
            //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/getView"
            // production endpoint is "https://services.ehealth.gov.au/getView"
            GetViewClient getViewClient = new GetViewClient(new Uri("https://b2b.ehealthvendortest.health.gov.au/getView"), cert, cert);

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

            try
            {
                getView request = new getView()
                {
                    // Creates a healthRecordOverView
                    view = new healthRecordOverView()
                    {
                        clinicalSynopsisLength = 200,
                        // 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 = "1.1"
                    }
                };

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

                // Get the soap request and response
                string soapRequest  = getViewClient.SoapMessages.SoapRequest;
                string soapResponse = getViewClient.SoapMessages.SoapResponse;

                // Convert XML response into Class for healthRecordOverview
                XmlDocument xml = new XmlDocument();
                xml.PreserveWhitespace = true;
                xml.LoadXml(Encoding.Default.GetString(responseStatus.view.data));
                healthRecordOverviewResponse data = new healthRecordOverviewResponse();
                data = (healthRecordOverviewResponse)DeserialiseElementToClass(xml.DocumentElement, data);
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
Esempio n. 7
0
        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
            }
        }
        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
            }
        }
Esempio n. 9
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
            }
        }
        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
            }
        }
        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
            }
        }
        public void Remove()
        {
            //Get Certificate and Header objects
            CertAndHeaderInfo CertAndHeaderInfo = Support.CertAndHeaderFactory.Get(
                certSerial: "06fba6",
                serialHPIO: "8003629900019338",
                patientType: Support.PatientType.LudwigHOBBS);

            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = CertAndHeaderInfo.Certificate;

            // Create PCEHR header
            CommonPcehrHeader header = CertAndHeaderInfo.Header;

            // 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://b2b.ehealthvendortest.health.gov.au/removeDocument"), cert, cert);

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

            try
            {
                var request = new removeDocument()
                {
                    // this should be the value of the ExternalIdentifier "XDSDocumentEntry.uniqueId" in the GetDocumentList response
                    documentID = "2.25.262187743541392638493047310439698728609",
                    // 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
            }
        }
Esempio n. 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();

            // 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
            }
        }
Esempio n. 14
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
            }
        }
Esempio n. 15
0
        public void Run()
        {
            //Get Certificate and Header objects
            CertAndHeaderInfo CertAndHeaderInfo = Support.CertAndHeaderFactory.Get(
                certSerial: "06fba6",
                serialHPIO: "8003629900019338",
                patientType: Support.PatientType.MaxwellThomas);

            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = CertAndHeaderInfo.Certificate;

            // Create PCEHR header
            CommonPcehrHeader header = CertAndHeaderInfo.Header;

            // 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://b2b.ehealthvendortest.health.gov.au/getDocument"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += Support.CertificateHelper.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 = "2.25.5801464458231145855085038232999883849",
                // This should be the value of "repositoryUniqueId" in the GetDocumentList response
                RepositoryUniqueId = "1.2.36.1.2001.1007.10.8003640002000050"
            });

            try
            {
                // Invoke the service
                RetrieveDocumentSetResponseType response = getDocumentClient.GetDocument(header, request.ToArray());
            }
            catch (FaultException e)
            {
                // Handle any errors
            }
        }
        public void Run()
        {
            //certSerial: "06fba6",
            //serialHPIO: "8003629900019338",


            //Get Certificate and Header objects
            CertAndHeaderInfo CertAndHeaderInfo = Support.CertAndHeaderFactory.Get(
                certSerial: "06fba6",
                serialHPIO: "8003629900019338",
                patientType: Support.PatientType.FrankHarding);

            // 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/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 += Support.CertificateHelper.ValidateServiceCertificate;

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

                Console.WriteLine($"Success Full at : {DateTime.Now.ToString()}");
                Console.WriteLine($"PCEHR Exists: {response.PCEHRExists.ToString()}");
                Console.WriteLine($"Access Code Required: {response.accessCodeRequired.ToString()}");
                Console.WriteLine($"AccessCodeRequiredSpecified: {response.accessCodeRequiredSpecified.ToString()}");

                // Get the soap request and response
                string soapRequest  = doesPcehrExistClient.SoapMessages.SoapRequest;
                string soapResponse = doesPcehrExistClient.SoapMessages.SoapResponse;
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
Esempio n. 17
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
            }
        }
Esempio n. 18
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()
        {
            // 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
            }
        }
        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);
            }
        }
        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/getChangeHistoryView"
            // production endpoint is "https://services.ehealth.gov.au/getChangeHistoryView"
            GetChangeHistoryViewClient changeHistoryViewClient = new GetChangeHistoryViewClient(new Uri("https://b2b.ehealthvendortest.health.gov.au/getChangeHistoryView"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += Support.CertificateHelper.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 = "2.25.33982669477651998710317483962006911980"
                }
                    );
            }
            catch (FaultException e)
            {
                // Handle any errors
            }
        }
Esempio n. 22
0
        private CommonPcehrHeader CreateCommonPcehrHeader(SubmitObjectsRequest submitObjectsRequest)
        {
            // Extract the header data from the XDS data
            PcehrHeaderData pcehrHeaderData = XdsUtils.ExtractPcehrHeaderData(submitObjectsRequest);

            // Create the common header using the data from the XDS metadata
            var commonPcehrHeader = new CommonPcehrHeader
            {
                IhiNumber        = pcehrHeaderData.Ihi,
                UserId           = pcehrHeaderData.ProviderId,
                UserIdType       = pcehrHeaderData.IsProviderIdLocal ? CommonPcehrHeaderUserIDType.HPII : CommonPcehrHeaderUserIDType.LocalSystemIdentifier,
                UserName         = pcehrHeaderData.ProviderName,
                OrganisationName = pcehrHeaderData.OrganisationName,
                OrganisationId   = pcehrHeaderData.Hpio,
                ClientSystemType = _clientSystem,

                ProductPlatform = _productInfo.Platform,
                ProductName     = _productInfo.Name,
                ProductVersion  = _productInfo.Version,
                ProductVendor   = _productInfo.Vendor
            };

            return(commonPcehrHeader);
        }
        private bool GetDocumentId(string IHI, out string documentId, out 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();

            // Instantiate the client
            GetDocumentListClient documentListClient = new GetDocumentListClient(new Uri("https://GetDocumentListEndpoint"), cert, cert);

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

            // Create a query
            AdhocQueryBuilder adhocQueryBuilder = new AdhocQueryBuilder(IHI, new[] { DocumentStatus.Approved });

            // Reduce documents returned to just SHS from yesterday onwards (Medicines View will always be returned in this query)
            // as cannot filter on Medicines View as a document
            adhocQueryBuilder.ClassCode = new List <ClassCodes>();
            adhocQueryBuilder.ClassCode.Add(ClassCodes.SharedHealthSummary);
            adhocQueryBuilder.ServiceStopTimeFrom = new ISO8601DateTime(Convert.ToDateTime(DateTime.Now).AddDays(-1));

            // Create the request using the query
            AdhocQueryRequest queryRequest = adhocQueryBuilder.BuildRequest();

            // Initialise
            repositoryId = "";
            documentId   = "";

            try
            {
                // Invoke the service
                AdhocQueryResponse queryResponse = documentListClient.GetDocumentList(header, queryRequest);

                if (queryResponse != null &&
                    queryResponse.status == "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success" &&
                    queryResponse.RegistryObjectList != null)
                {
                    const string XDS_DOCUMENT_ENTRY_CLASS_CODE = "urn:uuid:41a5887f-8865-4c09-adf7-e362475b143a";
                    const string XDS_DOCUMENT_ENTRY_UNIQUE_ID  = "urn:uuid:2e82c1f6-a085-4c72-9da3-8640a32e42ab";
                    const string NCTIS_CLASS_CODE_MEDS_VIEW    = "100.32002";

                    //Loop through responses
                    foreach (var entry in queryResponse.RegistryObjectList.ExtrinsicObject)
                    {
                        var classification = entry.Classification.FirstOrDefault(o => o.classificationScheme == XDS_DOCUMENT_ENTRY_CLASS_CODE);
                        if (classification != null && classification.nodeRepresentation == NCTIS_CLASS_CODE_MEDS_VIEW)
                        {
                            // Get Values
                            var repid = entry.Slot.FirstOrDefault(o => o.name == "repositoryUniqueId");
                            var docId = entry.ExternalIdentifier.FirstOrDefault(o => o.identificationScheme == XDS_DOCUMENT_ENTRY_UNIQUE_ID);

                            // Set Values
                            repositoryId = (repid != null ? repid.ValueList.Value[0] : "");
                            documentId   = (docId != null ? docId.value : "");
                            break;
                        }
                    }
                }
                return(true);
            }
            catch (FaultException e)
            {
                // Handle any errors
                return(false);
            }
        }
Esempio n. 24
0
        public void GetPathologyView()
        {
            //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/getView"
            // production endpoint is "https://services.ehealth.gov.au/getView"
            GetViewClient getViewClient = new GetViewClient(new Uri("https://b2b.ehealthvendortest.health.gov.au/getView"), cert, cert);

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

            try
            {
                getView request = new getView()
                {
                    // Creates a pathologyReportView
                    view = new pathologyReportView()
                    {
                        //2 years = 365 * 2 Days
                        fromDate = DateTime.Now.Subtract(new TimeSpan((365 * 2), 0, 0, 0)),
                        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 = "1.0"
                    }
                };

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

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

                // Get the soap request and response
                string soapRequest  = getViewClient.SoapMessages.SoapRequest;
                string soapResponse = getViewClient.SoapMessages.SoapResponse;

                foreach (var item in data.pathologyReport.OrderByDescending(x => x.reportInformation.CDAeffectiveTime))
                {
                    Console.WriteLine($"");
                    Console.WriteLine($"##################################################################################");
                    Console.WriteLine($"DocumentId: {item.reportInformation.documentId}");
                    Console.WriteLine($"DocumentLink: {item.reportInformation.documentLink}");
                    Console.WriteLine($"ReportName: {item.reportInformation.reportName}");
                    Console.WriteLine($"PathologistLocalReportId: {item.reportInformation.pathologistLocalReportId}");
                    Console.WriteLine($"ReportStatus(code): {item.reportInformation.reportStatus.code}");
                    Console.WriteLine($"DateTimeRequested: {item.testRequesterInformation.dateTimeRequested}");
                    Console.WriteLine($"CDAeffectiveTime: {item.reportInformation.CDAeffectiveTime}");
                    Console.WriteLine($"DateTimeReportAuthored: {item.reportInformation.dateTimeReportAuthored}");
                    Console.WriteLine($"DateTimeAuthorisation: {item.reportInformation.dateTimeAuthorisation}");
                    foreach (var Report in item.pathologyTestResult)
                    {
                        Console.WriteLine($"  -------------------------------------------------");
                        Console.WriteLine($"  TestResultName(code): {Report.testResultName.code}");
                        Console.WriteLine($"  TestResultName(displayName): {Report.testResultName.displayName}");
                        Console.WriteLine($"  TestResultName(originalText): {Report.testResultName.originalText}");
                        Console.WriteLine($"  PathologyDiscipline(code): {Report.pathologyDiscipline.code}");
                        Console.WriteLine($"  OverallTestResultStatus(code): {Report.overallTestResultStatus.code}");
                        Console.WriteLine($"  SpecimenCollectionDate: {Report.specimenCollectionDate}");
                    }
                }
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
        // 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
            }
        }
Esempio n. 26
0
        public void Run()
        {
            // 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

            //Get Certificate and Header objects
            CertAndHeaderInfo CertAndHeaderInfo = Support.CertAndHeaderFactory.Get(
                certSerial: "06fba6",
                serialHPIO: "8003629900019338",
                patientType: Support.PatientType.FrankHarding);

            // 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/getDocumentList"
            // production endpoint is "https://services.ehealth.gov.au/getDocumentList"
            GetDocumentListClient documentListClient = new GetDocumentListClient(new Uri("https://b2b.ehealthvendortest.health.gov.au/getDocumentList"), cert, cert);

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

            // Create a query
            AdhocQueryBuilder adhocQueryBuilder = new AdhocQueryBuilder(header.IhiNumber, new[] { DocumentStatus.Approved });

            adhocQueryBuilder.ServiceStartTimeFrom = new ISO8601DateTime(new DateTime(2018, 03, 18));
            adhocQueryBuilder.ServiceStopTimeTo    = new ISO8601DateTime(new DateTime(2020, 07, 17));

            adhocQueryBuilder.ClassCode = new List <ClassCodes>()
            {
                ClassCodes.AdvanceCareDirectiveCustodianRecord,
                ClassCodes.AdvanceCareInformation
            };

            //adhocQueryBuilder.TypeCode = new List<ClassCodes>()
            //{
            //  ClassCodes.AdvanceCareDirectiveCustodianRecord,
            //  ClassCodes.AdvanceCareInformation
            //};

            // To further filter documents, build on the adhocQueryBuilder helper functions
            // For example, filtering on document type
            //adhocQueryBuilder.ClassCode = new List<ClassCodes>() {ClassCodes.AdvanceCareInformation};
            // See Table 3 XDSDocumentEntry Document Type and Class Code value set from
            // the Document Exchange Service Technical Service Specification

            // Create the request using the query
            AdhocQueryRequest queryRequest = adhocQueryBuilder.BuildRequest();


            try
            {
                // Invoke the service
                AdhocQueryResponse queryResponse = documentListClient.GetDocumentList(header, queryRequest);

                // Get the soap request and response
                string soapRequest  = documentListClient.SoapMessages.SoapRequest;
                string soapResponse = documentListClient.SoapMessages.SoapResponse;

                // Process data into a more simple model
                if (queryResponse.RegistryObjectList.ExtrinsicObject == null)
                {
                    Console.WriteLine($"Total Documents: 0");
                }
                else
                {
                    XdsRecord[] data        = XdsMetadataHelper.ProcessXdsMetadata(queryResponse.RegistryObjectList.ExtrinsicObject);
                    int         UseTimeZone = 11;
                    // For displaying the data in a list
                    Console.WriteLine($"Total Documents {data.Count().ToString()}");
                    Console.WriteLine($"{"Document Date".PadRight(23)} | {"Service Date".PadRight(23)} | {"Document".PadRight(35)} | {"Org".PadRight(35)} | {"Org Type".PadRight(35)}|");
                    Console.WriteLine($"================================================================================================================================================================================");
                    foreach (var row in data.OrderByDescending(x => x.creationTimeUTC))
                    {
                        Console.WriteLine($"{row.creationTimeUTC.Add(TimeSpan.FromHours(UseTimeZone)).ToString().PadRight(23)} | {row.serviceStartTimeUTC.Add(TimeSpan.FromHours(UseTimeZone)).ToString().PadRight(23)} | {row.typeCodeDisplayName.PadRight(35)} | {row.authorInstitution.institutionName.PadRight(35)} | {row.healthcareFacilityTypeCodeDisplayName.PadRight(35)}");
                        //Console.WriteLine($"DocumentId: {row.documentId}");
                        //Console.WriteLine($"ClassCode DisplayName: {row.classCodeDisplayName}");
                        //Console.WriteLine($"TypeCode DisplayName: {row.typeCodeDisplayName}");
                        //Console.WriteLine($"Creation Time UTC: {row.creationTimeUTC.Add(TimeSpan.FromHours(UseTimeZone)).ToString()}");
                        //Console.WriteLine($"Service Start Time UTC: {row.serviceStartTimeUTC.Add(TimeSpan.FromHours(UseTimeZone)).ToString()}");
                        //Console.WriteLine($"Service Stop Time UTC: {row.serviceStopTimeUTC.Add(TimeSpan.FromHours(UseTimeZone)).ToString()}");
                        //Console.WriteLine($"Healthcare Facility TypeCode DisplayName: {row.healthcareFacilityTypeCodeDisplayName}");
                        //Console.WriteLine($"Repository Unique Id: {row.repositoryUniqueId}");
                        //Console.WriteLine($"Status: {row.status}");
                        //Console.WriteLine($"Remove Reason: {row.removeReason}");
                        //Console.WriteLine($"Record Version: {row.recordVersion}");
                        //Console.WriteLine($"AuthorInstitution.InstitutionName: {row.authorInstitution.institutionName}");



                        // Convert dates from UTC to local time
                        //row.creationTimeUTC.ToLocalTime();
                        //row.serviceStopTimeUTC.ToLocalTime();

                        // Document name
                        //row.classCodeDisplayName

                        // Organisation
                        //row.authorInstitution.institutionName

                        // Organisation Type
                        //row.healthcareFacilityTypeCodeDisplayName

                        // Identifiers to retrieve the document
                        //row.repositoryUniqueId
                        //row.documentId
                    }
                }
            }
            catch (FaultException e)
            {
                // Handle any errors
            }
        }
        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
            }
        }
Esempio n. 28
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";

            // Instantiate the client
            // SVT endpoint is "https://b2b.ehealthvendortest.health.gov.au/getDocumentList"
            // production endpoint is "https://services.ehealth.gov.au/getDocumentList"
            GetDocumentListClient documentListClient = new GetDocumentListClient(new Uri("https://GetDocumentListEndpoint"), cert, cert);

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

            // Create a query
            AdhocQueryBuilder adhocQueryBuilder = new AdhocQueryBuilder("patient IHI", new[] { DocumentStatus.Approved });

            // To further filter documents, build on the adhocQueryBuilder helper functions
            // For example, filtering on document type
            // adhocQueryBuilder.ClassCode = new List<ClassCodes>() {ClassCodes.DischargeSummary};
            // See Table 3 XDSDocumentEntry Document Type and Class Code value set from
            // the Document Exchange Service Technical Service Specification

            // Create the request using the query
            AdhocQueryRequest queryRequest = adhocQueryBuilder.BuildRequest();


            try
            {
                // Invoke the service
                AdhocQueryResponse queryResponse = documentListClient.GetDocumentList(header, queryRequest);

                // Process data into a more simple model
                XdsRecord[] data = XdsMetadataHelper.ProcessXdsMetadata(queryResponse.RegistryObjectList.ExtrinsicObject);

                // For displaying the data in a list
                foreach (var row in data)
                {
                    // Convert dates from UTC to local time
                    //row.creationTimeUTC.ToLocalTime();
                    //row.serviceStopTimeUTC.ToLocalTime();

                    // Document name
                    //row.classCodeDisplayName

                    // Organisation
                    //row.authorInstitution.institutionName

                    // Organisation Type
                    //row.healthcareFacilityTypeCodeDisplayName

                    // Identifiers to retrieve the document
                    //row.repositoryUniqueId
                    //row.documentId
                }


                // Get the soap request and response
                string soapRequest  = documentListClient.SoapMessages.SoapRequest;
                string soapResponse = documentListClient.SoapMessages.SoapResponse;
            }
            catch (FaultException e)
            {
                // Handle any errors
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Uploads a document.
        /// </summary>
        /// <param name="documentUploadRequest"></param>
        /// <returns></returns>
        public async Task <DocumentUploadResult> UploadDocument(DocumentUploadRequest documentUploadRequest)
        {
            // Validate the request
            await _documentUploadRequestValidator.ValidateAndThrowAsync(documentUploadRequest);

            Log.Debug("Uploading to endpoint '{endpoint}' with '{certificate}'", _endpoint, _certificate.Subject);

            // Create the client
            var uploadDocumentClient = new UploadDocumentClient(new Uri(_endpoint), _certificate, _certificate);

            DocumentUploadResult documentUploadResult;

            try
            {
                // Create the request
                ProvideAndRegisterDocumentSetRequestType provideAndRegisterDocumentSetRequest;
                if (!string.IsNullOrWhiteSpace(documentUploadRequest.ReplaceDocumentId))
                {
                    // Replace request
                    provideAndRegisterDocumentSetRequest = uploadDocumentClient.CreateRequestForReplacement(
                        documentUploadRequest.DocumentData,
                        documentUploadRequest.FormatCode,
                        documentUploadRequest.FormatCodeName,
                        _facilityType,
                        _practiceSetting,
                        documentUploadRequest.ReplaceDocumentId);
                }
                else
                {
                    // New document request
                    provideAndRegisterDocumentSetRequest = uploadDocumentClient.CreateRequestForNewDocument(
                        documentUploadRequest.DocumentData,
                        documentUploadRequest.FormatCode,
                        documentUploadRequest.FormatCodeName,
                        _facilityType,
                        _practiceSetting);
                }

                if (Log.IsEnabled(LogEventLevel.Verbose))
                {
                    Log.Verbose("Upload request '{requestJson}'", JsonConvert.SerializeObject(provideAndRegisterDocumentSetRequest));
                }

                // Create the PCEHR header
                CommonPcehrHeader commonPcehrHeader = CreateCommonPcehrHeader(provideAndRegisterDocumentSetRequest.SubmitObjectsRequest);

                if (Log.IsEnabled(LogEventLevel.Verbose))
                {
                    Log.Verbose("PCEHR header {header}", JsonConvert.SerializeObject(commonPcehrHeader));
                }

                // Upload the document
                RegistryResponseType registryResponse = uploadDocumentClient.UploadDocument(commonPcehrHeader, provideAndRegisterDocumentSetRequest);

                LogSoapMessages(uploadDocumentClient.SoapMessages);

                if (Log.IsEnabled(LogEventLevel.Verbose))
                {
                    Log.Verbose("Upload response {responseJson}", JsonConvert.SerializeObject(registryResponse));
                }

                // Map the response
                documentUploadResult = DocumentUploadResultMapper.Map(registryResponse);
            }
            catch (Exception e)
            {
                Log.Error(e, "Error uploading document to endpoint '{endpoint}'", _endpoint);

                LogSoapMessages(uploadDocumentClient.SoapMessages);

                throw;
            }
            finally
            {
                uploadDocumentClient.Close();
            }

            return(documentUploadResult);
        }
Esempio n. 30
0
        public void Upload()
        {
            //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;

            // 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://b2b.ehealthvendortest.health.gov.au/uploadDocument"), cert, cert);

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

            byte[] packageBytes = File.ReadAllBytes(@"C:\temp\MyHealthRecordTools\CDAPackager\Output\LastOutputRun\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
            // "Discharge Summary" - 1.2.36.1.2001.1006.1.20000.18
            // "eHealth Dispense Record" - 1.2.36.1.2001.1006.1.171.4
            // "Goals of Care" - 1.2.36.1.2001.1006.1.100001.1
            // "Event Summary" - 1.2.36.1.2001.1006.1.16473.12
            ProvideAndRegisterDocumentSetRequestType request = uploadDocumentClient.CreateRequestForNewDocument(
                packageBytes,
                "1.2.36.1.2001.1006.1.16473.12",
                "Event Summary",
                //You must chooose a valid type below
                HealthcareFacilityTypeCodes.Hospitals,
                PracticeSettingTypes.GeneralHospital
                );

            // 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,
            //   "1.2.36.1.2001.1006.1.220.4",
            //    "Pathology Report",
            //   HealthcareFacilityTypeCodes.Hospitals,
            //   PracticeSettingTypes.GeneralHospital,
            //   "2.25.311256170906902265756795034001543718058" //Document Id of doc to replace
            //   );

            // 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
            }
        }