code: async def delete(self, iden):
          '''
          Delete an appointment
          '''
          appt = self.appts.get(iden)
          if appt is None:
              raise s_exc.NoSuchIden()
  
          try:
              heappos = self.apptheap.index(appt)
          except ValueError:
              pass  # this is OK, just a non-recurring appt that has no more records
          else:
              # If we're already the last item, just delete it
              if heappos == len(self.apptheap) - 1:
                  del self.apptheap[heappos]
              else:
                  # put the last item at the current position and reheap
                  self.apptheap[heappos] = self.apptheap.pop()
                  heapq.heapify(self.apptheap)
  
          del self.appts[iden]
          await self._hivedict.pop(idenync def delete(self, iden):
          '''
          Delete an appointment
          '''
          appt = self.appts.get(iden)
          if appt is None:
              raise s_exc.NoSuchIden()
  
          try:
              heappos = self.apptheap.index(appt)
          except ValueError:
              pass  # this is OK, just a non-recurring appt that has no more records
          else:
              # If we're already the last item, just delete it
              if heappos == len(self.apptheap) - 1:
                  del self.apptheap[heappos]
              else:
                  # put the last item at the current position and reheap
                  self.apptheap[heappos] = self.apptheap.pop()
                  heapq.heapify(self.apptheap)
  
          del self.appts[iden]
          await self._hivedict.pop(iden)
docs: Delete an appointment