Пример #1
0
    def test_multiple_matches(self):
        text = "\n".join([
            "HPI: 50 yo m with hx of dm2, presents with chest pain",
            "Assessment: Plan:",
            "50 yo m with hx of dm2, presents with chest pain",
            "chest pain:",
            "- PCI today",
            "- DAPT, statin, bb",
        ])

        # A delimiter matching the regex (:) is found inside the marker
        marker_dict = {
            "hpi": ["history of present illness"],
            "assessment": ["assessment and plan"],
            "assessment: plan": ["assessment and plan"],
        }
        section_finder = note_section_lib.SectionFinder(marker_dict)

        self.assertListEqual(section_finder.find_sections(text), [
            note_section_lib.Section(
                char_start=0,
                char_end=54,
                section_types=["history of present illness"]),
            note_section_lib.Section(char_start=54,
                                     char_end=163,
                                     section_types=["assessment and plan"]),
        ])
Пример #2
0
    def test_extract_ap_sections(self):
        section_markers = {
            "hpi": ["history of present illness"],
            "a&p": ["assessment and plan"],
        }
        note = data_lib.Note(
            note_id=1,
            text="hpi:\n 50yof with hx of dm2.\na&p:\n # dm2:\n-RISS",
            subject_id=0,
            category="PHYSICIAN")

        expected = [note_section_lib.Section(28, 46, ["assessment and plan"])]
        self.assertEqual(
            list(data_lib.extract_ap_sections(note.text, section_markers)),
            expected)

        # multi section
        note = data_lib.Note(
            note_id=1,
            text="hpi:\n 50yof with hx of dm2.\na&p: DM2\na&p:\n # dm2:\n-RISS",
            subject_id=0,
            category="PHYSICIAN")

        expected = [
            note_section_lib.Section(28, 37, ["assessment and plan"]),
            note_section_lib.Section(37, 55, ["assessment and plan"]),
        ]
        self.assertEqual(
            list(data_lib.extract_ap_sections(note.text, section_markers)),
            expected)
Пример #3
0
    def test_multiple_section_types(self):
        text = "\n".join([
            "HPI: 50 yo m with hx of dm2, presents with chest pain",
            "past medical and surgical history:",
            "-DM2 on insulin",
            "-s/p CABG 1999",
            "A&P:",
            "50 yo m with hx of dm2, presents with chest pain",
            "chest pain:",
            "- PCI today",
            "- DAPT, statin, bb",
        ])

        self.assertListEqual(self.section_finder.find_sections(text), [
            note_section_lib.Section(
                char_start=0,
                char_end=54,
                section_types=["history of present illness"]),
            note_section_lib.Section(char_start=54,
                                     char_end=120,
                                     section_types=[
                                         "past medical history",
                                         "past surgical history"
                                     ]),
            note_section_lib.Section(char_start=120,
                                     char_end=216,
                                     section_types=["assessment and plan"]),
        ])
Пример #4
0
    def test_process_rating_labels(self):
        rating_labels = [
            ap_parsing_lib.LabeledCharSpan(
                span_type=ap_parsing_lib.LabeledSpanType.PROBLEM_TITLE,
                start_char=0,
                end_char=50),  # before
            ap_parsing_lib.LabeledCharSpan(
                span_type=ap_parsing_lib.LabeledSpanType.PROBLEM_TITLE,
                start_char=45,
                end_char=65),  # partially contained
            ap_parsing_lib.LabeledCharSpan(
                span_type=ap_parsing_lib.LabeledSpanType.PROBLEM_TITLE,
                start_char=50,
                end_char=150),  # exactly matches section
            ap_parsing_lib.LabeledCharSpan(
                span_type=ap_parsing_lib.LabeledSpanType.PROBLEM_TITLE,
                start_char=100,
                end_char=105),  # contained
            ap_parsing_lib.LabeledCharSpan(
                span_type=ap_parsing_lib.LabeledSpanType.PROBLEM_TITLE,
                start_char=150,
                end_char=155),  # after
        ]

        expected = [
            ap_parsing_lib.LabeledCharSpan(
                span_type=ap_parsing_lib.LabeledSpanType.PROBLEM_TITLE,
                start_char=0,
                end_char=100),
            ap_parsing_lib.LabeledCharSpan(
                span_type=ap_parsing_lib.LabeledSpanType.PROBLEM_TITLE,
                start_char=50,
                end_char=55)
        ]
        self.assertEqual(
            data_lib.process_rating_labels(
                rating_labels, note_section_lib.Section(50, 150, [])),
            expected)