Skip to content

Running PrecisionOCR

Scripting the upload of documents with the Python SDK is as easy as using the PrecisionOCR interface.

phc.Ocr.upload_and_run("./John History Notes (D Harris).pdf")

# =>
# {'resourceType': 'DocumentReference',
#  'meta.tag_system__lifeomic.com/fhir/dataset__code': '637475e1-3b26-4d78-87eb-5df66ab9ef59',
#  'meta.tag_system__lifeomic.com/fhir/source__code': 'PrecisionOCR Service',
#  'meta.tag_lastUpdated.tz': 0.0,
#  'meta.tag_lastUpdated.local': Timestamp('2021-03-23 15:04:22.366000+0000', tz='UTC'),
#  'type.coding_system__loinc.org__code': '11488-4',
#  'type.coding_system__loinc.org__display': 'Consult note',
#  'indexed': '2021-03-23T15:04:21.958Z',
#  'status': 'current',
#  'meta.tag_system__lifeomic.com/ocr/document/status__code': 'OCR_RUNNING',
#  'docStatus': 'preliminary',
#  'description': 'ocr-uploads/John History Notes (D Harris).pdf',
#  'content': [{'attachment': {'contentType': 'application/pdf',
#     'url': 'https://api.dev.lifeomic.com/v1/files/6f71d72a-27ae-4883-94e7-8067d05e74d5'},
#    'format': {'system': 'https://lifeomic.com/fhir/identifier-type',
#     'code': 'ocr-file-id',
#     'display': 'OCR File Identifier'}}],
#  'author': [{'reference': 'user@example.com'}],
#  'id': 'ca0ae21a-2129-4f45-b5c9-d0e29bd6c125',
#  'account': 'sandbox'}

This process can also be divided into two steps: upload and run.

phc.Ocr.upload("./John History Notes (D Harris).pdf", folder="ocr-uploads")
# =>
# {'id': '8284d569-79d0-458f-93e7-67e977d8da9a',
#  'name': 'John History Notes (D Harris).pdf',
#  'datasetId': '637475e1-3b26-4d78-87eb-5df66ab9ef59',
#  'contentType': 'application/pdf',
#  'userId': 'lifeomic:lifeomic_christian.dilorenzo@lifeomic.com',
#  'uploadUrl': '...'}
phc.Ocr.run(file_id="8284d569-79d0-458f-93e7-67e977d8da9a")
# =>
# {'resourceType': 'DocumentReference',
#  ...}

Last update: 2021-03-24