gcp-nrces-fhir
Version:
Google cloud healthcare api NRCES FHIR implimenataion
103 lines • 4.07 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.MedicationStatement = exports.MedicationStatementStatusArray = void 0;
const ResourceMai_1 = __importDefault(require("./ResourceMai"));
exports.MedicationStatementStatusArray = [
"active",
"completed",
"entered-in-error",
"intended",
"stopped",
"on-hold",
"unknown",
"not-taken",
];
class MedicationStatement extends ResourceMai_1.default {
constructor() {
super(...arguments);
this.statusArray = () => {
return exports.MedicationStatementStatusArray.map((el) => el);
};
}
toHtml() {
return __awaiter(this, void 0, void 0, function* () {
throw new Error("Method not implemented.");
});
}
getFHIR(options) {
var _a, _b;
const dosage = options.dosage
? options.dosage.map((el) => {
return this.createDosageInstrction(el);
})
: [];
const getMedications = () => {
let ret = "";
ret = options.medicationCodeableConcept.text || "";
return ret;
};
const body = {
resourceType: "MedicationStatement",
id: options.id || undefined,
meta: {
profile: [
"https://nrces.in/ndhm/fhir/r4/StructureDefinition/MedicationStatement",
],
},
text: {
status: "generated",
div: getMedications(),
},
status: options.status,
medicationCodeableConcept: options.medicationCodeableConcept,
informationSource: options.informationSource && {
reference: `${(_a = options.informationSource) === null || _a === void 0 ? void 0 : _a.resource}/${(_b = options.informationSource) === null || _b === void 0 ? void 0 : _b.id}`,
},
reasonCode: options.reasonCode,
subject: { reference: `Patient/${options.patientid}` },
dateAsserted: options.date,
dosage: dosage
};
return body;
}
convertFhirToObject(options) {
let ret = {
id: options.id,
status: options.status,
medicationCodeableConcept: options.medicationCodeableConcept,
patientid: this.getIdFromReference({
ref: options.subject.reference,
resourceType: "Patient",
}),
date: options.dateAsserted,
};
if (options.dosage) {
ret.dosage = options.dosage.map((el) => {
return this.convertDosageInstructionToObject(el);
});
}
if (options.informationSource) {
options.informationSource = this.getFromMultResource({
reference: options.informationSource.reference,
});
}
if (options.reasonCode) {
ret.reasonCode = options.reasonCode;
}
return ret;
}
}
exports.MedicationStatement = MedicationStatement;
//# sourceMappingURL=MedicationStatement.js.map