def _refresh_participant_summary(self, session, obj):
        # called when cancelled/restored
        participant_summary_dao = ParticipantSummaryDao()
        participant_summary = participant_summary_dao.get_for_update(
            session, obj.participantId)
        non_cancelled_orders = self._get_non_cancelled_biobank_orders(
            session, obj.participantId)
        participant_summary.biospecimenStatus = OrderStatus.UNSET
        participant_summary.biospecimenOrderTime = None
        participant_summary.biospecimenSourceSiteId = None
        participant_summary.biospecimenCollectedSiteId = None
        participant_summary.biospecimenProcessedSiteId = None
        participant_summary.biospecimenFinalizedSiteId = None

        participant_summary.lastModified = clock.CLOCK.now()
        for sample in obj.samples:
            status_field = 'sampleOrderStatus' + sample.test
            setattr(participant_summary, status_field, OrderStatus.UNSET)
            setattr(participant_summary, status_field + 'Time', None)

        if len(non_cancelled_orders) > 0:
            for order in non_cancelled_orders:
                self._set_participant_summary_fields(order,
                                                     participant_summary)
        participant_summary_dao.update_enrollment_status(participant_summary)
 def _update_participant_summary(self, session, obj):
     participant_summary_dao = ParticipantSummaryDao()
     participant_summary = participant_summary_dao.get_for_update(
         session, obj.participantId)
     if not participant_summary:
         raise BadRequest(
             "Can't submit biospecimens for participant %s without consent"
             % obj.participantId)
     raise_if_withdrawn(participant_summary)
     self._set_participant_summary_fields(obj, participant_summary)
     participant_summary_dao.update_enrollment_status(participant_summary)
Exemplo n.º 3
0
    def _update_participant_summary(self, session, obj):
        """ called on insert"""
        participant_summary_dao = ParticipantSummaryDao()
        participant_summary = participant_summary_dao.get_for_update(
            session, obj.participantId)
        if not participant_summary:
            raise BadRequest(
                "Can't submit biospecimens for participant %s without consent"
                % obj.participantId)
        raise_if_withdrawn(participant_summary)
        self._set_participant_summary_fields(obj, participant_summary)
        participant_summary_dao.update_enrollment_status(participant_summary)

        finalized_time = self.get_random_sample_finalized_time(obj)
        is_distinct_visit = ParticipantSummaryDao().calculate_distinct_visits(
            participant_summary.participantId, finalized_time,
            obj.biobankOrderId)

        if is_distinct_visit:
            participant_summary.numberDistinctVisits += 1
Exemplo n.º 4
0
    def _refresh_participant_summary(self, session, obj):
        # called when cancelled/restored/amended
        participant_summary_dao = ParticipantSummaryDao()
        participant_summary = participant_summary_dao.get_for_update(
            session, obj.participantId)
        non_cancelled_orders = self._get_non_cancelled_biobank_orders(
            session, obj.participantId)
        participant_summary.biospecimenStatus = OrderStatus.UNSET
        participant_summary.biospecimenOrderTime = None
        participant_summary.biospecimenSourceSiteId = None
        participant_summary.biospecimenCollectedSiteId = None
        participant_summary.biospecimenProcessedSiteId = None
        participant_summary.biospecimenFinalizedSiteId = None

        finalized_time = self.get_random_sample_finalized_time(obj)
        amendment = False
        if not finalized_time:
            amendment = True
        is_distinct_visit = ParticipantSummaryDao().calculate_distinct_visits(
            participant_summary.participantId, finalized_time,
            obj.biobankOrderId, amendment)

        if is_distinct_visit and obj.orderStatus != BiobankOrderStatus.CANCELLED:
            participant_summary.numberDistinctVisits += 1

        if (obj.orderStatus == BiobankOrderStatus.CANCELLED
                and participant_summary.numberDistinctVisits > 0
                and is_distinct_visit):
            participant_summary.numberDistinctVisits -= 1

        participant_summary.lastModified = clock.CLOCK.now()
        for sample in obj.samples:
            status_field = 'sampleOrderStatus' + sample.test
            setattr(participant_summary, status_field, OrderStatus.UNSET)
            setattr(participant_summary, status_field + 'Time', None)

        if len(non_cancelled_orders) > 0:
            for order in non_cancelled_orders:
                self._set_participant_summary_fields(order,
                                                     participant_summary)
        participant_summary_dao.update_enrollment_status(participant_summary)
 def _update_participant_summary(self, session, obj):
     participant_summary_dao = ParticipantSummaryDao()
     participant_summary = participant_summary_dao.get_for_update(
         session, obj.participantId)
     if not participant_summary:
         raise BadRequest(
             "Can't submit biospecimens for participant %s without consent"
             % obj.participantId)
     raise_if_withdrawn(participant_summary)
     participant_summary.biospecimenStatus = OrderStatus.FINALIZED
     participant_summary.biospecimenOrderTime = obj.created
     participant_summary.biospecimenSourceSiteId = obj.sourceSiteId
     participant_summary.biospecimenCollectedSiteId = obj.collectedSiteId
     participant_summary.biospecimenProcessedSiteId = obj.processedSiteId
     participant_summary.biospecimenFinalizedSiteId = obj.finalizedSiteId
     participant_summary.lastModified = clock.CLOCK.now()
     for sample in obj.samples:
         status_field = 'sampleOrderStatus' + sample.test
         status, time = self._get_order_status_and_time(sample, obj)
         setattr(participant_summary, status_field, status)
         setattr(participant_summary, status_field + 'Time', time)