public abstract class DICOMActiveParticipantRoleIdCodes extends CodedValueType
{
	protected DICOMActiveParticipantRoleIdCodes(String value, String meaning)
	{
		setCodeSystemName("DCM");
		setCode(value);
		setOriginalText(meaning);
	}
	/**
	 * "DCM","110150", "Application"
	 *
	 * @since Eclipse OHF IHE 0.1.0
	 */
	public static class  Application extends DICOMActiveParticipantRoleIdCodes
	{
		/**
		 * "DCM","110150", "Application"
		 */
		public Application()
		{
			super("110150", "Application");
		}
	}
	/**
	 * "DCM","110151", "Application Launcher"
	 *
	 * @since Eclipse OHF IHE 0.1.0
	 */
	public static class  ApplicationLauncher extends DICOMActiveParticipantRoleIdCodes
	{
		/**
		 * "DCM","110151", "Application Launcher"
		 */
		public ApplicationLauncher()
		{
			super("110151", "Application Launcher");
		}
	}
	
	/**
	 * "DCM","110152", "Destination Role ID"
	 *
	 * @since Eclipse OHF IHE 0.1.0
	 */
	public static class  Destination extends DICOMActiveParticipantRoleIdCodes
	{
		/**
		 * "DCM","110152", "Destination Role ID"
		 */
		public Destination()
		{
			super("110152", "Destination");
		}
	}
	/**
	 * "DCM","110153", "Source Role ID"
	 *
	 * @since Eclipse OHF IHE 0.1.0
	 */
	public static class  Source extends DICOMActiveParticipantRoleIdCodes
	{
		/**
		 * "DCM","110153", "Source Role ID"
		 */
		public Source()
		{
			super("110153", "Source");
		}
	}
	/**
	 *
	 * "DCM","110154", "Destination Media"
	 * @since Eclipse OHF IHE 0.1.0
	 */
	public static class  DestinationMedia extends DICOMActiveParticipantRoleIdCodes
	{
		/**
		 * "DCM","110154", "Destination Media"
		 */
		public DestinationMedia()
		{
			super("110154", "Destination Media");
		}
	}
	/**
	 * "DCM","110155", "Source Media"
	 *
	 * @since Eclipse OHF IHE 0.1.0
	 */
	public static class  SourceMedia extends DICOMActiveParticipantRoleIdCodes
	{
		/**
		 * "DCM",
		 */
		public SourceMedia()
		{
			super("110155", "Source Media");
		}
	}

} public abstract class IHETransactionEventTypeCodes extends CodedValueType
{
	/**
	 * Create a new IHE Event Code using a specific code and value
	 * 
	 * @param value Coded value for IHE event code
	 * @param meaning Display name for IHE event code
	 */
	protected IHETransactionEventTypeCodes(String value, String meaning)
	{
		
		setCodeSystemName("IHE Transactions");
		setCode(value);
		setOriginalText(meaning);
	}
	

	/**
	 * "IHE Transactions","ITI8","Patient Identity Feed"
	 * 
	 * @since OHT IHE 0.3.0
	 */
	public static final class PatientIdentityFeed extends IHETransactionEventTypeCodes
	{
		public PatientIdentityFeed()
		{
			super("ITI-8","Patient Identity Feed");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI8","Patient Identity Feed"
	 * 
	 * @since OHT IHE 0.3.0
	 */
	public static final class PatientIdentityFeedV3 extends IHETransactionEventTypeCodes
	{
		public PatientIdentityFeedV3()
		{
			super("ITI-44","Patient Identity Feed");
		}	
	}	
	
	/**
	 * "IHE Transactions","ITI-9","PIX Query"
	 * 
	 * @since OHT IHE 0.3.0
	 */
	public static final class PIXQuery extends IHETransactionEventTypeCodes
	{
		public PIXQuery()
		{
			super("ITI-9","PIX Query");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-45","PIX Query"
	 * 
	 * @since OHT IHE 0.3.0
	 */
	public static final class PIXQueryV3 extends IHETransactionEventTypeCodes
	{
		public PIXQueryV3()
		{
			super("ITI-45","PIX Query");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-10","PIX Update Notification"
	 * 
	 * @since OHT IHE 0.3.0
	 */
	public static final class PIXUpdateNotification extends IHETransactionEventTypeCodes
	{
		public PIXUpdateNotification()
		{
			super("ITI-10","PIX Update Notification");
		}	
	}	
	
	/**
	 * "IHE Transactions","ITI-46","PIX Update Notification"
	 * 
	 * @since OHT IHE 0.3.0
	 */
	public static final class PIXUpdateNotificationV3 extends IHETransactionEventTypeCodes
	{
		public PIXUpdateNotificationV3()
		{
			super("ITI-46","PIX Update Notification");
		}	
	}	
	
	/**
	 * "IHE Transactions","ITI-21","PDQ Query"
	 * 
	 * @since OHT IHE 0.3.0
	 */
	public static final class PatientDemographicsQuery extends IHETransactionEventTypeCodes
	{
		public PatientDemographicsQuery()
		{
			super("ITI-21","Patient Demographics Query");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-47","PDQ Query"
	 * 
	 * @since OHT IHE 0.3.0
	 */
	public static final class PatientDemographicsQueryV3 extends IHETransactionEventTypeCodes
	{
		public PatientDemographicsQueryV3()
		{
			super("ITI-47","Patient Demographics Query");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-22","PDVQ Query"
	 * 
	 * @since OHT IHE 0.3.0
	 */
	public static final class PatientDemographicsAndVisitQuery extends IHETransactionEventTypeCodes
	{
		public PatientDemographicsAndVisitQuery()
		{
			super("ITI-22","Patient Demographics and Visit Query");
		}	
	}	
	
	
	/**
	 * "IHE Transactions","ITI-14","Register Document Set"
	 *  
	 * @since OHT IHE 0.3.0
	 */
	public static final class RegisterDocumentSet extends IHETransactionEventTypeCodes
	{
		public RegisterDocumentSet()
		{
			super("ITI-14","Register Document Set");
		}	
	}	
	
	/**
	 * "IHE Transactions","ITI-15","Provide and Register Document Set"
	 * 
	 * @since OHT IHE 0.3.0
	 */
	public static final class ProvideAndRegisterDocumentSet extends IHETransactionEventTypeCodes
	{
		public ProvideAndRegisterDocumentSet()
		{
			super("ITI-15","Provide and Register Document Set");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-16","Registry SQL Query"
	 *  
	 * @since OHT IHE 0.3.0
	 */
	public static final class RegistrySQLQuery extends IHETransactionEventTypeCodes
	{
		public RegistrySQLQuery()
		{
			super("ITI-16","Registry SQL Query");
		}	
	}	

	/**
	 * "IHE Transactions","ITI-17","Retrieve Document"
	 *  
	 * @since OHT IHE 0.3.0
	 */
	public static final class RetrieveDocument extends IHETransactionEventTypeCodes
	{
		public RetrieveDocument()
		{
			super("ITI-17","Retrieve Document");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-18","Registry Stored Query"
	 *  
	 * @since OHT IHE 0.3.0
	 */
	public static final class RegistryStoredQuery extends IHETransactionEventTypeCodes
	{
		public RegistryStoredQuery()
		{
			super("ITI-18","Registry Stored Query");
		}	
	}

	/**
	 * "IHE Transactions","ITI-32","Distribute Document Set on Media"
	 *  
	 * @since OHT IHE 0.4.0
	 */
	public static final class DistributeDocumentSetOnMedia extends IHETransactionEventTypeCodes
	{
		public DistributeDocumentSetOnMedia()
		{
			super("ITI-32","Distribute Document Set on Media");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-30","Patient Identity Management"
	 *  
	 * @since OHT IHE 0.4.0
	 */
	public static final class PatientDemographicsSupplier extends IHETransactionEventTypeCodes
	{
		public PatientDemographicsSupplier()
		{
			super("ITI-30","Patient Identity Management");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-38","Cross Gateway Query"
	 *  
	 * @since OHT IHE 0.4.0
	 */
	public static final class CrossGatewayQuery extends IHETransactionEventTypeCodes
	{
		public CrossGatewayQuery()
		{
			super("ITI-38","Cross Gateway Query");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-39","Cross Gateway Retrieve"
	 *  
	 * @since OHT IHE 0.4.0
	 */
	public static final class CrossGatewayRetrieve extends IHETransactionEventTypeCodes
	{
		public CrossGatewayRetrieve()
		{
			super("ITI-39","Cross Gateway Retrieve");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-41","Provide and Register Document Set-b"
	 *  
	 * @since OHT IHE 0.3.0
	 */
	public static final class ProvideAndRegisterDocumentSetB extends IHETransactionEventTypeCodes
	{
		public ProvideAndRegisterDocumentSetB()
		{
			super("ITI-41","Provide and Register Document Set-b");
		}	
	}
	
	/**
	 * "IHE Transactions","ITI-42","Register Document Set-b"
	 *  
	 * @since OHT IHE 0.3.0
	 */
	public static final class RegisterDocumentSetB extends IHETransactionEventTypeCodes
	{
		public RegisterDocumentSetB()
		{
			super("ITI-42","Register Document Set-b");
		}	
	}	
	
	/**
	 * "IHE Transactions","ITI-43","Retrieve Document Set"
	 *  
	 * @since OHT IHE 0.3.0
	 */
	public static final class RetrieveDocumentSet extends IHETransactionEventTypeCodes
	{
		public RetrieveDocumentSet()
		{
			super("ITI-43","Retrieve Document Set");
		}	
	}	
	
	/**
	 * "IHE Transactions","ITI-48","Retrieve Value Set"
	 *  
	 * @since OHT IHE 0.4.0
	 */
	public static final class RetrieveValueSet extends IHETransactionEventTypeCodes
	{
		public RetrieveValueSet()
		{
			super("ITI-48","Retrieve Value Set");
		}	
	}	
	
	/**
	 * "IHE Transactions","ITI-55","Cross Gateway Patient Discovery"
	 *  
	 * @since OHT IHE 1.2.0
	 */
	public static final class CrossGatewayPatientDiscovery extends IHETransactionEventTypeCodes
	{
		public CrossGatewayPatientDiscovery()
		{
			super("ITI-55","Cross Gateway Patient Discovery");
		}	
	}


} public abstract class IHETransactionParticipantObjectIDTypeCodes extends CodedValueType
{
	/**
	 * Create a new IHE Event Code using a specific code and value
	 * 
	 * @param value Coded value for IHE event code
	 * @param meaning Display name for IHE event code
	 */
	protected IHETransactionParticipantObjectIDTypeCodes(String value, String meaning, String codeSystemName)
	{
		
		setCodeSystemName(codeSystemName);
		setCode(value);
		setOriginalText(meaning);
	}
	

	/**
	 *  "IHE Transactions","ITI8","Patient Identity Feed"
	 *
	 * @since OHF IHE 0.3.0
	 */
	public static final class SubmissionSet extends IHETransactionParticipantObjectIDTypeCodes
	{
		public SubmissionSet()
		{
			super("urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd", "submission set classificationNode", "IHE XDS Metadata");
		}
	}

	public static class RegistryObjectReference extends IHETransactionParticipantObjectIDTypeCodes {
		public RegistryObjectReference() {
			super("urn:ihe:iti:2017:ObjectRef", "registry object reference", "IHE XDS Metadata");
		}
	}

} public abstract class RFC3881ParticipantObjectCodes 
{
	/**
	 * Participant Object Type codes defined by RFC 3881
	 * 
	 * @author <a href="mailto:mattadav@us.ibm.com">Matthew Davis</a>
	 * @since OHT IHE Profiles 0.4.0
	 */		
	public enum RFC3881ParticipantObjectTypeCodes 
	{
		/**
		 * 1, Person
		 */
		PERSON(1),
		/**
		 * 2, System
		 */
		SYSTEM(2),
		/**
		 * 3, Organization
		 */
		ORGANIZATION(3),
		/**
		 * 4, Other
		 */
		OTHER(4);
		
		private Short code;
		
		private RFC3881ParticipantObjectTypeCodes(int code)
		{
			this.code = (short)code;
		}
		
		public Short getCode()
		{
			return this.code;
		}
	}
	
	
	/**
	 * Participant Object Type Role codes defined by RFC 3881
	 * 
	 * @author <a href="mailto:mattadav@us.ibm.com">Matthew Davis</a>
	 * @since OHT IHE Profiles 0.4.0
	 */	
	public enum RFC3881ParticipantObjectTypeRoleCodes
	{
		/**
		 * 1, PATIENT
		 */
		PATIENT(1),
		/**
		 * 2, LOCATION
		 */
		LOCATION(2),
		/**
		 * 3, REPORT
		 */
		REPORT(3),
		/**
		 * 4, RESOURCE
		 */
		RESOURCE(4),
		/**
		 * 5, MASTER FILE
		 */
		MASTER_FILE(5),
		/**
		 * 6, USER
		 */
		USER(6),
		/**
		 * 7, LIST
		 */
		LIST(7),
		/**
		 * 8, DOCTOR
		 */
		DOCTOR(8),
		/**
		 * 9, SUBSCRIBER
		 */
		SUBSCRIBER(9),
		/**
		 * 10, GUARANTOR
		 */
		GUARANTOR(10),
		/**
		 * 11, SECURITY USER ENTITY
		 */
		SECURITY_USER_ENTITY(11),
		/**
		 * 12, SECURITY USER GROUP
		 */
		SECURITY_USER_GROUP(12),
		/**
		 * 13, SECURITY RESOURCE
		 */
		SECURITY_RESOURCE(13),
		/**
		 * 14, SECURITY GRANULARITY DEFINITION
		 */
		SECURITY_GRANULARITY_DEFINITION(14),
		/**
		 * 15, PROVIDER
		 */
		PROVIDER(15),
		/**
		 * 16, DATA DESTINATION
		 */
		DATA_DESTINATION(16),
		/**
		 * 17, DATA REPOSITORY
		 */
		DATA_REPOSITORY(17),
		/**
		 * 18, SCHEDULE
		 */
		SCHEDULE(18),
		/**
		 * 19, CUSTOMER
		 */
		CUSTOMER(19),
		/**
		 * 20, JOB
		 */
		JOB(20),
		/**
		 * 21, JOB STREAM
		 */
		JOB_STREAM(21),
		/**
		 * 22, TABLE
		 */
		TABLE(22),
		/**
		 * 23, ROUTING CRITERIA
		 */
		ROUTING_CRITERIA(23),
		/**
		 * 24, QUERY
		 */
		QUERY(24);
		
		private Short code;
		
		private RFC3881ParticipantObjectTypeRoleCodes(int code)
		{
			this.code = (short)code;
		}
		
		public Short getCode()
		{
			return this.code;
		}
	}
	
	/**
	 * Participant Object Data Life Cycle codes defined by RFC 3881
	 * 
	 * @author <a href="mailto:mattadav@us.ibm.com">Matthew Davis</a>
	 * @since OHT IHE Profiles 0.4.0
	 */
	public enum RFC3881ParticipantObjectDataLifeCycleCodes
	{
		/**
		 * 1, ORIGINATION
		 */
		ORIGINATION(1),
		/**
		 * 2, IMPORT
		 */
		IMPORT(2),
		/**
		 * 3, AMENDMENT
		 */
		AMENDMENT(3),
		/**
		 * 4, VERIFICATION
		 */
		VERIFICATION(4),
		/**
		 * 5, TRANSLATION
		 */
		TRANSLATION(5),
		/**
		 * 6, ACCESS
		 */
		ACCESS(6),
		/**
		 * 7, DEIDENTIFICATION
		 */
		DEIDENTIFICATION(7),
		/**
		 * 8, AGGREGATION
		 */
		AGGREGATION(8),
		/**
		 * 9, REPORT
		 */
		REPORT(9),
		/**
		 * 10, EXPORT
		 */
		EXPORT(10),
		/**
		 * 11, DISCLOSURE
		 */
		DISCLOSURE(11),
		/**
		 * 12, RECEIPT OF DISCLOSURE
		 */
		RECEIPT_OF_DISCLOSURE(12),
		/**
		 * 13, ARCHIVING
		 */
		ARCHIVING(13),
		/**
		 * 14, LOGICAL DELETION
		 */
		LOGICAL_DELETION(14),
		/**
		 * 15, PERMANENT ERASURE
		 */
		PERMANENT_ERASURE(15);
		
		private Short code;
		
		private RFC3881ParticipantObjectDataLifeCycleCodes(int code)
		{
			this.code = (short)code;
		}
		
		public Short getCode()
		{
			return this.code;
		}
	}
	
	/**
	 * Participant Object ID Type codes defined by RFC 3881
	 * 
	 * @author <a href="mailto:mattadav@us.ibm.com">Matthew Davis</a>
	 * @since OHT IHE Profiles 0.4.0
	 */
	public static class RFC3881ParticipantObjectIDTypeCodes extends CodedValueType
	{
		protected RFC3881ParticipantObjectIDTypeCodes(String value, String originalText)
		{
			setCodeSystemName("RFC-3881");
			setOriginalText(originalText);
			setCode(value);
		}
		
		/**
		 * "1", "Medical Record Number"
		 */
		public static class MedicalRecordNumber extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "1", "Medical Record Number"
			 */
			public MedicalRecordNumber()
			{
				super("1", "Medical Record Number");
			}
		}
		
		/**
		 * "2", "Patient Number"
		 */		
		public static class PatientNumber extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "2", "Patient Number"
			 */
			public PatientNumber()
			{
				super("2", "Patient Number");
			}
		}
		
		/**
		 * "3", "Encounter Number"
		 */		
		public static class EncounterNumber extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "3", "Encounter Number"
			 */
			public EncounterNumber()
			{
				super("3", "Encounter Number");
			}
		}
		
		/**
		 * "4", "Enrollee Number"
		 */
		public static class EnrolleeNumber extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "4", "Enrollee Number"
			 */
			public EnrolleeNumber()
			{
				super("4", "Enrollee Number");
			}
		}
		
		/**
		 * "5", "Social Security Number"
		 */		
		public static class SocialSecurityNumber extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "5", "Social Security Number"
			 */
			public SocialSecurityNumber()
			{
				super("5", "Social Security Number");
			}
		}
		
		/**
		 * "6", "Account Number"
		 */		
		public static class AccountNumber extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "6", "Account Number"
			 */
			public AccountNumber()
			{
				super("6", "Account Number");
			}
		}
		
		/**
		 * "7", "Guarantor Number"
		 */		
		public static class GuarantorNumber extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "7", "Guarantor Number"
			 */
			public GuarantorNumber()
			{
				super("7", "Guarantor Number");
			}
		}
		
		/**
		 * "8", "Report Name"
		 */
		public static class ReportName extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "8", "Report Name"
			 */
			public ReportName()
			{
				super("8", "Report Name");
			}
		}
		
		/**
		 * "9", "Report Number"
		 */
		public static class ReportNumber extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "9", "Report Number"
			 */
			public ReportNumber()
			{
				super("9", "Report Number");
			}
		}
		
		/**
		 * "10", "Search Criteria"
		 */
		public static class SearchCriteria extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "10", "SearchCriteria"
			 */
			public SearchCriteria()
			{
				super("10", "Search Criteria");
			}
		}
		
		/**
		 * "11", "User Identifier"
		 */
		public static class UserIdentifier extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "11", "User Identifier"
			 */
			public UserIdentifier()
			{
				super("11", "User Identifier");
			}
		}
		
		/**
		 * "12", "URI"
		 */
		public static class URI extends RFC3881ParticipantObjectIDTypeCodes
		{
			/**
			 * "12", "URI"
			 */
			public URI()
			{
				super("12", "URI");
			}
		}		

	}
} public enum RFC3881EventActionCodes
{
	/**
	 * "C", Create
	 */
	CREATE("C"),
	/**
	 * "R", Read
	 */
	READ("R"),
	/**
	 * "U", Update
	 */
	UPDATE("U"),
	/**
	 * "D", Delete
	 */
	DELETE("D"),
	/**
	 * "E", Execute
	 */
	EXECUTE("E");
		
	private String code;
		
	private RFC3881EventActionCodes(String code)
	{
		this.code = code;
	}
		
	public String getCode()
	{
		return this.code;
	}
} public enum RFC3881EventOutcomeCodes
{
	/**
	 * "0", Success
	 */
	SUCCESS (0),
	/**
	 * "4", Minor Failure
	 */
	MINOR_FAILURE (4),
	/**
	 * "8", Serious Failure
	 */
	SERIOUS_FAILURE (8),
	/**
	 * "12", Major Failure
	 */
	MAJOR_FAILURE (12);
		
	private Integer code;
		
	private RFC3881EventOutcomeCodes(int code)
	{
		this.code = code;
	}
		
	public Integer getCode()
	{
		return this.code;
	}
		
	public static RFC3881EventOutcomeCodes getCodeForInt(int value)
	{
		switch (value) {
			case 4: return MINOR_FAILURE;
			case 8: return SERIOUS_FAILURE;
			case 12: return MAJOR_FAILURE;
			default: return SUCCESS;
		}
	}
} public enum RFC3881ParticipantObjectTypeCodes 
{
	/**
	 * 1, Person
	 */
	PERSON(1),
	/**
	 * 2, System
	 */
	SYSTEM(2),
	/**
	 * 3, Organization
	 */
	ORGANIZATION(3),
	/**
	 * 4, Other
	 */
	OTHER(4);
		
	private Short code;
		
	private RFC3881ParticipantObjectTypeCodes(int code)
	{
		this.code = (short)code;
	}
		
	public Short getCode()
	{
		return this.code;
	}
} public enum RFC3881ParticipantObjectTypeRoleCodes
{
	/**
	 * 1, PATIENT
	 */
	PATIENT(1),
	/**
	 * 2, LOCATION
	 */
	LOCATION(2),
	/**
	 * 3, REPORT
	 */
	REPORT(3),
	/**
	 * 4, RESOURCE
	 */
	RESOURCE(4),
	/**
	 * 5, MASTER FILE
	 */
	MASTER_FILE(5),
	/**
	 * 6, USER
	 */
	USER(6),
	/**
	 * 7, LIST
	 */
	LIST(7),
	/**
	 * 8, DOCTOR
	 */
	DOCTOR(8),
	/**
	 * 9, SUBSCRIBER
	 */
	SUBSCRIBER(9),
	/**
	 * 10, GUARANTOR
	 */
	GUARANTOR(10),
	/**
	 * 11, SECURITY USER ENTITY
	 */
	SECURITY_USER_ENTITY(11),
	/**
	 * 12, SECURITY USER GROUP
	 */
	SECURITY_USER_GROUP(12),
	/**
	 * 13, SECURITY RESOURCE
	 */
	SECURITY_RESOURCE(13),
	/**
	 * 14, SECURITY GRANULARITY DEFINITION
	 */
	SECURITY_GRANULARITY_DEFINITION(14),
	/**
	 * 15, PROVIDER
	 */
	PROVIDER(15),
	/**
	 * 16, DATA DESTINATION
	 */
	DATA_DESTINATION(16),
	/**
	 * 17, DATA REPOSITORY
	 */
	DATA_REPOSITORY(17),
	/**
	 * 18, SCHEDULE
	 */
	SCHEDULE(18),
	/**
	 * 19, CUSTOMER
	 */
	CUSTOMER(19),
	/**
	 * 20, JOB
	 */
	JOB(20),
	/**
	 * 21, JOB STREAM
	 */
	JOB_STREAM(21),
	/**
	 * 22, TABLE
	 */
	TABLE(22),
	/**
	 * 23, ROUTING CRITERIA
	 */
	ROUTING_CRITERIA(23),
	/**
	 * 24, QUERY
	 */
	QUERY(24);
		
	private Short code;
		
	private RFC3881ParticipantObjectTypeRoleCodes(int code)
	{
		this.code = (short)code;
	}
		
	public Short getCode()
	{
		return this.code;
	}
} public class GenericAuditEventMessageImpl extends AbstractAuditEventMessageImpl
{

	public GenericAuditEventMessageImpl( RFC3881EventOutcomeCodes outcome,
										 RFC3881EventActionCodes action,
										 CodedValueType id, CodedValueType[] type,
										 Date eventDateTime,
										 List<CodedValueType> purposesOfUse)
	{
		super(eventDateTime);
		setEventIdentification(outcome,action,id,type, purposesOfUse);
	}

	public GenericAuditEventMessageImpl( RFC3881EventOutcomeCodes outcome,
										 RFC3881EventActionCodes action,
										 CodedValueType id, CodedValueType[] type,
										 List<CodedValueType> purposesOfUse)
	{
		this(outcome,action,id,type, new Date(), purposesOfUse);
	}

	@Deprecated
    public GenericAuditEventMessageImpl( RFC3881EventOutcomeCodes outcome,
                                         RFC3881EventActionCodes action,
                                         CodedValueType id, CodedValueType[] type)
    {
        this(outcome, action, id, type, null);
    }


    /**
	 * Sets a Audit Source Identification block for a given Audit Source ID
	 * @param sourceId The Audit Source ID to use
	 */
	public void setAuditSourceId(String sourceId)
	{
		setAuditSourceId(sourceId, null, (RFC3881AuditSourceTypes[])null);
	}
	
	/**
	 * Sets a Audit Source Identification block for a given Audit Source ID
	 * and Audit Source Enterprise Site ID
	 * @param sourceId The Audit Source ID to use
	 * @param enterpriseSiteId The Audit Enterprise Site ID to use
	 */
	public void setAuditSourceId(String sourceId, String enterpriseSiteId)
	{
		setAuditSourceId(sourceId, enterpriseSiteId, (RFC3881AuditSourceTypes[])null);
	}
	
	/**
	 * Sets a Audit Source Identification block for a given Audit Source ID,
	 * Audit Source Enterprise Site ID, and a list of audit source type codes
	 * @param sourceId The Audit Source ID to use
	 * @param enterpriseSiteId The Audit Enterprise Site ID to use
	 * @param typeCodes The RFC 3881 Audit Source Type codes to use
	 *
	 * @deprecated use {@link #setAuditSourceId(String, String, RFC3881AuditSourceTypes[])}
	 */
	public void setAuditSourceId(String sourceId, String enterpriseSiteId, RFC3881AuditSourceTypeCodes[] typeCodes)
	{
		addAuditSourceIdentification(sourceId, enterpriseSiteId, typeCodes);
	}

	/**
	 * Sets a Audit Source Identification block for a given Audit Source ID,
	 * Audit Source Enterprise Site ID, and a list of audit source type codes
	 * @param sourceId The Audit Source ID to use
	 * @param enterpriseSiteId The Audit Enterprise Site ID to use
	 * @param typeCodes The RFC 3881 Audit Source Type codes to use
	 */
	public void setAuditSourceId(String sourceId, String enterpriseSiteId, RFC3881AuditSourceTypes[] typeCodes)
	{
		addAuditSourceIdentification(sourceId, enterpriseSiteId, typeCodes);
	}

} public class CodedValueType implements Serializable {

    //@XmlAttribute(required = true)
    protected String code;
    //@XmlAttribute
    protected String originalText;
    //@XmlAttribute
    protected String codeSystem;
    //@XmlAttribute
    protected String codeSystemName;

    
    public String toString(String tagName)
    {
    	StringBuilder sb = new StringBuilder();
    	sb.append("<"+ tagName);
    	//code
    	sb.append(" csd-code=\"");
    	sb.append(code);
    	sb.append("\"");

    	//originalText
    	if (originalText != null) {
	    	sb.append(" originalText=\"");
	    	sb.append(StringEscapeUtils.escapeXml10(originalText));
	    	sb.append("\"");
    	}

    	//codeSystem
    	if (codeSystem != null) {
	    	sb.append(" codeSystem=\"");
	    	sb.append(StringEscapeUtils.escapeXml10(codeSystem));
	    	sb.append("\"");
    	}
    	//codeSystemName
    	if (codeSystemName != null) {
	    	sb.append(" codeSystemName=\"");
	    	sb.append(StringEscapeUtils.escapeXml10(codeSystemName));
	    	sb.append("\"");
    	}
    	
    	sb.append("/>");
    	return sb.toString();
    }
    
    /**
     * Gets the value of the code property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCode() {
        return code;
    }

    /**
     * Sets the value of the code property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCode(String value) {
        this.code = value;
    }

    /**
     * Gets the value of the originalText property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getOriginalText() {
        return originalText;
    }

    /**
     * Sets the value of the originalText property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setOriginalText(String value) {
        this.originalText = value;
    }

    /**
     * Gets the value of the codeSystem property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCodeSystem() {
        return codeSystem;
    }

    /**
     * Sets the value of the codeSystem property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCodeSystem(String value) {
        this.codeSystem = value;
    }

    /**
     * Gets the value of the codeSystemName property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCodeSystemName() {
        return codeSystemName;
    }

    /**
     * Sets the value of the codeSystemName property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCodeSystemName(String value) {
        this.codeSystemName = value;
    }


    /**
     * Gets the value of the displayName property.
     *
     * @return possible object is {@link String}
     * @deprecated use getOriginalText instead
     */
    @Deprecated
    public String getDisplayName() {
        return originalText;
    }

    /**
     * Sets the value of the displayName property.
     *
     * @param value allowed object is {@link String}
     * @deprecated use setOriginalText instead
     */
    @Deprecated
    public void setDisplayName(String value) {
        this.originalText = value;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof CodedValueType)) return false;
        CodedValueType that = (CodedValueType) o;
        return Objects.equals(code, that.code) &&
                Objects.equals(originalText, that.originalText) &&
                Objects.equals(codeSystem, that.codeSystem) &&
                Objects.equals(codeSystemName, that.codeSystemName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(code, originalText, codeSystem, codeSystemName);
    }
} public class TypeValuePairType {

    //@XmlAttribute(required = true)
    protected String type;
    //@XmlAttribute(required = true)
    protected byte[] value;
    
    public String toString(String tagName, boolean useSpacing)
    {
    	StringBuilder sb = new StringBuilder();
    	sb.append("<"+ tagName);
    	//type
    	if (type != null) {
	    	sb.append(" type=\"");
	    	sb.append(StringEscapeUtils.escapeXml10(type));
	    	sb.append("\"");
    	}
    	//value
    	if (value != null) {
	    	sb.append(" value=\"");
	    	sb.append(StringEscapeUtils.escapeXml10(new String(value)));
	    	sb.append("\"");
    	}
    	sb.append("/>");
    	return sb.toString();
    }
    public String toString(String tagName)
    {
    	return toString(tagName, true);
    }

    /**
     * Gets the value of the type property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getType() {
        return type;
    }

    /**
     * Sets the value of the type property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setType(String value) {
        this.type = value;
    }

    /**O
     * Gets the value of the value property.
     * 
     * @return
     *     possible object is
     *     byte[]
     */
    public byte[] getValue() {
        return value;
    }

    /**
     * Sets the value of the value property.
     * 
     * @param value
     *     allowed object is
     *     byte[]
     */
    public void setValue(byte[] value) {
        this.value = EventUtils.encodeBase64(value);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof TypeValuePairType)) return false;
        TypeValuePairType that = (TypeValuePairType) o;
        return Objects.equals(type, that.type) &&
                Arrays.equals(value, that.value);
    }

    @Override
    public int hashCode() {
        return Objects.hash(type, value);
    }
} public class EventUtils 
{

    /**
     * Extract host name from the given endpoint URI.
     * @see <a href="http://tools.ietf.org/html/rfc3986#section-3">RFC 3986, Section 3</a>
     *
     * @param address
     *      endpoint URI or bare IP address.
     * @param resolveForIp
     *      dummy.
     * @return
     *      host name contained in the URI.
     */
    public static String getAddressForUrl(String address, boolean resolveForIp) {
        if (address == null) {
            return null;
        }

        // drop schema
        int pos = address.indexOf("://");
        if (pos > 0) {
            address = address.substring(pos + 3);
        }

        // drop user authentication information
        pos = address.indexOf('@');
        if (pos > 0) {
            address = address.substring(pos + 1);
        }

        // drop trailing parts: port number, query parameters, path, fragment
        for (int i = 0; i < address.length(); ++i) {
            char c = address.charAt(i);
            if ((c == ':') || (c == '?') || (c == '/') || (c == '#')) {
                return address.substring(0, i);
            }
        }
        return address;
    }

	
	public static CodedValueType getIHETransactionCodeFromMessage(AuditEventMessage msg)
	{
		List<CodedValueType> eventTypeCodes = msg.getAuditMessage().getEventIdentification().getEventTypeCode();
		if (!EventUtils.isEmptyOrNull(eventTypeCodes)) {
			Iterator<CodedValueType> iter = eventTypeCodes.iterator();
			CodedValueType code = null;
			while (iter.hasNext()) {
				code=iter.next();
				if (code.getCodeSystemName().equals("IHE Transactions")) {
					return code;
				}
			}
		}
		return null;
	}

	public static boolean containsCode(CodedValueType codeToCheck, List<String> codesToCheckAgainst)
	{
		if (null != codeToCheck) {
			if (codesToCheckAgainst.contains(codeToCheck.getCode()) ||
					codesToCheckAgainst.contains(codeToCheck.getOriginalText())) {
				return true;
			}
		}
		return false;
	}
	
	public static boolean containsCode(List<CodedValueType> codesToCheck, List<String> codesToCheckAgainst)
	{
		if (!EventUtils.isEmptyOrNull(codesToCheck)) {
			Iterator<CodedValueType> iter = codesToCheck.iterator();
			CodedValueType code = null;
			while (iter.hasNext()) {
				code=iter.next();
				if (EventUtils.containsCode(code, codesToCheckAgainst)) {
					return true;
				}
			}
		}
		return false;
	}
	
	public static String concatHL7FacilityApplication(String facility, String application)
	{
		return facility + "|" + application;
	}
	
	public static byte[] encodeBase64(String str)
	{
		if (null == str) {
			return new byte[0];
		}
		return encodeBase64(str.getBytes());
	}
	
	public static byte[] encodeBase64(byte[] bytes)
	{
		if (null == bytes) {
			return new byte[0];
		}
		return org.apache.commons.codec.binary.Base64.encodeBase64(bytes);
	}
	

	
	public static boolean isEmptyOrNull(Object obj) 
	{
		return (null == obj);
	}
	
	public static boolean isEmptyOrNull(String str) 
	{
		return (null == str || str.length() == 0);
	}
	
	public static boolean isEmptyOrNull(Object[] array) 
	{
		return (null == array || array.length == 0);
	}
	
	public static boolean isEmptyOrNull(Object[] array, boolean checkItems) 
	{
		if (isEmptyOrNull(array)) {
			return true;
		}
		for (int i=0; i<array.length; i++) {
			if (!isEmptyOrNull(array[i])) {
				return false;
			}
		}
		return true;
	}
	
	public static boolean isEmptyOrNull(Collection<?> collection)
	{
		return ( null == collection || collection.size() == 0);
	}
	
	public static boolean isEmptyOrNull(Collection<?> collection, boolean checkItems)
	{
		if (isEmptyOrNull(collection)) {
			return true;
		}
        for (Object aCollection : collection) {
            if (!isEmptyOrNull(aCollection)) {
                return false;
            }
        }
		return true;
	}
	
	public static boolean isEmptyOrNull(byte[] array) 
	{
		return (null == array || array.length == 0);
	}
}
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.openhealthtools.ihe.atna.auditor.codes.dicom.DICOMActiveParticipantRoleIdCodes;
import org.openhealthtools.ihe.atna.auditor.codes.ihe.IHETransactionEventTypeCodes;
import org.openhealthtools.ihe.atna.auditor.codes.ihe.IHETransactionParticipantObjectIDTypeCodes;
import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881ParticipantObjectCodes;
import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes.RFC3881EventActionCodes;
import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes.RFC3881EventOutcomeCodes;
import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeCodes;
import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectTypeRoleCodes;
import org.openhealthtools.ihe.atna.auditor.events.GenericAuditEventMessageImpl;
import org.openhealthtools.ihe.atna.auditor.models.rfc3881.CodedValueType;
import org.openhealthtools.ihe.atna.auditor.models.rfc3881.TypeValuePairType;
import org.openhealthtools.ihe.atna.auditor.utils.EventUtils;
/*******************************************************************************
 * Copyright (c) 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.openhealthtools.ihe.atna.auditor.events.ihe;



/**
 * Generic audit message that creates a valid audit event message 
 * for IHE transactions.  This is intended to be further extended
 * by message pertaining to specific events.
 * 
 * @author <a href="mailto:mattadav@us.ibm.com">Matthew Davis</a>
 */
public class GenericIHEAuditEventMessage extends GenericAuditEventMessageImpl
{
	/**
	 * Whether the system sending the message is the event source
	 */
	private final boolean systemIsSource;
	
	/**
	 * IHE Transaction code used in event
	 */
	protected IHETransactionEventTypeCodes eventType;
	
	/**
	 * @param systemIsSource
	 * @param outcome
	 * @param action
	 * @param id
	 * @param type
	 */
	public GenericIHEAuditEventMessage(boolean systemIsSource, 
			RFC3881EventOutcomeCodes outcome, 
			RFC3881EventActionCodes action,
			CodedValueType id, 
			IHETransactionEventTypeCodes type,
            List<CodedValueType> purposesOfUse)
	{
		super(outcome,action,id,new IHETransactionEventTypeCodes[] {type}, purposesOfUse);
		this.systemIsSource = systemIsSource;	
		this.eventType = type;
	}

    @Deprecated
    public GenericIHEAuditEventMessage(boolean systemIsSource,
                                       RFC3881EventOutcomeCodes outcome,
                                       RFC3881EventActionCodes action,
                                       CodedValueType id,
                                       IHETransactionEventTypeCodes type)
    {
        this(systemIsSource, outcome, action, id, type, null);
    }

	/**
	 * Gets whether the system that generated the message is the 
	 * event source
	 * @return Whether the system is the event source
	 */
	public boolean systemIsSource()
	{
		return systemIsSource;
	}
	
	/**
	 * Adds an Active Participant block representing the source participant 
	 * @param userId The Active Participant's User ID
	 * @param altUserId The Active Participant's Alternate UserID
	 * @param userName The Active Participant's UserName
	 * @param networkId The Active Participant's Network Access Point ID
	 * @param isRequestor Whether the participant represents the requestor
	 */
	public void addSourceActiveParticipant(String userId, String altUserId, String userName, String networkId, boolean isRequestor)
	{
		addActiveParticipant(
				userId, 
				altUserId, 
				userName, 
				isRequestor,
				Collections.singletonList(new DICOMActiveParticipantRoleIdCodes.Source()),
				networkId);
	}
	
	/**
	 * Adds an Active Participant block representing the destination participant 
	 * @param userId The Active Participant's User ID
	 * @param altUserId The Active Participant's Alternate UserID
	 * @param userName The Active Participant's UserName
	 * @param networkId The Active Participant's Network Access Point ID
	 * @param isRequestor Whether the participant represents the requestor
	 */
	public void addDestinationActiveParticipant(String userId, String altUserId, String userName, String networkId, boolean isRequestor)
	{
		addActiveParticipant(
				userId, 
				altUserId, 
				userName, 
				isRequestor, 
				Collections.singletonList(new DICOMActiveParticipantRoleIdCodes.Destination()),
				networkId);
	}

	/**
	 * Adds an Active Participant block representing the human requestor participant 
	 * @param userId The Active Participant's User ID
	 * @param altUserId The Active Participant's Alternate UserID
	 * @param userName The Active Participant's UserName
	 * @param roles The participant's roles
	 */
	public void addHumanRequestorActiveParticipant(String userId, String altUserId, String userName, List<CodedValueType> roles)
	{
		addActiveParticipant(
				userId,
				altUserId,
				userName,
				true,
				roles,
				null);
	}

	/**
	 * Adds an Active Participant block representing the human requestor participant
	 * @param userId The Active Participant's User ID
	 * @param altUserId The Active Participant's Alternate UserID
	 * @param userName The Active Participant's UserName
	 * @param role The participant's role
	 */
	@Deprecated
	public void addHumanRequestorActiveParticipant(String userId, String altUserId, String userName, CodedValueType role)
	{
		addActiveParticipant(
				userId,
				altUserId,
				userName,
				true,
				Collections.singletonList(role),
				null);
	}

	/**
	 * Adds a Participant Object Identification block that representing a patient 
	 * involved in the event
	 * 
	 * @param patientId Identifier of the patient involved
	 */
	public void addPatientParticipantObject(String patientId)
	{
		addParticipantObjectIdentification(
				new RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectIDTypeCodes.PatientNumber(), 
				null,
				null, 
				null, 
				patientId, 
				RFC3881ParticipantObjectTypeCodes.PERSON, 
				RFC3881ParticipantObjectTypeRoleCodes.PATIENT, 
				null, 
				null);
	}	

	/**
	 * Adds a Participant Object representing an XDS Submission Set
	 * 
	 * @param submissionSetUniqueId The Submission Set Unique ID of the Submission Set
	 */
	public void addSubmissionSetParticipantObject(String submissionSetUniqueId)
	{
		addParticipantObjectIdentification(
				new IHETransactionParticipantObjectIDTypeCodes.SubmissionSet(), 
				null, 
				null, 
				null, 
				submissionSetUniqueId, 
				RFC3881ParticipantObjectTypeCodes.SYSTEM, 
				RFC3881ParticipantObjectTypeRoleCodes.JOB,
				null, 
				null);
	}
	
	/**
	 * Adds a Participant Object representing a URI
	 * 
	 * @param documentRetrieveUri The URI of the Participant Object
	 * @param documentUniqueId The Document Entry Unique ID
	 */
	public void addDocumentUriParticipantObject(String documentRetrieveUri, String documentUniqueId)
	{
		List<TypeValuePairType> tvp = new LinkedList<>();
		if (documentUniqueId != null) {
			tvp.add(getTypeValuePair("XDSDocumentEntry.uniqueId", documentUniqueId.getBytes()));
		}
		addParticipantObjectIdentification(
				new RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectIDTypeCodes.URI(), 
				null, 
				null, 
				tvp, 
				documentRetrieveUri, 
				RFC3881ParticipantObjectTypeCodes.SYSTEM, 
				RFC3881ParticipantObjectTypeRoleCodes.REPORT,
				null, 
				null);
	}
	
	/**
	 * Adds a Participant Object representing a document for XDS Exports
	 * 
	 * @param documentUniqueId The Document Entry Unique Id
	 * @param repositoryUniqueId The Repository Unique Id of the Repository housing the document
	 * @param homeCommunityId The Home Community Id
	 */
	public void addDocumentParticipantObject(String documentUniqueId, String repositoryUniqueId, String homeCommunityId)
	{
		List<TypeValuePairType> tvp = new LinkedList<>();
        //SEK - 10/19/2011 - added check for empty or null, RE: Issue Tracker artifact artf2295 (was Issue 135)
 		if (!EventUtils.isEmptyOrNull(repositoryUniqueId)) {