UNPKG

gcp-nrces-fhir

Version:

Google cloud healthcare api NRCES FHIR implimenataion

258 lines 12.9 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.CoverageEligibiltyResponse = void 0; const ResourceMai_1 = __importDefault(require("../resources/ResourceMai")); const TimeZone_1 = require("../TimeZone"); const Coverage_1 = require("./Coverage"); const CoverageEligibilityResponcePurpose = [ "auth-requirements", "benefits", "discovery", "validation", ]; class CoverageEligibiltyResponse extends ResourceMai_1.default { toHtml(option) { return __awaiter(this, void 0, void 0, function* () { let ret = ""; const body = this.convertFhirToObject(option.body); if (option.addResourceType) { ret += `<h1>Coverage Eligibility Response</h1>`; } // Date ret += `Date : ${new TimeZone_1.TimeZone().convertTZ(body.createdDate, "Asia/Kolkata", false)} <br/>`; // Error if (body.error) { ret += body.error && body.error.length > 0 && `<h3><b>Error</b> : ${body.error .map((el) => this.codeableConceptToHtml(el)) .toString()}</h3>`; } if (body.status) { ret += `<b>Satus</b> : ${body.status}<br/>`; } if (body.outcome) { ret += `<h3><b>Outcome</b> : ${body.outcome}</h3>`; } // Text if (body.text) { ret += `<h2>Text</h2>`; ret += ` ${body.text}<br/>`; } ret += `<h2> Object to Text</h2>`; // disposition if (body.disposition) { ret += `<b>Disposition</b> : ${body.disposition} <br/>`; } // Purpose if (body.purpose) { ret += `<h3><b>Purpose</b> : ${body.purpose.toString()}</h3>`; } if (body.insurance && body.insurance.length > 0) { ret += `<h4>Insurances</h4>`; for (let index = 0; index < body.insurance.length; index++) { const el = body.insurance[index]; ret += `<br/><hr/>`; if (el.benefitPeriod) { ret += `<h4>Benefit Period</h4>`; ret += el.benefitPeriod.start && `Start : ${new TimeZone_1.TimeZone().convertTZ(el.benefitPeriod.start, "Asia/Kolkata", false)}<br/>`; ret += el.benefitPeriod.end && `End : ${new TimeZone_1.TimeZone().convertTZ(el.benefitPeriod.end, "Asia/Kolkata", false)} <br/>`; } if (el.inforce) { ret += `<b>Inforce</b> ${el.inforce}<br/>`; } // ret += el.coverage if (el.coverage && el.coverage.reference && option.coverages && option.coverages.length > 0) { try { const coverage = new Coverage_1.Coverage(); const id = coverage.getIdFromReference({ resourceType: 'Coverage', ref: el.coverage.reference, }); const filCoverage = option.coverages.filter((cl) => cl.id == id); if (filCoverage && filCoverage.length > 0) { ret += '<h3>Coverage</h3>'; ret += yield coverage.toHtml({ addResourceType: false, patient: option.patient, payerCode: option.payerCode, payerName: option.payerName, body: filCoverage[0], showInsuranceCompany: false, "showPatient": false, }); } } catch (error) { console.error('Error in coverage if block:', error); } } if (el.item && el.item.length > 0) { try { el.item.forEach((it, i) => { ret += `<h4>Item No ${i + 1}</h4>`; if (it.name) { ret += `Name : ${it.name}<br/>`; } if (it.network) { ret += `<b>Network</b> : ${this.codeableConceptToHtml(it.network)}<br/>`; } if (it.productOrService) { ret += `Product Or Service : ${this.codeableConceptToHtml(it.productOrService)}`; } if (it.description) { ret += `<b>Description</b> : ${it.description}<br/>`; } if (it.category) { ret += `<b>Category</b> ${this.codeableConceptToHtml(it.category)}`; } if (it.excluded) { ret += `<b>Excluded</b> : ${it.excluded}<br/>`; } if (it.modifier) { ret += `<b>Modifier</b> : ${it.modifier}<br/>`; } if (it.term) { ret += `<b>Term</b> : ${this.codeableConceptToHtml(it.term)}<br/>`; } if (it.unit) { ret += `<b>Unit</b> : ${this.codeableConceptToHtml(it.unit)}<br/>`; } if (it.benefit) { ret += `<h5>Benfits</h5>`; it.benefit.forEach((be) => { var _a, _b, _c, _d; if (be.type) { ret += `<b>Type</b> : ${this.codeableConceptToHtml(be.type)}`; } if (be.allowedMoney && be.allowedMoney.value) { ret += `<b>Allowed Money</b> : ${(_a = be.allowedMoney) === null || _a === void 0 ? void 0 : _a.currency} ${(_b = be.allowedMoney) === null || _b === void 0 ? void 0 : _b.value}<br/> `; } if (be.allowedUnsignedInt) { ret += `<b>Allowed UnsignedInt</b> : ${be.allowedUnsignedInt}<br/>`; } if (be.allowedString) { ret += `<b>Allowed String</b> : ${be.allowedString}<br/>`; } if (be.usedMoney && be.usedMoney.value) { ret += `<b>Used Money</b> : ${(_c = be.usedMoney) === null || _c === void 0 ? void 0 : _c.currency} ${(_d = be.usedMoney) === null || _d === void 0 ? void 0 : _d.value}<br/> `; } if (be.usedUnsignedInt) { ret += `<b>Used UnsignedInt</b> : ${be.usedUnsignedInt}<br/>`; } if (be.usedString) { ret += `<b>Used String</b> : ${be.usedString}<br/>`; } }); } }); } catch (error) { console.log(`CoverageEligibiltyResponse.toHtml.item ${error}`); } } } ; } return ret; }); } getFHIR(options) { const body = { resourceType: "CoverageEligibilityResponse", id: options.id || undefined, meta: { profile: options.hcx == "nhcx" ? [ "https://nrces.in/ndhm/fhir/r4/StructureDefinition/CoverageEligibilityResponse", ] : [ "https://ig.hcxprotocol.io/v0.7.1/StructureDefinition-CoverageEligibilityResponse.html", ], }, language: "en", text: { status: "generated", div: options.text, }, status: options.status, purpose: options.purpose, patient: { reference: `Patient/${options.patientId}`, }, created: options.createdDate, requestor: options.practitionerId && { reference: `Practitioner/${options.practitionerId}`, }, request: { reference: `CoverageEligibilityRequest/${options.coverageEligibilityRequestId}`, }, outcome: options.outcome, disposition: options.disposition, insurer: { reference: `Organization/${options.insurerId}`, }, insurance: options.insurance, error: options.error, identifier: options.identifiers, }; return body; } convertFhirToObject(options) { const ret = { id: options.id, text: (options.text && options.text.div) || "", status: options.status, purpose: options.purpose, patientId: options.patient && options.patient.reference && this.getIdFromReference({ resourceType: "Patient", ref: options.patient.reference, }), createdDate: options.created, coverageEligibilityRequestId: options.request && options.request.reference && this.getIdFromReference({ resourceType: "CoverageEligibilityRequest", ref: options.request.reference, }), outcome: options.outcome, insurerId: options.insurer && options.insurer.reference && this.getIdFromReference({ resourceType: "Organization", ref: options.insurer.reference, }), insurance: options.insurance, error: options.error, identifiers: options.identifier, practitionerId: options.requestor && this.getIdFromReference({ resourceType: "Practitioner", ref: options.requestor.reference, }), resourceType: "CoverageEligibilityResponse" }; if (options.disposition) { ret.disposition = options.disposition; } return ret; } } exports.CoverageEligibiltyResponse = CoverageEligibiltyResponse; //# sourceMappingURL=CoverageEligibilityResponse%20copy.js.map