package cdac.medinfo.sdk.hl7282.hl7model;


import java.io.BufferedReader;
import java.io.InputStreamReader;

import cdac.medinfo.sdk.hl7282.baselibs.CNE;
import cdac.medinfo.sdk.hl7282.baselibs.CWE;
import cdac.medinfo.sdk.hl7282.baselibs.CX;
import cdac.medinfo.sdk.hl7282.baselibs.DTM;
import cdac.medinfo.sdk.hl7282.baselibs.ED;
import cdac.medinfo.sdk.hl7282.baselibs.EI;
import cdac.medinfo.sdk.hl7282.baselibs.FN;
import cdac.medinfo.sdk.hl7282.baselibs.HD;
import cdac.medinfo.sdk.hl7282.baselibs.MO;
import cdac.medinfo.sdk.hl7282.baselibs.OG;
import cdac.medinfo.sdk.hl7282.baselibs.PL;
import cdac.medinfo.sdk.hl7282.baselibs.SAD;
import cdac.medinfo.sdk.hl7282.baselibs.XAD;
import cdac.medinfo.sdk.hl7282.baselibs.XCN;
import cdac.medinfo.sdk.hl7282.baselibs.XON;
import cdac.medinfo.sdk.hl7282.baselibs.XPN;
import cdac.medinfo.sdk.hl7282.baselibs.XTN;
import cdac.medinfo.sdk.hl7282.baselibs.datatypefactory.DataTypeMapReader;
import cdac.medinfo.sdk.hl7282.baselibs.messagedictionary.MessageMapReader;
import cdac.medinfo.sdk.hl7282.baselibs.messages.Group;
import cdac.medinfo.sdk.hl7282.baselibs.messages.Message;
import cdac.medinfo.sdk.hl7282.baselibs.parserserializer.HL7Parser;
import cdac.medinfo.sdk.hl7282.baselibs.parserserializer.HL7Serializer;
import cdac.medinfo.sdk.hl7282.baselibs.segments.ACC;
import cdac.medinfo.sdk.hl7282.baselibs.segments.AL1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.ARV;
import cdac.medinfo.sdk.hl7282.baselibs.segments.DB1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.DG1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.DRG;
import cdac.medinfo.sdk.hl7282.baselibs.segments.EVN;
import cdac.medinfo.sdk.hl7282.baselibs.segments.GT1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.IN1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.IN2;
import cdac.medinfo.sdk.hl7282.baselibs.segments.IN3;
import cdac.medinfo.sdk.hl7282.baselibs.segments.MSH;
import cdac.medinfo.sdk.hl7282.baselibs.segments.NK1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.OBX;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PD1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PDA;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PID;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PR1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PV1;
import cdac.medinfo.sdk.hl7282.baselibs.segments.PV2;
import cdac.medinfo.sdk.hl7282.baselibs.segments.ROL;
import cdac.medinfo.sdk.hl7282.baselibs.segments.SFT;
import cdac.medinfo.sdk.hl7282.baselibs.segments.UAC;
import cdac.medinfo.sdk.hl7282.baselibs.segments.UB2;
import cdac.medinfo.sdk.hl7282.commoninterface.IGroup;
import cdac.medinfo.sdk.hl7282.commoninterface.ISegmentSet;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.hl7model.messages.patientadministration.ADTRecepient;
import cdac.medinfo.sdk.hl7282.hl7model.messages.patientadministration.ADT_A01;
import cdac.medinfo.sdk.hl7282.hl7net.localextension.PopulateDataType;
import cdac.medinfo.sdk.hl7282.utils.EnumDataType;
import cdac.medinfo.sdk.hl7282.utils.EnumMessageCode;
import cdac.medinfo.sdk.hl7282.utils.EnumSegments;
import cdac.medinfo.sdk.hl7282.utils.EnumTriggerEvent;
import cdac.medinfo.sdk.hl7282.utils.HL7Config;
import cdac.medinfo.sdk.hl7282.utils.HL7Constants;
import cdac.medinfo.sdk.hl7282.utils.IDataTypeMap;
import cdac.medinfo.sdk.hl7282.utils.IDataTypeMapReader;
import cdac.medinfo.sdk.hl7282.utils.IMap;

/**
 * This class tests Serialization & parsing of ADT_A01 message.
 */
