#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ai ts=4 sts=4 et sw=4
# Alan Viars

import argparse
import functools
import hashlib
import json
import os
import time
import string
import sys
from collections import OrderedDict
import ndjson
import requests
from jdt.ndjson2fhir import ndjson2fhir

if __name__ == "__main__":

    # Parse args
    parser = argparse.ArgumentParser(
        description='Load in the NDJSON doc into MongoDB')
    parser.add_argument(
        dest='input_ndjson_file',
        action='store',
        help='Input the NDJSON file to load here')
    parser.add_argument(
        dest='fhir_base_url',
        action='store',
        help="Enter the FHIR base URL where you want to create new new FHIR resources.")

    args = parser.parse_args()
    ndjson_file = args.input_ndjson_file
    fhir_base_url = args.fhir_base_url

    result = ndjson2fhir(ndjson_file,fhir_base_url)

    # output the JSON transaction summary
    print(json.dumps(result, indent=4))
