Spaces:
Runtime error
Runtime error
| 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") | |