예제 #1
0
        /// <summary>This method will build a primitive conformance class (ST, NM, etc) which is
        /// a Component or Subcomponent.
        /// </summary>
        public virtual void  buildClass(Genetibase.NuGenHL7.conf.spec.message.AbstractComponent primitive, int profileType)
        {
            GeneratedPrimitive genClass    = new GeneratedPrimitive();
            ProfileName        profileName = new ProfileName(primitive.Name, profileType);

            // Set up class
            genClass.ClassPackage = packageName;
            genClass.addClassImport("Genetibase.NuGenHL7.model.*");
            genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
            genClass.Properties = "extends AbstractConformanceDataType";

            genClass.Name = profileName.ClassName;
            docBuilder.decorateConstructor(genClass.Constructor, profileName.ClassName);

            if (primitive.ConstantValue != null && primitive.ConstantValue.Length > 0)
            {
                // Add constant value constraints if there are any
                genClass.addConstantValue(primitive.ConstantValue);
            }
            else
            {
                // if no constant value, then we add a setter method
                GeneratedMethod setter = new GeneratedMethod();
                setter.addParam("java.lang.String value");
                setter.addToThrows("ConfDataException");
                setter.addToBody("super.setValue( value );");
                setter.ReturnType = "void";
                setter.Visibility = "public";
                setter.Name       = "setValue";
                docBuilder.decorateSetValue(setter, primitive.Length);
                genClass.addMethod(setter);

                genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*");
            }
            genClass.addMaxLength(primitive.Length);

            // Decorate with comments
            docBuilder.decoratePrimitive(genClass, primitive);
            if (depManager.Verbose)
            {
                System.Console.Out.WriteLine("Generating Primitive: " + packageName + "." + genClass.Name);
            }

            depManager.generateFile(genClass, packageName, genClass.Name);
        }
		/// <summary>This method will build a primitive conformance class (ST, NM, etc) which is
		/// a Component or Subcomponent. 
		/// </summary>
		public virtual void  buildClass(Genetibase.NuGenHL7.conf.spec.message.AbstractComponent primitive, int profileType)
		{
			GeneratedPrimitive genClass = new GeneratedPrimitive();
			ProfileName profileName = new ProfileName(primitive.Name, profileType);
			
			// Set up class
			genClass.ClassPackage = packageName;
			genClass.addClassImport("Genetibase.NuGenHL7.model.*");
			genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
			genClass.Properties = "extends AbstractConformanceDataType";
			
			genClass.Name = profileName.ClassName;
			docBuilder.decorateConstructor(genClass.Constructor, profileName.ClassName);
			
			if (primitive.ConstantValue != null && primitive.ConstantValue.Length > 0)
			{
				// Add constant value constraints if there are any
				genClass.addConstantValue(primitive.ConstantValue);
			}
			else
			{
				// if no constant value, then we add a setter method
				GeneratedMethod setter = new GeneratedMethod();
				setter.addParam("java.lang.String value");
				setter.addToThrows("ConfDataException");
				setter.addToBody("super.setValue( value );");
				setter.ReturnType = "void";
				setter.Visibility = "public";
				setter.Name = "setValue";
				docBuilder.decorateSetValue(setter, primitive.Length);
				genClass.addMethod(setter);
				
				genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*");
			}
			genClass.addMaxLength(primitive.Length);
			
			// Decorate with comments
			docBuilder.decoratePrimitive(genClass, primitive);
			if (depManager.Verbose)
				System.Console.Out.WriteLine("Generating Primitive: " + packageName + "." + genClass.Name);
			
			depManager.generateFile(genClass, packageName, genClass.Name);
		}
		/// <summary>Adds a Component to a conformance Message
		/// adds a line to the constructor to instantiate that member variable
		/// </summary>
		/// <param name="profileName">this is the profile name associated with this Class
		/// </param>
		/// <param name="componentNumber">the number associated with the component in the profile 
		/// </param>
		/// <param name="childGetter">adds this line to the constructor to instantiate Conformance Component class
		/// </param>
		private void  addChild(ProfileName profileName, int componentNumber, System.String childGetter)
		{
			
			// Add member variable to class for holding Conformance Component class
			this.addMemberVariable("private " + profileName.ClassName + " " + profileName.MemberName + ";");
			
			// Add line to constructor to instantiate Conformance Component class
			this.Constructor.addToBody(childGetter);
			
			// Add method for retrieving Conformance Component Class
			GeneratedMethod getChildMethod = new GeneratedMethod();
			getChildMethod.addToComments("Provides access to the " + profileName.OriginalName + " component child");
			getChildMethod.addToComments("@return " + profileName.ClassName + " The " + profileName.OriginalName + " component child");
			getChildMethod.Visibility = "public";
			getChildMethod.ReturnType = profileName.ClassName;
			getChildMethod.Name = profileName.AccessorName;
			getChildMethod.addToBody("return " + profileName.MemberName + ";");
			this.addMethod(getChildMethod);
		}
        /// <summary>This method builds a Conformance Segment Class</summary>
        /// <param name="seg">the Segment to build
        /// </param>
        /// <param name="parentUnderlyingType">the data type of the parent Message or SegGroup for this segment
        /// example "Genetibase.NuGenHL7.model.v24.group.ADR_A19_..."
        /// </param>
        /// <param name="profileName">this is the profile name associated with this Class
        /// </param>
        public virtual void  buildClass(Seg seg, System.String parentUnderlyingType, ProfileName profileName)
        {
            GeneratedConformanceContainer gcc = new GeneratedConformanceContainer();

            System.String underlyingDataType;             // The underlying HAPI Type

            // Check for possible snags in the Runtime Profile Segment
            if (seg.Name == null || seg.Name.Length < 1)
            {
                throw new ConformanceError("Error building ConformanceSegment: Runtime Segment does not contain a name.");
            }

            // Set up class
            gcc.ClassPackage = packageName;
            gcc.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
            gcc.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*");
            gcc.addClassImport("Genetibase.NuGenHL7.*");
            gcc.addClassImport(packageName + "." + profileName.PackageName + ".*");

            gcc.Name       = profileName.ClassName;
            gcc.Properties = "extends AbstractConformanceContainer implements Repeatable";
            gcc.setMinMaxReps(seg.Min, seg.Max);
            underlyingDataType = "Genetibase.NuGenHL7.model." + versionString + ".segment." + seg.Name;

            System.String segClassName = UnderlyingAccessor.getHapiModelClass(underlyingDataType).FullName;
            gcc.addMemberVariable("private " + segClassName + " hapiSegment;");

            docBuilder.decorateConstructor(gcc.Constructor, profileName.ClassName);

            // Set up underlying Segment type
            GeneratedMethod theConstructor = gcc.Constructor;

            theConstructor.addParam(parentUnderlyingType + " underlyingMessage", "The underlying message object");
            theConstructor.addParam("int rep", "The underlying rep number");
            UnderlyingAccessor underlyingAccessor = new UnderlyingAccessor(parentUnderlyingType, profileName.AccessorName);

            theConstructor.addToBody("this.hapiSegment = (" + segClassName + ") underlyingMessage." + underlyingAccessor.ToString() + ";");
            theConstructor.addToThrows("HL7Exception");

            // Loop through each child. Note that array is 1-offset
            for (int i = 1; i <= seg.Fields; i++)
            {
                //don't build not supported, backward, or unknown types
                System.String usage = seg.getField(i).Usage;
                if (usage != null && (usage.Equals("X") || usage.Equals("B") || usage.Equals("U")))
                {
                    continue;
                }

                // Create the names for each type of child
                //         //CHANGED to use field # instead of name, in support of Z-segments
                //         ProfileName childProfileName = profileName.newInstance(String.valueOf(i), ProfileName.PS_FIELD);
                ProfileName childProfileName = profileName.newInstance(seg.getField(i).Name, ProfileName.PS_FIELD);

                // Add the member variable vector to hold them
                gcc.addMemberVariable("private FiniteList " + childProfileName.MemberName + ";");

                // Set up the constructor
                theConstructor.addToBody(childProfileName.MemberName + " = new FiniteList( " + childProfileName.ClassName + ".class, hapiSegment );");

                // Add the getter
                UnderlyingAccessor childAccessor = new UnderlyingAccessor(underlyingDataType, childProfileName.AccessorName);
                GeneratedRepGetter repGetter     = new GeneratedRepGetter(childProfileName, childAccessor.AcceptsRep);
                docBuilder.decorateRepGetter(repGetter, seg.getField(i), childProfileName.ClassName);
                gcc.addMethod(repGetter);

                // If the field has no components it is a primitive, so build as such.
                if (seg.getField(i).Components > 0)
                {
                    ConformanceFieldBuilder childBuilder = new ConformanceFieldBuilder(packageName + "." + profileName.PackageName, versionString, depManager);
                    childBuilder.buildClass(seg.getField(i), segClassName, childProfileName.clearNameMap());
                }
                else
                {
                    ConformancePrimitiveBuilder childBuilder = new ConformancePrimitiveBuilder(packageName + "." + profileName.PackageName, depManager);
                    childBuilder.buildClass(seg.getField(i), segClassName, childProfileName.clearNameMap());
                }
            }

            // Decorate with comments
            docBuilder.decorateSegment(gcc, seg);

            if (depManager.Verbose)
            {
                System.Console.Out.WriteLine("Generating Segment: " + packageName + "." + gcc.Name);
            }

            depManager.generateFile(gcc, packageName, profileName.ClassName);
        }
        /// <summary>This method builds a Conformance Field Class</summary>
        /// <param name="field">the Field to build
        /// </param>
        /// <param name="parentUnderlyingType">the data type of the parent Segment for this field
        /// example "Genetibase.NuGenHL7.model.v24.segment.MSH"
        /// </param>
        /// <param name="profileName"> ProfileName
        /// </param>
        public virtual void  buildClass(Field field, System.String parentUnderlyingType, ProfileName profileName)
        {
            GeneratedConformanceContainer gcc = new GeneratedConformanceContainer();
            GeneratedMethod gm = new GeneratedMethod();

            // Check for possible snags in the Runtime Profile Segment
            if (field.Name == null || field.Name.Length < 1)
            {
                throw new ConformanceError("Error building ConformanceField: Runtime Field does not contain a name.");
            }

            // Set up class
            gcc.ClassPackage = packageName;
            gcc.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
            gcc.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*");
            gcc.addClassImport("Genetibase.NuGenHL7.model.*");
            gcc.addClassImport("Genetibase.NuGenHL7.*");

            if (field.Components > 0)
            {
                gcc.addClassImport(packageName + "." + profileName.PackageName + ".*");
            }

            gcc.Name = profileName.ClassName;

            gcc.Properties = "extends AbstractConformanceContainer implements Repeatable";
            gcc.setMinMaxReps(field.Min, field.Max);
            underlyingType = "Genetibase.NuGenHL7.model." + versionString + ".datatype." + field.Datatype;
            gcc.addMemberVariable(underlyingType + " hapiType;");
            gcc.addMemberVariable("private final short MAX_LENGTH = " + field.Length + ";");
            gm.ReturnType = "long";
            gm.Visibility = "public";
            gm.Name       = "getMaxLength";
            gm.addToBody("return this.MAX_LENGTH;");
            docBuilder.decorateMaxLength(gm);
            gcc.addMethod(gm);

            // Set up underlying Field type
            gcc.Constructor.addParam(parentUnderlyingType + " hapiSegment", "The underlying HAPI field object");

            gcc.Constructor.addParam("int rep", "The desired repetition");
            gcc.Constructor.addToBody("try {");

            UnderlyingAccessor underlyingAccessor = new UnderlyingAccessor(parentUnderlyingType, profileName.AccessorName);

            gcc.Constructor.addToBody("   this.hapiType = hapiSegment." + underlyingAccessor + ";");

            docBuilder.decorateConstructor(gcc.Constructor, profileName.ClassName);

            // Create the getters and member variables associated with each child
            for (int i = 1; i <= field.Components; i++)
            {
                //don't build not supported, backward, or unknown types
                System.String usage = field.getComponent(i).Usage;
                if (usage != null && (usage.Equals("X") || usage.Equals("B") || usage.Equals("U")))
                {
                    continue;
                }

                bool        hasChildren      = (field.getComponent(i).SubComponents > 0)?true:false;
                ProfileName childProfileName = new ProfileName(field.getComponent(i).Name, ProfileName.PS_COMP);
                gcc.addComponent(childProfileName, (short)(i - 1), hasChildren);
            }

            gcc.Constructor.addToBody("} catch ( HL7Exception e ) {");
            gcc.Constructor.addToBody("   throw new ConformanceError( \"Invalid Attempt to access a rep. This is a bug.\" );");
            gcc.Constructor.addToBody("}");

            // Decorate with comments
            docBuilder.decorateField(gcc, field);

            if (depManager.Verbose)
            {
                System.Console.Out.WriteLine("Generating Field: " + packageName + "." + gcc.Name);
            }

            // Create the components
            for (int i = 1; i <= field.Components; i++)
            {
                if (field.getComponent(i).SubComponents == 0)
                {
                    ConformancePrimitiveBuilder childBuilder = new ConformancePrimitiveBuilder(packageName + "." + profileName.PackageName, depManager);
                    childBuilder.buildClass(field.getComponent(i), ProfileName.PS_COMP);
                }
                else
                {
                    ConformanceComponentBuilder childBuilder = new ConformanceComponentBuilder(packageName + "." + profileName.PackageName, depManager, versionString);
                    childBuilder.buildClass(field.getComponent(i));
                }
            }
            depManager.generateFile(gcc, packageName, gcc.Name);
        }
		/// <summary>This method will build a primitive conformance class (ST, NM, etc) which is
		/// a Field. 
		/// </summary>
		public virtual void  buildClass(Genetibase.NuGenHL7.conf.spec.message.Field primitive, System.String parentUnderlyingType, ProfileName profileName)
		{
			GeneratedPrimitive genClass = new GeneratedPrimitive();
			
			// Check for possible snags in the Runtime Profile Component
			if (primitive.Name == null || primitive.Name.Length < 1)
				throw new ConformanceError("Error building ConformanceSegment: Runtime AbstractComponent does not contain a name.");
			
			GeneratedMethod theConstructor = new GeneratedMethod();
			genClass.Constructor = theConstructor;
			genClass.addClassImport("Genetibase.NuGenHL7.model.*");
			
			UnderlyingAccessor underlyingAccessor = new UnderlyingAccessor(parentUnderlyingType, profileName.AccessorName);
			theConstructor.addParam(parentUnderlyingType + " parentSeg", "The parent underlying data type");
			theConstructor.addParam("int rep", "The desired repetition");
			theConstructor.Name = profileName.ClassName;
			theConstructor.Visibility = "public ";
			theConstructor.addToThrows("Genetibase.NuGenHL7.HL7Exception");
			theConstructor.addToBody("super( (Primitive)parentSeg." + underlyingAccessor + " );");
			theConstructor.addToBody("if ( parentSeg." + underlyingAccessor + " == null )");
			theConstructor.addToBody("   throw new Genetibase.NuGenHL7.HL7Exception( \"Error accussing underlying object. This is a bug.\", 0 );");
			
			// Set up class
			genClass.ClassPackage = packageName;
			//genClass.addClassImport("Genetibase.NuGenHL7.model.*");
			genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
			//genClass.addClassImport( "Genetibase.NuGenHL7.conf.classes.exceptions.*" );
			genClass.Properties = "extends AbstractConformanceDataType implements Repeatable";
			
			// Add min and max reps stuff
			genClass.setMinMaxReps(primitive.Min, primitive.Max);
			
			genClass.Name = profileName.ClassName;
			docBuilder.decorateConstructor(genClass.Constructor, profileName.ClassName);
			
			// Add constant value constraints if there are any, if not, add a setter method
			if (primitive.ConstantValue != null && primitive.ConstantValue.Length > 0)
			{
				genClass.addConstantValue(primitive.ConstantValue);
			}
			else
			{
				GeneratedMethod setter = new GeneratedMethod();
				setter.addParam("java.lang.String value");
				setter.addToThrows("ConfDataException");
				setter.addToBody("super.setValue( value );");
				setter.ReturnType = "void";
				setter.Visibility = "public";
				setter.Name = "setValue";
				docBuilder.decorateSetValue(setter, primitive.Length);
				genClass.addMethod(setter);
				
				genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*");
			}
			genClass.addMaxLength(primitive.Length);
			
			// Decorate with comments
			docBuilder.decoratePrimitive(genClass, primitive);
			if (depManager.Verbose)
				System.Console.Out.WriteLine("Generating Primitive: " + packageName + "." + genClass.Name);
			
			depManager.generateFile(genClass, packageName, genClass.Name);
		}
