Skip to main content
ID
DG-3104
Type
Guide
Version
1.0
Status
Active
Created date
Updated date

Reading & Development: 4-6 hours

Quick Intro

This guide will walk through the steps to create and upload clinical documents. The following steps are involved in this process.

  • Create the clinical document (such as Specialist letter, Event Summary, etc)
  • Generate a CDA package which will contain the clinical document
  • Upload the CDA package to the My Health Record system
  • Understand the test cases from the conformance test specifications

At the end of this walkthrough, you'll have a windows form with the series of buttons required to do each step in uploading clinical documents. Within your final product these steps will likely all be done together and (depending on your target sector) it is often recommended to include the generation and upload of a document as part of an existing workflow (i.e. the end of an appointment) as opposed to some separate button or menu option.

upload-document-create-screenshot

Step 1: Prepare prerequisites for UploadDocument

1. Add a new Windows forms called UploadDocuments inside the same project that was created in the previous guides.

2. Right click on the newly created UploadDocuments, click view code and add the following namespaces and code.

using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using Nehta.VendorLibrary.PCEHR;
using System.ServiceModel;
using Nehta.VendorLibrary.PCEHR.DocumentRepository;

3. Add the following in the class to load your certificate and header information from your helper class.

// Obtain the certificate for use with TLS and signing
X509Certificate2 cert = PCEHRHelper.GetCertificate();

// Create PCEHR header
CommonPcehrHeader header = PCEHRHelper.CreateHeader();
upload-document-namespace-screenshot

4. Open the Visual Studio Package Manager Console and copy the following command. Hit enter to install the required libraries. 

Install-Package Nehta.VendorLibrary.CDA.Generator.v3
upload-document-package-manager-console-screenshot

Once installed successfully, check the project references to ensure that Nehta.VendorLibrary.CDA.Generator.v3 is installed correctly.

upload-document-nehta-vendor-library-cda-generator-screenshot

Step 2: Generating a Specialist Letter

The first step of uploading a clinical document is to generate the clinical document. In this section we look into sample code available on GitHub to generate a Specialist Letter.

1. Add a new class called SpecialistLetterSample.cs into the project. 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

// namespace can be different based on project structure.
namespace ADHA.MyHR.ClinicalDocuments
{
    public class SpecialistLetterSample
    {
    }
}

2. Copy the sample code from Specialist Letter Sample GitHub link and paste it into the class. Make sure the namespace of your class is not changed as it is different in the sample code. Add the additional namespace which is not in the sample code.

using Nehta.VendorLibrary.CDA;

3. Create a new class called GenericObjectReuseSample and copy the code from this GitHub Link, and paste it into the class. Make sure the namespace of your class is not changed as it is different in the sample code. Check that the following namespaces have been added correctly.

using Nehta.VendorLibrary.CDA;
using Nehta.VendorLibrary.CDA.Common;
using Nehta.VendorLibrary.CDA.Common.Enums;
using Nehta.VendorLibrary.CDA.Generator.Enums;
using Nehta.VendorLibrary.CDA.SCSModel;
using Nehta.VendorLibrary.CDA.SCSModel.Common;
using Nehta.VendorLibrary.CDA.SCSModel.Common.Entities;
using Nehta.VendorLibrary.CDA.SCSModel.DischargeSummary;
using Nehta.VendorLibrary.Common;
using PathologyTestResult = Nehta.VendorLibrary.CDA.SCSModel.Common.PathologyTestResult;

4. Ensure the project can compile by checking the library packages installed and missing namespaces.

5. Add a button on the UploadDocuments form to generate the Specialist Letter as shown in the screenshot.

upload-document-clinical-document-create-screenshot

6. Double click on the Create Specialist Letter Sample button and add the following code on button click event.

private void btnGenerateSpecialistLetter_Click(object sender, EventArgs e)
{
    var specialistLetterSampleCode = new SpecialistLetterSample();
    SpecialistLetterSample.OutputFolderPath = @"C:\adha\cda\upload";
    var maxSpecialistLetterCda = specialistLetterSampleCode.MaxPopulatedSpecialistLetterSample("SpecialistLetter_3A_Max.xml");
}

