예제 #1
0
    def test_iodi_location_investigator_duplicate(self):
        """ Tests the IODI insertion of duplicate `LocationInvestigator` records
            to ensure deduplication functions as intended.
        """

        # Create a `Location` record as a fixture.
        facility_id, _ = create_facility(dal=self.dal)
        person_id, _ = create_person(dal=self.dal)
        contact_id, _ = create_contact(dal=self.dal, person_id=person_id)
        location_id, _ = create_location(
            dal=self.dal,
            facility_id=facility_id,
            contact_primary_id=contact_id,
            contact_backup_id=contact_id,
        )
        # Create an `Investigator` record as a fixture.
        investigator_id, _ = create_investigator(
            dal=self.dal,
            person_id=person_id,
        )
        # Create additional `Investigator` record.
        investigator_02_id, _ = create_investigator(
            dal=self.dal,
            person_id=person_id,
            affiliation="NewAffiliation"
        )

        # IODI a new `LocationInvestigator` record.
        obj_id = self.dal.iodi_location_investigator(
            location_id=location_id,
            investigator_id=investigator_id,
        )

        self.assertEqual(obj_id, 1)

        # IODI an identical `Intervention` record.
        obj_id = self.dal.iodi_location_investigator(
            location_id=location_id,
            investigator_id=investigator_id,
        )

        self.assertEqual(obj_id, 1)

        # IODI a new `Intervention` record.
        obj_id = self.dal.iodi_location_investigator(
            location_id=location_id,
            investigator_id=investigator_02_id,
        )

        self.assertEqual(obj_id, 3)

        # IODI the same `Intervention` record as before.
        obj_id = self.dal.iodi_location_investigator(
            location_id=location_id,
            investigator_id=investigator_02_id,
        )

        self.assertEqual(obj_id, 3)
예제 #2
0
    def test_iodi_get_location_investigator(self):
        """ Tests the insertion of a `LocationInvestigator` record via the
            `iodi_location_investigator` method of the `DalClinicalTrials` class
            and its retrieval via the `get` method.
        """

        # Create a `Location` record as a fixture.
        facility_id, _ = create_facility(dal=self.dal)
        person_id, _ = create_person(dal=self.dal)
        contact_id, _ = create_contact(dal=self.dal, person_id=person_id)
        location_id, _ = create_location(
            dal=self.dal,
            facility_id=facility_id,
            contact_primary_id=contact_id,
            contact_backup_id=contact_id,
        )
        # Create an `Investigator` record as a fixture.
        investigator_id, _ = create_investigator(
            dal=self.dal,
            person_id=person_id,
        )

        # IODI a new `LocationInvestigator` record.
        obj_id = self.dal.iodi_location_investigator(
            location_id=location_id,
            investigator_id=investigator_id,
        )

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(
            LocationInvestigator,
            obj_id,
        )  # type: LocationInvestigator

        # Assert that the different fields of the record match.
        self.assertEqual(obj.location_investigator_id, 1)
        self.assertEqual(obj.location_id, location_id)
        self.assertEqual(obj.investigator_id, investigator_id)
예제 #3
0
    def test_delete_location_investigator(self):
        """ Tests the deletion of a `LocationInvestigator` record via the
            `delete` method of the `DalClinicalTrials` class.
        """

        # Create a `Location` record as a fixture.
        facility_id, _ = create_facility(dal=self.dal)
        person_id, _ = create_person(dal=self.dal)
        contact_id, _ = create_contact(dal=self.dal, person_id=person_id)
        location_id, _ = create_location(
            dal=self.dal,
            facility_id=facility_id,
            contact_primary_id=contact_id,
            contact_backup_id=contact_id,
        )
        # Create an `Investigator` record as a fixture.
        investigator_id, _ = create_investigator(
            dal=self.dal,
            person_id=person_id,
        )

        # IODI a new `LocationInvestigator` record.
        obj_id = self.dal.iodi_location_investigator(
            location_id=location_id,
            investigator_id=investigator_id,
        )

        self.assertEqual(obj_id, 1)

        # Delete the new record.
        self.dal.delete(LocationInvestigator, obj_id)

        # (Attempt to) retrieve the deleted record.
        obj = self.dal.get(
            LocationInvestigator,
            obj_id,
        )  # type: LocationInvestigator

        self.assertIsNone(obj)
