部分患者信息存储在Asymmetrik FHIR mongo中。
代码示例:
假设我们有以下患者信息要存储:
{
"name": "John Doe",
"gender": "male",
"birthdate": "1990-01-01",
"city": "New York"
}
我们可以使用以下代码将其存储在Asymmetrik FHIR mongo中:
const { MongoClient } = require('mongodb');
const assert = require('assert');
// Connection URL
const url = 'mongodb://localhost:27017';
// Database Name
const dbName = 'myproject';
// Create a new MongoClient
const client = new MongoClient(url, { useUnifiedTopology: true });
// Use connect method to connect to the Server
client.connect(function(err) {
assert.equal(null, err);
console.log("Connected successfully to server");
const db = client.db(dbName);
// Get the patients collection
const collection = db.collection('patients');
// Insert a single document
collection.insertOne({
"name": "John Doe",
"gender": "male",
"birthdate": "1990-01-01",
"city": "New York"
}, function(err, result) {
assert.equal(null, err);
console.log("Successfully inserted document");
});
// Close the client and connection
client.close();
});