gcp-nrces-fhir
Version:
Google cloud healthcare api NRCES FHIR implimenataion
169 lines • 7.16 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.Location = exports.bedOPertaionalStatusArray = exports.locationFormTypesArray = void 0;
const ResourceMai_1 = __importDefault(require("./ResourceMai"));
const gcp_1 = __importDefault(require("../classess/gcp"));
const locatioStatusArray = ["active", "suspended", "inactive"];
exports.locationFormTypesArray = ["Site", "Building", "Wing", "Ward", "Level", "Corridor", "Room", "Bed", "Vehicle", "House", "Cabinet", "Road", "Area", "Jurisdiction", "Virtual"];
exports.bedOPertaionalStatusArray = ["Closed", "Housekeeping", "Occupied", "Unoccupied", "Contaminated", "Isolated"];
class Location extends ResourceMai_1.default {
constructor() {
super(...arguments);
this.statusArray = () => {
return locatioStatusArray.map(el => el);
};
}
toHtml(option) {
return __awaiter(this, void 0, void 0, function* () {
let ret = "";
if (option.body.name) {
ret += `<h3>${option.body.name}</h3>`;
}
if (option.body.description) {
ret += `<b>Description</b> :${option.body.description}<br/>`;
}
if (option.body.alias) {
ret += `<b>Alias</b> : ${option.body.alias.join(' ,')}<br/>`;
}
if (option.body.availabilityExceptions) {
ret += `Availability Exceptions :${option.body.availabilityExceptions}`;
}
if (option.body.indentifiers) {
ret += `<h4>Identifiers</h4>`;
option.body.indentifiers.forEach(el => {
ret += `${this.identifierToHtml(el)}<br/>`;
});
}
if (option.body.mode) {
ret += `<b>Mode</b> : ${this.codeDiplaytoHtml(option.body.mode)} `;
}
if (option.body.operationalStatus) {
ret += `Operational Status : ${this.codingtoHtml(option.body.operationalStatus)}`;
}
if (option.body.status) {
ret += `<b>Status</b> : ${option.body.status}`;
}
if (option.body.partOfLocationId) {
try {
const resource = yield new gcp_1.default().getFhirResource(option.body.partOfLocationId, "Location");
if (resource.data) {
const locationObj = new Location().convertFhirToObject(resource.data);
ret += `<b>Part Of Location</b> : ${locationObj.name}<br/>`;
}
}
catch (error) {
console.log(error);
ret += `Invalid Part of location id ${option.body.partOfLocationId}`;
}
}
if (option.body.physicalType) {
ret += `<b>Physical Type</b> : ${this.codeableConceptToHtml(option.body.physicalType)}<br/>`;
}
if (option.body.position) {
ret += `<b>Position</b> : ${this.positionToHtml(option.body.position)}`;
}
return ret;
});
}
getFHIR(options) {
const body = {
id: options.id,
resourceType: "Location",
"text": {
"status": "generated",
"div": `<div>${options.description}</div>`
},
identifier: options.indentifiers,
name: options.name,
alias: options.alias,
description: options.description,
mode: options.mode,
type: options.type,
physicalType: options.physicalType,
position: options.position,
managingOrganization: {
reference: `Organization/${options.managingOrganizationId}`,
},
availabilityExceptions: options.availabilityExceptions,
};
if (options.status) {
body.status = options.status;
}
if (options.operationalStatus) {
body.operationalStatus = options.operationalStatus;
}
if (options.partOfLocationId) {
body.partOf = {
reference: `Location/${options.partOfLocationId}`,
};
}
if (options.endpointId) {
body.endpoint = {
reference: `Endpoint/${options.endpointId}`
};
}
return body;
}
convertFhirToObject(options) {
const ret = {
id: options.id,
};
if (options.indentifier) {
ret.indentifiers = options.identifier;
}
if (options.name) {
ret.name = options.name;
}
if (options.alias) {
ret.alias = options.alias;
}
if (options.description) {
ret.description = options.description;
}
if (options.mode) {
ret.mode = options.mode;
}
if (options.type) {
ret.type = options.type;
}
if (options.physicalType) {
ret.physicalType = options.physicalType;
}
if (options.position) {
ret.position = options.position;
}
if (options.managingOrganization) {
ret.managingOrganizationId = this.getIdFromReference({ "ref": options.managingOrganization.reference, "resourceType": "Organization" });
}
if (options.partOf) {
ret.partOfLocationId = this.getIdFromReference({ "ref": options.partOf.reference, "resourceType": "Location" });
}
if (options.availabilityExceptions) {
ret.availabilityExceptions = options.availabilityExceptions;
}
if (options.endpoint) {
ret.endpointId = this.getIdFromReference({ "ref": options.endpoint.reference, "resourceType": "Endpoint" });
}
if (options.operationalStatus) {
ret.operationalStatus = options.operationalStatus;
}
if (options.status) {
ret.status = options.status;
}
return ret;
}
}
exports.Location = Location;
//# sourceMappingURL=Location.js.map