gcp-nrces-fhir
Version:
Google cloud healthcare api NRCES FHIR implimenataion
195 lines • 7.86 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.CarePlan = exports.carePlanIntentArray = exports.careplanActivityDetailStatusArray = void 0;
const ResourceMai_1 = __importDefault(require("./ResourceMai"));
exports.careplanActivityDetailStatusArray = [
"not-started",
"scheduled",
"in-progress",
"on-hold",
"completed",
"cancelled",
"stopped",
"unknown",
"entered-in-error"
];
const carePlanStatusArray = [
"draft",
"active",
"on-hold",
"revoked",
"completed",
"entered-in-error",
"unknown",
];
exports.carePlanIntentArray = [
"proposal",
"plan",
"order",
"option",
];
class CarePlan extends ResourceMai_1.default {
constructor() {
super(...arguments);
this.statusArray = () => {
return carePlanStatusArray.map((el) => el);
};
/***
* This method retuns the CARE_PLAN["activity"][number]["detail"]["status"][]
* */
this.careplanActivityDetailStatusArray = () => {
return exports.careplanActivityDetailStatusArray;
};
}
toHtml() {
return __awaiter(this, void 0, void 0, function* () {
throw new Error("Method not implemented.");
});
}
getFHIR(options) {
let activity;
if (options.activity) {
activity = [...options.activity];
activity.forEach((el) => {
var _a;
el.outcomeReference =
el.outcomeReference &&
((_a = el.outcomeReference) === null || _a === void 0 ? void 0 : _a.map((out) => {
return {
reference: `${out.resource}/${out.id}`,
};
}));
if (el.reference) {
el.reference = {
reference: `${el.reference.resource}/${el.reference.id}`,
};
}
});
}
const body = {
resourceType: "CarePlan",
id: options.id || undefined,
meta: {
profile: ["https://nrces.in/ndhm/fhir/r4/StructureDefinition/CarePlan"],
lastUpdated: options.lastUpdated
},
text: {
status: "additional",
div: options.text,
},
author: options.author && { "reference": `${options.author.resource}/${options.author.id}` },
contributor: options.contributor && options.contributor.map(el => {
return { "reference": `${el.resource}/${el.id}` };
}),
addresses: options.addresses && options.addresses.map(el => {
return { "reference": `${el.resource}/${el.id}` };
}),
encounter: options.encounterId && { "reference": `Encounter/${options.encounterId}` },
basedOn: options.basedOnCarePlanId &&
options.basedOnCarePlanId.map((el) => {
return { reference: `CarePlan/${el}` };
}),
replaces: options.replacesCarePlanId &&
options.replacesCarePlanId.map((el) => {
return { reference: `CarePlan/${el}` };
}),
partOf: options.partOfCarePlanId &&
options.partOfCarePlanId.map((el) => {
return { reference: `CarePlan/${el}` };
}),
status: options.status,
intent: options.inetent,
category: options.category,
title: options.title,
description: options.description,
goal: options.goal &&
options.goal.map((el) => {
return { reference: `${el.resource}/${el.id}` };
}),
subject: {
reference: `Patient/${options.patientId}`,
},
activity: options.activity,
};
return body;
}
convertFhirToObject(options) {
const ret = {
id: options.id,
status: options.status,
inetent: options.intent,
text: options.text.div,
patientId: options.patient && this.getIdFromReference({ "ref": options.patient.reference, "resourceType": "Patient" }),
category: options.category,
title: options.title,
lastUpdated: options.meta.lastUpdated
};
if (options.basedOn) {
ret.basedOnCarePlanId = options.basedOn.map((el) => {
return this.getFromMultResource({ "reference": el.reference });
});
}
if (options.partOf) {
ret.partOfCarePlanId = options.partOf.map((el) => {
return this.getFromMultResource({ "reference": el.reference });
});
}
if (options.replaces) {
ret.replacesCarePlanId = options.replaces.map((el) => {
return this.getFromMultResource({ "reference": el.reference });
});
}
if (options.author) {
ret.author = this.getFromMultResource({ "reference": options.author.reference });
}
if (options.addresses) {
ret.addresses = options.addresses.map((el) => {
return this.getFromMultResource({ "reference": el.reference });
});
}
if (options.contributor) {
ret.contributor = options.contributor.map((el) => {
return this.getFromMultResource({ "reference": el.reference });
});
}
if (options.activity) {
if (options.activity.reference) {
options.activity.reference = options.activity.reference.map((el) => this.getFromMultResource({ "reference": el.reference }));
}
ret.activity = options.activity;
}
if (options.title) {
ret.title = options.title;
}
if (options.description) {
ret.description = options.description;
}
if (options.goal) {
ret.goal = options.goal.map((el) => this.getFromMultResource({ "reference": el.reference }));
}
if (options.subject) {
ret.patientId = this.getIdFromReference({ "resourceType": "Patient", "ref": options.subject.reference });
}
if (options.encounter) {
ret.encounterId = this.getIdFromReference({ "ref": options.encounter.reference, "resourceType": "Encounter" });
}
if (options.subject) {
ret.patientId = this.getIdFromReference({ "ref": options.subject.reference, "resourceType": "Patient" });
}
return ret;
}
}
exports.CarePlan = CarePlan;
//# sourceMappingURL=CarePlan.js.map