Esempio n. 1
0
def get_fev1fvc(sentence):
    fev1fvc_list = []
    # Running a loop on the range in which fev1/fvc value could be found.
    # Includes ratios both exprecessed as percent and decimal, > 100% is for predicted values
    for x,y in [(0,2),(10,180)]:
        fev1_fvc = ve.run("fev1/fvc", sentence, x, y)
        fev1_fvc_json = json.loads(fev1_fvc)
        if fev1_fvc_json['querySuccess']:
            for i in range(fev1_fvc_json['measurementCount']):
                fev1fvc_dict = dict()
                fev1fvc_dict['type'] = "fev1_fvc_ratio"
                fev1fvc_dict['text'] = fev1_fvc_json['measurementList'][i]['text']
                fev1fvc_dict['condition'] = fev1_fvc_json['measurementList'][i]['condition']
                fev1fvc_dict['start'] = fev1_fvc_json['measurementList'][i]['start']
                fev1fvc_dict['end'] = fev1_fvc_json['measurementList'][i]['end']
                fev1fvc_dict['x'] = fev1_fvc_json['measurementList'][i]['x']
                fev1fvc_dict['y'] = fev1_fvc_json['measurementList'][i]['y']

                clean_text = fev1_fvc_json['measurementList'][i]['text'].replace(')','').replace('(','')
                sentence = sentence.replace(')','').replace('(','')

                fev1_fvc_units = re.findall(clean_text+r'\s?(%)?',sentence)[0]
                if fev1_fvc_units == '%':
                    fev1_fvc_units = re.findall(clean_text+r'\s?(% ?pred|% ?of ?pred| ?%)',sentence)[0]
                if fev1_fvc_units == '':
                    fev1_fvc_units = ve.EMPTY_FIELD
                fev1fvc_dict['units'] = fev1_fvc_units
                fev1fvc_list.append(fev1fvc_dict)
        else:
            pass
    return fev1fvc_list
Esempio n. 2
0
def get_fev1(sentence):
    fev1_list = []
    # Includes values in ml, l and % predicted
    for x, y in [(0, 6), (20, 190), (300, 6000)]:
        fev1 = ve.run("fev1", sentence, x, y)
        fev1_json = json.loads(fev1)
        if fev1_json['querySuccess']:
            for i in range(fev1_json['measurementCount']):
                fev1_dict = dict()
                fev1_dict['type'] = "fev1"
                fev1_dict['text'] = fev1_json['measurementList'][i]['text']
                fev1_dict['condition'] = fev1_json['measurementList'][i][
                    'condition']
                fev1_dict['x'] = fev1_json['measurementList'][i]['x']
                fev1_dict['y'] = fev1_json['measurementList'][i]['y']
                fev1_dict['start'] = fev1_json['measurementList'][i]['start']
                fev1_dict['end'] = fev1_json['measurementList'][i]['end']

                clean_text = fev1_json['measurementList'][i]['text'].replace(
                    ')', '').replace('(', '')
                sentence = sentence.replace(')', '').replace('(', '')

                fev1_units = re.findall(
                    clean_text + r'\s?(ml|cc|l|L|ML|CC|%)?', sentence)[0]
                if fev1_units == '%':
                    fev1_units = re.findall(
                        clean_text +
                        r'\s?(% ?predicted|% ?of ?predicted|% ?pred|% ?of ?pred| ?%)',
                        sentence)[0]
                if fev1_units == '':
                    fev1_units = ve.EMPTY_FIELD
                fev1_dict['units'] = fev1_units
                fev1_list.append(fev1_dict)
    return fev1_list
Esempio n. 3
0
def get_fev1(sentence):
    fev1_list = []
    # Includes values in ml, l and % predicted
    for x,y in [(0,6),(20,190),(300,6000)]:
        fev1 = ve.run("fev1", sentence, x, y)
        fev1_json = json.loads(fev1)
        if fev1_json['querySuccess']:
            for i in range(fev1_json['measurementCount']):
                fev1_dict = dict()
                fev1_dict['type'] = "fev1"
                fev1_dict['text'] = fev1_json['measurementList'][i]['text']
                fev1_dict['condition'] = fev1_json['measurementList'][i]['condition']
                fev1_dict['x'] = fev1_json['measurementList'][i]['x']
                fev1_dict['y'] = fev1_json['measurementList'][i]['y']
                fev1_dict['start'] = fev1_json['measurementList'][i]['start']
                fev1_dict['end'] = fev1_json['measurementList'][i]['end']

                clean_text = fev1_json['measurementList'][i]['text'].replace(')','').replace('(','')
                sentence = sentence.replace(')','').replace('(','')

                fev1_units = re.findall( clean_text +r'\s?(ml|cc|l|L|ML|CC|%)?',sentence)[0]
                if fev1_units == '%':
                    fev1_units = re.findall( clean_text +r'\s?(% ?predicted|% ?of ?predicted|% ?pred|% ?of ?pred| ?%)',sentence)[0]
                if fev1_units == '':
                    fev1_units = ve.EMPTY_FIELD
                fev1_dict['units'] = fev1_units
                fev1_list.append(fev1_dict)
    return fev1_list