UNPKG

gcp-nrces-fhir

Version:

Google cloud healthcare api NRCES FHIR implimenataion

238 lines 9.66 kB
"use strict"; 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.PatientResource = exports.Patient = exports.relationships = void 0; const TimeZone_1 = require("../TimeZone"); const ResourceMai_1 = __importDefault(require("./ResourceMai")); const relationships = [ { relationship: { code: "FTH", display: "Father" } }, { relationship: { code: "MTH", display: "Mother" } }, { relationship: { code: "SPS", display: "Wife" } }, { relationship: { code: "HUSB", display: "Husband" } }, { relationship: { code: "SON", display: "Son" } }, { relationship: { code: "DAU", display: "Daughter" } }, { relationship: { code: "BRO", display: "Brother" } }, { relationship: { code: "SIS", display: "Sister" } }, { relationship: { code: "UNCLE", display: "Uncle" } }, { relationship: { code: "AUNT", display: "Aunt" } }, { relationship: { code: "FRIEND", display: "Friend" } } ]; exports.relationships = relationships; class Patient extends ResourceMai_1.default { toHtml(options) { return __awaiter(this, void 0, void 0, function* () { let ret = ""; if (options.addResourceType) { ret += `<h1>Patient</h1>`; } if (options.body.name) { ret += `<b>Name</b> : ${options.body.name}<br/>`; } if (options.body.MRN) { ret += `<b>UHID</b> : ${options.body.MRN}<br/>`; } if (options.body.facilityId) { ret += `<b>Id</b> : ${options.body.facilityId}<br/>`; } if (options.body.phrAddress) { ret += `<b>ABHA</b>: ${options.body.phrAddress}<br/>`; } if (options.body.gender) { ret += `<b>Gender</b> : ${options.body.gender}<br/>`; } if (options.body.dob) { ret += `<b>Age</b> : ${new TimeZone_1.TimeZone().dobToAge(new Date(options.body.dob))}<br/>`; } if (options.body.mobile) { ret += `<b>Mobile</b> : ${options.body.mobile}<br/>`; } return ret; }); } getFHIR(options) { const identifiers = []; if (options.internalId) { const id = { type: { coding: [ { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MR", display: "Medical record number", }, ], }, system: "https://www.nicehms.com/internalid", value: `${options.internalId}`, }; identifiers.push(id); } if (options.facilityId) { const id = { type: { coding: [ { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MR", display: "Medical record number", }, ], }, system: "https://www.nicehms.com/facilityId", value: `${options.facilityId}`, }; identifiers.push(id); } if (options.healthNumber) { const id = { type: { coding: [ { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MR", display: "Medical record number", }, ], }, system: "https://healthid.ndhm.gov.in/health-number", value: `${options.healthNumber}`, }; identifiers.push(id); } if (options.phrAddress) { const id = { type: { coding: [ { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MR", display: "Medical record number", }, ], }, system: "https://healthid.ndhm.gov.in/phr-address", value: `${options.phrAddress}`, }; identifiers.push(id); } if (options.identifier && options.identifier.length > 0) { identifiers.push(...options.identifier); } if (options.MRN) { const id = { type: { coding: [ { system: "http://terminology.hl7.org/CodeSystem/v2-0203", code: "MR", display: "Medical record number", }, ], }, system: "https://www.nicehms.com", value: `${options.MRN}`, }; identifiers.push(id); } const body = { resourceType: "Patient", id: options.id || undefined, meta: { versionId: "1", lastUpdated: new Date().toISOString(), profile: ["https://nrces.in/ndhm/fhir/r4/StructureDefinition/Patient"], }, text: { status: "generated", div: `<div xmlns=\"http://www.w3.org/1999/xhtml\">Patient name - ${options.name},Gender- ${options.gender}</div>`, }, identifier: identifiers, name: [ { text: `${options.name}`, }, ], telecom: [ { system: "phone", value: `${options.mobile}`, use: "mobile", }, ], gender: `${options.gender}`, birthDate: `${options.dob}`, managingOrganization: { reference: `Organization/${options.organizationId}`, }, contact: options.contact }; return body; } convertFhirToObject(options) { let ret = { name: options.name[0].text, gender: options.gender, mobile: options.telecom[0].value, dob: options.birthDate, organizationId: `${options.managingOrganization.reference}`.substring(13), id: options.id, }; if (options.identifier) { const mrn = options.identifier.filter((el) => el.system == "https://www.nicehms.com"); if (mrn.length > 0) { ret.MRN = mrn[0].value; } const internalId = options.identifier.filter((el) => el.system == "https://www.nicehms.com/internalid"); if (internalId.length > 0) { ret.internalId = internalId[0].value; } const facilityId = options.identifier.filter((el) => el.system == "https://www.nicehms.com/facilityId"); if (facilityId.length > 0) { ret.facilityId = facilityId[0].value; } const healthNumber = options.identifier.filter((el) => el.system == "https://healthid.ndhm.gov.in/health-number"); if (healthNumber.length > 0) { ret.healthNumber = healthNumber[0].value; } const phrAddress = options.identifier.filter((el) => el.system == "https://healthid.ndhm.gov.in/phr-address"); if (phrAddress.length > 0) { ret.phrAddress = phrAddress[0].value; } ret.identifier = options.identifier.filter((el) => { if (el.system != "https://healthid.ndhm.gov.in/phr-address" && el.system != "https://healthid.ndhm.gov.in/health-number" && el.system != "https://www.nicehms.com/internalid" && el.system != "https://www.nicehms.com") { return el; } }); if (options.contact) { ret.contact = options.contact; } } return ret; } } exports.Patient = Patient; /** * @deprecated * @param options * @returns */ const PatientResource = (options) => { const body = new Patient().getFHIR(options); return body; }; exports.PatientResource = PatientResource; //# sourceMappingURL=Patient.js.map