text: // GENERATED CODE
  // Manual modification is NOT RECOMMENDED as changes will be overwritten the next time the class is generated.
  
  import { setPropertiesFromJSON, uuid, FHIRHelper } from '../../json-helper';
  
  import ClassRegistry from '../../ClassRegistry';
  
  /**
   * Generated class for shr.core.UseContext.
   */
  class UseContext {
  
    /**
     * Get the Code.
     * @returns {Code} The shr.core.Code
     */
    get code() {
      return this._code;
    }
  
    /**
     * Set the Code.
     * This field/value is required.
     * @param {Code} code - The shr.core.Code
     */
    set code(code) {
      this._code = code;
    }
  
    /**
     * Set the Code and return 'this' for chaining.
     * This field/value is required.
     * @param {Code} code - The shr.core.Code
     * @returns {UseContext} this.
     */
    withCode(code) {
      this.code = code; return this;
    }
  
    /**
     * Get the ContextValue.
     * @returns {ContextValue} The shr.core.ContextValue
     */
    get contextValue() {
      return this._contextValue;
    }
  
    /**
     * Set the ContextValue.
     * This field/value is required.
     * @param {ContextValue} contextValue - The shr.core.ContextValue
     */
    set contextValue(contextValue) {
      this._contextValue = contextValue;
    }
  
    /**
     * Set the ContextValue and return 'this' for chaining.
     * This field/value is required.
     * @param {ContextValue} contextValue - The shr.core.ContextValue
     * @returns {UseContext} this.
     */
    withContextValue(contextValue) {
      this.contextValue = contextValue; return this;
    }
  
    /**
     * Deserializes JSON data to an instance of the UseContext class.
     * The JSON must be valid against the UseContext JSON schema, although this is not validated by the function.
     * @param {object} json - the JSON data to deserialize
     * @returns {UseContext} An instance of UseContext populated with the JSON data
     */
    static fromJSON(json={}) {
      const klass = ClassRegistry.get('shr.core', 'UseContext');
      const inst = new klass();
      setPropertiesFromJSON(inst, json);
      return inst;
    }
  
    /**
     * Serializes an instance of the UseContext class to a JSON object.
     * The JSON is expected to be valid against the UseContext JSON schema, but no validation checks are performed.
     * @returns {object} a JSON object populated with the data from the element
     */
    toJSON() {
      const inst = { 'EntryType': { 'Value' : 'http://standardhealthrecord.org/spec/shr/core/UseContext' } };
      if (this.code != null) {
        inst['Code'] = typeof this.code.toJSON === 'function' ? this.code.toJSON() : this.code;
      }
      if (this.contextValue != null) {
        inst['ContextValue'] = typeof this.contextValue.toJSON === 'function' ? this.contextValue.toJSON() : this.contextValue;
      }
      return inst;
    }
  
    /**
     * Deserializes FHIR JSON data to an instance of the UseContext class.
     * The FHIR must be valid against the UseContext FHIR profile, although this is not validated by the function.
     * @param {object} fhir - the FHIR JSON data to deserialize
     * @param {string} fhirType - the type of the FHIR object that was passed in, in case not otherwise identifiable from the object itself
     * @param {string} shrId - a unique, persistent, permanent identifier for the overall health record belonging to the Patient; will be auto-generated if not provided
     * @param {Array} allEntries - the list of all entries that references in 'fhir' refer to
     * @param {object} mappedResources - any resources that have already been mapped to SHR objects. Format is { fhir_key: {shr_obj} }
     * @param {Array} referencesOut - list of all SHR ref() targets that were instantiated during this function call
     * @param {boolean} asExtension - Whether the provided instance is an extension
     * @returns {UseContext} An instance of UseContext populated with the FHIR data
     */
    static fromFHIR(fhir, fhirType, shrId=uuid(), allEntries=[], mappedResources={}, referencesOut=[], asExtension=false) {
      const klass = ClassRegistry.get('shr.core', 'UseContext');
      const inst = new klass();
      if (asExtension) {
        const match_3 = fhir['extension'].find(e => e.url == 'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-Code-extension');
        if (match_3 != null) {
          inst.code = FHIRHelper.createInstanceFromFHIR('shr.core.Code', match_3, 'Extension', shrId, allEntries, mappedResources, referencesOut, true);
        }
        const match_4 = fhir['extension'].find(e => e.url == 'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-ContextValue-extension');
        if (match_4 != null) {
          inst.contextValue = FHIRHelper.createInstanceFromFHIR('shr.core.ContextValue', match_4, 'Extension', shrId, allEntries, mappedResources, referencesOut, true);
        }
      }
      return inst;
    }
  
  }
  export default UseContext;
  