doctolib-client
v0.0.3
Published
Doctolib API for NodeJS
Downloads
17
Readme
doctolib-client
[![Coverage Status][coveralls-image]][coveralls-url]
Simple module for using Doctolib's API in node.js
Install
$ npm install --save doctolib-client
Usage
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);
Client API
Initialization
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.
DoctolibClient.setDataFormat(format)
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.
Methods
DoctolibClient.authenticate(callback)
Use this method to ensure the authentication is correct.
The callback is of the form function(err, data)
.
DoctolibClient.getAgenda(function (err, data)
The callback is of the form function(err, data)
. The data
is an array of agendas.
DoctolibClient.getVisitMotive(agendaIds, function (err, data)
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.
DoctolibClient.getAvailabilityService(agendaIds, visitMotiveId, date, limit, function (err, data)
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)
.
DoctolibClient.createAppointment(appointment,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
}
DoctolibClient.getAppointment(patientId,function (err, data)
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.
DoctolibClient.deleteAppointment(appointmentId,function (err, data)
The appointmentId
is a string.
The callback is of the form function(err, data)
.
Async Methods
DoctolibClient.getAgendaAsync()
DoctolibClient.getVisitMotiveAsync()
DoctolibClient.getAvailabilityServiceAsync()
DoctolibClient.getAppointmentAsync()
DoctolibClient.createAppointmentAsync()
DoctolibClient.deleteAppointment()
This methods return a promise
Contributing
Contributions are welcome. See issues here.
Release Notes
See release notes here.
License
Licensed under Apache 2.0.