private CdaSubject CreateBabySubject()
        {
            // *** Create the subject of the section for the baby ***

            CdaSubject returnVal = new CdaSubject();

            if (this.Observations != null)
            {
                foreach (var obs in this.Observations)
                {
                    switch (obs.Code.Code)
                    {
                    case "46098-0":     // Sex
                        CdaTextObservation tempObservation = obs as CdaTextObservation;
                        CdaGender          gender          = new CdaGender(obs.DisplayValue);
                        returnVal.Gender = gender.Value;
                        break;

                    case "45392-8":     // First Name
                        returnVal.FirstName = obs.DisplayValue;
                        break;

                    case "21112-8":     // Birth Date + Time
                        CdaDateObservation dateObs = obs as CdaDateObservation;
                        returnVal.BirthTime = dateObs.Value;
                        break;
                    }
                }
            }

            return(returnVal);
        }
        /// <summary>
        /// Creates the organizer
        /// </summary>
        /// <returns>A CDA birth event organizer</returns>
        public override POCD_MT000040Organizer ToPocdOrganizer()
        {
            POCD_MT000040Organizer returnVal = base.ToPocdOrganizer();

            // *** Create subject from observations ***
            CdaSubject babySubject = this.CreateBabySubject();

            returnVal.subject = babySubject.ToPocdSubject();

            return(returnVal);
        }
        // *** Sample code from IHE PCC TF ***

        //<entry>
        //    <organizer classCode='CLUSTER' moodCode='EVN'>
        //        <templateId root='2.16.840.1.113883.10.20.1.23'/>
        //        <templateId root='1.3.6.1.4.1.19376.1.5.3.1.4.15'/>
        //        <subject typeCode='SBJ'>
        //            <relatedSubject classCode='PRS'>
        //            <code code='' displayName='' codeSystem='2.16.840.1.113883.5.111' codeSystemName='RoleCode'/>
        //            <subject>
        //                <sdtc:id root='' extension=''/>
        //                <administrativeGenderCode code='' displayName='' codeSystem='' codeSystemName=''/>
        //            </subject>
        //            </relatedSubject>
        //        </subject>
        //        <!-- zero or more participants linking to other relations -->
        //        <participant typeCode='IND'>
        //            <participantRole classCode='PRS'>
        //                <code code='' displayName='' codeSystem='2.16.840.1.113883.5.111' codeSystemName='RoleCode'/>
        //                <playingEntity classCode='PSN'>
        //                    <sdtc:id root='' extension=''/>
        //                </playingEntity>
        //            </participantRole>
        //        </participant>
        //        <!-- one or more entry relationships for family history observations -->
        //        <component typeCode='COMP'>
        //            <observation classCode='OBS' moodCode='EVN'>
        //                <templateId root='2.16.840.1.113883.10.20.1.22'/>
        //            </observation>
        //        </component>
        //    </organizer>
        //</entry>

        public override POCD_MT000040Component3 ToPocdComponent()
        {
            if (this.Observations.Count == 0)
            {
                this.Narrative = "(No Data)";
            }

            // *** Create the component ***
            POCD_MT000040Component3 returnVal = base.ToPocdComponent();

            // *** There is one "organizer" per family member ***

            // *** Add the text ***
            //returnVal.section.text = this.GetSectionText();

            // *** Create list of entries ***
            List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

            // *** If we don't have anything ***
            if (this.UnknownObservation != null)
            {
                // *** Create an entry ***
                POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

                // *** Each entry has one organizer ***
                POCD_MT000040Organizer organizer = new POCD_MT000040Organizer();

                // *** Set the organizer attributes ***
                organizer.classCode = x_ActClassDocumentEntryOrganizer.CLUSTER;
                organizer.moodCode  = "EVN";

                // *** Create the template ids ***
                CdaTemplateIdList ids = new CdaTemplateIdList("2.16.840.1.113883.10.20.1.23", "1.3.6.1.4.1.19376.1.5.3.1.4.15");
                organizer.templateId = ids.ToPocd();

                organizer.statusCode = new CS()
                {
                    code = "completed"
                };

                CdaSubject cdaSubject = new CdaSubject()
                {
                    FamilyMember = Hl7FamilyMember.FamilyMember
                };

                // *** Add the subject to the organizer ***
                organizer.subject = cdaSubject.ToPocdSubject();

                // *** Create a list of components for the observations for this family member ***
                List <POCD_MT000040Component4> componentList = new List <POCD_MT000040Component4>();

                // *** Create a component ***
                POCD_MT000040Component4 component = new POCD_MT000040Component4();

                // *** Add observation to component ***
                component.Item = this.UnknownObservation.ToPocd();

                // *** Add component to list ***
                componentList.Add(component);

                // *** Add component array to organizer ***
                organizer.component = componentList.ToArray();

                // *** Add organizer to entry ***
                newEntry.Item = organizer;

                // *** Add entry to the list ***
                entryList.Add(newEntry);
            }
            else
            {
                // *** Loop through family members ***
                foreach (Hl7FamilyMember key in this.Observations.Keys)
                {
                    // *** Create an entry ***
                    POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

                    // *** Each entry has one organizer ***
                    POCD_MT000040Organizer organizer = new POCD_MT000040Organizer();

                    // *** Set the organizer attributes ***
                    organizer.classCode = x_ActClassDocumentEntryOrganizer.CLUSTER;
                    organizer.moodCode  = "EVN";

                    // *** Create the template ids ***
                    CdaTemplateIdList ids = new CdaTemplateIdList("2.16.840.1.113883.10.20.1.23", "1.3.6.1.4.1.19376.1.5.3.1.4.15");
                    organizer.templateId = ids.ToPocd();

                    organizer.statusCode = new CS()
                    {
                        code = "completed"
                    };

                    //// *** Create the subject ***
                    //POCD_MT000040Subject subject = new POCD_MT000040Subject() { typeCode = ParticipationTargetSubject.SBJ, typeCodeSpecified = true };

                    //// *** Create the related subject ***
                    //POCD_MT000040RelatedSubject relatedSubject = new POCD_MT000040RelatedSubject() { classCode = x_DocumentSubject.PRS };

                    //// *** Create the role and add as code ***
                    //CdaRoleCode roleCode = new CdaRoleCode() { FamilyMember = key };
                    //relatedSubject.code = roleCode.ToCe();

                    //// *** Add the related subject to the subject ***
                    //subject.relatedSubject = relatedSubject;

                    CdaSubject cdaSubject = new CdaSubject()
                    {
                        FamilyMember = key
                    };

                    // *** Add the subject to the organizer ***
                    organizer.subject = cdaSubject.ToPocdSubject();

                    // *** Create a list of components for the observations for this family member ***
                    List <POCD_MT000040Component4> componentList = new List <POCD_MT000040Component4>();

                    // *** Loop through all observations for this family member ***
                    foreach (CdaCodeObservation obs in this.Observations[key])
                    {
                        // *** Create a component ***
                        POCD_MT000040Component4 component = new POCD_MT000040Component4();

                        // *** Add observation to component ***
                        component.Item = obs.ToPocd();

                        // *** Add component to list ***
                        componentList.Add(component);
                    }

                    // *** Add component array to organizer ***
                    organizer.component = componentList.ToArray();

                    // *** Add organizer to entry ***
                    newEntry.Item = organizer;

                    // *** Add entry to the list ***
                    entryList.Add(newEntry);
                }
            }

            // *** Add entry list to section ***
            returnVal.section.entry = entryList.ToArray();

            return(returnVal);
        }