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)
示例#2
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)
示例#3
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)
示例#4
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))
示例#5
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)
示例#6
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)
示例#7
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.")
示例#8
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)
示例#9
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")
示例#10
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")
示例#11
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",
        )
示例#12
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,
     )
示例#13
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.")
示例#14
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))
示例#15
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)