예제 #4
0
    def test_delete_reference(self):
        """ Tests the deletion of a `Study` record via the `delete` method
            of the `DalClinicalTrials` class.
        """

        # Create fixtures.
        person_01_id, _ = create_person(dal=self.dal, name_first="A")
        person_02_id, _ = create_person(dal=self.dal, name_first="B")
        contact_primary_id, _ = create_contact(
            dal=self.dal,
            person_id=person_01_id,
        )
        contact_backup_id, _ = create_contact(
            dal=self.dal,
            person_id=person_02_id,
        )
        oversight_info_id, _ = create_oversight_info(dal=self.dal)
        expanded_access_info_id, _ = create_expanded_access_info(dal=self.dal)
        study_design_info_id, _ = create_study_design_info(dal=self.dal)
        enrollment_id, _ = create_enrollment(dal=self.dal)
        eligibility_id, _ = create_eligibility(dal=self.dal)
        study_dates_id, _ = create_study_dates(dal=self.dal)
        responsible_party_id, _ = create_responsible_party(dal=self.dal)
        patient_data_id, _ = create_patient_data(dal=self.dal)
        # IODU a new `Study` record.
        obj_id = self.dal.iodu_study(
            org_study_id="org_study_id",
            nct_id="nct_id",
            brief_title="brief_title",
            acronym="acronym",
            official_title="official_title",
            source="source",
            oversight_info_id=oversight_info_id,
            brief_summary="brief_summary",
            detailed_description="detailed_description",
            overall_status=OverallStatusType.ACTIVE_NOT,
            last_known_status=OverallStatusType.APPROVED,
            why_stopped="why_stopped",
            start_date=datetime.date(2019, 1, 1),
            completion_date=datetime.date(2019, 1, 1),
            primary_completion_date=datetime.date(2019, 1, 1),
            verification_date=datetime.date(2019, 1, 1),
            phase=PhaseType.PHASE_1,
            study_type=StudyType.EXPANDED,
            expanded_access_info_id=expanded_access_info_id,
            study_design_info_id=study_design_info_id,
            target_duration="target_duration",
            enrollment_id=enrollment_id,
            biospec_retention=BiospecRetentionType.SAMPLES_W_DNA,
            biospec_description="biospec_description",
            eligibility_id=eligibility_id,
            contact_primary_id=contact_primary_id,
            contact_backup_id=contact_backup_id,
            study_dates_id=study_dates_id,
            responsible_party_id=responsible_party_id,
            patient_data_id=patient_data_id,
        )

        self.assertEqual(obj_id, 1)

        # Delete the new record.
        self.dal.delete(Study, obj_id)

        # (Attempt to) retrieve the deleted record.
        obj = self.dal.get(Study, obj_id)  # type: Study

        self.assertIsNone(obj)
