UNPKG

gcp-nrces-fhir

Version:

Google cloud healthcare api NRCES FHIR implimenataion

110 lines 5.35 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.PrescriptionRecord = void 0; const TimeZone_1 = require("../../TimeZone"); const _1 = require("."); const gcp_1 = __importDefault(require("../../classess/gcp")); class PrescriptionRecord extends _1.Composition { constructor() { super(...arguments); this.create = (options) => __awaiter(this, void 0, void 0, function* () { options = yield this.getOptions(options); const body = this.getFHIR(options.composition); const gcpFhirCrud = new gcp_1.default(); body.section = options.composition.section; const res = yield gcpFhirCrud.createFhirResource(body, "Composition"); return res; }); this.update = (options) => __awaiter(this, void 0, void 0, function* () { if (!options.composition.id) { throw (new Error().message = "id of composition is required"); } options = yield this.getOptions(options); const body = this.getFHIR(options.composition); body.section = options.composition.section; const gcpFhirCrud = new gcp_1.default(); const res = yield gcpFhirCrud.updateFhirResource(body, options.composition.id || "", "Composition"); return res; }); this.getOptions = (options) => __awaiter(this, void 0, void 0, function* () { let docHtml = ""; let diagnosis = []; yield this.getDiagnosisFromEnconter(options.composition.encounter.diagnosis, 0, diagnosis); if (diagnosis && diagnosis.length > 0) { let diagnosisString = ""; diagnosis.forEach((el, i) => diagnosisString += `(${i + 1}). ${el} `); docHtml += `<p><b>Diagnosis [ICD 11]:- </b>${diagnosisString}</p><p></p>`; } const sectionZero = { code: { coding: [ { code: "440545006", display: "Prescription", system: "https://ndhm.gov.in/sct", }, ], }, entry: [], title: "Prescription", }; if (options.notes) { sectionZero.entry.push({ reference: `Condition/${options.notes.id}`, type: "Condition", }); docHtml += `${options.notes.text.div}`; } sectionZero.entry.push({ reference: `MedicationRequest/${options.medicationRequest.id}`, type: "MedicationRequest", }); options.composition.section.push(sectionZero); if (options.followUp) { options.composition.section.push({ title: "Follow Up", code: { coding: [ { system: "http://snomed.info/sct", code: "736271009", display: "Outpatient care plan", }, ], }, entry: [ { reference: `Appointment/${options.followUp.id}`, }, ], }); // docHtml = // docHtml + // `<div"><span><b>Follow up:-</b>${ // new Date(options.followUp.start).toDateString() || // new Date(options.followUp.end).toDateString() // }${options.followUp.text.div}</br>`; docHtml = docHtml + `<div"><span><b>Follow up:-</b>${new TimeZone_1.TimeZone().convertTZ(options.followUp.start, process.env.TZ, true) || new TimeZone_1.TimeZone().convertTZ(options.followUp.end, process.env.TZ, true)}${options.followUp.text.div}</br>`; } docHtml += options.medicationRequest.text.div; options.composition.documentDatahtml = docHtml; return options; }); } } exports.PrescriptionRecord = PrescriptionRecord; //# sourceMappingURL=PrescriptionRecord.js.map