text: const DomainResource = require('./DomainResource');
  const Identifier = require('./Identifier');
  const ContactDetail = require('./ContactDetail');
  const UsageContext = require('./UsageContext');
  const CodeableConcept = require('./CodeableConcept');
  const Reference = require('./Reference');
  const Coding = require('./Coding');
  const MessageDefinition_Focus = require('./MessageDefinition_Focus');
  const MessageDefinition_AllowedResponse = require('./MessageDefinition_AllowedResponse');
  
  class MessageDefinition extends DomainResource {
  
  	constructor ( opts ) {
  		super();
  		Object.assign(this, opts);
  	}
  
  	static get __resourceType () {
  		return 'MessageDefinition';
  	}
  
  	// This is a MessageDefinition resource
  	get resourceType () {
  		return this._resourceType;
  	}
  
  	set resourceType ( new_value ) {
  		// Throw if new value is not in the allowed values
  		let allowed_values = ['MessageDefinition'];
  		if ( allowed_values.indexOf(new_value) === -1 ) {
  			throw new Error(`Expected one of ${allowed_values}, got ${new_value} for field resourceType`);
  		}
  		this._resourceType = new_value;
  	}
  
  	// An absolute URI that is used to identify this message definition when it is referenced in a specification, model, design or an instance. This SHALL be a URL, SHOULD be globally unique, and SHOULD be an address at which this message definition is (or will be) published. The URL SHOULD include the major version of the message definition. For more information see [Technical and Business Versions](resource.html#versions).
  	get url () {
  		return this._url;
  	}
  
  	set url ( new_value ) {
  		this._url = new_value;
  	}
  
  	// A formal identifier that is used to identify this message definition when it is represented in other formats, or referenced in a specification, model, design or an instance.
  	get identifier () {
  		return this._identifier;
  	}
  
  	set identifier ( new_value ) {
  		this._identifier = new Identifier(new_value);
  	}
  
  	// The identifier that is used to identify this version of the message definition when it is referenced in a specification, model, design or instance. This is an arbitrary value managed by the message definition author and is not expected to be globally unique. For example, it might be a timestamp (e.g. yyyymmdd) if a managed version is not available. There is also no expectation that versions can be placed in a lexicographical sequence.
  	get version () {
  		return this._version;
  	}
  
  	set version ( new_value ) {
  		this._version = new_value;
  	}
  
  	// A natural language name identifying the message definition. This name should be usable as an identifier for the module by machine processing applications such as code generation.
  	get name () {
  		return this._name;
  	}
  
  	set name ( new_value ) {
  		this._name = new_value;
  	}
  
  	// A short, descriptive, user-friendly title for the message definition.
  	get title () {
  		return this._title;
  	}
  
  	set title ( new_value ) {
  		this._title = new_value;
  	}
  
  	// The status of this message definition. Enables tracking the life-cycle of the content.
  	get status () {
  		return this._status;
  	}
  
  	set status ( new_value ) {
  		// Throw if new value is not in the allowed values
  		let allowed_values = ['draft', 'active', 'retired', 'unknown'];
  		if ( allowed_values.indexOf(new_value) === -1 ) {
  			throw new Error(`Expected one of ${allowed_values}, got ${new_value} for field status`);
  		}
  		this._status = new_value;
  	}
  
  	// A boolean value to indicate that this message definition is authored for testing purposes (or education/evaluation/marketing), and is not intended to be used for genuine usage.
  	get experimental () {
  		return this._experimental;
  	}
  
  	set experimental ( new_value ) {
  		this._experimental = new_value;
  	}
  
  	// The date  (and optionally time) when the message definition was published. The date must change if and when the business version changes and it must change if the status code changes. In addition, it should change when the substantive content of the message definition changes.
  	get date () {
  		return this._date;
  	}
  
  	set date ( new_value ) {
  		// Throw if new value does not match the pattern
  		let pattern = /-?[0-9]{4}(-(0[1-9]|1[0-2])(-(0[0-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?/;
  		if ( !pattern.test(new_value) ) {
  			throw new Error(`Invalid format for ${new_value} on field date`);
  		}
  		this._date = new_value;
  	}
  
  	// The name of the individual or organization that published the message definition.
  	get publisher () {
  		return this._publisher;
  	}
  
  	set publisher ( new_value ) {
  		this._publisher = new_value;
  	}
  
  	// Contact details to assist a user in finding and communicating with the publisher.
  	get contact () {
  		return this._contact;
  	}
  
  	set contact ( new_value ) {
  		this._contact = Array.isArray(new_value) ? new_value.map(val => new ContactDetail(val)) : [new ContactDetail(new_value)];
  	}
  
  	// A free text natural language description of the message definition from a consumer's perspective.
  	get description () {
  		return this._description;
  	}
  
  	set description ( new_value ) {
  		this._description = new_value;
  	}
  
  	// The content was developed with a focus and intent of supporting the contexts that are listed. These terms may be used to assist with indexing and searching for appropriate message definition instances.
  	get useContext () {
  		return this._useContext;
  	}
  
  	set useContext ( new_value ) {
  		this._useContext = Array.isArray(new_value) ? new_value.map(val => new UsageContext(val)) : [new UsageContext(new_value)];
  	}
  
  	// A legal or geographic region in which the message definition is intended to be used.
  	get jurisdiction () {
  		return this._jurisdiction;
  	}
  
  	set jurisdiction ( new_value ) {
  		this._jurisdiction = Array.isArray(new_value) ? new_value.map(val => new CodeableConcept(val)) : [new CodeableConcept(new_value)];
  	}
  
  	// Explaination of why this message definition is needed and why it has been designed as it has.
  	get purpose () {
  		return this._purpose;
  	}
  
  	set purpose ( new_value ) {
  		this._purpose = new_value;
  	}
  
  	// A copyright statement relating to the message definition and/or its contents. Copyright statements are generally legal restrictions on the use and publishing of the message definition.
  	get copyright () {
  		return this._copyright;
  	}
  
  	set copyright ( new_value ) {
  		this._copyright = new_value;
  	}
  
  	// The MessageDefinition that is the basis for the contents of this resource.
  	get base () {
  		return this._base;
  	}
  
  	set base ( new_value ) {
  		this._base = new Reference(new_value);
  	}
  
  	// Identifies a protocol or workflow that this MessageDefinition represents a step in.
  	get parent () {
  		return this._parent;
  	}
  
  	set parent ( new_value ) {
  		this._parent = Array.isArray(new_value) ? new_value.map(val => new Reference(val)) : [new Reference(new_value)];
  	}
  
  	// A MessageDefinition that is superseded by this definition.
  	get replaces () {
  		return this._replaces;
  	}
  
  	set replaces ( new_value ) {
  		this._replaces = Array.isArray(new_value) ? new_value.map(val => new Reference(val)) : [new Reference(new_value)];
  	}
  
  	// A coded identifier of a supported messaging event.
  	get event () {
  		return this._event;
  	}
  
  	set event ( new_value ) {
  		this._event = new Coding(new_value);
  	}
  
  	// The impact of the content of the message.
  	get category () {
  		return this._category;
  	}
  
  	set category ( new_value ) {
  		// Throw if new value does not match the pattern
  		let pattern = /[^\s]+([\s]?[^\s]+)*/;
  		if ( !pattern.test(new_value) ) {
  			throw new Error(`Invalid format for ${new_value} on field category`);
  		}
  		this._category = new_value;
  	}
  
  	// Identifies the resource (or resources) that are being addressed by the event.  For example, the Encounter for an admit message or two Account records for a merge.
  	get focus () {
  		return this._focus;
  	}
  
  	set focus ( new_value ) {
  		this._focus = Array.isArray(new_value) ? new_value.map(val => new MessageDefinition_Focus(val)) : [new MessageDefinition_Focus(new_value)];
  	}
  
  	// Indicates whether a response is required for this message.
  	get responseRequired () {
  		return this._responseRequired;
  	}
  
  	set responseRequired ( new_value ) {
  		this._responseRequired = new_value;
  	}
  
  	// Indicates what types of messages may be sent as an application-level response to this message.
  	get allowedResponse () {
  		return this._allowedResponse;
  	}
  
  	set allowedResponse ( new_value ) {
  		this._allowedResponse = Array.isArray(new_value) ? new_value.map(val => new MessageDefinition_AllowedResponse(val)) : [new MessageDefinition_AllowedResponse(new_value)];
  	}
  
  	toJSON () {
  		return Object.assign(super.toJSON(), {
  			resourceType: this._resourceType,
  			url: this._url,
  			identifier: this._identifier,
  			version: this._version,
  			name: this._name,
  			title: this._title,
  			status: this._status,
  			experimental: this._experimental,
  			date: this._date,
  			publisher: this._publisher,
  			contact: this._contact,
  			description: this._description,
  			useContext: this._useContext,
  			jurisdiction: this._jurisdiction,
  			purpose: this._purpose,
  			copyright: this._copyright,
  			base: this._base,
  			parent: this._parent,
  			replaces: this._replaces,
  			event: this._event,
  			category: this._category,
  			focus: this._focus,
  			responseRequired: this._responseRequired,
  			allowedResponse: this._allowedResponse
  		});
  	}
  
  }
  
  module.exports = MessageDefinition;
  