UNPKG

gcp-nrces-fhir

Version:

Google cloud healthcare api NRCES FHIR implimenataion

124 lines 4.93 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.MedicationAdministration = exports.MedicationAdministrationStatusArray = void 0; const ResourceMai_1 = __importDefault(require("./ResourceMai")); exports.MedicationAdministrationStatusArray = [ "in-progress", "not-done", "on-hold", "completed", "entered-in-error", "stopped", "unknown", ]; class MedicationAdministration extends ResourceMai_1.default { constructor() { super(...arguments); this.statusArray = () => { return exports.MedicationAdministrationStatusArray.map((el) => el); }; } toHtml() { return __awaiter(this, void 0, void 0, function* () { throw new Error("Method not implemented."); }); } getFHIR(options) { const body = { resourceType: "MedicationAdministration", id: options.id || undefined, meta: { profile: [ "https://nrces.in/ndhm/fhir/r4/StructureDefinition/MedicationAdministration", ], }, text: { status: "generated", div: options.medicationCodeableConcept.text || "", }, status: options.status, medicationCodeableConcept: options.medicationCodeableConcept, subject: { reference: `Patient/${options.patientId}` }, }; if (options.performer) { body.performer = [ { actor: { reference: `${options.performer.resource}/${options.performer.id}`, display: options.performer.display, }, }, ]; } if (options.requestId) { body.request = { reference: `MedicationRequest/${options.requestId}` }; } if (options.encounterId) { body.context = { reference: `Encounter/${options.encounterId}` }; } if (options.effectiveDateTime) { body.effectiveDateTime = options.effectiveDateTime; } else if (options.effectivePeriod) { body.effectivePeriod = options.effectivePeriod; } if (options.note) { body.note = [{ text: options.note }]; } return body; } convertFhirToObject(options) { var _a, _b; let ret = { id: options.id, status: options.status, medicationCodeableConcept: options.medicationCodeableConcept, patientId: this.getIdFromReference({ ref: options.subject.reference, resourceType: "Patient", }), }; if (options.performer && options.performer[0]) { ret.performer = this.getFromMultResource({ reference: (_a = options.performer[0].actor) === null || _a === void 0 ? void 0 : _a.reference, display: (_b = options.performer[0].actor) === null || _b === void 0 ? void 0 : _b.display, }); } if (options.request) { ret.requestId = this.getIdFromReference({ ref: options.request.reference, resourceType: "MedicationRequest", }); } if (options.context) { ret.encounterId = this.getIdFromReference({ ref: options.context.reference, resourceType: "Encounter", }); } if (options.effectiveDateTime) { ret.effectiveDateTime = options.effectiveDateTime; } if (options.effectivePeriod) { ret.effectivePeriod = options.effectivePeriod; } if (options.note && options.note[0]) { ret.note = options.note[0].text; } return ret; } } exports.MedicationAdministration = MedicationAdministration; //# sourceMappingURL=MedicationAdministration.js.map