gcp-nrces-fhir
Version:
Google cloud healthcare api NRCES FHIR implimenataion
74 lines • 3.44 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.DietaryRecord = void 0;
const _1 = require(".");
const gcp_1 = __importDefault(require("../../classess/gcp"));
class DietaryRecord extends _1.Composition {
constructor() {
super(...arguments);
this.create = (options, Credentials, DatabasePath) => __awaiter(this, void 0, void 0, function* () {
options = yield this.getOptions(options);
const body = this.getFHIR(options.composition);
let gcpFhirCrud;
if (Credentials) {
gcpFhirCrud = new gcp_1.default(Credentials, DatabasePath);
}
else {
gcpFhirCrud = new gcp_1.default();
}
body.section = options.composition.section;
const res = yield gcpFhirCrud.createFhirResource(body, "Composition");
return res;
});
this.update = (options, Credentials, DatabasePath) => __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;
let gcpFhirCrud;
if (Credentials) {
gcpFhirCrud = new gcp_1.default(Credentials, DatabasePath);
}
else {
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 = options.composition.documentDatahtml || "";
const sectionZero = {
code: {
coding: [
{
code: "440654000",
display: "Dietary record",
system: "https://ndhm.gov.in/sct",
},
],
},
entry: [],
title: options.title,
};
options.composition.documentDatahtml = docHtml;
options.composition.section = [sectionZero];
return options;
});
}
}
exports.DietaryRecord = DietaryRecord;
//# sourceMappingURL=Dietaryrecord.js.map