private static IParticipationAcdCustodian CreateAcdCustodianOrganisation(string name, string department, string id,
                                                                                 string addressLine, string phone, bool mandatoryOnly)
        {
            var custodianParticipation = AcdCustodianRecord.CreateParticipationAcdCustodian();

            custodianParticipation.ParticipationPeriod = BaseCDAModel.CreateInterval(
                new ISO8601DateTime(DateTime.Now.AddDays(-50)),
                new ISO8601DateTime(DateTime.Now));

            custodianParticipation.Role        = BaseCDAModel.CreateRole(Occupation.GeneralMedicalPractitioner);
            custodianParticipation.Participant = AcdCustodianRecord.CreateAcdCustodian();

            IOrganisation organisation = BaseCDAModel.CreateOrganisation();

            organisation.Name        = name;
            organisation.Identifiers = new List <Identifier> {
                BaseCDAModel.CreateHealthIdentifier(HealthIdentifierType.HPIO, id)
            };

            custodianParticipation.Participant.Organisation = organisation;

            if (!mandatoryOnly)
            {
                organisation.Department = department;
                organisation.NameUsage  = OrganisationNameUsage.EnterpriseName;

                // Address
                IAddressAustralian address1 = BaseCDAModel.CreateAddress();
                address1.AddressPurpose    = AddressPurpose.Residential;
                address1.AustralianAddress = BaseCDAModel.CreateAustralianAddress();
                address1.AustralianAddress.UnstructuredAddressLines = new List <string> {
                    addressLine
                };
                address1.AustralianAddress.SuburbTownLocality = "Nehtaville";
                address1.AustralianAddress.State             = AustralianState.QLD;
                address1.AustralianAddress.PostCode          = "5555";
                address1.AustralianAddress.DeliveryPointId   = 32568931;
                custodianParticipation.Participant.Addresses = new List <IAddressAustralian> {
                    address1
                };

                // Communication
                var electronicCommunicationDetail = BaseCDAModel.CreateElectronicCommunicationDetail
                                                    (
                    phone,
                    ElectronicCommunicationMedium.Telephone,
                    ElectronicCommunicationUsage.WorkPlace
                                                    );
                custodianParticipation.Participant.ElectronicCommunicationDetails = new List <ElectronicCommunicationDetail> {
                    electronicCommunicationDetail
                };
            }

            return(custodianParticipation);
        }
        /// <summary>
        /// Creates a patient nominated contact.
        /// </summary>
        /// <param name="givenName">Given name</param>
        /// <param name="familyName">Family name</param>
        /// <param name="hpii">Hpii</param>
        /// <param name="addressLine">Address line</param>
        /// <param name="phone">Phone</param>
        /// <param name="mandatoryOnly">Show mandatory objects</param>
        /// <returns>IParticipationAcdCustodian</returns>
        private static IParticipationAcdCustodian CreateAcdCustodianPerson(
            string givenName, string familyName, string hpii, string addressLine, string phone, bool mandatoryOnly)
        {
            IParticipationAcdCustodian paticipation = AcdCustodianRecord.CreateParticipationAcdCustodian();

            paticipation.ParticipationPeriod = BaseCDAModel.CreateInterval(
                new ISO8601DateTime(DateTime.Now.AddDays(-50)),
                new ISO8601DateTime(DateTime.Now));

            paticipation.Role        = BaseCDAModel.CreateRole(Occupation.GeneralMedicalPractitioner);
            paticipation.Participant = AcdCustodianRecord.CreateAcdCustodian();

            // Name
            var person     = BaseCDAModel.CreatePersonConsumer();
            var personName = BaseCDAModel.CreatePersonName();

            personName.GivenNames = new List <string> {
                givenName
            };
            personName.FamilyName = familyName;
            personName.Titles     = new List <string> {
                "Dr"
            };
            personName.NameUsages = new List <NameUsage> {
                NameUsage.Legal
            };
            person.PersonNames = new List <IPersonName> {
                personName
            };

            paticipation.Participant.Person = person;

            // Address
            IAddressAustralian address = BaseCDAModel.CreateAddress();

            address.AddressPurpose    = AddressPurpose.Business;
            address.AustralianAddress = BaseCDAModel.CreateAustralianAddress();
            address.AustralianAddress.UnstructuredAddressLines = new List <string> {
                addressLine
            };
            address.AustralianAddress.SuburbTownLocality = "Nehtaville";
            address.AustralianAddress.State    = AustralianState.QLD;
            address.AustralianAddress.PostCode = "5555";

            paticipation.Participant.Addresses = new List <IAddressAustralian> {
                address
            };

            // Identifiers
            paticipation.Participant.Person.Identifiers = new List <Identifier>
            {
                BaseCDAModel.CreateHealthIdentifier(HealthIdentifierType.HPII, hpii)
            };


            if (!mandatoryOnly)
            {
                person.DateOfBirth = new ISO8601DateTime(DateTime.Now);
                person.Gender      = Gender.Male;

                // Communication
                var electronicCommunicationDetail = AcdCustodianRecord.CreateElectronicCommunicationDetail
                                                    (
                    phone,
                    ElectronicCommunicationMedium.Telephone,
                    ElectronicCommunicationUsage.WorkPlace
                                                    );
                paticipation.Participant.ElectronicCommunicationDetails = new List <ElectronicCommunicationDetail>
                {
                    electronicCommunicationDetail
                };

                person.Organisation             = BaseCDAModel.CreateEmploymentOrganisation();
                person.Organisation.Identifiers = new List <Identifier> {
                    BaseCDAModel.CreateHealthIdentifier(HealthIdentifierType.HPIO, "8003620000021100")
                };
                person.Organisation.Name       = "Super Healthy Hospital";
                person.Organisation.NameUsage  = OrganisationNameUsage.EnterpriseName;
                person.Organisation.Department = "Endocrinology";

                person.Organisation.EmploymentType         = BaseCDAModel.CreateCodableText(EmploymentType.FullTime);
                person.Organisation.Occupation             = BaseCDAModel.CreateRole(Occupation.GeneralMedicalPractitioner);
                person.Organisation.PositionInOrganisation = BaseCDAModel.CreateCodableText(null, null, null, "SMO", null);
            }

            return(paticipation);
        }