The SpecialistLetterSample class contains sample methods to generate a Specialist Letter filled with sample data, however, there is some information that needs to be replaced such as organisation, provider, and the health recipient’s IHI. For this example we will use the provided sample data. In your final product the patient context will be obvious based on the existing search, UI and workflow.

Step 3: Replace the required data for Specialist Letter

Inside the MaxPopulatedSpecialistLetterSample method, open the method PopulateSpecialistLetter. This method uses the GenericObjectReuseSample class to populate custodian, authenticator, author and subject of care. We will replace each of these values. The document upload will return an error if there is a mismatch between identifiers.

There are three sets of data values which need to be replaced inside the PopulateSpecialistLetter method. First is the CDA Context model, and the second and third are the SCS Context and Content model. Use test data provided by Services Australia for testing.

CDA Context model

1. Update HydrateCustodian to load the HPI-O of the organisation using your software.

upload-document-hydrate-custodian-screenshot

2. Update HydrateAuthenticator to load the HPI-I and HPI-O of the document uploader.

upload-document-health-identifier-type-hpii-screenshot
upload-document-health-identifier-type-hpio-screenshot

SCS Context Model

1. Update the HydrateAuthor method as follows.

upload-document-scs-context-model-hpii-screenshot
upload-document-scs-context-model-hpio-screenshot

2. Update the HydrateSubjectOfCare method as follows.

upload-document-hydrate-subject-care-screenshot

SCS Content model

This is the actual clinical information which would likely be entered by the healthcare provider which your system could then prepopulate into the Clinical Document. In the sample code, the CDA Content model is already populated with some sample data, and we can use that data to generate your first Specialist Letter.

Inside the PopulateSpecialistLetter method you will find the method calls which load the clinical information. To change the content you will navigate into the methods and load clinical content from your local data model.

For example, the following code changes AdverseReactions data by hardcoding a different SNOMED-CT AU Adverse Reaction. Your product would obviously not be hardcoding specific entries. 

#region Setup and populate the SCS Content model

specialistLetter.SCSContent = SpecialistLetter.CreateSCSContent();

// Response details
specialistLetter.SCSContent.ResponseDetails = CreateResponseDetails(mandatorySectionsOnly);

// Recommendations
specialistLetter.SCSContent.Recommendations = CreateRecommendations(mandatorySectionsOnly);

// Medications
specialistLetter.SCSContent.Medications = CreateMedications(mandatorySectionsOnly);

if (!mandatorySectionsOnly)
{
    // Adverse reactions
    specialistLetter.SCSContent.AdverseReactions = CreateAdverseReactions();

    // Diagnostic Investigations
    specialistLetter.SCSContent.DiagnosticInvestigations = CreateDiagnosticInvestigations(mandatorySectionsOnly);
}

#endregion
private static IAdverseReactionsWithoutExclusions CreateAdverseReactions()
{
    var reactions = SpecialistLetter.CreateAdverseReactionsWithoutExclusions();

    reactions.AdverseSubstanceReaction = new List<Reaction>
    {
        CreateAdverseReaction(BaseCDAModel.CreateCodableText("86461001", CodingSystem.SNOMED, "Plant diterpene")),
        CreateAdverseReaction(BaseCDAModel.CreateCodableText("117491007", CodingSystem.SNOMED, "trans-Nonachlor"))
    };
    return reactions;
}

Once the correct values are replaced, we can create a CDA package from the CDA document (XML file). First let’s create the Specialist Letter clinical document before going to next step.

3. Run the application and click Create Specialist Letter Sample on the UploadDocuments form and it should create the clinical document in the provided local path.

upload-document-create-specialist-letter-screenshot

4. If IncludeLogo is set to true, your logo must be present inside the OutputFolderPath as per the code below.