예제 #7
0
        /// <summary>This method will build a primitive conformance class (ST, NM, etc) which is
        /// a Field.
        /// </summary>
        public virtual void  buildClass(Genetibase.NuGenHL7.conf.spec.message.Field primitive, System.String parentUnderlyingType, ProfileName profileName)
        {
            GeneratedPrimitive genClass = new GeneratedPrimitive();

            // Check for possible snags in the Runtime Profile Component
            if (primitive.Name == null || primitive.Name.Length < 1)
            {
                throw new ConformanceError("Error building ConformanceSegment: Runtime AbstractComponent does not contain a name.");
            }

            GeneratedMethod theConstructor = new GeneratedMethod();

            genClass.Constructor = theConstructor;
            genClass.addClassImport("Genetibase.NuGenHL7.model.*");

            UnderlyingAccessor underlyingAccessor = new UnderlyingAccessor(parentUnderlyingType, profileName.AccessorName);

            theConstructor.addParam(parentUnderlyingType + " parentSeg", "The parent underlying data type");
            theConstructor.addParam("int rep", "The desired repetition");
            theConstructor.Name       = profileName.ClassName;
            theConstructor.Visibility = "public ";
            theConstructor.addToThrows("Genetibase.NuGenHL7.HL7Exception");
            theConstructor.addToBody("super( (Primitive)parentSeg." + underlyingAccessor + " );");
            theConstructor.addToBody("if ( parentSeg." + underlyingAccessor + " == null )");
            theConstructor.addToBody("   throw new Genetibase.NuGenHL7.HL7Exception( \"Error accussing underlying object. This is a bug.\", 0 );");

            // Set up class
            genClass.ClassPackage = packageName;
            //genClass.addClassImport("Genetibase.NuGenHL7.model.*");
            genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
            //genClass.addClassImport( "Genetibase.NuGenHL7.conf.classes.exceptions.*" );
            genClass.Properties = "extends AbstractConformanceDataType implements Repeatable";

            // Add min and max reps stuff
            genClass.setMinMaxReps(primitive.Min, primitive.Max);

            genClass.Name = profileName.ClassName;
            docBuilder.decorateConstructor(genClass.Constructor, profileName.ClassName);

            // Add constant value constraints if there are any, if not, add a setter method
            if (primitive.ConstantValue != null && primitive.ConstantValue.Length > 0)
            {
                genClass.addConstantValue(primitive.ConstantValue);
            }
            else
            {
                GeneratedMethod setter = new GeneratedMethod();
                setter.addParam("java.lang.String value");
                setter.addToThrows("ConfDataException");
                setter.addToBody("super.setValue( value );");
                setter.ReturnType = "void";
                setter.Visibility = "public";
                setter.Name       = "setValue";
                docBuilder.decorateSetValue(setter, primitive.Length);
                genClass.addMethod(setter);

                genClass.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*");
            }
            genClass.addMaxLength(primitive.Length);

            // Decorate with comments
            docBuilder.decoratePrimitive(genClass, primitive);
            if (depManager.Verbose)
            {
                System.Console.Out.WriteLine("Generating Primitive: " + packageName + "." + genClass.Name);
            }

            depManager.generateFile(genClass, packageName, genClass.Name);
        }
