lib/catissue/domain/specimen.rb
def validate_local
      super
      if parent.nil? and specimen_collection_group.nil? then
        raise Jinx::ValidationError.new("Top-level specimen #{self} is missing specimen collection group")
      end
      if available_quantity and initial_quantity and available_quantity > initial_quantity then
        raise Jinx::ValidationError.new("#{self} available quantity #{available_quantity} cannot exceed the initial quantity #{initial_quantity}")
      end
      if available? and (initial_quantity.zero? or available_quantity.zero?) then
        raise Jinx::ValidationError.new("#{self} availablility flag cannot be set if the available quantity is zero")
      end
      if collected? then
        unless event_parameters.detect { |ep| CaTissue::CollectionEventParameters === ep } then
          raise Jinx::ValidationError.new("#{self} is missing CollectionEventParameters")
        end
        unless event_parameters.detect { |ep| CaTissue::ReceivedEventParameters === ep } then
          raise Jinx::ValidationError.new("#{self} is missing ReceivedEventParameters")
        end
      end
    end
def validate_local
      super
      if parent.nil? and specimen_collection_group.nil? then
        raise Jinx::ValidationError.new("Top-level specimen #{self} is missing specimen collection group")
      end
      if available_quantity and initial_quantity and available_quantity > initial_quantity then
        raise Jinx::ValidationError.new("#{self} available quantity #{available_quantity} cannot exceed the initial quantity #{initial_quantity}")
      end
      if available? and (initial_quantity.zero? or available_quantity.zero?) then
        raise Jinx::ValidationError.new("#{self} availablility flag cannot be set if the available quantity is zero")
      end
      if collected? then
        unless event_parameters.detect { |ep| CaTissue::CollectionEventParameters === ep } then
          raise Jinx::ValidationError.new("#{self} is missing CollectionEventParameters")
        end
        unless event_parameters.detect { |ep| CaTissue::ReceivedEventParameters === ep } then
          raise Jinx::ValidationError.new("#{self} is missing ReceivedEventParameters")
        end
      end
    end
def validate_local super if parent . nil? and specimen_collection_group . nil? then raise Jinx :: ValidationError . new ( "Top-level specimen #{self} is missing specimen collection group" ) end if available_quantity and initial_quantity and available_quantity > initial_quantity then raise Jinx :: ValidationError . new ( "#{self} available quantity #{available_quantity} cannot exceed the initial quantity #{initial_quantity}" ) end if available? and ( initial_quantity . zero? or available_quantity . zero? ) then raise Jinx :: ValidationError . new ( "#{self} availablility flag cannot be set if the available quantity is zero" ) end if collected? then unless event_parameters . detect { | ep | CaTissue :: CollectionEventParameters === ep } then raise Jinx :: ValidationError . new ( "#{self} is missing CollectionEventParameters" ) end unless event_parameters . detect { | ep | CaTissue :: ReceivedEventParameters === ep } then raise Jinx :: ValidationError . new ( "#{self} is missing ReceivedEventParameters" ) end end end
Validates that the following conditions hold:
 * a top-level Specimen does not have a SGC
 * the available_quantity exceeds the initial_quantity
 * the availability flag is set and the available_quantity is zero

 @quirk caTissue Bug #160: Missing Is Available? validation.
 Updating Specimen with the availablity flag set and available_quantity zero
 silently leaves the availablity flag unset.

  @raise [Jinx::ValidationError] if the validation fails
Validates that the following conditions hold : * a top - level Specimen does not have a SGC * the available_quantity exceeds the initial_quantity * the availability flag is set and the available_quantity is zero