upload-document-include-logo-screenshot

Step 4: Create a CDA package from a clinical document

The next step is to create the CDA Package from the Clinical Document generated in the previous steps.

1. Install the CDAPackage library by running the following command in the Package Manager console. 

Install-Package Nehta.VendorLibrary.CDAPackage 
upload-document-package-manager-console-install-screenshot

Once the library is installed successfully, add the following namespace in the UploadDocuments form class. 

using Nehta.VendorLibrary.CDAPackage;

2. Add a new button labelled Create CDA Package.

upload-document-create-cda-package-screenshot

3. Double click on the Create CDA Package button and add the following code on the button click event. Make the following changes;

a) Replace the  values for the approver, this may be the document author. The PersonId can be namespace-qualified HPI-I or local identifier.
b) Uncomment the image attachment code to include attachments.

private void btnCreateCDAPack_Click(object sender, EventArgs e)
{
    // ------------------------------------------------------------------------------
    // Create CDAPackage
    // ------------------------------------------------------------------------------

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

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

    // Create the CDA root document for the CDA package
    package.CreateRootDocument(File.ReadAllBytes(@"C:\adha\cda\upload\SpecialistLetter_3A_Max.xml"));

    // Add an image attachment
    //package.AddDocumentAttachment(
    //    "ImageAttachment1.jpg",
    //    File.ReadAllBytes(@"C:\adha\cda\upload\ImageAttachment1.jpg")
    //    );

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

    // Create the CDA package zip
    CDAPackageUtility.CreateZip(package, @"C:\adha\cda\upload\CdaPackageOutputFilePath.zip", cert);
}

4. Run the application and create the CDA package.

upload-document-extract-screenshot

Step 5: Upload a clinical document

1. Add a new button labelled Upload Document on the UploadDocumentsForm as shown in the screenshot below.

upload-document-form-screenshot

2. Double click on the Upload Document button and add the following code on the button click event. 

private void btnUploadDocument_Click(object sender, EventArgs e)
{

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

    // Create the client
    UploadDocumentClient uploadDocumentClient = new UploadDocumentClient(
        new Uri("https://services.svt.gw.myhealthrecord.gov.au/uploadDocument"), cert, cert);

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

    byte[] packageBytes = File.ReadAllBytes(@"C:\adha\cda\upload\CdaPackageOutputFilePath.zip"); 

    // For example (formateCodeName - formatCode):
    // Specialist Letter 3A 1.2.36.1.2001.1006.1.16615.31
    ProvideAndRegisterDocumentSetRequestType request = uploadDocumentClient.CreateRequestForNewDocument(
        packageBytes,
        "formatCode",
        "formatCodeName",
        HealthcareFacilityTypeCodes.GeneralPractice,                // Update to relevant code
        PracticeSettingTypes.GeneralPracticeMedicalClinicService    // Update to relevant code
        );

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

3. Replace the IHI in the header. This must match with the subject of care given in the previous step.

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

4. Provide the file path of CDA Package created in the previous step.

byte[] packageBytes = File.ReadAllBytes(@"C:\adha\cda\upload\CdaPackageOutputFilePath.zip");

5. Replace the formatCode and formatCodeName as per the clinical document. For example, formatCode for Specialist Letter 3A is “1.2.36.1.2001.1006.1.16615.31”.

6. Run the application and click the Upload Document button. The UploadDocument web service returns the following SOAP response if the document is uploaded successfully. Note that we have removed the contents of <soap:Header> for readability.

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header></soap:Header><soap:Body xml:id="Id-0001591841018735-ffffffff940adb55-1"><rs:RegistryResponse status="urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success" xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:rs="urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0"/></soap:Body></soap:Envelope

Step 6: Event Summary prerequisites

In this section, we develop code to generate an Event Summary sample from the sample code available on the Agency’s GitHub. We will not repeat 1) creating the CDA Package from the Clinical Document and 2) uploading the Clinical Document, as they are the same as Step 4 and Step 5 above.

