UNPKG

gcp-nrces-fhir

Version:

Google cloud healthcare api NRCES FHIR implimenataion

155 lines 8.04 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.PaymentNoctice = void 0; const ResourceMai_1 = __importDefault(require("../resources/ResourceMai")); const status = ["active", "cancelled", "draft", "entered-in-error"]; class PaymentNoctice extends ResourceMai_1.default { getFHIR(options) { const body = { resourceType: "PaymentNotice", id: options.id, meta: { versionId: "1", lastUpdated: "2023-09-07T14:58:58.181+05:30", profile: [ "https://nrces.in/ndhm/fhir/r4/StructureDefinition/PaymentNotice", ], }, text: { status: "generated", div: options.text, }, identifier: options.identifier, status: options.status, request: options.request && { reference: options.request.resource && options.request.id && `${options.request.resource}/${options.request.id}`, identifier: options.request.identifier, type: options.request.type, display: options.request.display, }, response: options.response && { reference: options.response.resource && options.response.id && `${options.response.resource}/${options.response.id}`, identifier: options.response.identifier, type: options.response.type, display: options.response.display, }, created: options.createdDate, payment: options.payment && { reference: options.payment.resource && options.payment.id && `${options.payment.resource}/${options.payment.id}`, identifier: options.payment.identifier, type: options.payment.type, display: options.payment.display, }, paymentDate: options.paymentDate, recipient: options.recipient && { reference: options.recipient.resource && options.recipient.id && `${options.recipient.resource}/${options.recipient.id}`, identifier: options.recipient.identifier, type: options.recipient.type, display: options.recipient.display, }, amount: options.amount, paymentStatus: options.paymentStatus, payee: options.payee && { reference: options.payee.resource && options.payee.id && `${options.payee.resource}/${options.payee.id}`, identifier: options.payee.identifier, type: options.payee.type, display: options.payee.display, }, extension: options.extension, modifierExtension: options.modifierExtension, implicitRules: options.implicitRules, }; return body; } convertFhirToObject(options) { const ret = { id: options.id, resourceType: "PaymentNotice", text: options.text && options.text.div, identifier: options.identifier, status: options.status, request: options.request && this.getFromMultResource(options.request), response: options.response && this.getFromMultResource(options.response), createdDate: options.created, payment: options.payment && this.getFromMultResource(options.payment), paymentDate: options.paymentDate, recipient: options.recipient && this.getFromMultResource(options.recipient), amount: options.amount, paymentStatus: options.paymentStatus, payee: options.payee && this.getFromMultResource(options.payee), extension: options.extension, modifierExtension: options.modifierExtension, implicitRules: options.implicitRules, }; // Remove keys with null or undefined values Object.keys(ret).forEach((key) => { if (ret[key] === null || ret[key] === undefined) { delete ret[key]; } }); return ret; } toHtml(option) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; return __awaiter(this, void 0, void 0, function* () { const body = this.convertFhirToObject(option.body); const htmlContent = ` <div> <h1>Payment Notice</h1> <p><strong>ID:</strong> ${body.id || "N/A"}</p> <p><strong>Status:</strong> ${body.status}</p> <p><strong>Created Date:</strong> ${body.createdDate}</p> <p><strong>Payment Date:</strong> ${body.paymentDate || "N/A"}</p> <p><strong>Payment Amount:</strong> ${((_a = body.amount) === null || _a === void 0 ? void 0 : _a.value) || "N/A"} ${((_b = body.amount) === null || _b === void 0 ? void 0 : _b.currency) || ""}</p> <p><strong>Payment Status:</strong> ${((_c = body.paymentStatus) === null || _c === void 0 ? void 0 : _c.text) || "N/A"}</p> <p><strong>Payee:</strong> ${((_d = body.payee) === null || _d === void 0 ? void 0 : _d.display) || "N/A"} (${((_e = body.payee) === null || _e === void 0 ? void 0 : _e.type) || "Unknown"}) ${((_f = body.payee) === null || _f === void 0 ? void 0 : _f.identifier) && this.identifierToHtml(body.payee.identifier)}</p> <p><strong>Recipient:</strong> ${((_g = body.recipient) === null || _g === void 0 ? void 0 : _g.display) || "N/A"} (${((_h = body.recipient) === null || _h === void 0 ? void 0 : _h.type) || "Unknown"}) ${((_j = body.recipient) === null || _j === void 0 ? void 0 : _j.identifier) && this.identifierToHtml(body.recipient.identifier)}</p> <p><strong>Request:</strong> ${((_k = body.request) === null || _k === void 0 ? void 0 : _k.display) || "N/A"} (${((_l = body.request) === null || _l === void 0 ? void 0 : _l.reference) || "Unknown"}) </p> <p><strong>Response:</strong> ${((_m = body.response) === null || _m === void 0 ? void 0 : _m.display) || "N/A"} (${((_o = body.response) === null || _o === void 0 ? void 0 : _o.reference) || "Unknown"})</p> <p><strong>Additional Details:</strong></p> <ul> ${body.extension ? body.extension .map((ext) => `<li>${this.extensionToHtml(ext)}</li>`) .join("") : "<li>No extensions provided</li>"} </ul> <p><strong>Text:</strong></p> <div>${body.text || "No text available"}</div> </div> `; return htmlContent; }); } statusArray() { return status.map((el) => el); } } exports.PaymentNoctice = PaymentNoctice; //# sourceMappingURL=PaymentNotice.js.map