예제 #5
0
    def test_iodu_get_study(self):
        """ Tests the IODU insertion of a `Study` record via the
            `iodu_study` method of the `DalClinicalTrials` class and its
            retrieval via the `get` method.
        """

        # Create fixtures.
        person_01_id, _ = create_person(dal=self.dal, name_first="A")
        person_02_id, _ = create_person(dal=self.dal, name_first="B")
        contact_primary_id, _ = create_contact(
            dal=self.dal,
            person_id=person_01_id,
        )
        contact_backup_id, _ = create_contact(
            dal=self.dal,
            person_id=person_02_id,
        )
        oversight_info_id, _ = create_oversight_info(dal=self.dal)
        expanded_access_info_id, _ = create_expanded_access_info(dal=self.dal)
        study_design_info_id, _ = create_study_design_info(dal=self.dal)
        enrollment_id, _ = create_enrollment(dal=self.dal)
        eligibility_id, _ = create_eligibility(dal=self.dal)
        study_dates_id, _ = create_study_dates(dal=self.dal)
        responsible_party_id, _ = create_responsible_party(dal=self.dal)
        patient_data_id, _ = create_patient_data(dal=self.dal)
        # IODU a new `Study` record.
        obj_id = self.dal.iodu_study(
            org_study_id="org_study_id",
            nct_id="nct_id",
            brief_title="brief_title",
            acronym="acronym",
            official_title="official_title",
            source="source",
            oversight_info_id=oversight_info_id,
            brief_summary="brief_summary",
            detailed_description="detailed_description",
            overall_status=OverallStatusType.ACTIVE_NOT,
            last_known_status=OverallStatusType.APPROVED,
            why_stopped="why_stopped",
            start_date=datetime.date(2019, 1, 1),
            completion_date=datetime.date(2019, 1, 1),
            primary_completion_date=datetime.date(2019, 1, 1),
            verification_date=datetime.date(2019, 1, 1),
            phase=PhaseType.PHASE_1,
            study_type=StudyType.EXPANDED,
            expanded_access_info_id=expanded_access_info_id,
            study_design_info_id=study_design_info_id,
            target_duration="target_duration",
            enrollment_id=enrollment_id,
            biospec_retention=BiospecRetentionType.SAMPLES_W_DNA,
            biospec_description="biospec_description",
            eligibility_id=eligibility_id,
            contact_primary_id=contact_primary_id,
            contact_backup_id=contact_backup_id,
            study_dates_id=study_dates_id,
            responsible_party_id=responsible_party_id,
            patient_data_id=patient_data_id,
        )

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(Study, obj_id)  # type: Study

        # Assert that the different fields of the record match.
        self.assertEqual(obj.study_id, obj_id)
        self.assertEqual(obj.org_study_id, "org_study_id")
        self.assertEqual(obj.nct_id, "nct_id")
        self.assertEqual(obj.brief_title, "brief_title")
        self.assertEqual(obj.acronym, "acronym")
        self.assertEqual(obj.official_title, "official_title")
        self.assertEqual(obj.source, "source")
        self.assertEqual(obj.oversight_info_id, oversight_info_id)
        self.assertEqual(obj.brief_summary, "brief_summary")
        self.assertEqual(obj.detailed_description, "detailed_description")
        self.assertEqual(obj.overall_status, OverallStatusType.ACTIVE_NOT)
        self.assertEqual(obj.last_known_status, OverallStatusType.APPROVED)
        self.assertEqual(obj.why_stopped, "why_stopped")
        self.assertEqual(obj.start_date, datetime.date(2019, 1, 1))
        self.assertEqual(obj.completion_date, datetime.date(2019, 1, 1))
        self.assertEqual(obj.primary_completion_date,
                         datetime.date(2019, 1, 1))
        self.assertEqual(obj.verification_date, datetime.date(2019, 1, 1))
        self.assertEqual(obj.phase, PhaseType.PHASE_1)
        self.assertEqual(obj.study_type, StudyType.EXPANDED)
        self.assertEqual(obj.expanded_access_info_id, expanded_access_info_id)
        self.assertEqual(obj.study_design_info_id, study_design_info_id)
        self.assertEqual(obj.target_duration, "target_duration")
        self.assertEqual(obj.enrollment_id, enrollment_id)
        self.assertEqual(
            obj.biospec_retention,
            BiospecRetentionType.SAMPLES_W_DNA,
        )
        self.assertEqual(obj.biospec_description, "biospec_description")
        self.assertEqual(obj.eligibility_id, eligibility_id)
        self.assertEqual(obj.contact_primary_id, contact_primary_id)
        self.assertEqual(obj.contact_backup_id, contact_backup_id)
        self.assertEqual(obj.study_dates_id, study_dates_id)
        self.assertEqual(obj.responsible_party_id, responsible_party_id)
        self.assertEqual(obj.patient_data_id, patient_data_id)
