forked from vikramc1/ccda-parser
-
Notifications
You must be signed in to change notification settings - Fork 1
/
__init__.py
42 lines (33 loc) · 1.13 KB
/
__init__.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 2 21:56:30 2018
@authors: mansooralam, yanjingwang
"""
from . import core
from . import documents
from . import parsers
class CCDA(object):
def __init__(self, source, options=None):
type, parsed_document, parsed_data = None, None, None
if options is None:
opts = dict()
parsed_data = core.parse_data(source)
if 'parser' in opts:
parsed_document = opts['parser']()
else:
type = documents.detect(parsed_data)
if 'c32' == type:
# TODO: add support for legacy C32
# parsed_data = documents.C32.process(parsed_data)
# parsed_document = parsers.C32.run(parsed_data)
pass
elif 'ccda' == type:
parsed_data = documents.ccda.process(parsed_data)
parsed_document = parsers.ccda.run(parsed_data)
elif 'json' == type:
# TODO: add support for JSON
pass
self.type = type
self.data = parsed_document
self.source = parsed_data