UNPKG

gcp-nrces-fhir

Version:

Google cloud healthcare api NRCES FHIR implimenataion

116 lines 5.07 kB
"use strict"; /** * FHIR ChargeItem resource for ABDM Invoice line items */ 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.ChargeItem = void 0; const gcp_1 = __importDefault(require("../classess/gcp")); class ChargeItem { /** * Convert internal item data to FHIR ChargeItem JSON */ static toFhir(options) { var _a; const body = { resourceType: "ChargeItem", id: options.id || undefined, meta: { profile: ["http://hl7.org/fhir/R4/chargeitem.html"], lastUpdated: new Date().toISOString(), }, status: options.status || "billable", code: { coding: options.code.coding, text: options.code.text || ((_a = options.code.coding[0]) === null || _a === void 0 ? void 0 : _a.display) || "", }, subject: options.subject, }; if (options.identifier) body.identifier = options.identifier; if (options.context) body.context = options.context; if (options.occurrenceDateTime) body.occurrenceDateTime = options.occurrenceDateTime; if (options.performer) body.performer = options.performer; if (options.performingOrganization) body.performingOrganization = options.performingOrganization; if (options.requestingOrganization) body.requestingOrganization = options.requestingOrganization; if (options.quantity) body.quantity = options.quantity; if (options.factorOverride != null) body.factorOverride = options.factorOverride; if (options.priceOverride) body.priceOverride = options.priceOverride; if (options.overrideReason) body.overrideReason = options.overrideReason; if (options.enterer) body.enterer = options.enterer; if (options.enteredDate) body.enteredDate = options.enteredDate; if (options.reason) body.reason = options.reason; if (options.service) body.service = options.service; if (options.note) body.note = options.note; return body; } /** * Build a ChargeItem from a voucher line item */ static fromVoucherItem(item, patientReference, encounterReference, organizationReference) { const itemName = item.itemName || item.item || `Item #${item.itemId}`; const qty = item.quantity || 1; return { status: "billable", code: { coding: [{ system: "https://www.nicehms.com/items", code: String(item.itemId || itemName), display: itemName, }], text: itemName, }, subject: { reference: patientReference }, context: encounterReference ? { reference: encounterReference } : undefined, performingOrganization: organizationReference ? { reference: organizationReference } : undefined, quantity: { value: qty, unit: item.unit || "each" }, priceOverride: { value: item.salePrice || 0, currency: "INR" }, }; } /** * Store a ChargeItem in GCP FHIR store */ static create(options, creds, dbPath) { return __awaiter(this, void 0, void 0, function* () { const fhirBody = ChargeItem.toFhir(options); const gcpFhirCrud = creds ? new gcp_1.default(creds, dbPath) : new gcp_1.default(); return yield gcpFhirCrud.createFhirResource(fhirBody, "ChargeItem"); }); } /** * Get ChargeItem from GCP FHIR store */ static get(id, creds, dbPath) { return __awaiter(this, void 0, void 0, function* () { const gcpFhirCrud = creds ? new gcp_1.default(creds, dbPath) : new gcp_1.default(); return yield gcpFhirCrud.getFhirResource(id, "ChargeItem"); }); } } exports.ChargeItem = ChargeItem; //# sourceMappingURL=ChargeItem.js.map