Ejemplo n.º 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
Ejemplo n.º 2
0
    # 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()
    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")