gcp-nrces-fhir
Version:
Google cloud healthcare api NRCES FHIR implimenataion
144 lines • 6.95 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.DiagnsoticReportBundle = void 0;
const gcp_1 = __importDefault(require("../../classess/gcp"));
const _1 = require(".");
const DiagnosticReport_1 = require("../DiagnosticReport");
class DiagnsoticReportBundle extends _1.BundelMain {
constructor() {
super(...arguments);
this.getMedia = (index, mediaids, entry) => __awaiter(this, void 0, void 0, function* () {
if (index >= mediaids.length) {
return;
}
const media = (yield new gcp_1.default(this.gcpCredetials, this.gcpPath).getFhirResource(mediaids[index], "Media")).data;
entry.push({
fullUrl: `Media/${mediaids[index]}`,
resource: media,
});
index = index + 1;
this.getMedia(index, mediaids, entry);
});
this.getSpecimen = (index, specimenids, entry) => __awaiter(this, void 0, void 0, function* () {
if (index >= specimenids.length) {
return;
}
const specimen = (yield new gcp_1.default(this.gcpCredetials, this.gcpPath).getFhirResource(specimenids[index], "Specimen")).data;
entry.push({
fullUrl: `Specimen/${specimenids[index]}`,
resource: specimen,
});
index = index + 1;
this.getSpecimen(index, specimenids, entry);
});
this.getObservations = (index, observationids, entry) => __awaiter(this, void 0, void 0, function* () {
if (index >= observationids.length) {
return;
}
const observation = (yield new gcp_1.default(this.gcpCredetials, this.gcpPath).getFhirResource(observationids[index], "Observation")).data;
entry.push({
fullUrl: `Observation/${observationids[index]}`,
resource: observation,
});
index = index + 1;
this.getObservations(index, observationids, entry);
});
this.getBasedOn = (index, basedOnRefs, entry) => __awaiter(this, void 0, void 0, function* () {
if (index >= basedOnRefs.length) {
return;
}
const basedOn = yield new gcp_1.default(this.gcpCredetials, this.gcpPath).getFhirResource(basedOnRefs[index].id, basedOnRefs[index].resource);
entry.push({
fullUrl: `${basedOnRefs[index].resource}/${basedOnRefs[index].id}`,
resource: basedOn.data,
});
index = index + 1;
this.getBasedOn(index, basedOnRefs, entry);
});
}
toHtml() {
return __awaiter(this, void 0, void 0, function* () {
throw new Error("Method not implemented.");
});
}
getFHIR(options) {
return __awaiter(this, void 0, void 0, function* () {
if (options.identifier) {
let ret = {
system: "http://www.nicehms.com",
value: options.identifier.value,
};
}
const bundlemain = yield new _1.BundelMain(this.gcpCredetials, this.gcpPath).getentries(options.composition, options.pdfData);
const entry = bundlemain.entry;
// write code to pusj diagnosticreport here
const sectionEntries = bundlemain.compositionObj.section[0].entry;
const diagnosticReportId = this.getIdFromReference({
ref: sectionEntries.filter((el) => el.type == "DiagnosticReport")[0]
.reference,
resourceType: "DiagnosticReport",
});
const gcpCrud = new gcp_1.default(this.gcpCredetials, this.gcpPath);
const diagnsoticReport = yield gcpCrud
.getFhirResource(diagnosticReportId, "DiagnosticReport")
.then((res) => res.data);
const diagnosticReportObj = new DiagnosticReport_1.DiagnosticReport().convertFhirToObject(diagnsoticReport);
const mediaIds = diagnosticReportObj.mediaId;
const specimenIDs = diagnosticReportObj.specimenId || [];
entry.push({
fullUrl: `DiagnosticReport/${diagnosticReportId}`,
resource: diagnsoticReport,
});
yield this.getMedia(0, mediaIds, entry);
if ((specimenIDs === null || specimenIDs === void 0 ? void 0 : specimenIDs.length) > 0) {
yield this.getSpecimen(0, specimenIDs, entry);
}
if (diagnosticReportObj.basedOn) {
yield this.getBasedOn(0, diagnosticReportObj.basedOn, entry);
}
if (diagnosticReportObj.observationResultid) {
yield this.getObservations(0, diagnosticReportObj.observationResultid, entry);
}
const body = {
resourceType: "Bundle",
id: options.id,
meta: {
versionId: "1",
lastUpdated: new Date().toISOString(),
profile: [
"https://nrces.in/ndhm/fhir/r4/StructureDefinition/DocumentBundle",
],
security: [
{
system: "http://terminology.hl7.org/CodeSystem/v3-Confidentiality",
code: "V",
display: "very restricted",
},
],
},
identifier: options.identifier,
type: "document",
timestamp: new Date().toISOString,
entry: entry,
};
return body;
});
}
convertFhirToObject(options) {
throw new Error("Method not implemented.");
}
}
exports.DiagnsoticReportBundle = DiagnsoticReportBundle;
//# sourceMappingURL=DiagnsoticReport%20copy.js.map