예제 #1
0
 def setUp(self):
     self.wb = AliquotType(name="whole_blood",
                           numeric_code="02",
                           alpha_code="WB")
     self.bc = AliquotType(name="buffy_coat",
                           numeric_code="12",
                           alpha_code="BC")
예제 #2
0
    def setup_site_labs(self):
        """Sets up the site_lab global."""
        site_labs._registry = {}
        site_labs.loaded = False

        self.profile_aliquot_count = 3

        # create aliquots and their relationship
        a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
        b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB")
        a.add_derivatives(b)

        # set up processes
        process = Process(aliquot_type=b,
                          aliquot_count=self.profile_aliquot_count)
        processing_profile = ProcessingProfile(name="process", aliquot_type=a)
        processing_profile.add_processes(process)

        # create a panel
        self.panel = RequisitionPanel(name="panel",
                                      processing_profile=processing_profile)

        # lab profile
        self.lab_profile = LabProfile(name="lab_profile",
                                      requisition_model=self.requisition_model)
        self.lab_profile.add_panel(self.panel)

        # register with site
        site_labs.register(lab_profile=self.lab_profile)
예제 #3
0
 def test_assert_cannot_add_duplicate_process(self):
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB")
     a.add_derivatives(b)
     process = Process(aliquot_type=b, aliquot_count=3)
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     processing_profile.add_processes(process)
     self.assertRaises(ProcessingProfileAlreadyAdded,
                       processing_profile.add_processes, process)
예제 #4
0
 def test_add_processing(self):
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB")
     a.add_derivatives(b)
     process = Process(aliquot_type=b, aliquot_count=3)
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     processing_profile.add_processes(process)
     panel = RequisitionPanel(name="Viral Load",
                              processing_profile=processing_profile)
     lab_profile = LabProfile(
         name="profile", requisition_model="edc_lab.subjectrequisition")
     lab_profile.add_panel(panel)
예제 #5
0
 def test_processing_bad(self):
     """Asserts CANNOT add process for aliquot B to a profile
     for aliquot A if B cannot be derived from A.
     """
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB")
     process = Process(aliquot_type=b, aliquot_count=3)
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     self.assertRaises(
         ProcessingProfileInvalidDerivative,
         processing_profile.add_processes,
         process,
     )
예제 #6
0
 def test_panel_adds_processing_profile(self):
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB")
     a.add_derivatives(b)
     process = Process(aliquot_type=b, aliquot_count=3)
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     processing_profile.add_processes(process)
     panel = RequisitionPanel(name="some panel",
                              processing_profile=processing_profile)
     lab_profile = LabProfile(
         name="profile", requisition_model="edc_lab.subjectrequisition")
     lab_profile.add_panel(panel)
     self.assertEqual(panel, lab_profile.panels.get(panel.name))
예제 #7
0
 def setUp(self):
     self.requisition_model = "edc_lab.subjectrequisition"
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB")
     a.add_derivatives(b)
     process = Process(aliquot_type=b, aliquot_count=3)
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     processing_profile.add_processes(process)
     panel = RequisitionPanel(name="Viral Load", processing_profile=processing_profile)
     self.lab_profile = LabProfile(name="profile", requisition_model=self.requisition_model)
     self.lab_profile.add_panel(panel)
     site_labs._registry = {}
     site_labs.loaded = False
     site_labs.register(lab_profile=self.lab_profile)
예제 #8
0
 def test_add_panel(self):
     """Assert same panel cannot be added twice."""
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB")
     a.add_derivatives(b)
     process = Process(aliquot_type=b, aliquot_count=3)
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     processing_profile.add_processes(process)
     panel = RequisitionPanel(name="Viral Load",
                              processing_profile=processing_profile)
     lab_profile = LabProfile(
         name="profile", requisition_model="edc_lab.subjectrequisition")
     lab_profile.add_panel(panel)
     self.assertRaises(PanelAlreadyRegistered, lab_profile.add_panel, panel)
예제 #9
0
 def test_processing_ok(self):
     """Asserts CAN add process for aliquot B to a profile
     for aliquot A since B can be derived from A.
     """
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB")
     a.add_derivatives(b)
     process = Process(aliquot_type=b, aliquot_count=3)
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     try:
         processing_profile.add_processes(process)
     except ProcessingProfileInvalidDerivative:
         self.fail(
             "ProcessingProfileInvalidDerivative unexpectedly raised.")
