code: def isQCValid(self):
          
          query = {"portal_type": "ReferenceAnalysis",
                   "getInstrumentUID": self.UID(),
                   "sort_on": "getResultCaptureDate",
                   "sort_order": "reverse",
                   "sort_limit": 1,}
          brains = api.search(query, CATALOG_ANALYSIS_LISTING)
          if len(brains) == 0:
              # There are no Reference Analyses assigned to this instrument yet
              return True
  
          # Look for siblings. These are the QC Analyses that were created
          # together with this last ReferenceAnalysis and for the same Reference
          # Sample. If they were added through "Add Reference Analyses" in a
          # Worksheet, they typically appear in the same slot.
          group_id = brains[0].getReferenceAnalysesGroupID
          query = {"portal_type": "ReferenceAnalysis",
                   "getInstrumentUID": self.UID(),
                   "getReferenceAnalysesGroupID": group_id,}
          brains = api.search(query, CATALOG_ANALYSIS_LISTING)
          for brain in brains:
              results_range = brain.getResultsRange
              if not results_range:
                  continue
              # Is out of range?
              out_of_range = is_out_of_range(brain)[0]
              if out_of_range:
                  return False
  
          # By default, in range
          return True
docs: Returns True if the results of the last batch of QC Analyses
          performed against this instrument was within the valid range.
  
          For a given Reference Sample, more than one Reference Analyses assigned
          to this same instrument can be performed and the Results Capture Date
          might slightly differ amongst them. Thus, this function gets the latest
          QC Analysis performed, looks for siblings (through RefAnalysisGroupID)
          and if the results for all them are valid, then returns True. If there
          is one single Reference Analysis from the group with an out-of-range
          result, the function returns False