예제 #6
0
    def test_iodu_study_duplicate(self):
        """ Tests the IODU insertion of duplicate `Study` records to ensure
            deduplication functions as intended.
        """

        # Create fixtures.
        person_01_id, _ = create_person(dal=self.dal, name_first="A")
        person_02_id, _ = create_person(dal=self.dal, name_first="B")
        contact_primary_id, _ = create_contact(
            dal=self.dal,
            person_id=person_01_id,
        )
        contact_backup_id, _ = create_contact(
            dal=self.dal,
            person_id=person_02_id,
        )
        oversight_info_id, _ = create_oversight_info(dal=self.dal)
        expanded_access_info_id, _ = create_expanded_access_info(dal=self.dal)
        study_design_info_id, _ = create_study_design_info(dal=self.dal)
        enrollment_id, _ = create_enrollment(dal=self.dal)
        eligibility_id, _ = create_eligibility(dal=self.dal)
        study_dates_id, _ = create_study_dates(dal=self.dal)
        responsible_party_id, _ = create_responsible_party(dal=self.dal)
        patient_data_id, _ = create_patient_data(dal=self.dal)
        # IODU a new `Study` record.
        obj_id = self.dal.iodu_study(
            org_study_id="org_study_id",
            nct_id="nct_id",
            brief_title="brief_title",
            acronym="acronym",
            official_title="official_title",
            source="source",
            oversight_info_id=oversight_info_id,
            brief_summary="brief_summary",
            detailed_description="detailed_description",
            overall_status=OverallStatusType.ACTIVE_NOT,
            last_known_status=OverallStatusType.APPROVED,
            why_stopped="why_stopped",
            start_date=datetime.date(2019, 1, 1),
            completion_date=datetime.date(2019, 1, 1),
            primary_completion_date=datetime.date(2019, 1, 1),
            verification_date=datetime.date(2019, 1, 1),
            phase=PhaseType.PHASE_1,
            study_type=StudyType.EXPANDED,
            expanded_access_info_id=expanded_access_info_id,
            study_design_info_id=study_design_info_id,
            target_duration="target_duration",
            enrollment_id=enrollment_id,
            biospec_retention=BiospecRetentionType.SAMPLES_W_DNA,
            biospec_description="biospec_description",
            eligibility_id=eligibility_id,
            contact_primary_id=contact_primary_id,
            contact_backup_id=contact_backup_id,
            study_dates_id=study_dates_id,
            responsible_party_id=responsible_party_id,
            patient_data_id=patient_data_id,
        )

        self.assertEqual(obj_id, 1)

        # IODU the same `Study` record.
        obj_id = self.dal.iodu_study(
            org_study_id="org_study_id",
            nct_id="nct_id",
            brief_title="brief_title",
            acronym="acronym",
            official_title="official_title",
            source="source",
            oversight_info_id=oversight_info_id,
            brief_summary="brief_summary",
            detailed_description="detailed_description",
            overall_status=OverallStatusType.ACTIVE_NOT,
            last_known_status=OverallStatusType.APPROVED,
            why_stopped="why_stopped",
            start_date=datetime.date(2019, 1, 1),
            completion_date=datetime.date(2019, 1, 1),
            primary_completion_date=datetime.date(2019, 1, 1),
            verification_date=datetime.date(2019, 1, 1),
            phase=PhaseType.PHASE_1,
            study_type=StudyType.EXPANDED,
            expanded_access_info_id=expanded_access_info_id,
            study_design_info_id=study_design_info_id,
            target_duration="target_duration",
            enrollment_id=enrollment_id,
            biospec_retention=BiospecRetentionType.SAMPLES_W_DNA,
            biospec_description="biospec_description",
            eligibility_id=eligibility_id,
            contact_primary_id=contact_primary_id,
            contact_backup_id=contact_backup_id,
            study_dates_id=study_dates_id,
            responsible_party_id=responsible_party_id,
            patient_data_id=patient_data_id,
        )

        self.assertEqual(obj_id, 1)

        # IODU the same `Study` record with a changed `brief_title` field
        # which should trigger an update on the existing record.
        obj_id = self.dal.iodu_study(
            org_study_id="org_study_id",
            nct_id="nct_id",
            brief_title="new_brief_title",
            acronym="acronym",
            official_title="official_title",
            source="source",
            oversight_info_id=oversight_info_id,
            brief_summary="brief_summary",
            detailed_description="detailed_description",
            overall_status=OverallStatusType.ACTIVE_NOT,
            last_known_status=OverallStatusType.APPROVED,
            why_stopped="why_stopped",
            start_date=datetime.date(2019, 1, 1),
            completion_date=datetime.date(2019, 1, 1),
            primary_completion_date=datetime.date(2019, 1, 1),
            verification_date=datetime.date(2019, 1, 1),
            phase=PhaseType.PHASE_1,
            study_type=StudyType.EXPANDED,
            expanded_access_info_id=expanded_access_info_id,
            study_design_info_id=study_design_info_id,
            target_duration="target_duration",
            enrollment_id=enrollment_id,
            biospec_retention=BiospecRetentionType.SAMPLES_W_DNA,
            biospec_description="biospec_description",
            eligibility_id=eligibility_id,
            contact_primary_id=contact_primary_id,
            contact_backup_id=contact_backup_id,
            study_dates_id=study_dates_id,
            responsible_party_id=responsible_party_id,
            patient_data_id=patient_data_id,
        )

        self.assertEqual(obj_id, 1)

        # Retrieve the new record.
        obj = self.dal.get(Study, obj_id)  # type: Study

        self.assertEqual(obj.brief_title, "new_brief_title")

        # IODU a new `Study` record.
        obj_id = self.dal.iodu_study(
            org_study_id="org_study_id",
            nct_id="new_nct_id",
            brief_title="brief_title",
            acronym="acronym",
            official_title="official_title",
            source="source",
            oversight_info_id=oversight_info_id,
            brief_summary="brief_summary",
            detailed_description="detailed_description",
            overall_status=OverallStatusType.ACTIVE_NOT,
            last_known_status=OverallStatusType.APPROVED,
            why_stopped="why_stopped",
            start_date=datetime.date(2019, 1, 1),
            completion_date=datetime.date(2019, 1, 1),
            primary_completion_date=datetime.date(2019, 1, 1),
            verification_date=datetime.date(2019, 1, 1),
            phase=PhaseType.PHASE_1,
            study_type=StudyType.EXPANDED,
            expanded_access_info_id=expanded_access_info_id,
            study_design_info_id=study_design_info_id,
            target_duration="target_duration",
            enrollment_id=enrollment_id,
            biospec_retention=BiospecRetentionType.SAMPLES_W_DNA,
            biospec_description="biospec_description",
            eligibility_id=eligibility_id,
            contact_primary_id=contact_primary_id,
            contact_backup_id=contact_backup_id,
            study_dates_id=study_dates_id,
            responsible_party_id=responsible_party_id,
            patient_data_id=patient_data_id,
        )

        self.assertEqual(obj_id, 4)

        # IODU the same `Descriptor` record as before.
        obj_id = self.dal.iodu_study(
            org_study_id="org_study_id",
            nct_id="new_nct_id",
            brief_title="brief_title",
            acronym="acronym",
            official_title="official_title",
            source="source",
            oversight_info_id=oversight_info_id,
            brief_summary="brief_summary",
            detailed_description="detailed_description",
            overall_status=OverallStatusType.ACTIVE_NOT,
            last_known_status=OverallStatusType.APPROVED,
            why_stopped="why_stopped",
            start_date=datetime.date(2019, 1, 1),
            completion_date=datetime.date(2019, 1, 1),
            primary_completion_date=datetime.date(2019, 1, 1),
            verification_date=datetime.date(2019, 1, 1),
            phase=PhaseType.PHASE_1,
            study_type=StudyType.EXPANDED,
            expanded_access_info_id=expanded_access_info_id,
            study_design_info_id=study_design_info_id,
            target_duration="target_duration",
            enrollment_id=enrollment_id,
            biospec_retention=BiospecRetentionType.SAMPLES_W_DNA,
            biospec_description="biospec_description",
            eligibility_id=eligibility_id,
            contact_primary_id=contact_primary_id,
            contact_backup_id=contact_backup_id,
            study_dates_id=study_dates_id,
            responsible_party_id=responsible_party_id,
            patient_data_id=patient_data_id,
        )

        self.assertEqual(obj_id, 4)