gcp-nrces-fhir
Version:
Google cloud healthcare api NRCES FHIR implimenataion
160 lines • 6.14 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.Appointment = exports.AppointmentActorStatusArray = exports.AppointmentStatusArray = void 0;
const Partipant_1 = require("./objects/Partipant");
const ResourceMai_1 = __importDefault(require("./ResourceMai"));
exports.AppointmentStatusArray = [
"proposed",
"pending",
"booked",
"arrived",
"fulfilled",
"cancelled",
"noshow",
"entered-in-error",
"checked-in",
"waitlist",
];
exports.AppointmentActorStatusArray = [
"accepted",
"declined",
"tentative",
"needs-action",
];
class Appointment extends ResourceMai_1.default {
constructor() {
super(...arguments);
this.statusArray = () => {
return exports.AppointmentStatusArray.map((el) => el);
};
this.actorStatusArray = () => {
return exports.AppointmentActorStatusArray.map((el) => el);
};
}
toHtml() {
return __awaiter(this, void 0, void 0, function* () {
throw new Error("Method not implemented.");
});
}
getFHIR(options) {
var _a;
const getText = () => {
let ret = ``;
if (options.serviceCategory) {
ret = `${ret} <div>Service Category ${options.serviceCategory[0].text}</div>`;
}
if (options.serviceType) {
ret = `${ret} <div>Service Type ${options.serviceType[0].text}</div>`;
}
if (options.reasonCode) {
ret = `${ret} <div>Reason ${options.reasonCode[0].text}</div>`;
}
ret = `${ret} <div>${options.description}</div>`;
return ret;
};
const getParticipant = () => {
const ret = [];
const participant = new Partipant_1.Participant();
options.participants.forEach(el => {
participant.setObject(el);
ret.push(participant.getJson());
});
return ret;
};
const identifiers = [];
identifiers.push({
"value": options.organizationId,
"system": "https://www.nicehms.com/orgnization"
});
let body = {
resourceType: "Appointment",
id: options.id || undefined,
identifier: identifiers,
meta: {
profile: [
"https://nrces.in/ndhm/fhir/r4/StructureDefinition/Appointment",
],
},
text: {
status: "generated",
div: getText(),
},
supportingInformation: [{
reference: `Organization/${options.organizationId}`
}],
status: options.status,
serviceCategory: options.serviceCategory,
serviceType: options.serviceCategory,
specialty: options.serviceType,
appointmentType: options.appointmentType,
reasonCode: options.reasonCode,
description: options.description,
start: options.startDate,
end: options.endDate,
created: options.createdDate,
participant: getParticipant(),
priority: options.priority,
};
if (options.slotId && ((_a = options.slotId) === null || _a === void 0 ? void 0 : _a.length) > 0) {
body.slot = options.slotId.map(el => {
return {
reference: `Slot/${el}`
};
});
}
return body;
}
convertFhirToObject(options) {
let orgIdentifierArray = options.identifier && options.identifier.filter((el) => el.system == "https://www.nicehms.com/orgnization") || [];
let organizationId = "";
if (orgIdentifierArray.length > 0) {
organizationId = orgIdentifierArray[0].value || "";
}
let ret = {
priority: options.priority,
status: options.status,
participants: options.participant.map((el) => new Partipant_1.Participant().getObject(el)),
createdDate: options.created,
startDate: options.start,
endDate: options.end,
description: options.description,
id: options.id,
organizationId: organizationId,
};
if (options.slot && options.slot.length > 0) {
ret.slotId = options.slot.map((el) => {
return this.getIdFromReference({
ref: el.reference,
resourceType: "Slot",
});
});
}
if (options.serviceCategory) {
ret.serviceCategory = options.serviceCategory;
}
if (options.serviceType) {
ret.serviceType = options.serviceType;
}
if (options.specialty) {
ret.specialty = options.specialty;
}
if (options.appointmentType) {
ret.appointmentType = options.appointmentType;
}
return ret;
}
}
exports.Appointment = Appointment;
//# sourceMappingURL=Appointment.js.map