1. Create a new class called EventSummarySample in our existing project and copy the code from the GitHub Link into this new class. Please be mindful of the namespace of your class, do not replace from the sample code.

Ensure the following namespaces are added correctly.

using System.Xml;
using Nehta.VendorLibrary.CDA;
using Nehta.VendorLibrary.CDA.Generator.Enums;
using Nehta.VendorLibrary.CDA.SCSModel.Common.Entities;
using Nehta.VendorLibrary.Common;
using Nehta.VendorLibrary.CDA.Generator;
using Nehta.VendorLibrary.CDA.Common.Enums;
using Nehta.VendorLibrary.CDA.Common;
using Nehta.VendorLibrary.CDA.SCSModel;
using Nehta.VendorLibrary.CDA.SCSModel.Common;

2. Add a new button Create Event Summary Sample on the UploadDocuments form.

upload-document-create-event-summary-sample-screenshot

3. Double click on Create Event Summary Sample button and add the following code on click event.

private void btnCreateEventSummary_Click(object sender, EventArgs e)
{
    var eEventSummarySampleCode = new EventSummarySample();
    EventSummarySample.OutputFolderPath = @"C:\adha\cda\upload";
    var maxEventSummaryCda = eEventSummarySampleCode.MaxPopulatedEventSummary("EventSummary_3A_Max.xml");
}

Step 7: Replace data for an Event Summary

In the next steps we will use the EventSummarySample class. We will be updating data for the provider organisation and certificates.

1. Open the MaxPopulatedEventSummary method. The code below creates the Event Summary sample and generates the XML document on your local file system.

There are two parts of the data in the Event Summary, first is the SCS Context model and second is Content model. 

