[![Coverage Status][coveralls-image]][coveralls-url]
Simple module for using Doctolib's API in node.js
$ npm install --save doctolib-client
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
var DoctolibClient = require('../dist/DoctolibClient').DoctolibClient;
// Create an API client
var options = {
clientAccessKey: process.env.clientAccessKey,
secretAccessKey: process.env.secretAccessKey,
url: "https://api-interf.doctolib.net"//SandBox
};
var client = new DoctolibClient(options);
app.get('/agenda', function (req, res) {
client.getAgenda(function (err, data) {
if (err) {
res.send(err);
return;
}
res.json(JSON.parse(data));
});
});
app.get('/visitMotive', function (req, res) {
var agendaId = req.query.agendaId;
client.getVisitMotive(agendaId, function (err, data) {
if (err) {
res.send(err);
return;
}
res.json(JSON.parse(data));
});
});
app.get('/availabilityService', function (req, res) {
var agendaId = req.query.agendaId;
var visitMotiveId = req.query.visitMotiveId;
var date = req.query.date;
client.getAvailabilityService(agendaId, visitMotiveId, date, 7, function (err, data) {
if (err) {
res.send(err);
return;
}
res.json(JSON.parse(data));
});
});
app.post('/appointment', function (req, res) {
client.createAppointment(req.body, function (err, data) {
if (err) {
res.send(err);
return;
}
res.json(JSON.parse(data));
});
});
app.get('/appointment', function (req, res) {
var patientId = req.query.patientId;
client.getAppointment(patientId, function (err, data) {
if (err) {
res.send(err);
return;
}
res.json(JSON.parse(data));
});
});
app.delete('/appointment', function (req, res) {
var appointmentId = req.query.appointmentId;
client.deleteAppointment(appointmentId, function (err, data) {
if (err) {
res.send(err);
return;
}
res.json(JSON.parse(data));
});
});
app.listen(3000);
var options = {
clientAccessKey: "your consumer Key",
secretAccessKey: "your consumer secret",
url: "https://api-interf.doctolib.net"
};
var client = new DoctolibClient(options);
Create an API client with options. Url is optional. Default url is the production API.
Set the format of the data you wish to receive (json or hl7 for specific endpoints). Default format is JSON.
The format
is a string.
Use this method to ensure the authentication is correct.
The callback is of the form function(err, data)
.
The callback is of the form function(err, data)
. The data
is an array of agendas.
The agendaIds
can be a string or an array of string.
The callback is of the form function(err, data)
. The data
is an array of visit motives.
The agendaIds
can be a string or an array of string.
The visitMotiveId
is a string.
The date
a string like YYYY-MM-DD.
The limit
a number and the value must be between 3 and 7.
The callback is of the form function(err, data)
.
The agendaIds
is a string.
The appointment
is a DoctolibPatientModel Object.
The callback is of the form function(err, data)
.
DoctolibPatientModel Object for an unknown patient
{
"visit_motive_id": "r:9",
"agenda_id": 7,
"start_date": "2016-10-10T12:45:00+0200",
"patient": {
"last_name": "John",
"first_name": "Doe",
"birthdate": "1985-19-03",
"maiden_name": "Smith",
"email": "[email protected]",
"phone_number": "0601012341",
"secondary_phone_number": "0601012341",
"external_patient_id": "1312^^^Application^PI",
"gender": "M"
}
}
DoctolibPatientModel Object For a known patient
{
"visit_motive_id": "r:9",
"agenda_id": 7,
"start_date": "2016-10-10T12:45:00+0200",
"patient_id": 3
}
The patientId
,the Doctolib ID of the patient, is a string.
The callback is of the form function(err, data)
. The data
is an array of appointments.
The appointmentId
is a string.
The callback is of the form function(err, data)
.
This methods return a promise
Contributions are welcome. See issues here.
See release notes here.
Licensed under Apache 2.0.