def derive_transfer( self, conversation: Gp2gpConversation, organisation_lookup: OrganisationLookup ) -> Transfer: sla_duration = _calculate_sla(conversation, self._probe) requesting_practice_asid = conversation.requesting_practice_asid() sending_practice_asid = conversation.sending_practice_asid() return Transfer( conversation_id=conversation.conversation_id(), sla_duration=sla_duration, requesting_practice=Practice( asid=requesting_practice_asid, supplier=conversation.requesting_supplier(), ods_code=organisation_lookup.practice_ods_code_from_asid(requesting_practice_asid), ), sending_practice=Practice( asid=sending_practice_asid, supplier=conversation.sending_supplier(), ods_code=organisation_lookup.practice_ods_code_from_asid(sending_practice_asid), ), sender_error_codes=conversation.sender_error_codes(), final_error_codes=conversation.final_error_codes(), intermediate_error_codes=conversation.intermediate_error_codes(), outcome=TransferOutcome.from_gp2gp_conversation(conversation, sla_duration), date_requested=conversation.date_requested(), date_completed=conversation.effective_final_acknowledgement_time(), last_sender_message_timestamp=conversation.last_sender_message_timestamp(), )
def record_negative_sla(self, conversation: Gp2gpConversation): self._logger.warning( f":Negative SLA duration for conversation: {conversation.conversation_id()}", extra={ "event": "NEGATIVE_SLA_DETECTED", "conversation_id": conversation.conversation_id(), "final_acknowledgement_time": conversation.effective_final_acknowledgement_time(), "request_completed_time": conversation.effective_request_completed_time(), }, )