gcp-nrces-fhir
Version:
Google cloud healthcare api NRCES FHIR implimenataion
332 lines • 14.2 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());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PaymentReconciliation = void 0;
const ResourceMai_1 = __importDefault(require("../resources/ResourceMai"));
const status = ["active", "cancelled", "draft", "entered-in-error"];
const outcome = ["queued", "complete", "error", "partial"];
class PaymentReconciliation extends ResourceMai_1.default {
getFHIR(options) {
const detailHandle = () => {
var _a;
const detail = options.detail &&
((_a = options.detail) === null || _a === void 0 ? void 0 : _a.map((el) => {
const ret = {
id: el.id,
extension: el.extension,
modifierExtension: el.modifierExtension,
identifier: el.identifier,
predecessor: el.predecessor,
type: el.type,
request: el.request && {
reference: el.request.resource &&
el.request.id &&
`${el.request.resource}/${el.request.id}`,
identifier: el.request.identifier,
display: el.request.display,
type: el.request.type,
},
submitter: el.submitter && {
reference: el.submitter.resource &&
el.submitter.id &&
`${el.submitter.resource}/${el.submitter.id}`,
identifier: el.submitter.identifier,
display: el.submitter.display,
type: el.submitter.type,
},
response: el.response && {
reference: el.response.resource &&
el.response.id &&
`${el.response.resource}/${el.response.id}`,
identifier: el.response.identifier,
display: el.response.display,
type: el.response.type,
},
date: el.date,
responsible: el.responsible && {
reference: el.responsible.resource &&
el.responsible.id &&
`${el.responsible.resource}/${el.responsible.id}`,
identifier: el.responsible.identifier,
display: el.responsible.display,
type: el.responsible.type,
},
payee: el.payee && {
reference: el.payee.resource &&
el.payee.id &&
`${el.payee.resource}/${el.payee.id}`,
identifier: el.payee.identifier,
display: el.payee.display,
type: el.payee.type,
},
amount: el.amount,
};
return ret;
}));
return detail;
};
const body = {
resourceType: "PaymentReconciliation",
id: options.id,
meta: {
profile: [
"https://nrces.in/ndhm/fhir/r4/StructureDefinition/PaymentReconciliation",
],
},
text: {
status: "generated",
div: options.text,
},
extension: options.extension,
modifierExtension: options.modifierExtension,
identifier: options.identifier,
status: options.status,
period: options.period,
created: options.createdDate,
paymentIssuer: options.paymentIssuer && {
reference: options.paymentIssuer.resource &&
options.paymentIssuer.id &&
`${options.paymentIssuer.resource}/${options.paymentIssuer.id}`,
identifier: options.paymentIssuer.identifier,
display: options.paymentIssuer.display,
type: options.paymentIssuer.type,
},
requestor: options.requestor && {
reference: options.requestor.resource &&
options.requestor.id &&
`${options.requestor.resource}/${options.requestor.id}`,
identifier: options.requestor.identifier,
display: options.requestor.display,
type: options.requestor.type,
},
request: options.request && {
reference: options.request.resource &&
options.request.id &&
`${options.request.resource}/${options.request.id}`,
identifier: options.request.identifier,
display: options.request.display,
type: options.request.type,
},
outcome: options.outcome,
disposition: options.disposition,
paymentDate: options.paymentDate,
paymentAmount: options.paymentAmount,
paymentIdentifier: options.paymentIdentifier,
implicitRules: options.implicitRules,
formCode: options.formCode,
detail: options.detail && detailHandle(),
processNote: options.processNote,
};
return body;
}
convertFhirToObject(options) {
const detailHandle = () => {
const details = options.detail.map((el) => {
const ret = {
amount: el.amount,
date: el.data,
extension: el.extension,
id: el.id,
identifier: el.identifier,
modifierExtension: el.modifierExtension,
payee: el.payee && this.getFromMultResource(el.payee),
predecessor: el.predecessor,
request: el.request && this.getFromMultResource(el.request),
response: el.response && this.getFromMultResource(el.response),
responsible: el.responsible && this.getFromMultResource(el.responsible),
submitter: el.submitter && this.getFromMultResource(el.submitter),
type: el.type,
};
// Remove keys with null or undefined values
Object.keys(ret).forEach((key) => {
if (ret[key] === null ||
ret[key] === undefined) {
delete ret[key];
}
});
return ret;
});
return details;
};
const processNoteHandle = () => {
const processNote = options.processNote.map((el) => {
const ret = el;
// Remove keys with null or undefined values
Object.keys(ret).forEach((key) => {
if (ret[key] === null ||
ret[key] === undefined) {
delete ret[key];
}
});
return ret;
});
return processNote;
};
const ret = {
id: options.id,
resourceType: "PaymentReconciliation",
text: options.text && options.text.div,
identifier: options.identifier,
status: options.status,
period: options.period,
createdDate: options.created,
extension: options.extension,
modifierExtension: options.modifierExtension,
paymentIssuer: options.paymentIssuer &&
this.getFromMultResource(options.paymentIssuer),
requestor: options.requestor && this.getFromMultResource(options.requestor),
request: options.request && this.getFromMultResource(options.request),
outcome: options.outcome,
disposition: options.disposition,
paymentDate: options.paymentDate,
paymentAmount: options.paymentAmount,
paymentIdentifier: options.paymentIdentifier,
implicitRules: options.implicitRules,
formCode: options.formCode,
detail: options.detail && detailHandle(),
processNote: options.processNote && processNoteHandle(),
};
// 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;
return __awaiter(this, void 0, void 0, function* () {
const { body } = option;
// Generate HTML for the PaymentReconciliation resource
let html = `
<html>
<head>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
}
th {
background-color: #f2f2f2;
text-align: left;
}
</style>
</head>
<body>
<h1>Payment Reconciliation</h1>
<table>
<tr>
<th>Field</th>
<th>Value</th>
</tr>
<tr>
<td>Resource Type</td>
<td>${body.resourceType}</td>
</tr>
<tr>
<td>ID</td>
<td>${body.id || "N/A"}</td>
</tr>
<tr>
<td>Status</td>
<td>${body.status}</td>
</tr>
<tr>
<td>Created Date</td>
<td>${body.createdDate}</td>
</tr>
<tr>
<td>Payment Date</td>
<td>${body.paymentDate}</td>
</tr>
<tr>
<td>Payment Amount</td>
<td>${(_a = body.paymentAmount) === null || _a === void 0 ? void 0 : _a.value} ${(_b = body.paymentAmount) === null || _b === void 0 ? void 0 : _b.currency}</td>
</tr>
<tr>
<td>Payment Issuer</td>
<td>${((_c = body.paymentIssuer) === null || _c === void 0 ? void 0 : _c.display) || "N/A"}</td>
</tr>
<tr>
<td>Requestor</td>
<td>${((_d = body.requestor) === null || _d === void 0 ? void 0 : _d.display) || "N/A"}</td>
</tr>
<tr>
<td>Disposition</td>
<td>${body.disposition || "N/A"}</td>
</tr>
<tr>
<td>Outcome</td>
<td>${body.outcome || "N/A"}</td>
</tr>
<tr>
<td>Details</td>
<td>
<ul>
${body.detail
? body.detail
.map((detail) => {
var _a, _b, _c, _d, _e;
return `
<li>
Type: ${((_a = detail.type) === null || _a === void 0 ? void 0 : _a.text) || "N/A"}<br>
Amount: ${((_b = detail.amount) === null || _b === void 0 ? void 0 : _b.value) || "N/A"} ${((_c = detail.amount) === null || _c === void 0 ? void 0 : _c.currency) || ""}<br>
Submitter: ${((_d = detail.submitter) === null || _d === void 0 ? void 0 : _d.display) || "N/A"}<br>
Payee: ${((_e = detail.payee) === null || _e === void 0 ? void 0 : _e.display) || "N/A"}<br>
Date: ${detail.date || "N/A"}
</li>
`;
})
.join("")
: "No details available"}
</ul>
</td>
</tr>
<tr>
<td>Process Notes</td>
<td>
<ul>
${body.processNote
? body.processNote
.map((note) => `
<li>
Type: ${note.type || "N/A"}<br>
Text: ${note.text || "N/A"}
</li>
`)
.join("")
: "No process notes available"}
</ul>
</td>
</tr>
</table>
</body>
</html>
`;
// Return the generated HTML as a string
return html;
});
}
statusArray() {
return status.map((el) => el);
}
}
exports.PaymentReconciliation = PaymentReconciliation;
//# sourceMappingURL=PaymentReconciliation.js.map