/// <summary>
        /// Creates and Hydrates an Dispensing Object
        ///
        /// Note: the data used within this method is intended as a guide and should be replaced.
        /// </summary>
        /// <param name="mandatorySectionsOnly">Only show mandatorySectionsOnly fields</param>
        /// <returns>A Hydrated Dispensing Object </returns>
        internal static DispensingInformation CreateDispensingInformation(Boolean mandatorySectionsOnly)
        {
            // The Dispensing Object
            var dispensingInformation = PCEHRPrescriptionRecord.CreateDispensingInformation();

            // Dispensing - Quantity Description - Free text description of the amount which may consist of the quantity and dose unit.
            dispensingInformation.QuantityDescription = "Dispensing Information - Quantity";

            if (!mandatorySectionsOnly)
            {
                // Brand Substitution Permitted - Indicates whether or not the substitution of a prescribed medicine with a different brand name of the same medicine, vaccine or other therapeutic good.
                // which has been determined as bioequivalent, is allowed when the medication is dispensed/supplied
                dispensingInformation.BrandSubstitutionPermitted = true;

                // Dispensing - Quantity Description - Free text description of the amount which may consist of the quantity and dose unit
                dispensingInformation.QuantityDescription = "Dispensing Information - Quantity";

                // Dispensing - Maximum Number Of Repeats - The number of times the expressed quantity of medicine, vaccine or other therapeutic good may be refilled or redispensed without a new prescription
                dispensingInformation.MaximumNumberOfRepeats = 6;

                // Dispensing - Minimum Interval Between Repeats - The minimum time between repeat dispensing of the medicine, vaccine or therapeutic good.
                dispensingInformation.MinimumIntervalBetweenRepeats = BaseCDAModel.CreateInterval("1", TimeUnitOfMeasure.Week);
            }

            return(dispensingInformation);
        }
        /// <summary>
        /// Creates and Hydrates an Prescription Item.
        ///
        /// Note: the data used within this method is intended as a guide and should be replaced.
        /// </summary>
        /// <param name="mandatorySectionsOnly">Only show mandatorySectionsOnly fields</param>
        /// <param name="prescriptionId">Prescription Identifier </param>
        /// <returns>A Hydrated PrescriptionItem </returns>
        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);
        }
        /// <summary>
        /// This method populates an PCEHRPrescriptionRecord model with either the mandatory sections only, or both
        /// the mandatory and optional sections
        /// </summary>
        /// <param name="mandatorySectionsOnly">mandatorySectionsOnly</param>
        /// <returns>PCEHRPrescriptionRecord</returns>
        internal static PCEHRPrescriptionRecord PopulatePrescriptionRecord(Boolean mandatorySectionsOnly)
        {
            var prescriptionRecord = PCEHRPrescriptionRecord.CreatePrescriptionRecord();

            // Set Creation Time
            prescriptionRecord.DocumentCreationTime = new ISO8601DateTime(DateTime.Now);

            // Include Logo
            prescriptionRecord.IncludeLogo = true;
            prescriptionRecord.LogoPath    = OutputFolderPath;

            #region Setup and populate the CDA context model

            // Setup and populate the CDA context model
            var cdaContext = PCEHRPrescriptionRecord.CreateCDAContext();
            // Document Id
            cdaContext.DocumentId = BaseCDAModel.CreateIdentifier(BaseCDAModel.CreateOid(), null);
            // Set Id
            cdaContext.SetId = BaseCDAModel.CreateIdentifier(BaseCDAModel.CreateGuid(), null);
            // CDA Context Version
            cdaContext.Version = "2";

            if (mandatorySectionsOnly)
            {
                // Hide Administrative Observations
                prescriptionRecord.ShowAdministrativeObservationsNarrativeAndTitle = false;

                // Set Parent Document
                cdaContext.ParentDocuments = new List <ParentDocument>
                {
                    CreateParentDocument(ReleatedDocumentType.Transform, null, BaseCDAModel.CreateGuid(), null, null, mandatorySectionsOnly)
                };
            }
            else
            {
                // Set Parent Document
                cdaContext.ParentDocuments = new List <ParentDocument>
                {
                    CreateParentDocument(ReleatedDocumentType.Transform, null, BaseCDAModel.CreateGuid(), null, "1", mandatorySectionsOnly),
                    CreateParentDocument(ReleatedDocumentType.Replace, cdaContext.SetId, BaseCDAModel.CreateGuid(), CDADocumentType.PrescriptionRecord, "1", mandatorySectionsOnly),
                };
            }

            var prescriberOrganisationId = new Guid(BaseCDAModel.CreateGuid());
            var prescriberId             = new Guid(BaseCDAModel.CreateGuid());

            // Custodian
            cdaContext.Custodian = CreateCustodian(mandatorySectionsOnly, prescriberOrganisationId);

            cdaContext.LegalAuthenticator = CreateLegalAuthenticator(mandatorySectionsOnly, prescriberId);

            prescriptionRecord.CDAContext = cdaContext;

            #endregion

            #region Setup and Populate the SCS Context model
            // Setup and Populate the SCS Context model

            prescriptionRecord.SCSContext = PCEHRPrescriptionRecord.CreateSCSContext();

            prescriptionRecord.SCSContext.Prescriber             = CreatePrescriber(mandatorySectionsOnly, prescriberId);
            prescriptionRecord.SCSContext.PrescriberOrganisation = CreatePrescriberOrganisation(mandatorySectionsOnly, prescriberOrganisationId);

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

            #endregion

            #region Setup and populate the SCS Content model
            // Setup and populate the SCS Content model

            // Create SCS Content
            prescriptionRecord.SCSContent = PCEHRPrescriptionRecord.CreateSCSContent();

            // Prescription Item
            prescriptionRecord.SCSContent.PrescriptionItem = CreatePrescriptionItem(mandatorySectionsOnly, BaseCDAModel.CreateGuid());

            #endregion

            return(prescriptionRecord);
        }