UNPKG

gcp-nrces-fhir

Version:

Google cloud healthcare api NRCES FHIR implimenataion

88 lines 4.05 kB
"use strict"; 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.HealthDocumentRecord = void 0; const _1 = require("."); const gcp_1 = __importDefault(require("../../classess/gcp")); class HealthDocumentRecord extends _1.Composition { constructor() { super(...arguments); this.create = (options, Credentials, DatabasePath) => __awaiter(this, void 0, void 0, function* () { options = yield this.getOptions(options); const body = this.getFHIR(options.composition); let gcpFhirCrud; if (Credentials) { gcpFhirCrud = new gcp_1.default(Credentials, DatabasePath); } else { gcpFhirCrud = new gcp_1.default(); } body.section = options.composition.section; const res = yield gcpFhirCrud.createFhirResource(body, "Composition"); return res; }); this.update = (options, Credentials, DatabasePath) => __awaiter(this, void 0, void 0, function* () { if (!options.composition.id) { throw (new Error().message = "id of composition is required"); } options = yield this.getOptions(options); const body = this.getFHIR(options.composition); body.section = options.composition.section; let gcpFhirCrud; if (Credentials) { gcpFhirCrud = new gcp_1.default(Credentials, DatabasePath); } else { gcpFhirCrud = new gcp_1.default(); } const res = yield gcpFhirCrud.updateFhirResource(body, options.composition.id || "", "Composition"); return res; }); this.getOptions = (options) => __awaiter(this, void 0, void 0, function* () { let docHtml = options.composition.documentDatahtml || ""; const sectionZero = { code: { coding: [ { code: "419891008", display: "Health Document", system: "https://ndhm.gov.in/sct", }, ], }, entry: [], title: options.title, }; if (options.media && options.media.length > 0) { options.media.forEach((el, i) => { sectionZero.entry.push({ reference: `Media/${el.id}`, type: "Media", }); }); } if (options.DocumentReference) { sectionZero.entry.push({ reference: `DocumentReference/${options.DocumentReference.id}`, type: "DocumentReference", }); } options.composition.documentDatahtml = docHtml; options.composition.section = [sectionZero]; return options; }); } } exports.HealthDocumentRecord = HealthDocumentRecord; //# sourceMappingURL=HealthDocumentRecord.js.map