/// <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>This method builds a Conformance Message Class</summary>
		/// <param name="runtimeProfile">the profile which to genrate Conformance Classes for
		/// </param>
		/// <param name="depManager">the DeploymentManager
		/// </param>
		public virtual void  buildClass(RuntimeProfile runtimeProfile, DeploymentManager depManager)
		{
			this.depManager = depManager;
			this.runtimeProfile = runtimeProfile;
			this.msg = runtimeProfile.Message;
			this.confMsg = new GeneratedConformanceMessage();
			
			ProfileName profileName = new ProfileName(msg.MsgStructID, ProfileName.PS_MSG);
			
            String version = Regex.Replace(runtimeProfile.getHL7Version(), "\\.", "");

			System.String underlyingDataType = "Genetibase.NuGenHL7.model." + version + ".message." + msg.MsgStructID;
			
			ConformanceSegmentBuilder confSegBuilder = new ConformanceSegmentBuilder(packageName, version, depManager);
			ConformanceSegGroupBuilder confSegGroupBuilder = new ConformanceSegGroupBuilder(packageName, version, depManager, msg.MsgStructID);
			DocumentationBuilder docBuilder = DocumentationBuilder.getDocumentationBuilder();
			
			// Add class package and imports
			confMsg.ClassPackage = packageName;
			confMsg.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
			confMsg.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*");
			
			// Set class properties
			confMsg.Name = profileName.ClassName;
			confMsg.Properties = "extends AbstractConformanceContainer";
			
			// Decorate the class with comments
			docBuilder.decorateConformanceMessage(confMsg, runtimeProfile);
			docBuilder.decorateConstructor(confMsg.Constructor, msg.MsgType);
			
			// add hapi message
			confMsg.addHAPIMessage(underlyingDataType);
			
			for (int i = 1; i <= msg.Children; i++)
			{
				//don't build not supported, backward, or unknown types
				System.String usage = msg.getChild(i).Usage;
				if (usage.Equals("X") || usage.Equals("B") || usage.Equals("U"))
					continue;
				
				if (msg.getChild(i) is Seg)
				{
					ProfileName childProfileName = profileName.newInstance(msg.getChild(i).Name, ProfileName.PS_SEG);
					
					// Add the member variable vector to hold them
					confMsg.addMemberVariable("private FiniteList " + childProfileName.MemberName + ";");
					confMsg.Constructor.addToBody(childProfileName.MemberName + " = new FiniteList( " + childProfileName.ClassName + ".class, hapiMessage );");
					
					UnderlyingAccessor childAccessor = new UnderlyingAccessor(underlyingDataType, childProfileName.AccessorName);
					GeneratedRepGetter repGetter = new GeneratedRepGetter(childProfileName, childAccessor.AcceptsRep);
					
					docBuilder.decorateRepGetter(repGetter, (Seg) msg.getChild(i), childProfileName.AccessorName);
					
					confMsg.addMethod(repGetter);
					if (depManager.Verbose)
						System.Console.Out.WriteLine("Generating Segment: " + packageName + "." + confMsg.Name);
					
					confSegBuilder.buildClass((Seg) msg.getChild(i), underlyingDataType, childProfileName.clearNameMap());
				}
				else if (msg.getChild(i) is SegGroup)
				{
					ProfileName childProfileName = profileName.newInstance(msg.getChild(i).Name, ProfileName.PS_SEGG);
					
					// Add the member variable vector to hold them
					confMsg.addMemberVariable("private FiniteList " + childProfileName.MemberName + ";");
					confMsg.Constructor.addToBody(childProfileName.MemberName + " = new FiniteList( " + childProfileName.ClassName + ".class, hapiMessage );");
					
					System.String underlyingAccessorName = "get" + msg.MsgStructID + "_" + ConformanceSegGroupBuilder.generateSegGroupName((SegGroup) msg.getChild(i));
					UnderlyingAccessor childAccessor = new UnderlyingAccessor(underlyingDataType, underlyingAccessorName);
					GeneratedRepGetter repGetter = new GeneratedRepGetter(childProfileName, childAccessor.AcceptsRep);
					
					docBuilder.decorateRepGetter(repGetter, (SegGroup) msg.getChild(i), childProfileName.OriginalName);
					confMsg.addMethod(repGetter);
					if (depManager.Verbose)
						System.Console.Out.WriteLine("Generating SegGroup: " + packageName + "." + confMsg.Name);
					
					confSegGroupBuilder.buildClass((SegGroup) msg.getChild(i), underlyingDataType, childProfileName.clearNameMap());
				}
			}
			
			depManager.generateFile(confMsg, packageName, profileName.ClassName);
		}
Пример #3
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>This method builds a Conformance Message Class</summary>
        /// <param name="runtimeProfile">the profile which to genrate Conformance Classes for
        /// </param>
        /// <param name="depManager">the DeploymentManager
        /// </param>
        public virtual void  buildClass(RuntimeProfile runtimeProfile, DeploymentManager depManager)
        {
            this.depManager     = depManager;
            this.runtimeProfile = runtimeProfile;
            this.msg            = runtimeProfile.Message;
            this.confMsg        = new GeneratedConformanceMessage();

            ProfileName profileName = new ProfileName(msg.MsgStructID, ProfileName.PS_MSG);

            String version = Regex.Replace(runtimeProfile.getHL7Version(), "\\.", "");

            System.String underlyingDataType = "Genetibase.NuGenHL7.model." + version + ".message." + msg.MsgStructID;

            ConformanceSegmentBuilder  confSegBuilder      = new ConformanceSegmentBuilder(packageName, version, depManager);
            ConformanceSegGroupBuilder confSegGroupBuilder = new ConformanceSegGroupBuilder(packageName, version, depManager, msg.MsgStructID);
            DocumentationBuilder       docBuilder          = DocumentationBuilder.getDocumentationBuilder();

            // Add class package and imports
            confMsg.ClassPackage = packageName;
            confMsg.addClassImport("Genetibase.NuGenHL7.conf.classes.abs.*");
            confMsg.addClassImport("Genetibase.NuGenHL7.conf.classes.exceptions.*");

            // Set class properties
            confMsg.Name       = profileName.ClassName;
            confMsg.Properties = "extends AbstractConformanceContainer";

            // Decorate the class with comments
            docBuilder.decorateConformanceMessage(confMsg, runtimeProfile);
            docBuilder.decorateConstructor(confMsg.Constructor, msg.MsgType);

            // add hapi message
            confMsg.addHAPIMessage(underlyingDataType);

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

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

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

                    UnderlyingAccessor childAccessor = new UnderlyingAccessor(underlyingDataType, childProfileName.AccessorName);
                    GeneratedRepGetter repGetter     = new GeneratedRepGetter(childProfileName, childAccessor.AcceptsRep);

                    docBuilder.decorateRepGetter(repGetter, (Seg)msg.getChild(i), childProfileName.AccessorName);

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

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

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

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

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

                    confSegGroupBuilder.buildClass((SegGroup)msg.getChild(i), underlyingDataType, childProfileName.clearNameMap());
                }
            }

            depManager.generateFile(confMsg, packageName, profileName.ClassName);
        }