gcp-nrces-fhir
Version:
Google cloud healthcare api NRCES FHIR implimenataion
172 lines • 6.76 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.OrganizationResource = exports.Organization = void 0;
const ResourceMai_1 = __importDefault(require("./ResourceMai"));
class Organization extends ResourceMai_1.default {
toHtml(options) {
return __awaiter(this, void 0, void 0, function* () {
let ret = "";
if (options.addResourceType) {
ret += `<h1>Organization</h1>`;
}
if (options.body.name) {
ret += `<b>Organization Name</b> : ${options.body.name}<br/>`;
}
if (options.body.providerNumber) {
ret += `<b>Provider Number</b> : ${options.body.providerNumber}<br/>`;
}
if (options.body.email) {
ret += `<b>Email</b> : ${options.body.email}<br/>`;
}
if (options.body.ndhmFacilityNumber) {
ret += `<b>HFR ID</b> : ${options.body.ndhmFacilityNumber} <br/>`;
}
if (options.body.participantCode) {
ret += `<b>Partticipant Code</b> : ${options.body.participantCode} <br/>`;
}
if (options.body.phone) {
ret += `<b>Phone</b> : ${options.body.phone}<br/>`;
}
return ret;
});
}
getFHIR(options) {
const identifiers = [];
if (options.ndhmFacilityNumber) {
const id = {
type: {
coding: [
{
system: "http://terminology.hl7.org/CodeSystem/v2-0203",
code: "PRN",
display: "Provider number",
},
],
},
system: "https://healthid.ndhm.gov.in",
value: `${options.ndhmFacilityNumber}`,
};
identifiers.push(id);
}
if (options.providerNumber) {
const id = {
type: {
coding: [
{
system: "http://terminology.hl7.org/CodeSystem/v2-0203",
code: "PRN",
display: "Provider number",
},
],
},
system: "https://www.nicehms.com",
value: `${options.providerNumber}`,
};
identifiers.push(id);
}
if (options.participantCode) {
const id = {
type: {
coding: [
{
display: "participantCode",
},
],
},
system: "NHCX",
value: `${options.participantCode}`,
};
identifiers.push(id);
}
if (options.identifier && options.identifier.length > 0) {
options.identifier.forEach(el => {
if (el.system !== "NHCX" && el.system !== "https://www.nicehms.com" && el.system !== "https://healthid.ndhm.gov.in") {
identifiers.push(el);
}
});
}
let body = {
resourceType: "Organization",
id: `${options.id}`,
meta: {
profile: [
"https://nrces.in/ndhm/fhir/r4/StructureDefinition/Organization",
],
},
text: {
status: "generated",
div: `<div xmlns=\"http://www.w3.org/1999/xhtml\">${options.name}. ph: ${options.phone}, email:<a href=\"mailto:${options.email}\">${options.email}</a></div>`,
},
identifier: identifiers,
name: `${options.name}`,
telecom: [
{
system: "phone",
value: `${options.phone}`,
use: "work",
},
{
system: "email",
value: `${options.email}`,
use: "work",
},
],
};
if (options.extension) {
// @ts-ignore
body.extension = options.extension;
}
return body;
}
convertFhirToObject(options) {
const ret = {
name: options.name,
phone: options.telecom[0].value,
email: options.telecom[1].value,
id: options.id,
};
if (options.identifier) {
const ndhmFacilityNumber = options.identifier.filter((el) => el.system == "https://healthid.ndhm.gov.in");
if (ndhmFacilityNumber.length > 0) {
ret.ndhmFacilityNumber = ndhmFacilityNumber[0].value;
}
const providerNumber = options.identifier.filter((el) => el.system == "https://www.nicehms.com");
if (providerNumber.length > 0) {
ret.providerNumber = providerNumber[0].value;
}
const participantCode = options.identifier.filter((el) => el.system == "NHCX");
if (participantCode.length > 0) {
ret.participantCode = participantCode[0].value;
}
ret.identifier = options.identifier;
}
if (options.extension) {
ret.extension = options.extension;
}
return ret;
}
}
exports.Organization = Organization;
/**
* @deprecated
* @param options
* @returns
*/
const OrganizationResource = (options) => {
const body = new Organization().getFHIR(options);
return body;
};
exports.OrganizationResource = OrganizationResource;
//# sourceMappingURL=Organization.js.map