UNPKG

elationjs

Version:

A node SDK for interacting with the Elation Health API

63 lines (52 loc) 1.93 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = PatientsFactory; var _queryString = require('query-string'); var _queryString2 = _interopRequireDefault(_queryString); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function PatientsFactory(client) { return class Patient { constructor(input) { this.toObject = () => ({ id: this.id, first_name: this.first_name, last_name: this.last_name, dob: this.dob, sex: this.sex, primary_physician: this.primary_physician, caregiver_practice: this.caregiver_practice, address: this.address, phones: this.phones, emails: this.emails, metadata: this.metadata, insurances: this.insurances }); this.id = input.id; this.first_name = input.first_name; this.last_name = input.last_name; this.dob = input.dob; this.sex = input.sex; this.primary_physician = input.primary_physician; this.caregiver_practice = input.caregiver_practice; this.address = input.address; this.phones = input.phones; this.emails = input.emails; this.metadata = input.metadata; this.insurances = input.insurances; } static update(patientID, input) { return client.put(`patients/${patientID}`, JSON.stringify(input)).then(({ data }) => new this(data)); } static findPatients(searchData) { return client.get(`/patients/?${_queryString2.default.stringify(searchData)}`).then(({ data }) => data.results.map(patient => new this(patient))); } static getPatient(id) { return client.get(`patients/${id}`).then(({ data }) => new this(data)); } static postPatient(patient) { return client.post('/patients/', JSON.stringify(patient)).then(({ data }) => new this(data)); } }; }