public class ADT_A01_PopulateTest
{
	static IDataTypeMapReader dataTypeMapReader = DataTypeMapReader.createInstance();
	static IDataTypeMap dtmap = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_HD.getValue());
	static HD objAssigningAuthority = new HD(HL7Constants.HL7_SUBCOMPONENT,dtmap);
	static HD objAssigningFacility = new HD(HL7Constants.HL7_SUBCOMPONENT,dtmap);
	
	static IDataTypeMap dtmap1 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_CWE.getValue());
	static CWE objAssigningJurisdiction = new CWE(HL7Constants.HL7_SUBCOMPONENT,dtmap1);
	static CWE objAssigningAgencyOrDepartment = new CWE(HL7Constants.HL7_SUBCOMPONENT,dtmap1);
	static CWE objNameContext = new CWE(HL7Constants.HL7_SUBCOMPONENT,dtmap1);
	
	static IDataTypeMap dtmap2 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_FN.getValue());
	static FN objFamilyName = new FN(HL7Constants.HL7_SUBCOMPONENT,dtmap2);
	
	static DTM objEffectiveDate = new DTM(4, 24, "8#");
	static DTM objExpirationDate = new DTM(4, 24, "8#");
	
	static IDataTypeMap dtmap3 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_SAD.getValue());
	static SAD objStreetAddress = new SAD(HL7Constants.HL7_SUBCOMPONENT,dtmap3);
	
	static IDataTypeMap dtmap4 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_CWE.getValue());
	static CWE objCWE_COMPONENT = new CWE(HL7Constants.HL7_COMPONENT,dtmap4);
	
	static IDataTypeMap dtmap5 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_HD.getValue());
	static HD objHD_COMPONENT = new HD(HL7Constants.HL7_COMPONENT,dtmap5);
	
	static IDataTypeMap dtmap6 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_XPN.getValue());
	static XPN objXPN_COMPONENT = new XPN(HL7Constants.HL7_COMPONENT,dtmap6);
	
	static IDataTypeMap dtmap7 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_XTN.getValue());
	static XTN objXTN = new XTN(HL7Constants.HL7_COMPONENT,dtmap7);
	
	static IDataTypeMap dtmap8 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_CX.getValue());
	static CX objCX_COMPONENT = new CX(HL7Constants.HL7_COMPONENT,dtmap8);
	
	static IDataTypeMap dtmap9 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_XAD.getValue());
	static XAD objXAD = new XAD(HL7Constants.HL7_COMPONENT,dtmap9);
	
	static IDataTypeMap dtmap10 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_XCN.getValue());
	static XCN objXCN = new XCN(HL7Constants.HL7_COMPONENT,dtmap10);
	
	static IDataTypeMap dtmap11 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_PL.getValue());
	static PL objPL= new PL(HL7Constants.HL7_COMPONENT,dtmap11);
	
	static IDataTypeMap dtmap12 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_EI.getValue());
	static EI objEI= new EI(HL7Constants.HL7_COMPONENT,dtmap12);
	
	static IDataTypeMap dtmap17 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_EI.getValue());
	static EI objEISUB= new EI(HL7Constants.HL7_SUBCOMPONENT,dtmap17);
	
	static IDataTypeMap dtmap13 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_CNE.getValue());
	static CNE objCNE= new CNE(HL7Constants.HL7_COMPONENT,dtmap13);
	
	static IDataTypeMap dtmap18 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_CNE.getValue());
	static CNE objCNESUB= new CNE(HL7Constants.HL7_SUBCOMPONENT,dtmap18);
	
	static IDataTypeMap dtmap14 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_MO.getValue());
	static MO objMO= new MO(HL7Constants.HL7_COMPONENT,dtmap14);
	
	static IDataTypeMap dtmap15 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_MO.getValue());
	static MO objMOSUB= new MO(HL7Constants.HL7_SUBCOMPONENT,dtmap15);
	
	static IDataTypeMap dtmap16 = dataTypeMapReader.getDataTypeMap(EnumDataType.HL7_DT_XON.getValue());
	static XON objXON= new XON(HL7Constants.HL7_COMPONENT,dtmap16);
	
	public ADT_A01_PopulateTest() 
	{
		objFamilyName.setSurname("Kulkarni");
		objFamilyName.setOwnSurnamePrefix("OSP");
		
		
		objNameContext.setIdentifier("X001");
		objNameContext.setText("X-ray impression");
		objNameContext.setNameOfCodingSystem("L");
		objNameContext.setAlternateIdentifier("X002");
		objNameContext.setAlternateText("X-ray image");
		objNameContext.setNameOfAlternateCodingSystem("L");
		objNameContext.setCodingSystemVersionID("German Alpha-ID v2006");
		objNameContext.setAlternateCodingSystemVersionId("German Alpha-ID v2011");
		objNameContext.setAlternateCodingSystemOID("2.16.840.1.113883.12.2011");
		objNameContext.setAlternateValueSetOID("2.16.840.1.113883.12.0136");
		objNameContext.setCodingSystemOID("2.16.840.1.113883.12.0121");
		objNameContext.setValueSetVersionID("20170628");
		objNameContext.setValueSetOID("2.16.840.1.113883.12");
		objNameContext.setSecondAlternateValueSetVersionID("20170628");
		objNameContext.setSecondAlternateValueSetOID("2.16.840.1.113883.12.0347");
		objNameContext.setSecondAlternateText("TEXT2");
		objNameContext.setSecondAlternateIdentifier("X003");
		objNameContext.setSecondAlternateCodingSystemVersionID("ALPHAID2009");
		objNameContext.setSecondAlternateCodingSystemOID("2.16.840.1.113883.12.0147");
		objNameContext.setNameofSecondAlternateCodingSystem("L");

		objEffectiveDate.setValue("20050302");
		objExpirationDate.setValue("20050303");
		
		objAssigningAuthority.setNamespaceId("REGAD1");
		objAssigningAuthority.setUniversalId("478A0114-EBF0-7701-A023-6841FF05731A");
		objAssigningAuthority.setUniversalIdType("GUID");
		
		objAssigningFacility.setNamespaceId("REGAD1");
		objAssigningFacility.setUniversalId("478A0114-EBF0-7701-A023-6841FF05731A");
		objAssigningFacility.setUniversalIdType("GUID");

		objAssigningJurisdiction.setIdentifier("X001");
		objAssigningJurisdiction.setText("X-ray impression");
		objAssigningJurisdiction.setNameOfCodingSystem("L");
		objAssigningJurisdiction.setAlternateIdentifier("X002");
		objAssigningJurisdiction.setAlternateText("X-ray image");
		objAssigningJurisdiction.setNameOfAlternateCodingSystem("L");
		objAssigningJurisdiction.setCodingSystemVersionID("German Alpha-ID v2006");
		objAssigningJurisdiction.setAlternateCodingSystemVersionId("German Alpha-ID v2011");
		objAssigningJurisdiction.setAlternateCodingSystemOID("2.16.840.1.113883.12.2011");
		objAssigningJurisdiction.setAlternateValueSetOID("2.16.840.1.113883.12.0136");
		objAssigningJurisdiction.setCodingSystemOID("2.16.840.1.113883.12.0121");
		objAssigningJurisdiction.setValueSetVersionID("20170628");
		objAssigningJurisdiction.setValueSetOID("2.16.840.1.113883.12");
		objAssigningJurisdiction.setSecondAlternateValueSetVersionID("20170628");
		objAssigningJurisdiction.setSecondAlternateValueSetOID("2.16.840.1.113883.12.0347");
		objAssigningJurisdiction.setSecondAlternateText("TEXT2");
		objAssigningJurisdiction.setSecondAlternateIdentifier("X003");
		objAssigningJurisdiction.setSecondAlternateCodingSystemVersionID("ALPHAID2009");
		objAssigningJurisdiction.setSecondAlternateCodingSystemOID("2.16.840.1.113883.12.0147");
		objAssigningJurisdiction.setNameofSecondAlternateCodingSystem("L");
		
		objAssigningAgencyOrDepartment.setIdentifier("X001");
		objAssigningAgencyOrDepartment.setText("X-ray impression");
		objAssigningAgencyOrDepartment.setNameOfCodingSystem("L");
		objAssigningAgencyOrDepartment.setAlternateIdentifier("X002");
		objAssigningAgencyOrDepartment.setAlternateText("X-ray image");
		objAssigningAgencyOrDepartment.setNameOfAlternateCodingSystem("L");
		objAssigningAgencyOrDepartment.setCodingSystemVersionID("German Alpha-ID v2006");
		objAssigningAgencyOrDepartment.setAlternateCodingSystemVersionId("German Alpha-ID v2011");
		objAssigningAgencyOrDepartment.setAlternateCodingSystemOID("2.16.840.1.113883.12.2011");
		objAssigningAgencyOrDepartment.setAlternateValueSetOID("2.16.840.1.113883.12.0136");
		objAssigningAgencyOrDepartment.setCodingSystemOID("2.16.840.1.113883.12.0121");
		objAssigningAgencyOrDepartment.setValueSetVersionID("20170628");
		objAssigningAgencyOrDepartment.setValueSetOID("2.16.840.1.113883.12");
		objAssigningAgencyOrDepartment.setSecondAlternateValueSetVersionID("20170628");
		objAssigningAgencyOrDepartment.setSecondAlternateValueSetOID("2.16.840.1.113883.12.0347");
		objAssigningAgencyOrDepartment.setSecondAlternateText("TEXT2");
		objAssigningAgencyOrDepartment.setSecondAlternateIdentifier("X003");
		objAssigningAgencyOrDepartment.setSecondAlternateCodingSystemVersionID("ALPHAID2009");
		objAssigningAgencyOrDepartment.setSecondAlternateCodingSystemOID("2.16.840.1.113883.12.0147");
		objAssigningAgencyOrDepartment.setNameofSecondAlternateCodingSystem("L");
		
		objStreetAddress.setStreetOrMailingAddress("ISHPEMING");
		objStreetAddress.setStreetName("HOME STREET");
		objStreetAddress.setDwellingNumber("22");
		
		objCWE_COMPONENT = PopulateDataType.populateCWE(HL7Constants.HL7_COMPONENT);
		
		objHD_COMPONENT = PopulateDataType.populateHD(HL7Constants.HL7_COMPONENT);
		
		objXPN_COMPONENT = PopulateDataType.populateXPN(HL7Constants.HL7_COMPONENT);
		
		objXTN = PopulateDataType.populateXTN(HL7Constants.HL7_COMPONENT);
		
		objCX_COMPONENT = PopulateDataType.populateCX(HL7Constants.HL7_COMPONENT);
		
		objXAD = PopulateDataType.populateXAD(HL7Constants.HL7_COMPONENT);
		
		objXCN = PopulateDataType.populateXCN(HL7Constants.HL7_COMPONENT);

		objPL = PopulateDataType.populatePL(HL7Constants.HL7_COMPONENT);
		
		objEI = PopulateDataType.populateEI(HL7Constants.HL7_COMPONENT);
		
		objEISUB = PopulateDataType.populateEI(HL7Constants.HL7_SUBCOMPONENT);
		
		objCNE = PopulateDataType.populateCNE(HL7Constants.HL7_COMPONENT);
		
		objCNESUB = PopulateDataType.populateCNE(HL7Constants.HL7_SUBCOMPONENT);
		
		objMO = PopulateDataType.populateMO(HL7Constants.HL7_COMPONENT);
		
		objMOSUB = PopulateDataType.populateMO(HL7Constants.HL7_SUBCOMPONENT);
		
		objXON = PopulateDataType.populateXON(HL7Constants.HL7_COMPONENT);
	}
	
	public   static   void   main( String[] args ) 
	{ 
		//Specifying logging directory.
		//User can specify any directory where log files will be created.
		//If no path is specified then logs will be generated in user's temp directory.
		HL7Config.createInstance().enableLogging("E:\\HL7Model_Logs");

		
		ADT_A01_PopulateTest objADT_A01_Test = new ADT_A01_PopulateTest();
		objADT_A01_Test.start("A01", "ADT");
	}

	public void start(String strTriggerEvent,String strMessageCode)
	{
		HL7Serializer objHL7Serializer = null;
		
		/* 
		 * The HL7Parser parses the HL7Message and provides a SegmentSet.
		 * SegmentSet contains all segments of a HL7 Message in the same order as they appeared.
		 */
		HL7Parser objHL7Parser = null;
		ISegmentSet objSegmentSet = null;

		try
		{
			System.out.println("Enter file name to serialize populated ADT_A01:   ");
			
			InputStreamReader input = new InputStreamReader(System.in);
			BufferedReader reader = new BufferedReader(input);
			
			String strHL7File = reader.readLine();
			
			ADT_A01 objADT_A01 = (ADT_A01)new ADTRecepient().createMessage(EnumMessageCode.ADT, EnumTriggerEvent.A01);
			populateMessage(objADT_A01);
			if(objADT_A01.validate())
			{
				objSegmentSet = objADT_A01.getSegmentSet();
				objHL7Serializer = new HL7Serializer();
				objHL7Serializer.serialize(objSegmentSet,strHL7File);

				System.out.print("Message serialized successfully\n");
			}
			
			Message objMessage = (ADT_A01)new ADTRecepient().createMessage(EnumMessageCode.ADT, EnumTriggerEvent.A01);
			objHL7Parser = new HL7Parser();
			objSegmentSet = objHL7Parser.parse(strHL7File);
			if(objMessage.populate(objSegmentSet) == HL7Constants.HL7_FUNCTION_SUCCESS)
			{
				System.out.print("Message parsed successfully\n");
			}

			System.out.println("Enter file name to serialize parsed ADT_A01:   ");
			strHL7File = reader.readLine();

			Message objNewMessage = (ADT_A01)new ADTRecepient().createMessage(EnumMessageCode.ADT, EnumTriggerEvent.A01);
			populateMessage(objMessage,objNewMessage);		
			if(objNewMessage.validate())
			{
				objSegmentSet = objNewMessage.getSegmentSet();
				objHL7Serializer = new HL7Serializer();
				objHL7Serializer.serialize(objSegmentSet,strHL7File);

				System.out.print("Message serialized successfully\n");
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

	public void populateMessage(ADT_A01 objADT_A01)  
	{ 
		
		MSH objMSH = populateMSH();
		objADT_A01.setHeader(objMSH);
		
		

		//SFT Segment
		SFT objSFT = populateSFT();
		objADT_A01.addSoftwareSegment(objSFT);
		
		//UAC Segment
		UAC objUAC=populateUAC();
		objADT_A01.setUserAuthenticationCredentialSegment(objUAC);

		//EVN Segment
		EVN objEVN = populateEVN();
		objADT_A01.setEventTypeSegment(objEVN);

		//PID segment
		PID objPID = populatePID();
		objADT_A01.setPatientIdentificationSegment(objPID);

		//PD1 segment
		PD1 objPD1 = populatePD1();
		objADT_A01.setAdditinalDemographicsSegment(objPD1);
		
		//ARV Segment
		ARV objARV=populateARV();
		objADT_A01.addPatientIdentificationAccessRestrictionsSegment(objARV);

		//ROL Segment
		ROL objROL = populateROL();
		objADT_A01.addPatientIdentificationRoleSegment(objROL);

		//NK1 Segment
		NK1 objNK1 = populateNK1();
		objADT_A01.addNextOfKinOrAssociatedPartiesSegment(objNK1);

		//PV1 Segment
		PV1 objPV1 = populatePV1();
		objADT_A01.setPatientVisitSegment(objPV1);

		//PV2 Segment
		PV2 objPV2 = populatePV2();
		objADT_A01.setPatientVisitAdditionalInfoSegment(objPV2);

		//ARV Segment
		objADT_A01.addPatientIdentificationAccessRestrictionsSegment(objARV);

		//ROL Segment
		objADT_A01.addPatientVisitRoleSegment(objROL);

		//DB1 segment
		DB1 objDB1 = populateDB1();
		objADT_A01.addDisabilityInformationSegment(objDB1);

		//OBX Segment
		OBX objOBX = populateOBX();
		objADT_A01.addObservationOrResultSegment(objOBX);

		//AL1 Segment
		AL1 objAL1 = populateAL1();
		objADT_A01.addAllergyInformationSegment(objAL1);

		//DG1 Segment
		DG1 objDG1 = populateDG1();
		objADT_A01.addDiagnosisInformationSegment(objDG1);

		//DRG Segment
		DRG objDRG = populateDRG();
		objADT_A01.setDiagnosisRelatedGroupSegment(objDRG);
		
		IMap objMessageMap = MessageMapReader.createInstance().getMessageMap(EnumMessageCode.ADT, EnumTriggerEvent.A01);
		
		IMap objProcedureGroupMap = objMessageMap.getGroupMap(EnumSegments.HL7_GROUP_PROCEDURE);

		IGroup objProcedureGroup = new Group(EnumSegments.HL7_GROUP_PROCEDURE, objProcedureGroupMap);

		//PR1 Segment
		PR1 objPR1 = populatePR1();
		objProcedureGroup.addSegment(EnumSegments.HL7_SEG_PR1, objPR1);

		//ROL Segment
		objProcedureGroup.addSegment(EnumSegments.HL7_SEG_ROL_PROCEDURE, objROL);

		objADT_A01.addProcedureGroup(objProcedureGroup);

		//GT1 Segment
		GT1 objGT1 = populateGT1();
		objADT_A01.addGuarantorSegment(objGT1);
		
		IMap objInsuranceGroupMap = objMessageMap.getGroupMap(EnumSegments.HL7_GROUP_INSURANCE);

		IGroup objInsuranceGroup = new Group(EnumSegments.HL7_GROUP_INSURANCE, objInsuranceGroupMap);

		//IN1 Segment
		IN1 objIN1 = populateIN1();
		objInsuranceGroup.addSegment(EnumSegments.HL7_SEG_IN1, objIN1);

		//IN2 Segment
		IN2 objIN2 = populateIN2();
		objInsuranceGroup.addSegment(EnumSegments.HL7_SEG_IN2, objIN2);

		//IN3 Segment
		IN3 objIN3 = populateIN3();
		objInsuranceGroup.addSegment(EnumSegments.HL7_SEG_IN3, objIN3);

		//ROL Segment
		objInsuranceGroup.addSegment(EnumSegments.HL7_SEG_ROL_INSURANCE, objROL);

		objADT_A01.addInsuranceGroup(objInsuranceGroup);

		//ACC Segment
		ACC objACC = populateACC();
		objADT_A01.setAccidentInformationSegment(objACC);

		//UB2 Segment
		UB2 objUB2 = populateUB2();
		objADT_A01.setUniversalBill92InformationSegment(objUB2);

		//PDA Segment
		PDA objPDA = populatePDA();
		objADT_A01.setPatientDeathandAutopsySegment(objPDA);
	}

	public void populateMessage(Message objParsedMessage , Message objNewMessage) 
	{
		ADT_A01	objParsedADT_A01 =(ADT_A01)objParsedMessage;

		ADT_A01	objNewADT_A01 =(ADT_A01)objNewMessage;

		MSH objNewMSH = populateMSH(objParsedADT_A01.getHeader());
		objNewADT_A01.setHeader(objNewMSH);

	//SFT Segment
		ISingleCollection<SFT> objSFTCollection = objParsedADT_A01.getSoftwareSegments();
		if(objSFTCollection.size() != 0)
		{
			for(SFT objSFT : objSFTCollection)
			{
				objNewADT_A01.addSoftwareSegment(populateSFT(objSFT));
			}
		}
		
		//UAC Segment
		UAC objUAC = populateUAC(objParsedADT_A01.getUserAuthenticationCredentialSegment());
		objNewADT_A01.setUserAuthenticationCredentialSegment(objUAC);

		//EVN Segment
		EVN objEVN = populateEVN(objParsedADT_A01.getEventTypeSegment());
		objNewADT_A01.setEventTypeSegment(objEVN);

		//PID segment
		PID objPID = populatePID(objParsedADT_A01.getPatientIdentificationSegment());
		objNewADT_A01.setPatientIdentificationSegment(objPID);

		//PD1 segment
		PD1 objPD1 = populatePD1(objParsedADT_A01.getAdditinalDemographicsSegment());
		objNewADT_A01.setAdditinalDemographicsSegment(objPD1);
		
		//ARV Segment
		ISingleCollection<ARV> objARVCollection=objParsedADT_A01.getPatientIdentificationAccessRestrictionsSegments();
		if(objARVCollection.size()!=0)
		{
			for (ARV objARV : objARVCollection)
			{
				objNewADT_A01.addPatientIdentificationAccessRestrictionsSegment(populateARV(objARV));
			}
		}

		//ROL Segment
		ISingleCollection<ROL> objROLCollection = objParsedADT_A01.getPatientIdentificationRoleSegments();
		if(objROLCollection.size() != 0)
		{
			for(ROL objROL : objROLCollection)
			{
				objNewADT_A01.addPatientIdentificationRoleSegment(populateROL(objROL));
			}
		}

		//NK1 Segment
		ISingleCollection<NK1> objNK1Collection = objParsedADT_A01.getNextOfKinOrAssociatedPartiesSegments();
		if(objNK1Collection.size() != 0)
		{
			for(NK1 objNK1 : objNK1Collection)
			{
				objNewADT_A01.addNextOfKinOrAssociatedPartiesSegment(populateNK1(objNK1));
			}
		}

		//PV1 Segment
		PV1 objPV1 = populatePV1(objParsedADT_A01.getPatientVisitSegment());
		objNewADT_A01.setPatientVisitSegment(objPV1);

		//PV2 Segment
		PV2 objPV2 = populatePV2(objParsedADT_A01.getPatientVisitAdditionalInfoSegment());
		objNewADT_A01.setPatientVisitAdditionalInfoSegment(objPV2);

		//ARV Segment
		objARVCollection=objParsedADT_A01.getPatientVisitAccessRestrictionsSegments();
		if(objARVCollection.size()!=0)
		{
			for (ARV objARV : objARVCollection) {
				objNewADT_A01.addPatientVisitAccessRestrictionsSegment(populateARV(objARV));
			}
		}
		
		//ROL Segment
		objROLCollection = objParsedADT_A01.getPatientVisitRoleSegments();
		if(objROLCollection.size() != 0)
		{
			for(ROL objROL : objROLCollection)
			{
				objNewADT_A01.addPatientVisitRoleSegment(populateROL(objROL));
			}
		}

		//DB1 segment
		ISingleCollection<DB1> objDB1Collection = objParsedADT_A01.getDisabilityInformationSegments();
		if(objDB1Collection.size() != 0)
		{
			for(DB1 objDB1 : objDB1Collection)
			{
				objNewADT_A01.addDisabilityInformationSegment(populateDB1(objDB1));
			}
		}

		//OBX Segment
		ISingleCollection<OBX> objOBXCollection = objParsedADT_A01.getObservationOrResultSegments();
		if(objOBXCollection.size() != 0)
		{
			for(OBX objOBX : objOBXCollection)
			{
				objNewADT_A01.addObservationOrResultSegment(populateOBX(objOBX));
			}
		}

		//AL1 Segment
		ISingleCollection<AL1> objAL1Collection = objParsedADT_A01.getAllergyInformationSegments();
		if(objAL1Collection.size() != 0)
		{
			for(AL1 objAL1 : objAL1Collection)
			{
				objNewADT_A01.addAllergyInformationSegment(populateAL1(objAL1));
			}
		}

		//DG1 Segment
		ISingleCollection<DG1> objDG1Collection = objParsedADT_A01.getDiagnosisInformationSegments();
		if(objDG1Collection.size() != 0)
		{
			for(DG1 objDG1 : objDG1Collection)
			{
				objNewADT_A01.addDiagnosisInformationSegment(populateDG1(objDG1));
			}
		}

		//DRG Segment
		DRG objDRG = populateDRG(objParsedADT_A01.getDiagnosisRelatedGroupSegment());
		objNewADT_A01.setDiagnosisRelatedGroupSegment(objDRG);
		
		IMap objMessageMap = MessageMapReader.createInstance().getMessageMap(EnumMessageCode.ADT, EnumTriggerEvent.A01);
		
		IMap objProcedureGroupMap = objMessageMap.getGroupMap(EnumSegments.HL7_GROUP_PROCEDURE);

		//Procedure Group
		IGroup objProcedureGroup = new Group(EnumSegments.HL7_GROUP_PROCEDURE, objProcedureGroupMap);

		objProcedureGroup.addSegment(EnumSegments.HL7_SEG_PR1,populatePR1((PR1)objParsedADT_A01.getProcedureGroups().elementAt(0).getSegment(EnumSegments.HL7_SEG_PR1).elementAt(0)));

		objProcedureGroup.addSegment(EnumSegments.HL7_SEG_ROL_PROCEDURE,populateROL((ROL)objParsedADT_A01.getProcedureGroups().elementAt(0).getSegment(EnumSegments.HL7_SEG_ROL_PROCEDURE).elementAt(0)));

		objNewADT_A01.addProcedureGroup(objProcedureGroup);

		//GT1 Segment
		ISingleCollection<GT1> objGT1Collection = objParsedADT_A01.getGuarantorSegments();
		if(objGT1Collection.size() != 0)
		{
			for(GT1 objGT1 : objGT1Collection)
			{
				objNewADT_A01.addGuarantorSegment(populateGT1(objGT1));
			}
		}
		
		IMap objInsuranceGroupMap = objMessageMap.getGroupMap(EnumSegments.HL7_GROUP_INSURANCE);

		//Insurance Group
		IGroup objInsuranceGroup = new Group(EnumSegments.HL7_GROUP_INSURANCE, objInsuranceGroupMap);

		objInsuranceGroup.addSegment(EnumSegments.HL7_SEG_IN1,populateIN1((IN1)objParsedADT_A01.getInsuranceGroups().elementAt(0).getSegment(EnumSegments.HL7_SEG_IN1).elementAt(0)));

		objInsuranceGroup.addSegment(EnumSegments.HL7_SEG_IN2,populateIN2((IN2)objParsedADT_A01.getInsuranceGroups().elementAt(0).getSegment(EnumSegments.HL7_SEG_IN2).elementAt(0)));

		objInsuranceGroup.addSegment(EnumSegments.HL7_SEG_IN3,populateIN3((IN3)objParsedADT_A01.getInsuranceGroups().elementAt(0).getSegment(EnumSegments.HL7_SEG_IN3).elementAt(0)));

		objInsuranceGroup.addSegment(EnumSegments.HL7_SEG_ROL_INSURANCE,populateROL((ROL)objParsedADT_A01.getInsuranceGroups().elementAt(0).getSegment(EnumSegments.HL7_SEG_ROL_INSURANCE).elementAt(0)));

		objNewADT_A01.addInsuranceGroup(objInsuranceGroup);

		//ACC Segment
		ACC objACC = populateACC(objParsedADT_A01.getAccidentInformationSegment());
		objNewADT_A01.setAccidentInformationSegment(objACC);


		//UB2 Segment
		UB2 objUB2 = populateUB2(objParsedADT_A01.getUniversalBill92InformationSegment());
		objNewADT_A01.setUniversalBill92InformationSegment(objUB2);

		//PDA Segment
		PDA objPDA = populatePDA(objParsedADT_A01.getPatientDeathandAutopsySegment());
		objNewADT_A01.setPatientDeathandAutopsySegment(objPDA);
	}

	private MSH populateMSH()
	{
		
		MSH objMSH = new MSH();
		objMSH.setFieldSeparator('|');//ST
		objMSH.setEncodingChars('^','&','~','\\','#');//ST
		objMSH.setDateTimeOfMessage("20000320");//TS
		objMSH.setMessageType("ADT","A01","ADT_A01");
		objMSH.setMessageControlID("MSG0001");//ST
		objMSH.setProcessingID("T", "T");//PT
		objMSH.setVersionID("2.8.2", null, null);//VID
		objMSH.setSequenceNumber("123");//NM
		objMSH.setContinuationPointer("ContinuationPointer");//ST
		objMSH.setAcceptAcknowledgmentType("AL");//ID
		objMSH.setApplicationAcknowledgmentType("AL");//ID
		objMSH.addCharacterSet("ASCII");//ID
		objMSH.setAlternateCharacterSetHandlingScheme("ISO 2022-1994");//ID
		return objMSH;
	}

	private MSH populateMSH(MSH objMSH)
	{
		MSH objNewMSH = new MSH();
		objNewMSH.setFieldSeparator(objMSH.getFieldSeparator());//ST
		objNewMSH.setEncodingChars(objMSH.getEncodingChar());//ST
		objNewMSH.setDateTimeOfMessage(objMSH.getDateTimeOfMessage());//TS
		objNewMSH.setMessageType(objMSH.getMessageType());
		objNewMSH.setMessageControlID(objMSH.getMessageControlID());//ST
		objNewMSH.setProcessingID(objMSH.getProcessingID());//PT
		objNewMSH.setVersionID(objMSH.getVersionID());//VID
		objNewMSH.setSequenceNumber(objMSH.getSequenceNumber());//NM
		objNewMSH.setContinuationPointer(objMSH.getContinuationPointer());//ST
		objNewMSH.setAcceptAcknowledgmentType(objMSH.getAcceptAcknowledgmentType());//ID
		objNewMSH.setApplicationAcknowledgmentType(objMSH.getApplicationAcknowledgmentType());//ID
		objNewMSH.setCharacterSet(objMSH.getCharacterSet());//ID
		objNewMSH.setAlternateCharacterSetHandlingScheme(objMSH.getAlternateCharacterSetHandlingScheme());//ID
		return objNewMSH;
	}

	/**
	 * populates SFT Segment
	 * @return SFT
	 */
	public  SFT populateSFT()
	{
		//SFT segment
		SFT objSFT = new SFT();
		objSFT.setSoftwareVendorOrganization(PopulateDataType.populateXON(HL7Constants.HL7_COMPONENT));
		objSFT.setSoftwareCertifiedVersionOrReleaseNO("AFR-093232");
		objSFT.setSoftwareProductName("ZIRCON");
		objSFT.setSoftwareBinaryId("100110111");
		return objSFT;
	}

	/**
	 * populates SFT Segment
	 * @return SFT
	 */
	public  SFT populateSFT(SFT objTempSFT)
	{
		//SFT segment
		SFT objSFT = new SFT();
		objSFT.setSoftwareVendorOrganization(objTempSFT.getSoftwareVendorOrganization());//XON
		objSFT.setSoftwareCertifiedVersionOrReleaseNO(objTempSFT.getSoftwareCertifiedVersionOrReleaseNO());
		objSFT.setSoftwareProductName(objTempSFT.getSoftwareProductName());
		objSFT.setSoftwareBinaryId(objTempSFT.getSoftwareBinaryId());
		return objSFT;
	}
	
	/**
	 * Populate UAC Segment
	 * @return UAC
	 */
	public UAC populateUAC()
	{
		ED objED = PopulateDataType.populateED(HL7Constants.HL7_COMPONENT);
		
		UAC objUAC=new UAC();
		objUAC.setUserAuthenticationCredential(objED);
		objUAC.setUserAuthenticationCredentialTypeCode(PopulateDataType.populateCWE(HL7Constants.HL7_COMPONENT));
		return objUAC;
	}
	/**
	 * Populate UAC Segment
	 * @return UAC 
	 */
	public UAC populateUAC(UAC objTempUAC)
	{
		UAC objUAC=new UAC();
		objUAC.setUserAuthenticationCredential(objTempUAC.getUserAuthenticationCredential());
		objUAC.setUserAuthenticationCredentialTypeCode(objTempUAC.getUserAuthenticationCredentialTypeCode());
		
		return objUAC;
	}
	

	/**
	 * populates EVN Segment
	 * @return EVN
	 */
	public EVN populateEVN()
	{
		XCN objXCN = PopulateDataType.populateXCN(HL7Constants.HL7_COMPONENT);
		
		//EVN segment	
		EVN objEVN = new EVN();
		objEVN.setRecordedDateTime("20110202");//TS
		objEVN.setDateTimePlannedEvent("20110202");//TS
		objEVN.setEventReasonCode(PopulateDataType.populateCWE(HL7Constants.HL7_COMPONENT));//IS
		objEVN.addOperatorID(objXCN);//XCN
		objEVN.setEventOccurred("20110202");//TS
		objEVN.setEventFacility("REGAD1", "UI1","DNS");//HD
		return objEVN;
	}

	/**
	 /** populates EVN Segment
	 * @return EVN
	 */ 
	public EVN populateEVN(EVN objTempEVN)
	{
		//EVN segment
		EVN objEVN = new EVN();
		objEVN.setRecordedDateTime(objTempEVN.getRecordedDateTime());//TS
		objEVN.setDateTimePlannedEvent(objTempEVN.getDateTimePlannedEvent());//TS
		objEVN.setEventReasonCode(objTempEVN.getEventReasonCode());//IS
		if(objTempEVN.getOperatorID().size() != 0)
			objEVN.setOperatorID(objTempEVN.getOperatorID());//XCN
		objEVN.setEventOccurred(objTempEVN.getEventOccurred());//TS
		objEVN.setEventFacility(objTempEVN.getEventFacility());//HD
		return objEVN;
	}
	
	/**
	 * populates PID Segment
	 * @return PID
	 */
	public PID populatePID()
	{
		XPN objXPN = PopulateDataType.populateXPN(HL7Constants.HL7_COMPONENT);
		CWE objCWE = PopulateDataType.populateCWE(HL7Constants.HL7_COMPONENT);
		//PID Segment
		PID objPID = new PID();
		objPID.setSetID_PID("5");
		objPID.addPatientIdentifierList(PopulateDataType.populateCX(HL7Constants.HL7_COMPONENT));//CX
		objPID.addPatientName(PopulateDataType.populateXPN(HL7Constants.HL7_COMPONENT));//XPN
		objPID.addPatientName(objXPN);
		objPID.addMotherMaidenName(objXPN);//XPN
		objPID.setDateTimeOfBirth("20040304");
		objPID.setAdministrativeSex(objCWE);
		objPID.addRace(objCWE);
		
		return objPID;
	}

	/**
	 /** populates PID Segment
	 * @return PID
	 */ 
	public PID populatePID(PID objTempPID)
	{
		//PID Segment
		PID objPID = new PID();
		objPID.setSetID_PID(objTempPID.getSetID_PID());
		if(objTempPID.getPatientIdentifierList().size() != 0)
			objPID.setPatientIdentifierList(objTempPID.getPatientIdentifierList());//CX
		if(objTempPID.getPatientName().size() != 0)
			objPID.setPatientName(objTempPID.getPatientName());//XPN
		if(objTempPID.getMotherMaidenName().size() != 0)
			objPID.setMotherMaidenName(objTempPID.getMotherMaidenName());//XPN
		objPID.setDateTimeOfBirth(objTempPID.getDateTimeOfBirth());
		objPID.setAdministrativeSex(objTempPID.getAdministrativeSex());
		if(objTempPID.getRace().size() != 0)
			objPID.setRace(objTempPID.getRace());
		
		return objPID;
	}

	/**
	 * populates PD1 Segment
	 * @return PD1
	 */
	public PD1 populatePD1()
	{

		//PD1 Segment
		PD1 objPD1 = new PD1();
		objPD1.addLivingDependency(objCWE_COMPONENT);//IS
		objPD1.setLivingArrangement(objCWE_COMPONENT);//IS
		objPD1.addPatientPrimaryFacility(PopulateDataType.populateXON(HL7Constants.HL7_COMPONENT));
		objPD1.setStudentIndicator(objCWE_COMPONENT);//IS
		objPD1.setHandicap(objCWE_COMPONENT);//IS
		objPD1.setLivingWillCode(objCWE_COMPONENT);//IS
		objPD1.setOrganDonorCode(objCWE_COMPONENT);//IS
		objPD1.setSeparateBill("Y");//ID
		objPD1.addDuplicatePatient(objCX_COMPONENT);
		objPD1.setPublicityCode(objCWE_COMPONENT);//CE
		objPD1.setProtectionIndicator("Y");//ID
		objPD1.setProtectionIEDate("19850212");//DT
		
		return objPD1;
	}
	/**
	 /** populates PD1 Segment
	 * @return PD1
	 */ 
	public PD1 populatePD1(PD1 objTempPD1)
	{
		//PD1 Segment
		PD1 objPD1 = new PD1();
		if(objTempPD1.getLivingDependency().size() != 0)
			objPD1.setLivingDependency(objTempPD1.getLivingDependency());//IS
		objPD1.setLivingArrangement(objTempPD1.getLivingArrangement());//IS
		if(objTempPD1.getPatientPrimaryFacility().size() != 0)
			objPD1.setPatientPrimaryFacility(objTempPD1.getPatientPrimaryFacility());//XON
		objPD1.setStudentIndicator(objTempPD1.getStudentIndicator());//IS
		objPD1.setHandicap(objTempPD1.getHandicap());//IS
		objPD1.setLivingWillCode(objTempPD1.getLivingWillCode());//IS
		objPD1.setOrganDonorCode(objTempPD1.getOrganDonorCode());//IS
		objPD1.setSeparateBill(objTempPD1.getSeparateBill());//ID
		if(objTempPD1.getDuplicatePatient().size() != 0)
			objPD1.setDuplicatePatient(objTempPD1.getDuplicatePatient());//CX
		objPD1.setPublicityCode(objTempPD1.getPublicityCode());//CE
		objPD1.setProtectionIndicator(objTempPD1.getProtectionIndicator());//ID
		objPD1.setProtectionIEDate(objTempPD1.getProtectionIEDate());//DT
		
		return objPD1;
	}


	/**
	 * populates ROL Segment
	 * @return ROL
	 */
	public  ROL populateROL()
	{		
		//ROL segment
		ROL objROL = new ROL();
		objROL.setRoleInstanceID("GUID", "GUID", "GUID", "GUID");
		objROL.setActionCode("AD");
		objROL.setRole_ROL(objCWE_COMPONENT);
		objROL.addRolePerson(objXCN);
		objROL.setRoleBeginDateTime("20030303");//TS
		objROL.setRoleEndDateTime("20030303");//TS
		objROL.setRoleDuration(objCWE_COMPONENT);
		objROL.setRoleActionReason(objCWE_COMPONENT);
		objROL.addProviderType(objCWE_COMPONENT);
		objROL.setOrganizationUnitType(objCWE_COMPONENT);
		objROL.addOfficeOrHome_AddressOrBirthplace(objXAD);//XAD
		objROL.addPhone(objXTN);//XTN
		objROL.setPersonsLocation(objPL);
		objROL.setOrganization(PopulateDataType.populateXON(HL7Constants.HL7_COMPONENT));
		return objROL;
	}

	/**
	 /** populates ROL Segment
	 * @return ROL
	 */ 
	public ROL populateROL(ROL objTempROL)
	{
		//ROL segment
		ROL objROL = new ROL();
		objROL.setRoleInstanceID(objTempROL.getRoleInstanceID());
		objROL.setActionCode(objTempROL.getActionCode());
		objROL.setRole_ROL(objTempROL.getRole_ROL());
		if(objTempROL.getRolePerson().size() != 0)
			objROL.setRolePerson(objTempROL.getRolePerson());
		objROL.setRoleBeginDateTime(objTempROL.getRoleBeginDateTime());//TS
		objROL.setRoleEndDateTime(objTempROL.getRoleEndDateTime());//TS
		objROL.setRoleDuration(objTempROL.getRoleDuration());
		objROL.setRoleActionReason(objTempROL.getRoleActionReason());
		if(objTempROL.getProviderType().size() != 0)
			objROL.setProviderType(objTempROL.getProviderType());
		objROL.setOrganizationUnitType(objTempROL.getOrganizationUnitType());
		if(objTempROL.getOfficeOrHome_AddrOrBirthplace().size() != 0)
			objROL.setOfficeOrHome_AddressOrBirthplace(objTempROL.getOfficeOrHome_AddrOrBirthplace());//XAD
		if(objTempROL.getPhone().size() != 0)
			objROL.setPhone(objTempROL.getPhone());//XTN
		
		objROL.setPersonsLocation(objTempROL.getPersonsLocation());
		objROL.setOrganization(objTempROL.getOrganization());
		return objROL;
	}

	/**
	 * populates NK1 Segment
	 * @return NK1
	 */
	public  NK1 populateNK1()
	{
	
		//NK1 segment
		NK1 objNK1 = new NK1();
		objNK1.setSetIDNK1("8");
		objNK1.addName(objXPN_COMPONENT);
		objNK1.setRelationship(objCWE_COMPONENT);
		objNK1.addAddress(objXAD);
		objNK1.addPhoneNumber(objXTN);
		objNK1.addBusinessPhoneNumber(objXTN);
		objNK1.setContactRole(objCWE_COMPONENT);
		objNK1.setStartDate("20060304");
		objNK1.setEndDate("20060304");
		objNK1.setNextOfKinAssociatedPartiesJobTitle("PartiesJobTitle");
		objNK1.setNextOfKinAssociatedPartiesJobCodeClass(objAssigningAgencyOrDepartment, objAssigningAgencyOrDepartment, "JDT");//JCC
		objNK1.setNextOfKinAssociatedPartiesEmployeeNumber(objCX_COMPONENT);
		objNK1.addOrganizationNameNK1(PopulateDataType.populateXON(HL7Constants.HL7_COMPONENT));
		
		return objNK1;
	}

	/**
	 * populates NK1 Segment
	 * @return NK1
	 */
	public  NK1 populateNK1(NK1 objTempNK1)
	{
		//NK1 segment
		NK1 objNK1 = new NK1();
		objNK1.setSetIDNK1(objTempNK1.getSetIDNK1());
		objNK1.setName(objTempNK1.getNameOFNextKin());//XPN
		objNK1.setRelationship(objTempNK1.getRelationship());
		objNK1.setAddress(objTempNK1.getAddress());//XAD
		objNK1.setPhoneNumber(objTempNK1.getPhoneNumber());//XTN
		objNK1.setBusinessPhoneNumber(objTempNK1.getBusinessPhoneNumber());//XTN
		objNK1.setContactRole(objTempNK1.getContactRole());
		objNK1.setStartDate(objTempNK1.getStartDate());
		objNK1.setEndDate(objTempNK1.getEndDate());
		objNK1.setNextOfKinAssociatedPartiesJobTitle(objTempNK1.getNextOfKinAssociatedPartiesJobTitle());
		objNK1.setNextOfKinAssociatedPartiesJobCodeClass(objTempNK1.getNextOfKinAssociatedPartiesJobCodeClass());//JCC
		objNK1.setNextOfKinAssociatedPartiesEmployeeNumber(objTempNK1.getNextOfKinAssociatedPartiesEmployeeNumber());//CX
		objNK1.setOrganizationNameNK1(objTempNK1.getOrganizationNameNK1());//XON
		
		return objNK1;
	}
	
	/**
	 * populates PV1 Segment
	 * @return PV1
	 */
	public  PV1 populatePV1()
	{
		
		
		//PV1 segment
		PV1 objPV1 = new PV1();
		objPV1.setSetID("3");
		objPV1.setPatientClass(objCWE_COMPONENT);
		objPV1.setPatientClass(objCWE_COMPONENT);
		objPV1.setAssignedPatientLocation(objPL);
		objPV1.setAdmissionType(objCWE_COMPONENT);
		objPV1.setPreAdmitNumber(objCX_COMPONENT);
		objPV1.setPriorPatientLocation(objPL);
		objPV1.addAttendingDoctor(objXCN);
		objPV1.addReferringDoctor(objXCN);
		objPV1.addConsultingDoctor(objXCN);
		objPV1.setHospitalService(objCWE_COMPONENT);
		objPV1.setTemporaryLocation(objPL);
		objPV1.setPreAdmitTestIndicator(objCWE_COMPONENT);
		objPV1.setReAdmissionIndicator(objCWE_COMPONENT);
		objPV1.setAdmitSource(objCWE_COMPONENT);
		objPV1.addAmbulatoryStatus(objCWE_COMPONENT);
		objPV1.setVipIndicator(objCWE_COMPONENT);
		
		return objPV1;
	}

	/**
	 * populates PV1 Segment
	 * @return PV1
	 */
	public  PV1 populatePV1(PV1 objTempPV1)
	{
		//PV1 segment
		PV1 objPV1 = new PV1();
		objPV1.setSetID(objTempPV1.getSetID());
		objPV1.setPatientClass(objTempPV1.getPatientClass());
		objPV1.setAssignedPatientLocation(objTempPV1.getAssignedPatientLocation());//PL
		objPV1.setAdmissionType(objTempPV1.getAdmissionType());
		objPV1.setPreAdmitNumber(objTempPV1.getPreAdmitNumber());//CX
		objPV1.setPriorPatientLocation(objTempPV1.getPriorPatientLocation());//PL
		if(objTempPV1.getAttendingDoctor().size() != 0)
			objPV1.setAttendingDoctor(objTempPV1.getAttendingDoctor());//XCN
		if(objTempPV1.getReferringDoctor().size() != 0)
			objPV1.setReferringDoctor(objTempPV1.getReferringDoctor());//XCN
		if(objTempPV1.getConsultingDoctor().size() != 0)
			objPV1.setConsultingDoctor(objTempPV1.getConsultingDoctor());//XCN
		objPV1.setHospitalService(objTempPV1.getHospitalService());
		objPV1.setTemporaryLocation(objTempPV1.getTemporaryLocation());//PL
		objPV1.setPreAdmitTestIndicator(objTempPV1.getPreAdmitTestIndicator());
		objPV1.setReAdmissionIndicator(objTempPV1.getReAdmissionIndicator());
		objPV1.setAdmitSource(objTempPV1.getAdmitSource());
		if(objTempPV1.getAmbulatoryStatus().size() != 0)
			objPV1.setAmbulatoryStatus(objTempPV1.getAmbulatoryStatus());
		objPV1.setVipIndicator(objTempPV1.getVipIndicator());
		
		return objPV1;
	}

	/**
	 * populates PV2 Segment
	 * @return PV2
	 */
	public  PV2 populatePV2()
	{
		
		PV2 objPV2 = new PV2();
		objPV2.setPriorPendingLocation(PopulateDataType.populatePL(HL7Constants.HL7_COMPONENT));
		objPV2.setAccomodationCode(objCWE_COMPONENT);
		objPV2.setAdmitReason(objCWE_COMPONENT);
		objPV2.setTransferReason(objCWE_COMPONENT);
		objPV2.addPatientValuables("PatientValuables");
		objPV2.setPatientValusblesLocation("strPatientValuab");
		objPV2.addVisitUserCode(objCWE_COMPONENT);
		objPV2.setExpectedAdmitDateOrTime("20030303");//TS
		objPV2.setExpectedDischargeDateOrTime("20030303");//TS
		objPV2.setEstimatedLengthOfInPatientStay("123");
		objPV2.setActualLengthOfInPatientStay("456");
		objPV2.setVisitDescription("VisitDescription");
		
		
		return objPV2;
	}

	/**
	 * populates PV2 Segment
	 * @return PV2
	 */
	public  PV2 populatePV2(PV2 objTempPV2)
	{
		//PV2 segment
		PV2 objPV2 = new PV2();
		objPV2.setPriorPendingLocation(objTempPV2.getPriorPendingLocation());//PL
		objPV2.setAccomodationCode(objTempPV2.getAccomodationCode());
		objPV2.setAdmitReason(objTempPV2.getAdmitReason());
		objPV2.setTransferReason(objTempPV2.getTransferReason());
		if(objTempPV2.getPatientValuables().size() != 0)
			objPV2.setPatientValuables(objTempPV2.getPatientValuables());
		objPV2.setPatientValusblesLocation(objTempPV2.getPatientValusblesLocation());
		if(objTempPV2.getVisitUserCode().size() != 0)
			objPV2.setVisitUserCode(objTempPV2.getVisitUserCode());
		objPV2.setExpectedAdmitDateOrTime(objTempPV2.getExpectedAdmitDateOrTime());//TS
		objPV2.setExpectedDischargeDateOrTime(objTempPV2.getExpectedDischargeDateOrTime());//TS
		objPV2.setEstimatedLengthOfInPatientStay(objTempPV2.getEstimatedLengthOfInPatientStay());
		objPV2.setActualLengthOfInPatientStay(objTempPV2.getActualLengthOfInPatientStay());
		objPV2.setVisitDescription(objTempPV2.getVisitDescription());
	
		return objPV2;
	}

	/**
	 * populates DB1 Segment
	 * @return DB1
	 */
	public  DB1 populateDB1()
	{
		
		//DB1 segment
		DB1 objDB1 = new DB1();
		objDB1.setSetID_DB1("6");
		objDB1.setDisabledPersonCode(objCWE_COMPONENT);
		objDB1.addDisabledPersonIdentifier(objCX_COMPONENT);
		objDB1.setDisabledIndicator("Y");
		objDB1.setDisabilityStartDate("20050202");
		objDB1.setDisabilityEndDate("20050202");
		objDB1.setDisabilityReturnToWorkDate("20050202");
		objDB1.setDisabilityUnableToWorkDate("20050202");
		return objDB1;
	}

	/**
	 * populates DB1 Segment
	 * @return DB1
	 */
	public  DB1 populateDB1(DB1 objTempDB1)
	{
		//DB1 segment
		DB1 objDB1 = new DB1();
		objDB1.setSetID_DB1(objTempDB1.getSetID_DB1());
		objDB1.setDisabledPersonCode(objTempDB1.getDisabledPersonCode());
		if(objTempDB1.getDisabledPersonIdentifier().size() != 0)
			objDB1.setDisabledPersonIdentifier(objTempDB1.getDisabledPersonIdentifier());//CX
		objDB1.setDisabledIndicator(objTempDB1.getDisabledIndicator());
		objDB1.setDisabilityStartDate(objTempDB1.getDisabilityStartDate());
		objDB1.setDisabilityEndDate(objTempDB1.getDisabilityEndDate());
		objDB1.setDisabilityReturnToWorkDate(objTempDB1.getDisabilityReturnToWorkDate());
		objDB1.setDisabilityUnableToWorkDate(objTempDB1.getDisabilityUnableToWorkDate());
		return objDB1;
	}

	/**
	 * populates OBX Segment
	 * @return OBX
	 */
	public  OBX populateOBX()
	{	
		

		//OBX segment
		OBX objOBX = new OBX();
		OG objOG = PopulateDataType.populateOG(HL7Constants.HL7_COMPONENT);
		objOBX.setSetID_OBX("1234");
		objOBX.setObservationIdentifier(objCWE_COMPONENT);
		objOBX.setObservationSubID(objOG);
		objOBX.addObservationValue(objCWE_COMPONENT);
		objOBX.setUnits(objCWE_COMPONENT);
		objOBX.setReferencesRange("References Range");
		objOBX.addAbnormalFlags(objCWE_COMPONENT);
		objOBX.setProbability("1");
		objOBX.addNatureOfAbnormalTest("SP");
		objOBX.setObservationResultStatus("U");
		objOBX.setEffectiveDateOfReferenceRange("20030303");//TS
		objOBX.setUserDefinedAccessChecks("user_defined");
		objOBX.setDtTimeOfObservation("20030303");//TS
		objOBX.setProducersID(objCWE_COMPONENT);
		objOBX.addResponsibleObserver(objXCN);
		objOBX.addObservationMethod(objCWE_COMPONENT);
		objOBX.addEquipmentInstanceIdentifier("En", "NA", "Un Id", "x500");
		objOBX.setDtTimeOfAnalysis("20030303");//TS
		objOBX.addObservationSite(objCWE_COMPONENT);
		objOBX.setObservationInstanceIdentifier("EID", "NI", "UI", "DNS");	
		objOBX.setMoodCode(objCNE);
		objOBX.setPerformingOrganizationName(PopulateDataType.populateXON(HL7Constants.HL7_COMPONENT));
		objOBX.setPerformingOrganizationAddress(objXAD);
		objOBX.setPerformingOrganizationMedicalDirector(objXCN);
		objOBX.setRootCause(objCWE_COMPONENT);
		objOBX.setLocalProcessControl(objCWE_COMPONENT);

		return objOBX;
	}

	
	/**
	 * populates OBX Segment
	 * @return OBX
	 */
	public  OBX populateOBX(OBX objTempOBX)
	{	
		//OBX segment
		OBX objOBX = new OBX();
		objOBX.setSetID_OBX(objTempOBX.getSetID_OBX());
		objOBX.setValueType(objTempOBX.getValueType());
		objOBX.setObservationIdentifier(objTempOBX.getObservationIdentifier());
		objOBX.setObservationSubID(objTempOBX.getObservationSubID());
		if(objTempOBX.getObservationValue().size() != 0)
			objOBX.setObservationValue(objTempOBX.getObservationValue());
		objOBX.setUnits(objTempOBX.getUnits());
		objOBX.setReferencesRange(objTempOBX.getReferencesRange());
		if(objTempOBX.getAbnormalFlags().size() != 0)
			objOBX.setAbnormalFlags(objTempOBX.getAbnormalFlags());
		objOBX.setProbability(objTempOBX.getProbability());
		if(objTempOBX.getNatureOfAbnormalTest().size() != 0)
			objOBX.setNatureOfAbnormalTest(objTempOBX.getNatureOfAbnormalTest());
		objOBX.setObservationResultStatus(objTempOBX.getObservationResultStatus());
		objOBX.setEffectiveDateOfReferenceRange(objTempOBX.getEffectiveDateOfReferenceRange());//TS
		objOBX.setUserDefinedAccessChecks(objTempOBX.getUserDefinedAccessChecks());
		objOBX.setDtTimeOfObservation(objTempOBX.getDtTimeOfObservation());//TS
		objOBX.setProducersID(objTempOBX.getProducersID());
		if(objTempOBX.getResponsibleObserver().size() != 0)
			objOBX.setResponsibleObserver(objTempOBX.getResponsibleObserver());//XCN
		if(objTempOBX.getObservationMethod().size() != 0)
			objOBX.setObservationMethod(objTempOBX.getObservationMethod());
		if(objTempOBX.getEquipmentInstanceIdentifier().size() != 0)
			objOBX.setEquipmentInstanceIdentifier(objTempOBX.getEquipmentInstanceIdentifier());
		objOBX.setDtTimeOfAnalysis(objTempOBX.getDtTimeOfAnalysis());//TS
		CWE objObservationSite=new CWE();
		objOBX.addObservationSite(objObservationSite);
		objOBX.setObservationInstanceIdentifier(objTempOBX.getObservationInstanceIdentifier());
		objOBX.setMoodCode(objTempOBX.getMoodCode());
		objOBX.setPerformingOrganizationName(objTempOBX.getPerformingOrganizationName());
		objOBX.setPerformingOrganizationAddress(objTempOBX.getPerformingOrganizationAddress());
		objOBX.setPerformingOrganizationMedicalDirector(objTempOBX.getPerformingOrganizationMedicalDirector());
		objOBX.setPatientResultsReleaseCategory(objTempOBX.getPatientResultsReleaseCategory());
		objOBX.setRootCause(objTempOBX.getRootCause());
		objOBX.setLocalProcessControl(objTempOBX.getLocalProcessControl());
		objOBX.setObservationType(objTempOBX.getObservationType());
		objOBX.setObservationSubType(objTempOBX.getObservationSubType());
		return objOBX;
	}

	/**
	 * populates AL1 Segment
	 * @return AL1
	 */
	public  AL1 populateAL1()
	{		
		
		//AL1 segment
		AL1 objAL1 = new AL1();
		objAL1.setSetID_AL1("456");
		objAL1.setAllergenTypeCode(objCWE_COMPONENT);
		objAL1.setAllergenCodeMnemonicDescription(objCWE_COMPONENT);
		objAL1.setAllergySeverityCode(objCWE_COMPONENT);
		objAL1.addAllergyReactionCode("ALLERGY_REACT");
		return objAL1;
	}

	/**
	 * populates AL1 Segment
	 * @return AL1
	 */
	public  AL1 populateAL1(AL1 objTempAL1)
	{			
		//AL1 segment
		AL1 objAL1 = new AL1();
		objAL1.setSetID_AL1(objTempAL1.getSetID_AL1());
		objAL1.setAllergenTypeCode(objTempAL1.getAllergenTypeCode());
		objAL1.setAllergenCodeMnemonicDescription(objTempAL1.getAllergenCodeMnemonicDescription());
		objAL1.setAllergySeverityCode(objTempAL1.getAllergySeverityCode());
		if(objTempAL1.getAllergyReactionCode().size() != 0)
			objAL1.setAllergyReactionCode(objTempAL1.getAllergyReactionCode());
		return objAL1;
	}

	/**
	 * populates DG1 Segment
	 * @return DG1
	 */
	public  DG1 populateDG1()
	{
	
		//DG1 segment
		DG1 objDG1 = new DG1();
		objDG1.setSetID_DG1("5");
		objDG1.setDiagnosisCode_DG1(objCWE_COMPONENT);
		objDG1.setDiagnosisDateTime("20030303");//TS
		objDG1.setDiagnosisType(objCWE_COMPONENT);
		objDG1.setDiagnosisPriority("1");
		objDG1.addDiagnosingClinician(objXCN);
		objDG1.setDiagnosisClassification(objCWE_COMPONENT);//IS
		objDG1.setConfidentialIndicator("Y");
		objDG1.setAttestationDateTime("20030303");//TS
		objDG1.setDiagnosisIdentifier(PopulateDataType.populateEI(HL7Constants.HL7_COMPONENT));//EI
		objDG1.setDiagnosisActionCode("U");
		objDG1.setParentDiagnosis(PopulateDataType.populateEI(HL7Constants.HL7_COMPONENT));
		objDG1.setDRGCCLValueCode(objCWE_COMPONENT);
		objDG1.setDRGDiagnosisDeterminationStatus(objCWE_COMPONENT);
		objDG1.setPresentOnAdmissionPOAIndicator(objCWE_COMPONENT);
		return objDG1;
	}

	/**
	 * populates DG1 Segment
	 * @return DG1
	 */
	public  DG1 populateDG1(DG1 objTempDG1)
	{
		//DG1 segment
		DG1 objDG1 = new DG1();
		objDG1.setSetID_DG1(objTempDG1.getSetID_DG1());
		objDG1.setDiagnosisCode_DG1(objTempDG1.getDiagnosisCode_DG1());
		objDG1.setDiagnosisDateTime(objTempDG1.getDiagnosisDateTime());//TS
		objDG1.setDiagnosisType(objTempDG1.getDiagnosisType());
		objDG1.setDiagnosisPriority(objTempDG1.getDiagnosisPriority());
		if(objTempDG1.getDiagnosingClinician().size()!=0)
			objDG1.setDiagnosingClinician(objTempDG1.getDiagnosingClinician());//XCN
		objDG1.setDiagnosisClassification(objTempDG1.getDiagnosisClassification());//IS
		objDG1.setConfidentialIndicator(objTempDG1.getConfidentialIndicator());
		objDG1.setAttestationDateTime(objTempDG1.getAttestationDateTime());//TS
		objDG1.setDiagnosisIdentifier(objTempDG1.getDiagnosisIdentifier());//EI
		objDG1.setDiagnosisActionCode(objTempDG1.getDiagnosisActionCode());
		objDG1.setParentDiagnosis(objTempDG1.getParentDiagnosis());
		objDG1.setDRGCCLValueCode(objTempDG1.getDRGCCLValueCode());
		objDG1.setDRGGroupingUsage(objTempDG1.getDRGGroupingUsage());
		objDG1.setDRGDiagnosisDeterminationStatus(objTempDG1.getDRGDiagnosisDeterminationStatus());
		objDG1.setPresentOnAdmissionPOAIndicator(objTempDG1.getPresentOnAdmissionPOAIndicator());
		return objDG1;
	}

	/**
	 * populates DRG Segment
	 * @return DRG
	 */
	public  DRG populateDRG()
	{
		//DRG segment
		DRG objDRG = new DRG();
		objDRG.setDiagnosticRelatedGroup(objCNE);
		objDRG.setDRGAssignedDateTime("20030303");//TS
		objDRG.setDRGApprovalIndicator("Y");
		objDRG.setDRGGrouperReviewCode(objCWE_COMPONENT);
		objDRG.setOutlierType(objCWE_COMPONENT);
		objDRG.setOutlierDays("234");
		objDRG.setOutlierCost(PopulateDataType.populateCP(HL7Constants.HL7_COMPONENT));
		objDRG.setDRGPayor(objCWE_COMPONENT);
		objDRG.setOutlierReimbursement(PopulateDataType.populateCP(HL7Constants.HL7_COMPONENT));
		objDRG.setConfidentialIndicator("Y");
		objDRG.setDRGTransferType(objCWE_COMPONENT);
		objDRG.setNameOfCoder(objXPN_COMPONENT);
		objDRG.setGrouperStatus(objCWE_COMPONENT);
		objDRG.setPCCLValueCode(objCWE_COMPONENT);
		
		return objDRG;
	}

	/**
	 * populates DRG Segment
	 * @return DRG
	 */
	public  DRG populateDRG(DRG objTempDRG)
	{
		//DRG segment
		DRG objDRG = new DRG();
		objDRG.setDiagnosticRelatedGroup(objTempDRG.getDiagnosticRelatedGroup());
		objDRG.setDRGAssignedDateTime(objTempDRG.getDRGAssignedDateTime());//TS
		objDRG.setDRGApprovalIndicator(objTempDRG.getDRGApprovalIndicator());
		objDRG.setDRGGrouperReviewCode(objTempDRG.getDRGGrouperReviewCode());
		objDRG.setOutlierType(objTempDRG.getOutlierType());
		objDRG.setOutlierDays(objTempDRG.getOutlierDays());
		objDRG.setOutlierCost(objTempDRG.getOutlierCost());//CP
		objDRG.setDRGPayor(objTempDRG.getDRGPayor());
		objDRG.setOutlierReimbursement(objTempDRG.getOutlierReimbursement());//CP
		objDRG.setConfidentialIndicator(objTempDRG.getConfidentialIndicator());
		objDRG.setDRGTransferType(objTempDRG.getDRGTransferType());
		objDRG.setNameOfCoder(objTempDRG.getNameOfCoder());
		objDRG.setGrouperStatus(objTempDRG.getGrouperStatus());
		objDRG.setPCCLValueCode(objTempDRG.getPCCLValueCode());
		
		return objDRG;
	}



	/**
	 * populates PR1 Segment
	 * @return PR1
	 */
	public  PR1 populatePR1()
	{

		//PR1 segment
		PR1 objPR1 = new PR1();
		objPR1.setSetID_PR1("2");//SI
		objPR1.setProcedureCode(objCNE);
		objPR1.setProcedureDateTime("20040303");//TS
		objPR1.setProcedureFunctionalType(objCWE_COMPONENT);//CWE
		objPR1.setProcedureMinutes("5");//NM
		objPR1.setAnesthesiaCode(objCWE_COMPONENT);//CWE
		objPR1.setAnesthesiaMinutes("5");//NM
		objPR1.setConsentCode(objCWE_COMPONENT);//CWE
		objPR1.setProcedurePriority("0");//ID
		objPR1.setAssociatedDiagnosisCode(objCWE_COMPONENT);//CWE
		objPR1.addProcedureCodeModifier(objCNE);//CWE
		objPR1.setProcedureDRGType(objCWE_COMPONENT);//CWE
		objPR1.addTissueTypeCode(objCWE_COMPONENT);//CWE
		objPR1.setProcedureIdentifier(objEI);//EI
		objPR1.setProcedureActionCode("A");//ID
		objPR1.setDRGProcedureDeterminationStatus(objCWE_COMPONENT);
		objPR1.setDRGProcedureRelevance(objCWE_COMPONENT);
		objPR1.addTreatingOrganizationalUnit(objPL);
		objPR1.setParentProcedureID(PopulateDataType.populateEI(HL7Constants.HL7_COMPONENT));
		
		return objPR1;
	}

	/**
	 * populates PR1 Segment
	 * @return PR1
	 */
	public  PR1 populatePR1(PR1 objTempPR1)
	{
		//PR1 segment
		PR1 objPR1 = new PR1();
		objPR1.setSetID_PR1(objTempPR1.getSetID_PR1());//SI
		objPR1.setProcedureCode(objTempPR1.getProcedureCode());//CE
		objPR1.setProcedureDateTime(objTempPR1.getProcedureDateTime());//TS
		objPR1.setProcedureFunctionalType(objTempPR1.getProcedureFunctionalType());//IS
		objPR1.setProcedureMinutes(objTempPR1.getProcedureMinutes());//NM
		objPR1.setAnesthesiaCode(objTempPR1.getAnesthesiaCode());//IS
		objPR1.setAnesthesiaMinutes(objTempPR1.getAnesthesiaMinutes());//NM
		objPR1.setConsentCode(objTempPR1.getConsentCode());//CE
		objPR1.setProcedurePriority(objTempPR1.getProcedurePriority());//ID
		objPR1.setAssociatedDiagnosisCode(objTempPR1.getAssociatedDiagnosisCode());//CE
		if(objTempPR1.getProcedureCodeModifier().size() != 0)
			objPR1.setProcedureCodeModifier(objTempPR1.getProcedureCodeModifier());//IS
		objPR1.setProcedureDRGType(objTempPR1.getProcedureDRGType());//IS
		if(objTempPR1.getTissueTypeCode().size() != 0)
			objPR1.setTissueTypeCode(objTempPR1.getTissueTypeCode());//CE
		objPR1.setProcedureIdentifier(objTempPR1.getProcedureIdentifier());//EI
		objPR1.setProcedureActionCode(objTempPR1.getProcedureActionCode());//ID
		objPR1.setDRGProcedureDeterminationStatus(objTempPR1.getDRGProcedureDeterminationStatus());
		objPR1.setDRGProcedureRelevance(objTempPR1.getDRGProcedureRelevance());
		
		if(objTempPR1.getTreatingOrganizationalUnit().size() != 0)
			objPR1.setTreatingOrganizationalUnit(objTempPR1.getTreatingOrganizationalUnit());//CE
		
		objPR1.setRespiratoryWithinSurgery(objTempPR1.getRespiratoryWithinSurgery());
		objPR1.setParentProcedureID(objTempPR1.getParentProcedureID());
		return objPR1;
	}
	
	/**
	 * populates GT1 Segment
	 * @return GT1
	 */
	public  GT1 populateGT1()
	{

		//GT1 segment
		GT1 objGT1 = new GT1();
		objGT1.setSetID_GT1("1145");
		objGT1.addGuarantorNumber(objCX_COMPONENT);
		objGT1.addGuarantorName(objXPN_COMPONENT);
		objGT1.addGuarantorSpouseName(objXPN_COMPONENT);
		objGT1.addGuarantorAddress(objXAD);
		objGT1.addGuarantorPhNum_Home(objXTN);
		objGT1.addGuarantorPhNum_Business(objXTN);
		objGT1.setGuarantorDtTmOfBirth("20030303");//TS
		objGT1.setGuarantorAdminSex(objCWE_COMPONENT);
		objGT1.setGuarantorType(objCWE_COMPONENT);
		objGT1.setGuarantorRelationship(objCWE_COMPONENT);
		objGT1.setGuarantorSSN("SSN");
		objGT1.setGuarantorDate_Begin("20040202");
		objGT1.setGuarantorDate_End("20040202");
		
		return objGT1;
	}

	/**
	 * populates GT1 Segment
	 * @return GT1
	 */
	public  GT1 populateGT1(GT1 objTempGT1)
	{
		//GT1 segment
		GT1 objGT1 = new GT1();
		objGT1.setSetID_GT1(objTempGT1.getSetID_GT1());
		if(objTempGT1.getGuarantorNumber().size() != 0)
			objGT1.setGuarantorNumber(objTempGT1.getGuarantorNumber());//CX
		if(objTempGT1.getGuarantorName().size() != 0)
			objGT1.setGuarantorName(objTempGT1.getGuarantorName());//XPN
		if(objTempGT1.getGuarantorSpouseName().size() != 0)
			objGT1.setGuarantorSpouseName(objTempGT1.getGuarantorSpouseName());//XPN
		if(objTempGT1.getGuarantorAddress().size() != 0)
			objGT1.setGuarantorAddress(objTempGT1.getGuarantorAddress());//XAD
		if(objTempGT1.getGuarantorPhNum_Home().size() != 0)
			objGT1.setGuarantorPhNum_Home(objTempGT1.getGuarantorPhNum_Home());//XTN
		if(objTempGT1.getGuarantorPhNum_Business().size() != 0)
			objGT1.setGuarantorPhNum_Business(objTempGT1.getGuarantorPhNum_Business());//XTN
		objGT1.setGuarantorDtTmOfBirth(objTempGT1.getGuarantorDtTmOfBirth());//TS
		objGT1.setGuarantorAdminSex(objTempGT1.getGuarantorAdminSex());
		objGT1.setGuarantorType(objTempGT1.getGuarantorType());
		objGT1.setGuarantorRelationship(objTempGT1.getGuarantorRelationship());
		objGT1.setGuarantorSSN(objTempGT1.getGuarantorSSN());
		objGT1.setGuarantorDate_Begin(objTempGT1.getGuarantorDate_Begin());
		objGT1.setGuarantorDate_End(objTempGT1.getGuarantorDate_End());
		
		return objGT1;
	}

	/**
	 * populates IN1 Segment
	 * @return IN1
	 */
	public  IN1 populateIN1()
	{
		
		//IN1 segment
		IN1 objIN1 = new IN1();
		objIN1.setSetID_IN1("1258");
		objIN1.setHealthPlanID(objCWE_COMPONENT);
		objIN1.addInsuranceCompanyID(PopulateDataType.populateCX(HL7Constants.HL7_COMPONENT));//CX
		objIN1.addInsuranceCompanyName("CDAC", objAssigningAgencyOrDepartment, objAssigningAuthority, "AM", objAssigningAuthority, "I", "text");//XON
		objIN1.addInsuranceCompanyAddr(objXAD);//XAD
		objIN1.addInsuranceCoContactPerson(objXPN_COMPONENT);//XPN
		objIN1.addInsuranceCoPhoneNumber(objXTN);//XTN
		objIN1.setGroupNumber("group_no");
		objIN1.addGroupName("CDAC", objAssigningAgencyOrDepartment, objAssigningAuthority, "AM", objAssigningAuthority, "I", "text");//XON
		objIN1.addInsuredGroupEmpID(PopulateDataType.populateCX(HL7Constants.HL7_COMPONENT));//CX
		objIN1.addInsuredGroupEmpName("CDAC", objAssigningAgencyOrDepartment, objAssigningAuthority, "AM", objAssigningAuthority, "I", "text");//XON
		objIN1.setPlanEffectiveDate("20050202");
		objIN1.setPlanExpirationDate("20030303");
		objIN1.setAuthorizationInformation("Authorization Number", "20010209", "Source");//AUI

		return objIN1;
	}

	/**
	 * populates IN1 Segment
	 * @return IN1
	 */
	public  IN1 populateIN1(IN1 objTempIN1)
	{
		//IN1 segment
		IN1 objIN1 = new IN1();
		objIN1.setSetID_IN1(objTempIN1.getSetID_IN1());
		objIN1.setHealthPlanID(objTempIN1.getHealthPlanID());
		if(objTempIN1.getInsuranceCompanyID().size() != 0)
			objIN1.setInsuranceCompanyID(objTempIN1.getInsuranceCompanyID());//CX
		if(objTempIN1.getInsuranceCompanyName().size() != 0)
			objIN1.setInsuranceCompanyName(objTempIN1.getInsuranceCompanyName());//XON
		if(objTempIN1.getInsuranceCompanyAddr().size() != 0)
			objIN1.setInsuranceCompanyAddr(objTempIN1.getInsuranceCompanyAddr());//XAD
		if(objTempIN1.getInsuranceCoContactPerson().size() != 0)
			objIN1.setInsuranceCoContactPerson(objTempIN1.getInsuranceCoContactPerson());//XPN
		if(objTempIN1.getInsuranceCoPhoneNumber().size() != 0)
			objIN1.setInsuranceCoPhoneNumber(objTempIN1.getInsuranceCoPhoneNumber());//XTN
		objIN1.setGroupNumber(objTempIN1.getGroupNumber());
		if(objTempIN1.getGroupName().size() != 0)
			objIN1.setGroupName(objTempIN1.getGroupName());//XON
		if(objTempIN1.getInsuredGroupEmpID().size() != 0)
			objIN1.setInsuredGroupEmpID(objTempIN1.getInsuredGroupEmpID());//CX
		if(objTempIN1.getInsuredGroupEmpName().size() != 0)
			objIN1.setInsuredGroupEmpName(objTempIN1.getInsuredGroupEmpName());//XON
		objIN1.setPlanEffectiveDate(objTempIN1.getPlanEffectiveDate());
		objIN1.setPlanExpirationDate(objTempIN1.getPlanExpirationDate());
		objIN1.setAuthorizationInformation(objTempIN1.getAuthorizationInformation());//AUI
	
		return objIN1;
	}

	/**
	 * populates IN2 Segment
	 * @return IN2
	 */
	public  IN2 populateIN2()
	{
		//IN2 segment
		IN2 objIN2 = new IN2();
		objIN2.addInsuredsEmployeeId(objCX_COMPONENT);//CX
		objIN2.setInsuredsSocialSecurityNumber("ASR-9038423");
		objIN2.addInsuredsEmployersNameandID(objXCN);//XCN
		objIN2.setEmployerInformationData(objCWE_COMPONENT);
		objIN2.addMailClaimParty(objCWE_COMPONENT);
		objIN2.addMedicaidCaseName(objXPN_COMPONENT);//XPN
		objIN2.setMedicaidCaseNumber("MedicaidCaseNum");
		objIN2.addMilitarySponsorName(objXPN_COMPONENT);//XPN
		objIN2.setMilitaryIDNumber("MilitaryIDNumbe");
		objIN2.setDependentOfMilitaryRecipient(objCWE_COMPONENT);
		objIN2.setMilitaryOrganization("MilitaryOrganization");
		objIN2.setMilitaryStation("MilitaryStation");
		objIN2.setMilitaryService(objCWE_COMPONENT);
		objIN2.setMilitaryRankOrGrade(objCWE_COMPONENT);
		objIN2.setMilitaryStatus(objCWE_COMPONENT);
		objIN2.setMilitaryRetireDate("20040202");
		objIN2.setMilitaryNonAvailCertOnFile("Y");
		objIN2.setBabyCoverage("Y");
		objIN2.setCombineBabyBill("Y");
		objIN2.setBloodDeductible("B");
		
		return objIN2;
	}

	/**
	 /** populates IN2 Segment
	 * @return IN2
	 */ 
	public IN2 populateIN2(IN2 objTempIN2)
	{
		//IN2 segment
		IN2 objIN2 = new IN2();
		if(objTempIN2.getInsuredsEmployeeId().size() != 0)
			objIN2.setInsuredsEmployeeId(objTempIN2.getInsuredsEmployeeId());//CX
		objIN2.setInsuredsSocialSecurityNumber(objTempIN2.getInsuredsSocialSecurityNumber());
		if(objTempIN2.getInsuredsEmployersNameandID().size() != 0)
			objIN2.setInsuredsEmployersNameandID(objTempIN2.getInsuredsEmployersNameandID());//XCN
		objIN2.setEmployerInformationData(objTempIN2.getEmployerInformationData());
		if(objTempIN2.getMailClaimParty().size() != 0)
			objIN2.setMailClaimParty(objTempIN2.getMailClaimParty());
		objIN2.setMedicareHealthInsCardNumber(objTempIN2.getMedicareHealthInsCardNumber());
		if(objTempIN2.getMedicaidCaseName().size() != 0)
			objIN2.setMedicaidCaseName(objTempIN2.getMedicaidCaseName());//XPN
		objIN2.setMedicaidCaseNumber(objTempIN2.getMedicaidCaseNumber());
		if(objTempIN2.getMilitarySponsorName().size() != 0)
			objIN2.setMilitarySponsorName(objTempIN2.getMilitarySponsorName());//XPN
		objIN2.setMilitaryIDNumber(objTempIN2.getMilitaryIDNumber());
		objIN2.setDependentOfMilitaryRecipient(objTempIN2.getDependentOfMilitaryRecipient());
		objIN2.setMilitaryOrganization(objTempIN2.getMilitaryOrganization());
		objIN2.setMilitaryStation(objTempIN2.getMilitaryStation());
		objIN2.setMilitaryService(objTempIN2.getMilitaryService());
		objIN2.setMilitaryRankOrGrade(objTempIN2.getMilitaryRankOrGrade());
		objIN2.setMilitaryStatus(objTempIN2.getMilitaryStatus());
		objIN2.setMilitaryRetireDate(objTempIN2.getMilitaryRetireDate());
		objIN2.setMilitaryNonAvailCertOnFile(objTempIN2.getMilitaryNonAvailCertOnFile());
		objIN2.setBabyCoverage(objTempIN2.getBabyCoverage());
		objIN2.setCombineBabyBill(objTempIN2.getCombineBabyBill());
		objIN2.setBloodDeductible(objTempIN2.getBloodDeductible());
	
		return objIN2;
	}

	/**
	 * populates IN3 Segment
	 * @return IN3
	 */
	public  IN3 populateIN3()
	{
		
		//IN3 segment
		IN3 objIN3 = new IN3();
		objIN3.setSetID_IN3("5");
		objIN3.setCertificationNo(objCX_COMPONENT);//CX
		objIN3.addCertifiedBy(objXCN);//XCN
		objIN3.setCertificationRequired("N");
		objIN3.setPenalty("AT", "99", "USD");
		objIN3.setCertificationDtOrTm("20030303");//TS
		objIN3.setCertificationModifyDateOrTime("20030303");//TS
		objIN3.addOperator(objXCN);//XCN
		objIN3.setCertificationBeginDt("20020202");
		objIN3.setCertificationEndDt("20020202");
		
		return objIN3;
	}

	/**
	 /** populates IN3 Segment
	 * @return IN3
	 */ 
	public IN3 populateIN3(IN3 objTempIN3)
	{
		//IN3 segment
		IN3 objIN3 = new IN3();
		objIN3.setSetID_IN3(objTempIN3.getSetID_IN3());
		objIN3.setCertificationNo(objTempIN3.getCertificationNo());//CX
		if(objTempIN3.getCertifiedBy().size() != 0)
			objIN3.setCertifiedBy(objTempIN3.getCertifiedBy());//XCN
		objIN3.setCertificationRequired(objTempIN3.getCertificationRequired());
		objIN3.setPenalty(objTempIN3.getPenalty());
		objIN3.setCertificationDtOrTm(objTempIN3.getCertificationDtOrTm());//TS
		objIN3.setCertificationModifyDateOrTime(objTempIN3.getCertificationModifyDtOrTm());//TS
		if(objTempIN3.getOperator().size() != 0)
			objIN3.setOperator(objTempIN3.getOperator());//XCN
		objIN3.setCertificationBeginDt(objTempIN3.getCertificationBeginDt());
		objIN3.setCertificationEndDt(objTempIN3.getCertificationEndDt());
		
		return objIN3;
	}
	
	/**
	 * populates ACC Segment
	 * @return ACC
	 */
	public ACC populateACC()
	{
		//ACC segment
		ACC objACC = new ACC();
		objACC.setAccidentDateOrTime("20030303");//TS
		objACC.setAccidentCode(objCWE_COMPONENT);
		objACC.setAccidentLocation("AccidentLocation");
		objACC.setAutoAccidentState(objCWE_COMPONENT);
		objACC.setAccidentJobRelatedIndicator("Y");
		objACC.setAccidentDeathIndicator("N");
		objACC.setEnteredBy(objXCN);
		objACC.setPoliceNotifiedIndicator("Y");
		objACC.setAccidentAddress(objXAD);
		objACC.addAccidentIdentifier(PopulateDataType.populateEI(HL7Constants.HL7_COMPONENT));
		return objACC;
	}

	/**
	 /** populates ACC Segment
	 * @return ACC
	 */ 
	public ACC populateACC(ACC objTempACC)
	{
		//ACC segment
		ACC objACC = new ACC();
		objACC.setAccidentDateOrTime(objTempACC.getAccidentDateOrTime());//TS
		objACC.setAccidentCode(objTempACC.getAccidentCode());
		objACC.setAccidentLocation(objTempACC.getAccidentLocation());
		objACC.setAutoAccidentState(objTempACC.getAutoAccidentState());
		objACC.setAccidentJobRelatedIndicator(objTempACC.getAccidentJobRelatedIndicator());
		objACC.setAccidentDeathIndicator(objTempACC.getAccidentDeathIndicator());
		objACC.setEnteredBy(objTempACC.getEnteredBy());//XCN
		objACC.setAccidentDescription(objTempACC.getAccidentDescription());
		objACC.setBroughtInBy(objTempACC.getBroughtInBy());
		objACC.setPoliceNotifiedIndicator(objTempACC.getPoliceNotifiedIndicator());
		objACC.setAccidentAddress(objTempACC.getAccidentAddress());//XAD
		objACC.setDegreeOfPatientliability(objTempACC.getDegreeOfPatientliability());
		if(objTempACC.getAccidentIdentifier().size() != 0)
			objACC.setAccidentIdentifier(objTempACC.getAccidentIdentifier());
		
		return objACC;
	}

	

	/**
	 * populates UB2 Segment
	 * @return UB2
	 */
	public UB2 populateUB2()
	{			
		//UB2 segment
		UB2 objUB2 = new UB2();
		objUB2.setSetID("1");//SI
		objUB2.setCoInsuranceDays("str");//ST
		objUB2.addConditionCode(objCWE_COMPONENT);//IS
		objUB2.setCoveredDays("str");//ST
		objUB2.setNonCoveredDays("str");//ST
		objUB2.addValueAmountAndCode(objAssigningAgencyOrDepartment, objMOSUB, null, objAssigningAgencyOrDepartment);
		objUB2.addOccuranceCodeAndDate(objCNESUB, "19850212");//OCD
		objUB2.addOccuranceSpanCodeOrDates(objCNESUB, "19850212", "19850312");//OSP
		objUB2.addUniformBillingLocator2State("P");//ST
		objUB2.addUniformBillingLocator11State("P");//ST
		objUB2.setUniformBillingLocator31National("P");//ST
		objUB2.addDocumentControlNumber("P");//ST
		objUB2.addUniformBillingLocator49National("P");//ST
		objUB2.addUniformBillingLocator56State("P");//ST
		objUB2.setUniformBillingLocator57National("P");//ST
		objUB2.addUniformBillingLocator78State("P");//ST
		objUB2.setSpecialVisitCount("5");//NM
		return objUB2;
	}

	/**
	 /** populates UB2 Segment
	 * @return UB2
	 */ 
	public UB2 populateUB2(UB2 objTempUB2)
	{
		//UB2 segment
		UB2 objUB2 = new UB2();
		objUB2.setSetID(objTempUB2.getSetID());//SI
		objUB2.setCoInsuranceDays(objTempUB2.getCoInsuranceDays());//ST
		if(objTempUB2.getConditionCode().size() != 0)
			objUB2.setConditionCode(objTempUB2.getConditionCode());//IS
		objUB2.setCoveredDays(objTempUB2.getCoveredDays());//ST
		objUB2.setNonCoveredDays(objTempUB2.getNonCoveredDays());//ST
		if(objTempUB2.getValueAmountAndCode().size() != 0)
			objUB2.setValueAmountAndCode(objTempUB2.getValueAmountAndCode());//UVC
		if(objTempUB2.getOccuranceCodeAndDate().size() != 0)
			objUB2.setOccuranceCodeAndDate(objTempUB2.getOccuranceCodeAndDate());//OCD
		if(objTempUB2.getOccuranceSpanCodeOrDates().size() != 0)
			objUB2.setOccuranceSpanCodeOrDates(objTempUB2.getOccuranceSpanCodeOrDates());//OSP
		if(objTempUB2.getUniformBillingLocator2State().size() != 0)
			objUB2.setUniformBillingLocator2State(objTempUB2.getUniformBillingLocator2State());//ST
		if(objTempUB2.getUniformBillingLocator11State().size() != 0)
			objUB2.setUniformBillingLocator11State(objTempUB2.getUniformBillingLocator11State());//ST
		objUB2.setUniformBillingLocator31National(objTempUB2.getUniformBillingLocator31National());//ST
		if(objTempUB2.getDocumentControlNumber().size() != 0)
			objUB2.setDocumentControlNumber(objTempUB2.getDocumentControlNumber());//ST
		if(objTempUB2.getUniformBillingLocator49National().size() != 0)
			objUB2.setUniformBillingLocator49National(objTempUB2.getUniformBillingLocator49National());//ST
		if(objTempUB2.getUniformBillingLocator56State().size() != 0)
			objUB2.setUniformBillingLocator56State(objTempUB2.getUniformBillingLocator56State());//ST
		objUB2.setUniformBillingLocator57National(objTempUB2.getUniformBillingLocator57National());//ST
		if(objTempUB2.getUniformBillingLocator78State().size() != 0)
			objUB2.setUniformBillingLocator78State(objTempUB2.getUniformBillingLocator78State());//ST
		objUB2.setSpecialVisitCount(objTempUB2.getSpecialVisitCount());//NM
		return objUB2;
	}
	
	/**
	 * populate PDA SEGMENT
	 * @return PDA
	 */
	public PDA populatePDA()
	{	
		DTM objEffectiveDate = new DTM();
		objEffectiveDate.setValue("20050302");
		DTM objExpirationDate = new DTM();
		objExpirationDate.setValue("20040702");
		
		PDA objPDA = new PDA();
		objPDA.addDeathCauseCode(objCWE_COMPONENT);
		objPDA.setDeathLocation(objPL);
		objPDA.setDeathCertifiedIndicator("N");
		objPDA.setDeathCertificateSignedDate_Time("20030303");//TS
		objPDA.setDeathCertifiedBy(PopulateDataType.populateXCN(HL7Constants.HL7_COMPONENT));//XCN
		objPDA.setAutopsyIndicator("N");
		objPDA.setAutopsyStartAndEndDateTime(objEffectiveDate, objExpirationDate);
		objPDA.setAutopsyPerformedBy(PopulateDataType.populateXCN(HL7Constants.HL7_COMPONENT));//XCN
		objPDA.setCoronerIndicator("Y");
		return objPDA;
	}

	/**
	 /** populate PDA SEGMENT
	 * @return PDA
	 */ 
	public PDA populatePDA(PDA objTempPDA)
	{
		//PDA Segment
		PDA objPDA = new PDA();
		if(objTempPDA.getDeathCauseCode().size() != 0)
			objPDA.setDeathCauseCode(objTempPDA.getDeathCauseCode());
		objPDA.setDeathLocation(objTempPDA.getDeathLocation());//PL
		objPDA.setDeathCertifiedIndicator(objTempPDA.getDeathCertifiedIndicator());
		objPDA.setDeathCertificateSignedDate_Time(objTempPDA.getDeathCertificateSignedDateTime());//TS
		objPDA.setDeathCertifiedBy(objTempPDA.getDeathCertifiedBy());//XCN
		objPDA.setAutopsyIndicator(objTempPDA.getAutopsyIndicator());
		objPDA.setAutopsyStartAndEndDateTime(objTempPDA.getAutopsyStartAndEndDateTime());
		objPDA.setAutopsyPerformedBy(objTempPDA.getAutopsyPerformedBy());//XCN
		objPDA.setCoronerIndicator(objTempPDA.getCoronerIndicator());
		return objPDA;
	}
	
	/**
	 * Populate ARV Segment
	 * @return ARV
	 */
	public ARV populateARV()
	{
		
		ARV objARV=new ARV();
		objARV.setAccessRestrictionActionCode(objCNE);
		objARV.setAccessRestrictionDateRange(objEffectiveDate, objExpirationDate);
		objARV.setSetID("1");
		objARV.addSpecialAccessRestrictionInstructions("ACCRI");
		objARV.addAccessRestrictionReason(objCWE_COMPONENT);
		objARV.setAccessRestrictionValue(objCWE_COMPONENT);
		return objARV;
	}
	
	/**
	 * Populate ARV Segment
	 * @return ARV
	 */
	public ARV populateARV(ARV objTempARV)
	{
		
		ARV objARV=new ARV();
		objARV.setAccessRestrictionActionCode(objTempARV.getAccessRestrictionActionCode());
		objARV.setAccessRestrictionDateRange(objTempARV.getAccessRestrictionDateRange());
		objARV.setSetID(objTempARV.getSetID());
		if(objTempARV.getSpecialAccessRestrictionInstructions().size()!= 0)
			objARV.setSpecialAccessRestrictionInstructions(objTempARV.getSpecialAccessRestrictionInstructions());
		if(objTempARV.getAccessRestrictionReason().size() != 0 )
			objARV.setAccessRestrictionReason(objTempARV.getAccessRestrictionReason());
		objARV.setAccessRestrictionValue(objTempARV.getAccessRestrictionValue());
		return objARV;
	}
}
