Exemplo n.º 1
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
            }
        }
Exemplo n.º 2
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
            }
        }