예제 #8
0
        /// <summary>This method will build all the field children for this Segment</summary>
        /// <param name="segGroup">the SegGroup to build
        /// </param>
        /// <param name="parentUnderlyingType">the data type of the parent Message for this field
        /// example "Genetibase.NuGenHL7.model.v24.group.ADR_A19_..."
        /// </param>
        /// <param name="profileName">this is the profile name associated with this Class
        /// </param>
        public virtual void  buildClass(SegGroup segGroup, System.String parentUnderlyingType, ProfileName profileName)
        {
            GeneratedConformanceContainer gcc                 = new GeneratedConformanceContainer();
            ConformanceSegmentBuilder     confSegBuilder      = new ConformanceSegmentBuilder(packageName + "." + profileName.PackageName, version, depManager);
            ConformanceSegGroupBuilder    confSegGroupBuilder = new ConformanceSegGroupBuilder(packageName + "." + profileName.PackageName, version, depManager, structID);

            System.String underlyingDataType    = structID + "_" + generateSegGroupName(segGroup);
            System.String underlyingPackageType = "Genetibase.NuGenHL7.model." + version + ".group." + underlyingDataType;

            // Set up class
            gcc.ClassPackage = packageName;
            gcc.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
            gcc.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*");
            gcc.addClassImport("Genetibase.NuGenHL7.*");
            gcc.addClassImport(packageName + "." + profileName.PackageName + ".*");

            gcc.Name       = profileName.ClassName;
            gcc.Properties = "extends AbstractConformanceContainer implements Repeatable";
            gcc.setMinMaxReps(segGroup.Min, segGroup.Max);
            gcc.addMemberVariable("private " + underlyingPackageType + " hapiSegGroup;");

            // Set up underlying Segment type
            GeneratedMethod theConstructor = gcc.Constructor;

            docBuilder.decorateConstructor(theConstructor, profileName.ClassName);
            theConstructor.addParam(parentUnderlyingType + " underlyingMessage", "The underlying message object");
            theConstructor.addParam("int rep", "The underlying rep number");
            theConstructor.addToThrows("HL7Exception");

            UnderlyingAccessor underlyingAccessor = new UnderlyingAccessor(parentUnderlyingType, "get" + underlyingDataType);

            theConstructor.addToBody("this.hapiSegGroup = underlyingMessage." + underlyingAccessor.ToString() + ";");

            for (int i = 1; i <= segGroup.Children; i++)
            {
                //don't build not supported, backward, or unknown types
                System.String usage = segGroup.getChild(i).Usage;
                if (usage != null && (usage.Equals("X") || usage.Equals("B") || usage.Equals("U")))
                {
                    continue;
                }

                if (segGroup.getChild(i) is Seg)
                {
                    ProfileName childProfileName = profileName.newInstance(segGroup.getChild(i).Name, ProfileName.PS_SEG);

                    // Add the member variable vector to hold them
                    gcc.addMemberVariable("private FiniteList " + childProfileName.MemberName + ";");
                    theConstructor.addToBody(childProfileName.MemberName + " = new FiniteList( " + childProfileName.ClassName + ".class, hapiSegGroup );");
                    UnderlyingAccessor childAccessor = new UnderlyingAccessor(underlyingPackageType, childProfileName.AccessorName);
                    GeneratedRepGetter repGetter     = new GeneratedRepGetter(childProfileName, childAccessor.AcceptsRep);

                    docBuilder.decorateRepGetter(repGetter, (Seg)segGroup.getChild(i), childProfileName.OriginalName);
                    gcc.addMethod(repGetter);
                    if (depManager.Verbose)
                    {
                        System.Console.Out.WriteLine("Generating Segment: " + packageName + "." + gcc.Name);
                    }

                    confSegBuilder.buildClass((Seg)segGroup.getChild(i), underlyingPackageType, childProfileName.clearNameMap());
                }
                else if (segGroup.getChild(i) is SegGroup)
                {
                    ProfileName childProfileName = profileName.newInstance(segGroup.getChild(i).Name, ProfileName.PS_SEGG);

                    // Add the member variable vector to hold them
                    gcc.addMemberVariable("private FiniteList " + childProfileName.MemberName + ";");
                    theConstructor.addToBody(childProfileName.MemberName + " = new FiniteList( " + childProfileName.ClassName + ".class, hapiSegGroup );");

                    System.String      underlyingAccessorName = "get" + structID + "_" + ConformanceSegGroupBuilder.generateSegGroupName((SegGroup)segGroup.getChild(i));
                    UnderlyingAccessor childAccessor          = new UnderlyingAccessor(underlyingPackageType, underlyingAccessorName);
                    GeneratedRepGetter repGetter = new GeneratedRepGetter(childProfileName, childAccessor.AcceptsRep);

                    docBuilder.decorateRepGetter(repGetter, (SegGroup)segGroup.getChild(i), childProfileName.OriginalName);
                    gcc.addMethod(repGetter);
                    if (depManager.Verbose)
                    {
                        System.Console.Out.WriteLine("Generating SegGroup: " + packageName + "." + gcc.Name);
                    }

                    confSegGroupBuilder.buildClass((SegGroup)segGroup.getChild(i), underlyingPackageType, childProfileName.clearNameMap());
                }
            }

            depManager.generateFile(gcc, packageName, profileName.ClassName);
        }
		/// <summary>Adds min and max reps to the genrated classes</summary>
		/// <param name="minReps">the Minimum Repetitions
		/// </param>
		/// <param name="maxReps">Maximum Repetitions
		/// </param>
		public virtual void  setMinMaxReps(short minReps, short maxReps)
		{
			
			GeneratedMethod maxRepsMethod = new GeneratedMethod();
			GeneratedMethod minRepsMethod = new GeneratedMethod();
			
			this.addMemberVariable("private final short MAX_REPS = " + maxReps + ";");
			this.addMemberVariable("private final short MIN_REPS = " + minReps + ";");
			
			// Creates the methos to return the maximum number of repitions for the generated Class
			DocumentationBuilder.getDocumentationBuilder().decorateMaxReps(maxRepsMethod);
			maxRepsMethod.Visibility = "public";
			maxRepsMethod.ReturnType = "short";
			maxRepsMethod.Name = "getMaxReps";
			maxRepsMethod.addToBody("return this.MAX_REPS;");
			this.addMethod(maxRepsMethod);
			
			// Creates the method to return the maximum number of repitions for the generated Class
			DocumentationBuilder.getDocumentationBuilder().decorateMaxReps(minRepsMethod);
			minRepsMethod.Visibility = "public";
			minRepsMethod.ReturnType = "short";
			minRepsMethod.Name = "getMinReps";
			minRepsMethod.addToBody("return this.MIN_REPS;");
			this.addMethod(minRepsMethod);
		}
		/// <summary>This method builds a Conformance Field Class</summary>
		/// <param name="field">the Field to build
		/// </param>
		/// <param name="parentUnderlyingType">the data type of the parent Segment for this field
		/// example "Genetibase.NuGenHL7.model.v24.segment.MSH"  
		/// </param>
		/// <param name="profileName"> ProfileName
		/// </param>
		public virtual void  buildClass(Field field, System.String parentUnderlyingType, ProfileName profileName)
		{
			GeneratedConformanceContainer gcc = new GeneratedConformanceContainer();
			GeneratedMethod gm = new GeneratedMethod();
			
			// Check for possible snags in the Runtime Profile Segment
			if (field.Name == null || field.Name.Length < 1)
				throw new ConformanceError("Error building ConformanceField: Runtime Field does not contain a name.");
			
			// Set up class
			gcc.ClassPackage = packageName;
			gcc.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
			gcc.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*");
			gcc.addClassImport("Genetibase.NuGenHL7.model.*");
			gcc.addClassImport("Genetibase.NuGenHL7.*");
			
			if (field.Components > 0)
				gcc.addClassImport(packageName + "." + profileName.PackageName + ".*");
			
			gcc.Name = profileName.ClassName;
			
			gcc.Properties = "extends AbstractConformanceContainer implements Repeatable";
			gcc.setMinMaxReps(field.Min, field.Max);
			underlyingType = "Genetibase.NuGenHL7.model." + versionString + ".datatype." + field.Datatype;
			gcc.addMemberVariable(underlyingType + " hapiType;");
			gcc.addMemberVariable("private final short MAX_LENGTH = " + field.Length + ";");
			gm.ReturnType = "long";
			gm.Visibility = "public";
			gm.Name = "getMaxLength";
			gm.addToBody("return this.MAX_LENGTH;");
			docBuilder.decorateMaxLength(gm);
			gcc.addMethod(gm);
			
			// Set up underlying Field type
			gcc.Constructor.addParam(parentUnderlyingType + " hapiSegment", "The underlying HAPI field object");
			
			gcc.Constructor.addParam("int rep", "The desired repetition");
			gcc.Constructor.addToBody("try {");
			
			UnderlyingAccessor underlyingAccessor = new UnderlyingAccessor(parentUnderlyingType, profileName.AccessorName);
			gcc.Constructor.addToBody("   this.hapiType = hapiSegment." + underlyingAccessor + ";");
			
			docBuilder.decorateConstructor(gcc.Constructor, profileName.ClassName);
			
			// Create the getters and member variables associated with each child
			for (int i = 1; i <= field.Components; i++)
			{
				//don't build not supported, backward, or unknown types
				System.String usage = field.getComponent(i).Usage;
				if (usage != null && (usage.Equals("X") || usage.Equals("B") || usage.Equals("U")))
					continue;
				
				bool hasChildren = (field.getComponent(i).SubComponents > 0)?true:false;
				ProfileName childProfileName = new ProfileName(field.getComponent(i).Name, ProfileName.PS_COMP);
				gcc.addComponent(childProfileName, (short) (i - 1), hasChildren);
			}
			
			gcc.Constructor.addToBody("} catch ( HL7Exception e ) {");
			gcc.Constructor.addToBody("   throw new ConformanceError( \"Invalid Attempt to access a rep. This is a bug.\" );");
			gcc.Constructor.addToBody("}");
			
			// Decorate with comments
			docBuilder.decorateField(gcc, field);
			
			if (depManager.Verbose)
				System.Console.Out.WriteLine("Generating Field: " + packageName + "." + gcc.Name);
			
			// Create the components
			for (int i = 1; i <= field.Components; i++)
			{
				if (field.getComponent(i).SubComponents == 0)
				{
					ConformancePrimitiveBuilder childBuilder = new ConformancePrimitiveBuilder(packageName + "." + profileName.PackageName, depManager);
					childBuilder.buildClass(field.getComponent(i), ProfileName.PS_COMP);
				}
				else
				{
					ConformanceComponentBuilder childBuilder = new ConformanceComponentBuilder(packageName + "." + profileName.PackageName, depManager, versionString);
					childBuilder.buildClass(field.getComponent(i));
				}
			}
			depManager.generateFile(gcc, packageName, gcc.Name);
		}