예제 #10
0
 def test_added_panel_knows_requisition_model(self):
     """Assert same panel cannot be added twice."""
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB")
     a.add_derivatives(b)
     process = Process(aliquot_type=b, aliquot_count=3)
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     processing_profile.add_processes(process)
     panel = RequisitionPanel(name="Viral Load",
                              processing_profile=processing_profile)
     lab_profile = LabProfile(
         name="profile", requisition_model="edc_lab.subjectrequisition")
     lab_profile.add_panel(panel)
     panel = lab_profile.panels.get("Viral Load")
     self.assertEqual(panel.requisition_model, "edc_lab.subjectrequisition")
     self.assertEqual(panel.requisition_model_cls, SubjectRequisition)
예제 #11
0
    def test_panel2(self):

        wb = AliquotType(name="Whole Blood", alpha_code="WB", numeric_code="02")

        whole_blood_processing = ProcessingProfile(name="whole_blood_store", aliquot_type=wb)

        wb_panel = RequisitionPanel(
            name="wb_storage",
            verbose_name="Whole Blood Storage",
            processing_profile=whole_blood_processing,
        )

        lab_profile = LabProfile(
            name="test_profile", requisition_model="edc_lab.subjectrequisition"
        )
        lab_profile.add_panel(wb_panel)

        site_labs.register(lab_profile=lab_profile)

        try:
            Panel.objects.get(name="wb_storage")
        except ObjectDoesNotExist:
            self.fail("Panel unexpectedly does not exist")

        panel = Panel.objects.get(name="wb_storage")

        self.assertEqual(panel.display_name, "Whole Blood Storage")
        self.assertEqual(panel.lab_profile_name, "test_profile")
예제 #12
0
 def test_requisition_panel_does_not_know_requisition_model(self):
     """Demonstrate that a panel not yet added to a lab profile
     does not know the requisition model.
     """
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     panel = RequisitionPanel(name="Viral Load", processing_profile=processing_profile)
     self.assertIsNone(panel.requisition_model)
     self.assertRaises(RequisitionPanelLookupError, getattr, panel, "requisition_model_cls")
예제 #13
0
class TestAliquotType(TestCase):
    def setUp(self):
        self.wb = AliquotType(name="whole_blood",
                              numeric_code="02",
                              alpha_code="WB")
        self.bc = AliquotType(name="buffy_coat",
                              numeric_code="12",
                              alpha_code="BC")

    def test_bad_aliquot_type1(self):
        self.assertRaises(
            AliquotTypeNumericCodeError,
            AliquotType,
            name="whole_blood",
            numeric_code="AA",
            alpha_code="WB",
        )

    def test_bad_aliquot_type2(self):
        self.assertRaises(
            AliquotTypeAlphaCodeError,
            AliquotType,
            name="whole_blood",
            numeric_code="02",
            alpha_code="99",
        )

    def test_aliquot_type_repr(self):
        aliquot_type = AliquotType(name="aliquot",
                                   numeric_code="00",
                                   alpha_code="AA")
        self.assertTrue(repr(aliquot_type))

    def test_aliquot_type_derivatives_single(self):
        """Asserts can add a derivative."""
        self.wb.add_derivatives(self.bc)
        self.assertEqual(self.wb.derivatives, [self.bc])

    def test_aliquot_type_derivatives_multi(self):
        """Asserts can add more than one derivative."""
        pl = AliquotType(name="plasma", numeric_code="32", alpha_code="PL")
        self.wb.add_derivatives(self.bc, pl)
        self.assertEqual(self.wb.derivatives, [self.bc, pl])
예제 #14
0
 def test_create_new_primary_aliquot(self):
     aliquot_type = AliquotType(name="aliquot_a",
                                numeric_code="22",
                                alpha_code="WW")
     p = PrimaryAliquot(
         requisition_identifier="ABCDE",
         identifier_prefix="066ABCDE",
         aliquot_type=aliquot_type,
         aliquot_creator_cls=MyAliquotCreator,
     )
     self.assertTrue(p.object)
