gcp-nrces-fhir
Version:
Google cloud healthcare api NRCES FHIR implimenataion
139 lines • 6.84 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.DiagnosticReportComp = void 0;
const _1 = require(".");
const gcp_1 = __importDefault(require("../../classess/gcp"));
const DiagnosticReport_1 = require("../DiagnosticReport");
const ServiceRequest_1 = require("../ServiceRequest");
const Specimen_1 = require("../Specimen");
class DiagnosticReportComp extends _1.Composition {
constructor() {
super(...arguments);
/**
* This sournads the table format in case data to be presented in table
* @param options
* @returns
*/
this.getTxtHTML = (options) => {
let ret = options.html;
if (options.intable) {
ret = "";
ret += `<table style="border-collapse: collapse; width: 99.9739%;" border="0">`;
ret += `<thead style="display: table-header-group"><tr>`;
ret += `<th style="width: 40%;">Test</th>`;
ret += `<th style="width: 20%;"> Value</th>`;
ret += `<th style="width: 20%;">Units</th>`;
ret += `<th style="width: 20%;">Reference Range </th>`;
ret += `</tr></thead>`;
ret += `<tbody>`;
ret += `${options.html}`;
ret += `</tbody></table>`;
}
return ret.trim();
};
this.setPerformerAndRequesterAndSpecimenAndReortTime = (options) => __awaiter(this, void 0, void 0, function* () {
const serviceRequest = new ServiceRequest_1.ServiceRequest();
const serviceRequestBody = serviceRequest.convertFhirToObject(options.serviceRequest);
const diagnosticReport = new DiagnosticReport_1.DiagnosticReport();
const diagnosticReportObj = diagnosticReport.convertFhirToObject(options.diagnosticReport);
this.setDiagnosticReportDateTime(diagnosticReportObj);
this.setRequester({
reesource: serviceRequestBody.requester.resource,
display: serviceRequestBody.requester.display,
});
// code to get specimen
if (serviceRequestBody.specimanIds &&
serviceRequestBody.specimanIds.length > 0) {
const resource = yield new gcp_1.default().getFhirResource(serviceRequestBody.specimanIds[0], "Specimen");
if (resource && resource.data) {
this.setSpecimenRecivedAndCollectedTime(new Specimen_1.Specimen().convertFhirToObject(resource.data));
}
}
if (diagnosticReportObj.performer) {
diagnosticReportObj.performer.forEach((el) => {
if (el.display) {
this.setPerformer({ display: el.display, reesource: el.resource });
}
});
}
});
this.create = (options, Credentials, DatabasePath) => __awaiter(this, void 0, void 0, function* () {
yield this.setPerformerAndRequesterAndSpecimenAndReortTime(options);
options.composition.section.push({
title: options.diagnosticReport.code.text,
code: options.diagnosticReport.code,
entry: [
{
reference: `DiagnosticReport/${options.diagnosticReport.id}`,
type: "DiagnosticReport",
},
],
});
options.composition.documentDatahtml = this.getTxtHTML({
html: options.diagnosticReport.text.div,
intable: options.textInTable,
diagnosticReportResourse: options.diagnosticReport,
});
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.createFhirResource(body, "Composition");
return res;
});
this.update = (options, Credentials, DatabasePath) => __awaiter(this, void 0, void 0, function* () {
yield this.setPerformerAndRequesterAndSpecimenAndReortTime(options);
options.composition.section = [];
options.composition.section.push({
title: options.diagnosticReport.code.text,
code: options.diagnosticReport.code,
entry: [
{
reference: `DiagnosticReport/${options.diagnosticReport.id}`,
type: "DiagnosticReport",
},
],
});
options.composition.documentDatahtml = this.getTxtHTML({
html: options.diagnosticReport.text.div,
intable: options.textInTable,
diagnosticReportResourse: options.diagnosticReport,
});
const body = this.getFHIR(options.composition);
body.section = options.composition.section;
// const gcpFhirCrud = new GcpFhirCRUD();
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) => {
let docHTML = "";
return docHTML;
};
}
}
exports.DiagnosticReportComp = DiagnosticReportComp;
//# sourceMappingURL=DiagnosticReportComp.js.map