public XmlDocument MinPopulatedEventSummary(string fileName)
{
    XmlDocument xmlDoc;

    var eEventSummary = PopulatedEventSummary(true);

    try
    {
        CDAGenerator.NarrativeGenerator = new CDANarrativeGenerator();

        //Pass the Event Summary model into the GenerateEventSummary method 
        xmlDoc = CDAGenerator.GenerateEventSummary(eEventSummary);

        using (var writer = XmlWriter.Create(OutputFolderPath + @"\" + fileName, new XmlWriterSettings { Indent = true }))
        {
            if (!fileName.IsNullOrEmptyWhitespace()) xmlDoc.Save(writer);
        }
    }
    catch (ValidationException ex)
    {
        //Catch any validation exceptions
        var validationMessages = ex.GetMessagesString();

        //Handle any validation errors as appropriate.
        throw;
    }

    return xmlDoc;
}

2. Navigate to the PopulatedEventSummary(false) method, replace the custodian, authenticator, author and subject of care values as per your data. In the Specialist Letter sample from previous steps, we have already replaced all SCS context values because it is using the same GenericObjectReuseSample class (excluding the author) and it uses the HydrateAuthorV2 method instead of HydrateAuthor.

// Custodian
cdaContext.Custodian = BaseCDAModel.CreateCustodian();
GenericObjectReuseSample.HydrateCustodian(cdaContext.Custodian, mandatorySectionsOnly);

cdaContext.LegalAuthenticator = BaseCDAModel.CreateLegalAuthenticator();
GenericObjectReuseSample.HydrateAuthenticator(cdaContext.LegalAuthenticator, mandatorySectionsOnly);

// Setup and Populate the SCS Context model
eventSummary.SCSContext.Author = BaseCDAModel.CreateAuthor();
GenericObjectReuseSample.HydrateAuthorV2(eventSummary.SCSContext.Author, mandatorySectionsOnly);

eventSummary.SCSContext.SubjectOfCare = BaseCDAModel.CreateSubjectOfCare();
GenericObjectReuseSample.HydrateSubjectofCare(eventSummary.SCSContext.SubjectOfCare, mandatorySectionsOnly, false);

3. Navigate to the GenericObjectReuseSample.HydrateAuthorV2 method and replace the author HPI-I value and HPI-O value:

upload-document-generic-object-reuse-sample-screenshot
upload-document-generic-object-reuse-sample-2-screenshot

4. Next replace the content model values. In your real software the healthcare provider would enter most of this data locally and your system would store it in your local data storage. We will be using the Event Summary sample class data already contained in the following objects.

#region Setup and populate the SCS Content model
// Setup and populate the SCS Content model
eventSummary.SCSContent = EventSummary.CreateSCSContent();

if (!mandatorySectionsOnly)
{
    eventSummary.SCSContent.EventDetails = CreateEventDetails();

    // Adverse reactions
    eventSummary.SCSContent.AdverseReactions = CreateAdverseReactions();

    // Medications
    eventSummary.SCSContent.Medications = CreateMedications();

    // Medical history
    eventSummary.SCSContent.DiagnosesIntervention = CreateDiagnosesIntervention(mandatorySectionsOnly);

    // Immunisations
    eventSummary.SCSContent.Immunisations = CreateImmunisations();

    // Diagnostic Investigations
    eventSummary.SCSContent.DiagnosticInvestigations = CreateDiagnosticInvestigations(mandatorySectionsOnly);
}

#endregion

You can navigate to each method and modify the data as required. For example, to modify Medications and enter a hard-coded value, go to

// Medications
eventSummary.SCSContent.Medications = CreateMedications();
private static List<IMedicationItem> CreateMedications()
{
    var medicationList = new List<IMedicationItem>
    {
        CreateMedication("79115011000036100", "paracetamol 500 mg + codeine phosphate hemihydrate 30 mg tablet"),
        CreateMedication("45260011000036108", "dextropropoxyphene hydrochloride 32.5 mg + paracetamol 325 mg tablet")
    };

    return medicationList;
}

5. Run the application and create an Event Summary CDA Package by clicking the Create Event Summary button.

upload-document-create-event-summary-screenshot

6. As per the previous Specialist Letter example, the Logo file must be present in the specified directory if Event Summary IncludeLogo is true as shown in the screenshot.

upload-document-event-summary-include-logo-screenshot

 

Step 8: Create and upload a CDA Package

This step uses almost identical code that we have used to create the CDA Package and upload the Specialist Letter. We will replace the Specialist Letter with the Event Summary sample document.

1. Double click on the Create CDA Package button and modify the code as below.

a.  Replace the correct value of the HPI-I in values for the approver, this may beis the document author. The PersonId can be namespace-qualified HPI-I or local identifier.

b.  Replace the Specialist Letter XML file with the Event Summary XML document created in the previous step. 

private void btnCreateCDAPack_Click(object sender, EventArgs e)
{
    // ------------------------------------------------------------------------------
    // Create CDAPackage
    // ------------------------------------------------------------------------------

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

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

    // Create the CDA root document for the CDA package
    package.CreateRootDocument(File.ReadAllBytes(@"C:\adha\cda\upload\EventSummary_3A_Max.xml"));

    // Add an image attachment
    //package.AddDocumentAttachment(
    //    "ImageAttachment1.jpg",
    //    File.ReadAllBytes(@"C:\adha\cda\upload\ImageAttachment1.jpg")
    //    );

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

    // Create the CDA package zip
    CDAPackageUtility.CreateZip(package, @"C:\adha\cda\upload\CdaPackageOutputFilePath.zip", cert);
}

2. Run the application and create the CDA Package from the Event Summary Sample document.

upload-document-run-the-application-screenshot

3. Double click on the Upload Document button on the UploadDocuments form and replace the values based on the Event Summary sample document.

a.  The IHI in the header must match the subject of care in previous steps.
b.  Replace the correct formatCode and formatCodeName i.e. Event Summary Report 3A - 1.2.36.1.2001.1006.1.16473.14 

private void btnUploadDocument_Click(object sender, EventArgs e)
        {

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

            // Create the client
            UploadDocumentClient uploadDocumentClient = new UploadDocumentClient(
                new Uri("https://services.svt.gw.myhealthrecord.gov.au/uploadDocument"), cert, cert);

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

            byte[] packageBytes = File.ReadAllBytes(@"C:\adha\cda\upload\CdaPackageOutputFilePath.zip"); // Create a package

            // 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
            // Event Summary Report 3A - 1.2.36.1.2001.1006.1.16473.14
            ProvideAndRegisterDocumentSetRequestType request = uploadDocumentClient.CreateRequestForNewDocument(
                packageBytes,
                "formatCode",
                "formatCodeName",
                HealthcareFacilityTypeCodes.GeneralPractice,                // Update to relevant code
                PracticeSettingTypes.GeneralPracticeMedicalClinicService    // Update to relevant code
                );

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

4. Run the application and click Upload Document. If the document is uploaded successfully, it will return the SOAP response as shown in the screenshot below. 

upload-document-soap-response-screenshot

Step 9: Prescription Record prerequisites

The Prescription Record Clinical Document is similar to the Specialist Letter and Event Summary that we have already created. We will look into sample code available on GitHub to create the Prescription Record sample in the same project.

1. Create a new class called PrescriptionRecordSample.cs in the existing project.

namespace ADHA.MyHR.ClinicalDocuments
{
    public class PrescriptionRecordSample
    {

    }

}

2. Copy the code from the GitHub Link and paste it into your newly created class. Be mindful of replacing your class namespace.

3. Add the additional following namespace which is not included in the sample code.

using Nehta.VendorLibrary.CDA;

4. PrescriptionRecordSample class should compile now and ready to be used.

upload-document-prescription-record-sample-screenshot

5. Add a new button labelled Create Prescription Record on the UploadDocumentsForm.

upload-document-create-prescription-record-screenshot

6. Double click on the Create Prescription Record button and add the following code on the button click event. This code creates a Prescription Record which is heavily populated.

private void btnCreatePrescription_Click(object sender, EventArgs e)
{
    var prescriptionRecord = new PrescriptionRecordSample();
    PrescriptionRecordSample.OutputFolderPath = @"C:\adha\cda\upload";
    var maxPrescriptionRecord = prescriptionRecord.MaxPopulatedPrescriptionRecordSample("PCEHRPrescriptionRecord_3A_Max.xml");
}

7. Inside the MaxPopulatedPrescriptionRecordSample method, navigate to the PopulatePrescriptionRecord method and replace organization and installed certificates along with the following values as we have done for the previous Clinical Documents.

a.  Custodian 
b.  Legal Authenticator 
c.  Prescriber 
d.  Prescriber Organisation
e.  Subject of Care

8. Sample prescription data (the SCS Content model) is provided and can be replaced using values from your local system’s data. 

internal static IPCEHRPrescriptionItem CreatePrescriptionItem(Boolean mandatorySectionsOnly, string prescriptionId)
{
    var prescriptionItem = PCEHRPrescriptionRecord.CreatePrescriptionItem();

    // The Dispensing Information Object
    prescriptionItem.DispensingInformation = CreateDispensingInformation(mandatorySectionsOnly);

    // Prescription Item Identifier - A globally unique object identifier for each instance of a Medication Instruction
    prescriptionItem.PrescriptionItemIdentifier = BaseCDAModel.CreateIdentifier("1.2.36.1.2001.1005.36", BaseCDAModel.CreateGuid());

    if (!mandatorySectionsOnly)
    {
        // Therapeutic Good Identification - The medicine, vaccine or other therapeutic good being ordered, administered to or used by the subject of care
        prescriptionItem.TherapeuticGoodId = BaseCDAModel.CreateCodableText("01158Y", CodingSystem.PBSCode, "cimetidine 400 mg tablet, 60", null, null);

        // Therapeutic Good Strength (Additional Therapeutic Good Detail) - Information concerning the strength of the Therapeutic Good
        prescriptionItem.TherapeuticGoodStrength = "Therapeutic Good Strength";

        // Therapeutic Good Generic Name (Additional Therapeutic Good Detail) - The generic name of the Therapeutic Good
        prescriptionItem.TherapeuticGoodGenericName = "Therapeutic Good Generic Name";

        // Directions - A complete narrative description of how much, when and how to use the medicine, vaccine or other therapeutic good
        prescriptionItem.Directions = "Directions";

        // Formula - The recipe for compounding a medicine
        prescriptionItem.Formula = "Formula";

        // Form - The formulation or presentation of the overall substance
        prescriptionItem.Form = BaseCDAModel.CreateCodableText("385057009", CodingSystem.SNOMED, "Film-coated tablet", null, null);

        // ClinicalIndication - A reason for ordering the medicine, vaccine or other therapeutic good 
        prescriptionItem.ClinicalIndication = "Clinical Indication";

        // Route - The route by which the medication is administered
        prescriptionItem.Route = BaseCDAModel.CreateCodableText("26643006", CodingSystem.SNOMED, "Oral route", null, null);

        // Comment - Any additional information that may be needed to ensure the continuity of supply, rationale for current dose and timing, or safe and appropriate use
        prescriptionItem.Comment = "Comment";

        // DateTime Prescription Expires
        prescriptionItem.DateTimePrescriptionExpires = new ISO8601DateTime(DateTime.Now.AddMonths(12));

        // PBS Manufacturer Code (Administrative Manufacturer Code) - Administrative code of the manufacturer of the pharmaceutical item supplied
        prescriptionItem.PBSManufacturerCode = BaseCDAModel.CreateExternalConceptIdentifier(ExternalConcepts.AustralianPBSManufacturerCode, "AB");
    }
    else
    {
        // Therapeutic Good Identification - The medicine, vaccine or other therapeutic good being ordered, administered to or used by the subject of care
        prescriptionItem.TherapeuticGoodId = BaseCDAModel.CreateCodableText("28237011000036107", CodingSystem.AMTV3, "amoxycillin 500 mg capsule, 20", null, null);
    }
    return prescriptionItem;
}

9. Run the application and create sample prescription record.

upload-document-create-sample-prescription-record-screenshot

10. Create the CDA Package and Upload the Prescription Record. The steps to create the CDA Package from a Clinical Document and upload it have already been demonstrated in Step 4 and Step 5.

Step 10: Advance Care Planning Document prerequisites

This section is also very similar to other Clinical Documents created in previous steps and will use the sample code available on GitHub.

1. Create a class called AdvanceCareInformationSample in your project. 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ADHA.MyHR.ClinicalDocuments
{
    class AdvanceCareInformationSample
    {
    }
}

2. Copy the code from the sample available on ADHA GitHub and paste into your newly created class. Be mindful of not replacing your class namespace.

upload-document-sample-code-github-screenshot

3. Add a new class called GenericObjectReuseSample inside the project.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ADHA.MyHR.CDA
{
    class GenericObjectReuseSample
    {
    }
}

4. Copy the code from the sample available on GitHub and paste into the GenericObjectReuseSample class. Be mindful of not replacing the namespace of your project in the class.

upload-document-github-generic-object-reuse-sample-screenshot

5. Double click on the Create Advance Care Planning button and add the following code on the button click event.

upload-document-create-advance-care-planning-screenshot
private void btnCreateAdvanceCarePlanning_Click(object sender, EventArgs e)
{
    // Advance Care Information Documents
    var advanceCareInformationSample = new AdvanceCareInformationSample();
    AdvanceCareInformationSample.OutputFolderPath = @"C:\adha\cda\upload";
    var minAdvanceCarePlanningAuthorHealthcareProviderSampleCda = advanceCareInformationSample.MinPopulatedAdvanceCareInformation("AdvanceCarePlanningSampleAuthorHealthcareProvider_3A_Min.xml", Nehta.VendorLibrary.CDA.Common.Enums.AuthorType.AuthorHealthcareProvider, Nehta.VendorLibrary.CDA.Common.Enums.DocumentType.AdvanceCareInformationAdvanceCarePlanning);
    //var maxAdvanceCarePlanningAuthorHealthcareProviderSampleCda = advanceCareInformationSample.MaxPopulatedAdvanceCareInformation("AdvanceCarePlanningSampleAuthorHealthcareProvider_3A_Max.xml", Nehta.VendorLibrary.CDA.Common.Enums.AuthorType.AuthorHealthcareProvider, Nehta.VendorLibrary.CDA.Common.Enums.DocumentType.AdvanceCareInformationAdvanceCarePlanning);
}

6. Replace the custodian, legalAuthenticator, author, and subjectOfCare values as per your data.

7. Once the values are replaced correctly you can create the CDA Package out of the Advance Care Planning Clinical Document and upload it to the patient’s My Health Record as per Step 4 and Step 5.

Step 11: Use Case 201 (UC.CIS.201)

Test Case IDPCEHR_CIS_019042
ObjectiveThe clinical information system shall provide an ability to support the withdrawal of the healthcare recipient's consent to upload clinical documents to the PCEHR System and shall prevent them from being uploaded where the consent has been withdrawn.
How to evaluate

Withdraw consent either before or after creating a clinical document for a healthcare recipient:

a. Verify the software provides the ability to withdraw consent to upload the document to the PCEHR System.

b. Verify that the document is not uploaded to the PCEHR system.

This test case explains that CIS software shall have the capability for the user to withdraw consent from uploading a Clinical Document. CIS software shall not upload a Clinical Document if the healthcare recipient advises the healthcare provider (your user) that they do not wish for it to be uploaded.

The screenshot below provides an example of a UI element to stop an upload from occurring while not negatively impacting the clinical workflow.

MHR Upload Document Patient Consent
Test Case IDPCEHR_CIS_019042a
ObjectiveThe Clinical Information System shall provide a mechanism to identify which clinical documents have been uploaded to the PCEHR System.
How to evaluate

Create a clinical document for a healthcare recipient using the software, and upload the clinical document to the PCEHR System:

a. Verify that the software has a mechanism to record that a document has been uploaded to the PCEHR.

This test case explains that every time a Clinical Document is uploaded, your software shall record this transaction. The following code provides a very simplified mechanism for you to invoke your software logging mechanism when the web service returns the success message.

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

     
    if(registryResponse.status.Contains("Success"))
    {
        // Add document into upload history.

    }

}
catch (FaultException fex)
{
    // Handle any errors
}

Sample screenshot demonstrating the clinical document upload history. You will want to capture much more detail about this transaction to assist users and your support team in troubleshooting issues. 

upload-document-history-screenshot
Test Case IDPCEHR_CIS_017841a
ObjectiveThe Clinical Information System shall either:
• Retain any clinical document uploaded to the PCEHR System; or
• Retain the original clinical information used to generate the clinical document uploaded to the PCEHR;
to meet requirements for relevant health records legislation, audit and business requirements.
How to evaluate

Create a clinical document for a healthcare recipient using the software, and upload the clinical document to the PCEHR System:

Verify that the software system fulfils either criteria a or b:

a. Retains the clinical information used to create the clinical documents locally.

b. Retains a copy of the clinical document that was uploaded

This test case requires that when a Clinical Document is successfully uploaded, it shall store either a copy of the Clinical Document or retain the clinical information to produce the document again.

This test case can be met easily by storing a copy of the Clinical Document or CDA Package on the file system or you can undertake a more advanced method of tracking which data was included within your database.

Conclusion

In this guide we have implemented the uploadDocument web service. The next guide will continue from this point and explore more functionality of the My Health Record system. Specifically you will learn how to supersede a Clinical Document and how to remove a Clinical Document, which are both requirements of uploading.

If you have any feedback about this guide, please contact us at [email protected]

 

View All | Back | Next: Supersede document - My Health Record B2B Developer Guide 6