@careevolution/orchestrate
Version:
A TypeScript client for the Orchestrate API
154 lines (153 loc) • 8.4 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.IdentityApi = void 0;
const httpHandlerFactory_js_1 = require("../httpHandlerFactory.js");
const monitoring_js_1 = require("./monitoring.js");
function buildSourceIdentifierRoute(source, identifier) {
return `${encodeURIComponent(source)}/${encodeURIComponent(identifier)}`;
}
class IdentityApi {
constructor(configuration = {}) {
this.httpHandler = (0, httpHandlerFactory_js_1.createIdentityHttpHandler)(configuration.apiKey, configuration.metricsKey, configuration.url);
this.monitoring = new monitoring_js_1.IdentityMonitoringApi(this.httpHandler);
}
toString() {
return `IdentityApi(${this.httpHandler.toString()})`;
}
/**
* Adds a new record or updates a previously created one.
* @param request The request to add or update a record.
* - `source` The system from which the record demographics were sourced.
* - `identifier` The unique identifier of the record within the source.
* - `demographic` The demographic information of the record.
* @returns The record's assigned person ID, along with any changes resulting from the addition or update.
* @link https://orchestrate.docs.careevolution.com/identity/operations/add_update_record.html
*/
addOrUpdateRecord(request) {
return __awaiter(this, void 0, void 0, function* () {
const sourceIdentifierRoute = buildSourceIdentifierRoute(request.source, request.identifier);
return this.httpHandler.post(`/mpi/v1/record/${sourceIdentifierRoute}`, request.demographic);
});
}
/**
* Adds a new record or updates a previously created one in privacy-preserving (blinded) mode.
* @param request The request to add or update a record.
* - `source`: The system from which the record demographics were sourced.
- `identifier`: The unique identifier of the record within the source.
- `data`: The B64 encoded hash provided by the local hashing service.
- `version`: The version number provided by the local hashing service.
* @returns Returns the record's assigned person ID, along with any changes resulting from the addition or update.
* @link https://orchestrate.docs.careevolution.com/identity/operations/add_update_record_blinded.html
*/
addOrUpdateBlindedRecord(request) {
return __awaiter(this, void 0, void 0, function* () {
const sourceIdentifierRoute = buildSourceIdentifierRoute(request.source, request.identifier);
const payload = {
data: request.blindedDemographic.data,
version: request.blindedDemographic.version
};
return this.httpHandler.post(`/mpi/v1/blindedRecord/${sourceIdentifierRoute}`, payload);
});
}
/**
* Given a source system and identifier, this retrieves the person's metadata (including their Person ID) and the collection of records grouped with that individual.
* @param request The request to get a person by record.
* - `source`: The system from which the record demographics were sourced.
- `identifier`: The unique identifier of the record within the source.
* @returns The matched person.
* @link https://orchestrate.docs.careevolution.com/identity/operations/get_person_by_record.html
*/
getPersonByRecord(request) {
return __awaiter(this, void 0, void 0, function* () {
const sourceIdentifierRoute = buildSourceIdentifierRoute(request.source, request.identifier);
return this.httpHandler.get(`/mpi/v1/record/${sourceIdentifierRoute}`);
});
}
/**
* Given a Person ID, this retrieves the person's metadata and the collection of records grouped with that individual.
* @param reuest The request to get a person by ID.
* - `id`: id of the person to fetch
* @returns The matched person.
* @link https://orchestrate.docs.careevolution.com/identity/operations/get_person_by_id.html
*/
getPersonByID(request) {
return __awaiter(this, void 0, void 0, function* () {
return this.httpHandler.get(`/mpi/v1/person/${encodeURIComponent(request.id)}`);
});
}
/**
* Finds all persons and their associated records that match the provided demographics. This operation is read-only, and will not create or update any person records.
* @param request The demographic The demographic to match.
* @returns Persons and their associated records that match the provided demographics.
* @link https://orchestrate.docs.careevolution.com/identity/operations/match_demographics.html
*/
matchDemographics(demographic) {
return __awaiter(this, void 0, void 0, function* () {
return this.httpHandler.post("/mpi/v1/match", demographic);
});
}
/**
* Finds all persons and their associated records that match the provided demographics in privacy-preserving (blinded) mode.
* @param request The blinded demographic to match
* @returns Persons and their associated records that match the provided demographics.
* @link https://orchestrate.docs.careevolution.com/identity/operations/match_demographics_blinded.html
*/
matchBlindedDemographics(demographic) {
return __awaiter(this, void 0, void 0, function* () {
return this.httpHandler.post("/mpi/v1/matchBlinded", demographic);
});
}
/**
* Deletes a record using a source system and identifier.
* @param request The request to delete a record.
* - `source`: The system from which the record demographics were sourced.
* - `identifier`: The unique identifier of the record within the source.
* @returns List of persons changed by the operation.
* @link https://orchestrate.docs.careevolution.com/identity/operations/delete_record.html
*/
deleteRecord(request) {
return __awaiter(this, void 0, void 0, function* () {
const sourceIdentifierRoute = buildSourceIdentifierRoute(request.source, request.identifier);
return this.httpHandler.post(`/mpi/v1/deleteRecord/${sourceIdentifierRoute}`, {});
});
}
/**
* Overrides automatic matching with manual guidance for a particular set of records.
* @param personId The persons to add match guidance for.
* - `record_one`: The first record
* - `record_two`: The second record
* - `action`: Use Match if the two records represent the same individual, and NoMatch if the two records represent different individuals.
* - `comment`: A comment for documentation/audit purposes.
* @returns List of persons changed by the operation.
* @link https://orchestrate.docs.careevolution.com/identity/operations/add_guidance.html
*/
addMatchGuidance(request) {
return __awaiter(this, void 0, void 0, function* () {
return this.httpHandler.post(`/mpi/v1/addGuidance`, request);
});
}
/**
* Removes a previously-created manual match guidance.
* @param personId The persons to remove match guidance for.
* - `record_one`: The first record
* - `record_two`: The second record
* - `comment`: A comment for documentation/audit purposes.
* @returns List of persons changed by the operation.
* @link https://orchestrate.docs.careevolution.com/identity/operations/remove_guidance.html
*/
removeMatchGuidance(request) {
return __awaiter(this, void 0, void 0, function* () {
return this.httpHandler.post(`/mpi/v1/removeGuidance`, request);
});
}
}
exports.IdentityApi = IdentityApi;