def METHOD_NAME(self, ip, data):
    try:
        if self._data[ip][-1][26] == data[26]:
            logging.warning("Skip this data item, duplicate of previous data item.")
            if self._data[ip][-1] != data:
                raise ValueError("Duplicate ID, but not duplicate data!")
            return
        # Every iCOM data item has an index, this check here is
        # making sure that the currently received data item is
        # incremented by exactly one compared to the most recently
        # received data item.
        if (self._data[ip][-1][26] + 1) % 256 != data[26]:
            raise ValueError("Data stream appears to be arriving out of order")
        self._data[ip].append(data)
    except KeyError:
        self._data[ip] = [data]
    timestamp = data[8:26].decode()
    shrunk_data, patient_id = extract.extract(data, "Patient ID")
    shrunk_data, patient_name = extract.extract(shrunk_data, "Patient Name")
    shrunk_data, machine_id = extract.extract(shrunk_data, "Machine ID")
    logging.info(  # pylint: disable = logging-fstring-interpolation
        f"IP: {ip} | Timestamp: {timestamp} | "
        f"Patient ID: {patient_id} | "
        f"Patient Name: {patient_name} | Machine ID: {machine_id}"
    )
    try:
        usage_start = self._usage_start[ip]
    except KeyError:
        usage_start = None
    if patient_id is not None:
        if usage_start is None:
            self._current_patient_data[ip] = []
            timestamp = data[8:26].decode()
            iso_timestamp = f"{timestamp[0:10]}T{timestamp[10::]}"
            self._usage_start[ip] = iso_timestamp
            logging.debug(
                "Starting data collection for patient id %(patient_id)s. "
                "Recording started at %(usage_start)s.",
                {"usage_start": self._usage_start[ip], "patient_id": patient_id},
            )
        self._current_patient_data[ip].append(data)
        logging.debug(
            "iCOM stream appended to the data being collected for "
            "patient id %(patient_id)s.",
            {"patient_id": patient_id},
        )
    elif not usage_start is None:
        logging.debug(
            "Delivery that started at %(usage_start)s appears to "
            "have completed.",
            {"usage_start": usage_start},
        )
        save_patient_data(
            usage_start, self._current_patient_data[ip], self._output_dir
        )
        self._current_patient_data[ip] = None
        self._usage_start[ip] = None
    else:
        logging.debug("No delivery is currently being recorded.")