|
| 1 | +from pydantic import BaseModel |
| 2 | + |
1 | 3 | """A file for models used in the converter tool""" |
| 4 | + |
| 5 | +class OBXSegmentBase(BaseModel): |
| 6 | + """Common OBX fields (1..5 without the value).""" |
| 7 | + |
| 8 | + line_number: int # OBX-2 |
| 9 | + |
| 10 | + variant_identifier_line: str # OBX-5 |
| 11 | + |
| 12 | + |
| 13 | +class OBXSegmentST(OBXSegmentBase): |
| 14 | + '''A class representing a segment with a string type''' |
| 15 | + |
| 16 | + observation_type: str = "ST" |
| 17 | + |
| 18 | + value: str |
| 19 | + |
| 20 | + |
| 21 | +class OBXSegmentCWE(OBXSegmentBase): |
| 22 | + '''A class representing a segment with a codeable concept type''' |
| 23 | + |
| 24 | + observation_type: str = "CWE" |
| 25 | + |
| 26 | + code: str |
| 27 | + |
| 28 | + coding_system: str |
| 29 | + |
| 30 | + label: str |
| 31 | + |
| 32 | + |
| 33 | +class OBXSegmentNM(OBXSegmentBase): |
| 34 | + '''A class representing a segment with a numeric type''' |
| 35 | + |
| 36 | + observation_type: str = "NM" |
| 37 | + |
| 38 | + value: float |
| 39 | + |
| 40 | + |
| 41 | +class OBXSegmentNR(OBXSegmentBase): |
| 42 | + '''A class representing a segment with a numeric range type''' |
| 43 | + |
| 44 | + observation_type: str = "NR" |
| 45 | + |
| 46 | + lower_bound: float |
| 47 | + |
| 48 | + upper_bound: float |
| 49 | + |
| 50 | + |
| 51 | +class OBXSegmentGroup(BaseModel): |
| 52 | + '''A class representing one or more segments that have the same type and segment identifier (e.g., the Discrete Genetic Variant lines)''' |
| 53 | + |
| 54 | + segments: list[OBXSegmentBase] |
| 55 | + |
| 56 | + segment_type: str = "OBX" # OBX-1 |
| 57 | + |
| 58 | + observation_type: str # OBX-3 |
| 59 | + |
| 60 | + variant_type: int = 2 # OBX-5 |
| 61 | + |
| 62 | + variant_identifier: str # OBX-5 |
| 63 | + |
| 64 | + segment_identifier: str # OBX-3.1 |
| 65 | + |
| 66 | + segment_name: str # OBX 3.2 |
| 67 | + |
| 68 | + segment_identifier_system: str # OBX 3.3 |
0 commit comments