/// <summary> /// Upload a document to the PCEHR. /// </summary> /// <param name="pcehrHeader">PCEHR header.</param> /// <param name="request">Document and metadata.</param> /// <returns>Response.</returns> public RegistryResponseType UploadDocument(CommonPcehrHeader pcehrHeader, ProvideAndRegisterDocumentSetRequestType request) { // PCEHRHeaderValidator.Validate(pcehrHeader); var header = pcehrHeader.GetHeader <PCEHRHeader>(); Validation.ValidateArgumentRequired("request", request); return(client.UploadDocument(header, request)); }
/// <summary> /// Creates a provide and register request. /// </summary> /// <param name="registryRequest">The registry request.</param> /// <param name="document">The document.</param> /// <returns>Returns the created provide and registry document set request type.</returns> public static ProvideAndRegisterDocumentSetRequestType CreateProvideAndRegisterRequest(SubmitObjectsRequest registryRequest, params ProvideAndRegisterDocumentSetRequestTypeDocument[] document) { var retVal = new ProvideAndRegisterDocumentSetRequestType { SubmitObjectsRequest = registryRequest, Document = document }; return(retVal); }
/// <summary> /// Upload a document. /// </summary> /// <param name="header">PCEHR header.</param> /// <param name="request">Request.</param> /// <returns>Response.</returns> internal RegistryResponseType UploadDocument(PCEHRHeader header, ProvideAndRegisterDocumentSetRequestType request) { var timestamp = new timestampType() { created = DateTime.Now }; var signatureContainer = new signatureContainerType(); return(repositoryClient.DocumentRepository_ProvideAndRegisterDocumentSetb(timestamp, ref signatureContainer, header, request)); }
/// <summary> /// Helper method to include Repository Unique ID, payload hash and payload size information in the XDS metadata. /// The Repository Unique ID must be specified, but the payload hash and payload size information is derived from the request object. /// This method must be invoked with a request created from CreateRequestForNewDocument or CreateRequestForReplacement. /// </summary> /// <param name="request">The request object.</param> /// <param name="repositoryId">The unique repository ID.</param> public void AddRepositoryIdAndCalculateHashAndSize(ProvideAndRegisterDocumentSetRequestType request, string repositoryId) { try { var size = request.Document[0].Value.Length; var hash = UploadDocumentMetadataClient.CalculateSHA1(request.Document[0].Value); var extrinsicObject = request.SubmitObjectsRequest.RegistryObjectList.ExtrinsicObject[0]; var slotList = extrinsicObject.Slot.ToList(); slotList.Add(new SlotType1() { name = "hash", ValueList = new ValueListType() { Value = new string[] { hash } } }); slotList.Add(new SlotType1() { name = "size", ValueList = new ValueListType() { Value = new string[] { size.ToString() } } }); slotList.Add(new SlotType1() { name = "repositoryUniqueId", ValueList = new ValueListType() { Value = new string[] { repositoryId } } }); extrinsicObject.Slot = slotList.ToArray(); } catch (Exception ex) { throw new ArgumentException("Error with request object. This method must be invoked with a ProvideAndRegisterDocumentSetRequestType object created using " + "CreateRequestForNewDocument or CreateRequestForReplacement."); } }
/// <summary> /// Helper method to generate the request object. /// </summary> /// <param name="cdaPackageContent">Byte content of the CDA package.</param> /// <param name="formatCode">Format code.</param> /// <param name="formatCodeName">Format code name.</param> /// <param name="healthcareFacilityTypeCode">Healthcare facility type code.</param> /// <param name="practiceSetting">Practice setting code.</param> /// <param name="uuidOfDocumentToReplace">UUID of document to replace. NULL for new documents.</param> /// <returns>The populated request object.</returns> internal ProvideAndRegisterDocumentSetRequestType CreateRequest( byte[] cdaPackageContent, string formatCode, string formatCodeName, HealthcareFacilityTypeCodes healthcareFacilityTypeCode, PracticeSettingTypes practiceSetting, string uuidOfDocumentToReplace) { Validation.ValidateArgumentRequired("cdaPackageContent", cdaPackageContent); Validation.ValidateArgumentRequired("formatCode", formatCodeName); Validation.ValidateArgumentRequired("formatCodeName", formatCodeName); var cdaFile = GetCdaDocument(cdaPackageContent); var cdaDoc = new XmlDocument(); cdaDoc.Load(new MemoryStream(cdaFile)); var metadata = new XdsMetadata( cdaDoc, null, formatCode, formatCodeName, healthcareFacilityTypeCode, practiceSetting, null, null, false, uuidOfDocumentToReplace ); var sor = metadata.CreateSubmitObjectsRequest(); var request = new ProvideAndRegisterDocumentSetRequestType(); request.Document = new ProvideAndRegisterDocumentSetRequestTypeDocument[] { new ProvideAndRegisterDocumentSetRequestTypeDocument() { id = "DOCUMENT_SYMBOLICID_01", Value = cdaPackageContent } }; request.SubmitObjectsRequest = sor; return(request); }
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 } }
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 } }