예제 #15
0
    def get_panel_group():
        a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
        b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB")
        a.add_derivatives(b)
        process = Process(aliquot_type=b, aliquot_count=3)
        processing_profile = ProcessingProfile(name="process", aliquot_type=a)
        processing_profile.add_processes(process)
        rft_panel = RequisitionPanel(
            name="chemistry_rft",
            verbose_name="Chemistry: Renal Function Tests",
            abbreviation="RFT",
            processing_profile=processing_profile,
            utest_ids=["urea", "creatinine", "uric_acid", "egfr"],
        )

        lipids_panel = RequisitionPanel(
            name="chemistry_lipids",
            verbose_name="Chemistry: Lipids",
            abbreviation="LIPIDS",
            processing_profile=processing_profile,
            utest_ids=["ldl", "hdl", "trig"],
        )

        lft_panel = RequisitionPanel(
            name="chemistry_lft",
            verbose_name="Chemistry: Liver Function Tests",
            abbreviation="LFT",
            processing_profile=processing_profile,
            utest_ids=["ast", "alt", "alp", "amylase", "ggt", "albumin"],
        )

        return RequisitionPanelGroup(
            lft_panel,
            rft_panel,
            lipids_panel,
            name="chemistry",
            verbose_name="Chemistry: LFT, RFT, Lipids",
            reference_range_collection_name="default",
        )
예제 #16
0
 def test_requisition_panel_raises_on_invalid_requisition_model(self):
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     for requisition_model in [None, "edc_lab.blah", "blah"]:
         with self.subTest(requisition_model=requisition_model):
             panel = RequisitionPanel(
                 name="Viral Load", processing_profile=processing_profile
             )
             # manually set, normally done by LabProfile
             panel.requisition_model = requisition_model
             try:
                 panel.requisition_model_cls
             except RequisitionPanelLookupError:
                 pass
             else:
                 self.fail("RequisitionPanelModelError unexpectedly not raised.")
예제 #17
0
 def test_primary_aliquot_exists2(self):
     """Asserts primary aliquot exists using requisition_identifier."""
     aliquot_type = AliquotType(name="aliquot_a",
                                numeric_code="22",
                                alpha_code="WW")
     primary_aliquot = PrimaryAliquot(
         requisition_identifier="ABCDE",
         identifier_prefix="066ABCDE",
         aliquot_type=aliquot_type,
         aliquot_creator_cls=MyAliquotCreator,
     )
     obj = primary_aliquot.object
     p = PrimaryAliquot(
         requisition_identifier=obj.requisition_identifier,
         aliquot_creator_cls=MyAliquotCreator,
     )
     self.assertEqual(obj.aliquot_identifier, p.object.aliquot_identifier)
예제 #18
0
 def test_get_primary_aliquot(self):
     """Asserts does not recreate aliquot model instance
     if already exists.
     """
     aliquot_type = AliquotType(name="aliquot_a",
                                numeric_code="22",
                                alpha_code="WW")
     p = PrimaryAliquot(
         requisition_identifier="ABCDE",
         identifier_prefix="066ABCDE",
         aliquot_type=aliquot_type,
         aliquot_creator_cls=MyAliquotCreator,
     )
     pk = p.object.id
     aliquot_identifier = p.object.aliquot_identifier
     p = PrimaryAliquot(
         requisition_identifier="ABCDE",
         identifier_prefix="066ABCDE",
         aliquot_type=aliquot_type,
         aliquot_creator_cls=MyAliquotCreator,
     )
     self.assertEqual(aliquot_identifier, p.object.aliquot_identifier)
     self.assertEqual(pk, p.object.id)
예제 #19
0
 def test_process_profile_repr(self):
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     processing_profile = ProcessingProfile(name="processing_profile",
                                            aliquot_type=a)
     self.assertTrue(repr(processing_profile))
예제 #20
0
 def test_process_repr(self):
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     process = Process(aliquot_type=a)
     self.assertTrue(repr(process))
예제 #21
0
 def test_aliquot_type_derivatives_multi(self):
     """Asserts can add more than one derivative."""
     pl = AliquotType(name="plasma", numeric_code="32", alpha_code="PL")
     self.wb.add_derivatives(self.bc, pl)
     self.assertEqual(self.wb.derivatives, [self.bc, pl])
예제 #22
0
 def test_aliquot_type_repr(self):
     aliquot_type = AliquotType(name="aliquot",
                                numeric_code="00",
                                alpha_code="AA")
     self.assertTrue(repr(aliquot_type))
예제 #23
0
 def test_requisition_panel(self):
     a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA")
     processing_profile = ProcessingProfile(name="process", aliquot_type=a)
     RequisitionPanel(name="Viral Load", processing_profile=processing_profile)