UNPKG

gcp-nrces-fhir

Version:

Google cloud healthcare api NRCES FHIR implimenataion

98 lines 4.51 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.WellnessRecordBundle = void 0; const _1 = require("."); const gcp_1 = __importDefault(require("../../classess/gcp")); const ResourceFactory_1 = __importDefault(require("../../classess/ResourceFactory")); class WellnessRecordBundle extends _1.BundelMain { constructor() { super(...arguments); this.getObservations = (index, observationids) => __awaiter(this, void 0, void 0, function* () { if (index >= observationids.length) { return; } const observation = (yield new gcp_1.default(this.gcpCredetials, this.gcpPath).getFhirResource(observationids[index], "Observation")).data; this.entry.push({ fullUrl: `Observation/${observationids[index]}`, resource: new ResourceFactory_1.default("Observation").bundlefy(observation), }); index = index + 1; yield this.getObservations(index, observationids); }); } toHtml() { return __awaiter(this, void 0, void 0, function* () { throw new Error("Method not implemented."); }); } getFHIR(options) { return __awaiter(this, void 0, void 0, function* () { if (options.identifier) { let ret = { system: "http://www.nicehms.com", value: options.identifier.value, }; } options.composition.title = "Wellness Record Document"; const bundlemain = yield new _1.BundelMain(this.gcpCredetials, this.gcpPath).getentries(options.composition, options.pdfData); this.entry = bundlemain.entry; // Extract observation IDs and non-observation entries from all sections const observationIds = []; const nonObsEntries = []; const sections = options.composition.section || []; for (const section of sections) { if (section.entry) { for (const entry of section.entry) { if (entry.type === "Observation" && entry.reference) { const refParts = entry.reference.split("/"); if (refParts.length === 2) { observationIds.push(refParts[1]); } } else if (entry.reference) { nonObsEntries.push(entry); } } } } if (observationIds.length > 0) { yield this.getObservations(0, observationIds); } if (nonObsEntries.length > 0) { yield this.getEntriesPerSection(0, nonObsEntries); } const body = { resourceType: "Bundle", id: options.id, meta: { lastUpdated: new Date().toISOString(), }, identifier: { system: "https://www.nicehms.com/bundle", value: options.id, }, type: "document", timestamp: options.composition.date, entry: this.entry, }; return body; }); } convertFhirToObject(options) { throw new Error("Method not implemented."); } } exports.WellnessRecordBundle = WellnessRecordBundle; //# sourceMappingURL=WellnessRecord.js.map