コード例 #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
ファイル: benchmark.py プロジェクト: joeportela/pyfhirstore
        t = tqdm(total=total_size,
                 unit='B',
                 unit_scale=True,
                 desc="Downloading example resources")
        with open('benchmark/examples.zip', 'wb') as f:
            for data in r.iter_content(block_size):
                t.update(len(data))
                f.write(data)
        t.close()
    else:
        print("Using cached resources")


download_resources()
client = MongoClient()
store = FHIRStore(client, "benchmark")
store.resume()
# store.reset()
# store.bootstrap(depth=3)

examples = tqdm(iter_examples(),
                total=count_examples(),
                desc="Running write benchmark")
stats = {}
inserted = []
for example, data in examples:
    if not data.get('id'):
        data["id"] = str(uuid4())
    start = timer()
    res = store.create(data)
    end = timer()
コード例 #3
0
ファイル: main.py プロジェクト: joeportela/pyfhirstore
from elasticsearch import Elasticsearch

from fhirstore import FHIRStore

if __name__ == '__main__':
    client = MongoClient(username="******", password="******")

    client_es = Elasticsearch(['http://localhost:9200'],
                              http_auth=("elastic", "SuperSecurePassword2019"))
    # uncomment the next 2 following line if you wish to activate
    # the replication mode of mongo (required by monstache)

    # res = client.admin.command("replSetInitiate", None)
    # time.sleep(1)

    store = FHIRStore(client, client_es, "fhirstore")

    # 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()