コード例 #1
0
def store():
    client = MongoClient(username=MONGO_USERNAME, password=MONGO_PASSWORD)
    try:
        client.server_info()
    except ServerSelectionTimeoutError as err:
        print("MongoClient could not reach server, is it running ?")
        raise
    client_es = Elasticsearch([ES_URL], http_auth=("elastic", ES_PASSWORD))

    fhirstore = FHIRStore(client, client_es, DB_NAME)
    fhirstore.reset()
    fhirstore.bootstrap(depth=2, resource="Patient")
    fhirstore.bootstrap(depth=2, resource="Practitioner")
    fhirstore.bootstrap(depth=2, resource="MedicationRequest")

    return fhirstore
コード例 #2
0
ファイル: main.py プロジェクト: joeportela/pyfhirstore
    # uncomment the following line if mongo already has initialised
    # collections and you don't want to bootstrap them all
    # store.resume()

    # reset collections (comment if you used `store.resume()`)
    print("Dropping collections...")
    start = timer()
    store.reset()
    end = timer()
    print(end - start, "seconds")

    # create collections (comment if you used `store.resume()`)
    print("Creating collections...")
    start = timer()
    store.bootstrap(depth=3)
    end = timer()
    print(end - start, "seconds")

    # creating document
    print("Inserting documents...")
    json_folder_path = os.path.join(os.getcwd(), "test/fixtures")
    json_files = [
        x for x in os.listdir(json_folder_path) if x.endswith(".json")
    ]
    total = 0
    for json_file in json_files:
        json_file_path = os.path.join(json_folder_path, json_file)
        with open(json_file_path, "r") as f:
            data = json.load(f)
            start = timer()