|
a |
|
b/lambda_handler.py |
|
|
1 |
|
|
|
2 |
import os |
|
|
3 |
import sys |
|
|
4 |
import nltk |
|
|
5 |
|
|
|
6 |
import moline_sheet_src |
|
|
7 |
import caa_sheet_src |
|
|
8 |
import sag_sheet_src |
|
|
9 |
|
|
|
10 |
from request_handling_aws import * |
|
|
11 |
|
|
|
12 |
|
|
|
13 |
def identify_pipeline(full_body): |
|
|
14 |
print(dir(moline_sheet_src.main)) |
|
|
15 |
identifiers = { |
|
|
16 |
'moline_id' : ('QUAD CITIES',moline_sheet_src.main.run_pipeline), |
|
|
17 |
'sag_id' : ('SAINT ANTHONY',sag_sheet_src.main.run_pipeline), |
|
|
18 |
'caa_id' : ('Advocate Illinois Masonic Medical Center',caa_sheet_src.main.run_pipeline) |
|
|
19 |
} |
|
|
20 |
|
|
|
21 |
for line in full_body: |
|
|
22 |
for key, val in identifiers.items(): |
|
|
23 |
if nltk.edit_distance(val[0], line.strip())<3: |
|
|
24 |
return val[1] |
|
|
25 |
|
|
|
26 |
|
|
|
27 |
def run_pipeline(event, context): |
|
|
28 |
full_body, ids, form_data = get_all_text(os.getenv("S3_BUCKET_NAME"),os.getenv("BUCKET_DIR"), event_list = event["Records"], require_form=True) |
|
|
29 |
|
|
|
30 |
pipeline_func = identify_pipeline(full_body) |
|
|
31 |
|
|
|
32 |
|
|
|
33 |
# block_markers = ['<START>', 'ENCOUNTER', 'PATIENT', 'GUARANTOR', 'COVERAGE'] |
|
|
34 |
# breaking_phrase = 'QUAD CITIES' |
|
|
35 |
|
|
|
36 |
# patient_list = get_patients(full_body,block_markers,breaking_phrase) |
|
|
37 |
# fin_df = compile_dataframe(patient_list) |
|
|
38 |
fin_df = pipeline_func(full_body, form_data) |
|
|
39 |
|
|
|
40 |
put_dynamo(os.getenv("DYNAMO_TABLE_NAME"), fin_df, ids) |
|
|
41 |
|
|
|
42 |
|
|
|
43 |
if __name__ == "__main__": |
|
|
44 |
os.environ["S3_BUCKET_NAME"] = "facesheet-ap" |
|
|
45 |
os.environ["BUCKET_DIR"] = "facesheet_moline/" |
|
|
46 |
os.environ["DYNAMO_TABLE_NAME"] = "patient_data" |
|
|
47 |
event = {"Records":[{"s3":{"object":{"key":"facesheet_moline/000a5953-9b4a-4abd-9002-a1347ba949e2.png"}}}]} |
|
|
48 |
run_pipeline(event, {}) |