File size: 2,353 Bytes
1a75d5d
 
 
 
38511f7
1a75d5d
 
38511f7
 
 
 
 
 
 
 
 
1a75d5d
 
 
 
 
 
 
 
 
38511f7
 
 
 
 
1a75d5d
 
 
38511f7
1a75d5d
 
 
38511f7
 
 
 
 
 
 
 
 
 
1a75d5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38511f7
1a75d5d
38511f7
1a75d5d
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from typing import Optional, List, Dict
from enum import Enum

from pydantic import BaseModel, Field
from utility import read_pdf

class Article(BaseModel):
    file: str|object = Field(None, alias="file")
    title: Optional[str] = Field(None, alias="title")
    content: Optional[str]

    def read_article(self):
        if isinstance(self.file,str):
            self.content = read_pdf(self.file)
        else:
            self.content = self.file.read()

class Table(BaseModel):
    title: str = Field(None, alias="title")
    fields: List[str] = Field(None, alias="Table column headings")
    content: Optional[str] = Field(None, alias="Table content body")

class Summary(BaseModel):
    tables: Optional[List[Table]] = Field(None, alias="tables")

class Region(Enum):
    spine = "Spine"
    extremity = "Extremity"
    all = "All"

class Assessment(Enum):
    overview = "overview"
    clinical = "clinical"
    radiologic = "radiologic"
    safety = "safety"
    other = "other"

class Section(Enum):
    abstract = "Abstract"
    introduction = "Introduction"
    methods = "Material and Methods"
    results = "Results"
    discussion = "Discussion"
    conclusion = "Conclusion"
    references = "References"
    ifu = "IFU"

class Parameter(BaseModel):
    name: str
    value: str
    unit: str
    condition:Optional[str] = Field(None, alias="condition")
    assessment:Assessment = Field(None, description="The clinical trail assessment steps")

class Preference(BaseModel):
    name: str
    params: List[Parameter] = Field(None, alias="parameters")

class ArticleCollection(BaseModel):
    articles: List[Article] = Field(None, alias="articles")
    summary: Optional[Summary] = Field(None, alias="summary")
    preferences: Preference = Field(None, alias="preferences")

class ClinicalStudy(Article):
    tables: Optional[List[Table]] = Field(None, alias="tables")
    acceptance_year: Optional[int] = Field(None, alias="acceptance_year")
    acceptance_month: Optional[int] = Field(None, alias="acceptance_month")
    sections: Optional[Dict[Section,str]] = Field(None, alias="sections")

class DeviceIFU(Article):
    tables: Optional[List[Table]] = Field(None, alias="tables")
    sections: Optional[List[str]] = Field(None, alias="sections")
    sectionCollection: Optional[List[str]] = Field(None, alias="sectionCollection")