diff --git a/.eslintrc.js b/.eslintrc.js
index b286795..fb9c41f 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,7 +1,8 @@
module.exports = {
"env": {
"browser": true,
- "es2021": true
+ "es2015": true,
+ "node": true
},
"extends": [
"eslint:recommended",
diff --git a/.nvmrc b/.nvmrc
index 0ff3804..23cc58a 100644
--- a/.nvmrc
+++ b/.nvmrc
@@ -1 +1 @@
-16.16.0
\ No newline at end of file
+18.20.0
\ No newline at end of file
diff --git a/lib/Client/BaseClient.js.map b/lib/Client/BaseClient.js.map
deleted file mode 100644
index ab747a5..0000000
--- a/lib/Client/BaseClient.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"BaseClient.js","sourceRoot":"","sources":["../../src/Client/BaseClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAsBrD;;EAEE;AACF;IAsDC;;;OAGG;IACH,oBAAY,iBAA4B;QAxD/B,yBAAoB,GAAgB,EAAE,CAAA;QAyD9C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC3C,CAAC;IAlDM,+BAAU,GAAjB;QACC,OAAO,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC;IAED;;;;;;;;OAQG;IACc,6BAAkB,GAAnC,UAAoC,OAA2B,EAAE,IAAwB,EAAE,WAA+B;QACzH,IAAI,OAAO,IAAI,SAAS;YACvB,MAAM,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC1C,IAAI,IAAI,KAAK,SAAS;YACrB,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAA;QACvC,IAAI,WAAW,KAAK,SAAS;YAC5B,MAAM,KAAK,CAAC,2BAA2B,CAAC,CAAA;QACzC,OAAO;YACN,KAAK,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC;YACvB,EAAE,EAAE,IAAI,GAAG,CAAC,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AA;;wBAArD,OAAO,GAAG,SAA2C;wBACrD,WAAW,GAAG,WAAW,CAAC,YAAY,CAC3C,OAAO,CACP,CAAA;wBACD,sBAAO,WAAW,EAAA;;;;KAClB;IAED,sKAAsK;IAChK,qCAAgB,GAAtB;;;;;4BACmB,qBAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,EAAA;;wBAAzD,SAAS,GAAG,SAA6C;wBACzD,aAAa,GAAG,WAAW,CAAC,YAAY,CAG5C,SAAS,CAAC,CAAA;wBACZ,sBAAO,aAAa,EAAA;;;;KACpB;IACF,iBAAC;AAAD,CAAC,AApSD,IAoSC"}
\ No newline at end of file
diff --git a/lib/Client/CernerClient.js.map b/lib/Client/CernerClient.js.map
deleted file mode 100644
index dd22b69..0000000
--- a/lib/Client/CernerClient.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"CernerClient.js","sourceRoot":"","sources":["../../src/Client/CernerClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAErD,OAAO,UAA6B,MAAM,cAAc,CAAC;AAEzD;;EAEE;AACF;IAA0C,gCAAU;IAmBlD;;;OAGG;IACH,sBAAY,iBAA4B;QACtC,YAAA,MAAK,YAAC,iBAAiB,CAAC,SAAC;QAvB3B,cAAQ,GAAQ,GAAG,CAAC,MAAM,CAAA;QAY1B;;qBAEa;QACJ,0BAAoB,GAAgB;YAC3C,MAAM,EAAE,uBAAuB;SAChC,CAAC;;IAOF,CAAC;IAnBM,yBAAY,GAAnB;QACE,OAAO,UAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,cAAc,EAAE,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC,kBAAkB,CAAC,CAAA;IAC9H,CAAC;IACD,mCAAY,GAAZ;QACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAgBD;;;;OAIG;IACG,sCAAe,GAArB,UACE,QAAW;;;;;;;wBAGL,qBAAM,gBAAK,CAAC,eAAe,YAAC,QAAQ,CAAC,EAAA;;gEAAtC,CAAC,SAAqC,CAAC;6BACtC,CAAA,QAAQ,IAAI,QAAQ,CAAA,EAApB,wBAAoB;wBAAG,KAAA,EAAE,CAAA;;4BAAG,qBAAM,gBAAK,CAAC,0BAA0B,WAAE,EAAA;;wBAAxC,KAAA,SAAwC,CAAA;;4BAF1E,wDAEK,IAAsE,KACzE;;;;KACH;IAED;;;;OAIG;IACG,sCAAe,GAArB,UAAsB,UAAkB;;;gBACtC,sBAAO,gBAAK,CAAC,eAAe,YAAC,UAAU,EAAE;wBACvC,OAAO,EAAE,IAAI,CAAC,oBAAoB;qBACnC,CAAC,EAAC;;;KACJ;IAhDe,+BAAkB,GAAG,8IAA8I,AAAjJ,CAAiJ;IACnK,2BAAc,GAAG,wHAAwH,AAA3H,CAA2H;IACzI,wBAAW,GAAG,0EAA0E,AAA7E,CAA6E;IA+C1G,mBAAC;CAAA,AAnDD,CAA0C,UAAU,GAmDnD;eAnDoB,YAAY"}
\ No newline at end of file
diff --git a/lib/Client/ClientFactory.js.map b/lib/Client/ClientFactory.js.map
deleted file mode 100644
index 5b23aa6..0000000
--- a/lib/Client/ClientFactory.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"ClientFactory.js","sourceRoot":"","sources":["../../src/Client/ClientFactory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAElC,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAEnE,OAAO,YAAY,MAAM,gBAAgB,CAAA;AACzC,OAAO,UAAU,MAAM,cAAc,CAAA;AACrC,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AAEnD,MAAM,CAAN,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AC,YAAY,EAAE,CAAA;YACnC,KAAK,GAAG,CAAC,KAAK,CAAC;YACf,KAAK,GAAG,CAAC,IAAI,CAAC;YACd;gBACC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;QAC1C,CAAC;IACF,CAAC;IAGD;;;;;;OAMG;IACK,4CAAoB,GAA5B,UAA6B,MAAe;QAC3C,IAAI,aAAa,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACzD,IAAI,aAAa,CAAC,MAAM,CAAC;YAAE,OAAQ,MAAc,CAAA;QACjD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACxC,CAAC;IAEF,oBAAC;AAAD,CAAC,AA9GD,IA8GC"}
\ No newline at end of file
diff --git a/lib/Client/EpicClient.js.map b/lib/Client/EpicClient.js.map
deleted file mode 100644
index 725ecb9..0000000
--- a/lib/Client/EpicClient.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"EpicClient.js","sourceRoot":"","sources":["../../src/Client/EpicClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAA;AAEpD,OAAO,UAA6B,MAAM,cAAc,CAAA;AAGxD;;GAEG;AACH;IAAwC,8BAAU;IAmBjD;;;OAGG;IACH,oBAAY,iBAA4B;QACvC,YAAA,MAAK,YAAC,iBAAiB,CAAC,SAAA;QAvBzB,cAAQ,GAAQ,GAAG,CAAC,IAAI,CAAA;QAaxB;wIACmI;QAC1H,uBAAiB,GAAgB;YACzC,MAAM,EAAE,uBAAuB;SAC/B,CAAA;;IAOD,CAAC;IAnBM,uBAAY,GAAnB;QACC,OAAO,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,cAAc,EAAE,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAA;IACvH,CAAC;IAED,iCAAY,GAAZ;QACC,OAAO,UAAU,CAAC,YAAY,EAAE,CAAA;IACjC,CAAC;IAeK,2BAAM,GAAZ,UAAmD,QAAW,EAC7D,SAAkB,EAClB,WAAoB;;;gBACpB,sBAAO,gBAAK,CAAC,MAAM,YAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAE,EAAA;;;KAClG;IA7Be,6BAAkB,GAAG,gEAAgE,AAAnE,CAAmE;IACrF,yBAAc,GAAG,4DAA4D,AAA/D,CAA+D;IAC7E,sBAAW,GAAG,2DAA2D,AAA9D,CAA8D;IA4B1F,iBAAC;CAAA,AAhCD,CAAwC,UAAU,GAgCjD;eAhCoB,UAAU"}
\ No newline at end of file
diff --git a/lib/Client/SmartHealthClient.js.map b/lib/Client/SmartHealthClient.js.map
deleted file mode 100644
index 8f4aad9..0000000
--- a/lib/Client/SmartHealthClient.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"SmartHealthClient.js","sourceRoot":"","sources":["../../src/Client/SmartHealthClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAA;AACpD,OAAO,UAA6B,MAAM,cAAc,CAAA;AAGxD;;GAEG;AACH;IAA+C,qCAAU;IAcxD;;;KAGI;IACJ,2BAAY,iBAA4B;QACvC,YAAA,MAAK,YAAC,iBAAiB,CAAC,SAAA;QAlBhB,cAAQ,GAAQ,GAAG,CAAC,KAAK,CAAA;;IAmBlC,CAAC;IAdM,8BAAY,GAAnB;QACC,OAAO,UAAU,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,WAAW,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAA;IAC5I,CAAC;IAED,wCAAY,GAAZ;QACC,OAAO,iBAAiB,CAAC,YAAY,EAAE,CAAA;IACxC,CAAC;IAVe,oCAAkB,GAAG,sDAAsD,AAAzD,CAAyD;IAC3E,gCAAc,GAAG,kDAAkD,AAArD,CAAqD;IACnE,6BAAW,GAAG,4CAA4C,AAA/C,CAA+C;IAiB3E,wBAAC;CAAA,AArBD,CAA+C,UAAU,GAqBxD;eArBoB,iBAAiB"}
\ No newline at end of file
diff --git a/lib/FhirClient.js.map b/lib/FhirClient.js.map
deleted file mode 100644
index dece239..0000000
--- a/lib/FhirClient.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"FhirClient.js","sourceRoot":"","sources":["../src/FhirClient.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAG3C,eAAe,MAAM,CAAC"}
\ No newline at end of file
diff --git a/lib/Launcher/Config.js.map b/lib/Launcher/Config.js.map
deleted file mode 100644
index 8845492..0000000
--- a/lib/Launcher/Config.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"Config.js","sourceRoot":"","sources":["../../src/Launcher/Config.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAC,IAAM,MAAM,GAAiB;IAClC,MAAM,EAAE;QACN,gBAAgB;QAChB,2BAA2B;QAC3B,oBAAoB;QACpB,eAAe;QACf,iBAAiB;QACjB,iBAAiB;QACjB,mBAAmB;QACnB,sBAAsB;QACtB,kBAAkB;QAClB,gBAAgB;QAChB,iBAAiB;QACjB,eAAe;QACf,0BAA0B;QAC1B,kBAAkB;QAClB,4BAA4B;QAC5B,aAAa;QACb,qBAAqB;QACrB,0BAA0B;QAC1B,uBAAuB;QACvB,oBAAoB;QACpB,gBAAgB;QAChB,eAAe;QACf,kBAAkB;QAClB,mBAAmB;QACnB,sBAAsB;QACtB,8BAA8B;QAC9B,sBAAsB;QACtB,iBAAiB;QACjB,uBAAuB;QACvB,aAAa;QACb,2BAA2B;QAC3B,oBAAoB;QACpB,cAAc;QACd,eAAe;QACf,sBAAsB;QACtB,kBAAkB;QAClB,iBAAiB;QACjB,0BAA0B;QAC1B,kBAAkB;QAClB,4BAA4B;QAC5B,qBAAqB;QACrB,0BAA0B;QAC1B,oBAAoB;QACpB,gBAAgB;QAChB,kBAAkB;QAClB,mBAAmB;QACnB,8BAA8B;QAC9B,sBAAsB;QACtB,aAAa;QACb,gBAAgB;QAChB,uBAAuB;QACvB,oBAAoB;QACpB,eAAe;QACf,iBAAiB;QACjB,iBAAiB;QACjB,mBAAmB;QACnB,sBAAsB;QACtB,cAAc;QACd,gBAAgB;QAChB,iBAAiB;QACjB,eAAe;QACf,sBAAsB;QACtB,cAAc;QACd,wBAAwB;QACxB,aAAa;QACb,iBAAiB;QACjB,aAAa;QACb,sBAAsB;QACtB,uBAAuB;QACvB,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,WAAW;QACX,iBAAiB;QACjB,cAAc;QACd,mBAAmB;QACnB,kBAAkB;QAClB,0BAA0B;QAC1B,sBAAsB;QACtB,iBAAiB;QACjB,mBAAmB;QACnB,aAAa;QACb,uBAAuB;QACvB,oBAAoB;QACpB,eAAe;QACf,cAAc;QACd,kBAAkB;QAClB,cAAc;QACd,aAAa;QACb,sBAAsB;QACtB,cAAc;QACd,wBAAwB;QACxB,iBAAiB;QACjB,sBAAsB;QACtB,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,iBAAiB;QACjB,cAAc;QACd,mBAAmB;QACnB,0BAA0B;QAC1B,kBAAkB;QAClB,YAAY;KACb;CACF,CAAC"}
\ No newline at end of file
diff --git a/lib/Launcher/SmartLaunchHandler.js.map b/lib/Launcher/SmartLaunchHandler.js.map
deleted file mode 100644
index 1886731..0000000
--- a/lib/Launcher/SmartLaunchHandler.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"SmartLaunchHandler.js","sourceRoot":"","sources":["../../src/Launcher/SmartLaunchHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KA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A;;iCACR,GAAG,CAAC,IAAI,CAAC,CAAT,wBAAQ;iCAGR,GAAG,CAAC,MAAM,CAAC,CAAX,wBAAU;iCAGV,GAAG,CAAC,KAAK,CAAC,CAAV,wBAAS;;;4BALZ,qBAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,CAAC,EAAA;;wBAAhD,SAAgD,CAAC;wBACjD,wBAAM;4BAEN,qBAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,CAAC,EAAA;;wBAAlD,SAAkD,CAAC;wBACnD,wBAAM;4BAEN,qBAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,CAAC,EAAA;;wBAAzD,SAAyD,CAAA;wBACzD,wBAAM;4BAEN,wBAAM;;;;;KAEX;IAED;;;;;OAKG;IACH,uCAAU,GAAV,UAAW,GAAY;;QACrB,IAAI,GAAG,EAAE,CAAC;YACR,IAAM,WAAW,GAAG,UAAC,OAAY,IAAK,OAAA,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAArB,CAAqB,CAAC;YAC5D,IAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpC,OAAO,MAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,mCAAI,GAAG,CAAC,IAAI,CAAC;QAChD,CAAC;QACD,IAAM,OAAO,GAAI,OAAO,CAAC,GAAG,CAAC,kBAA6B,CAAC,WAAW,EAAS,CAAA;QAC/E,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAA;QACxH,OAAO,OAAO,CAAA;IAChB,CAAC;IACH,yBAAC;AAAD,CAAC,AAjMD,IAiMC"}
\ No newline at end of file
diff --git a/lib/Resource/transformer.js.map b/lib/Resource/transformer.js.map
deleted file mode 100644
index 635b9ba..0000000
--- a/lib/Resource/transformer.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"transformer.js","sourceRoot":"","sources":["../../src/Resource/transformer.ts"],"names":[],"mappings":";;;;;;;;;;;AAKA;;;EAGE;AACF,MAAM,KAAW,WAAW,CAmE3B;AAnED,WAAiB,WAAW;IAC1B;;;;;OAKG;IACH,SAAgB,gBAAgB,CAC9B,gBAAmB;QAGnB,IAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAkB,CAAC;QAC5E,IAAM,mBAAmB,yBACpB,oBAAoB,CAAC,MAAM,CAC5B,+BAA+B,CAAI,gBAAgB,CAAC,EACpD,EAAE,CACH,KACD,YAAY,EAAE,gBAAgB,CAAC,cAAc,CAAC,GAC/C,CAAC;QACF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAbe,4BAAgB,mBAa/B,CAAA;IAED;;;;;;OAMG;IACH,SAAS,+BAA+B,CAGtC,gBAAmB;QAOnB,OAAO,UAAC,CAAC,EAAE,CAAC;;YAAK,OAAA,uBACZ,CAAC,gBACH,CAAC,IAAG,gBAAgB,CAAC,CAAC,CAAC,OACxB;QAHe,CAGf,CAAC;IACL,CAAC;IAEH;;;;OAIG;IACD,SAAgB,YAAY,CAC1B,gBAA2B;QAG3B,IAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAkB,CAAC;QAC5E,IAAM,mBAAmB,yBACpB,oBAAoB,CAAC,MAAM,CAC5B,UAAC,CAAC,EAAE,CAAC;;YAAK,OAAA,uBACL,CAAC,gBACH,CAAC,IAAG,gBAAgB,CAAC,CAAC,CAAC,OACxB;QAHQ,CAGR,EACF,EAAE,CACH,KACD,YAAY,EAAE,gBAAgB,CAAC,cAAc,CAAC,GAC/C,CAAC;QACF,OAAO,mBAA8B,CAAC;IACxC,CAAC;IAhBe,wBAAY,eAgB3B,CAAA;AACH,CAAC,EAnEgB,WAAW,KAAX,WAAW,QAmE3B"}
\ No newline at end of file
diff --git a/lib/Client/BaseClient.d.ts b/lib/cjs/Client/BaseClient.d.ts
similarity index 100%
rename from lib/Client/BaseClient.d.ts
rename to lib/cjs/Client/BaseClient.d.ts
diff --git a/lib/Client/BaseClient.js b/lib/cjs/Client/BaseClient.js
similarity index 96%
rename from lib/Client/BaseClient.js
rename to lib/cjs/Client/BaseClient.js
index c6a52d3..ce54a40 100644
--- a/lib/Client/BaseClient.js
+++ b/lib/cjs/Client/BaseClient.js
@@ -1,3 +1,4 @@
+"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -45,7 +46,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
-import { Transformer } from "../Resource/transformer";
+Object.defineProperty(exports, "__esModule", { value: true });
+var transformer_1 = require("../Resource/transformer");
/**
Represents the BaseClient abstract class.
*/
@@ -297,14 +299,14 @@ var BaseClient = /** @class */ (function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
- transformedResource = Transformer.toFhirClientType(resource);
+ transformedResource = transformer_1.Transformer.toFhirClientType(resource);
return [4 /*yield*/, this.hydrateResource(transformedResource, patientId, encounterId)];
case 1:
hydratedResource = _a.sent();
return [4 /*yield*/, this.createHydratedResource(hydratedResource, additionalHeaders)];
case 2:
resultResource = _a.sent();
- resultAsR4 = Transformer.toR4FhirType(resultResource);
+ resultAsR4 = transformer_1.Transformer.toR4FhirType(resultResource);
return [2 /*return*/, resultAsR4];
}
});
@@ -392,7 +394,7 @@ var BaseClient = /** @class */ (function () {
case 1:
user = _a.sent();
if (isPractitioner(user)) {
- userInR4 = Transformer.toR4FhirType(user);
+ userInR4 = transformer_1.Transformer.toR4FhirType(user);
return [2 /*return*/, userInR4];
}
throw new Error("User is Not a Practitioner");
@@ -412,7 +414,7 @@ var BaseClient = /** @class */ (function () {
case 0: return [4 /*yield*/, this.fhirClientDefault.patient.read()];
case 1:
patient = _a.sent();
- patientInR4 = Transformer.toR4FhirType(patient);
+ patientInR4 = transformer_1.Transformer.toR4FhirType(patient);
return [2 /*return*/, patientInR4];
}
});
@@ -427,7 +429,7 @@ var BaseClient = /** @class */ (function () {
case 0: return [4 /*yield*/, this.fhirClientDefault.encounter.read()];
case 1:
encounter = _a.sent();
- encounterInR4 = Transformer.toR4FhirType(encounter);
+ encounterInR4 = transformer_1.Transformer.toR4FhirType(encounter);
return [2 /*return*/, encounterInR4];
}
});
@@ -435,5 +437,5 @@ var BaseClient = /** @class */ (function () {
};
return BaseClient;
}());
-export default BaseClient;
+exports.default = BaseClient;
//# sourceMappingURL=BaseClient.js.map
\ No newline at end of file
diff --git a/lib/cjs/Client/BaseClient.js.map b/lib/cjs/Client/BaseClient.js.map
new file mode 100644
index 0000000..afd1733
--- /dev/null
+++ b/lib/cjs/Client/BaseClient.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"BaseClient.js","sourceRoot":"","sources":["../../../src/Client/BaseClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,uDAAqD;AAsBrD;;EAEE;AACF;IAsDC;;;OAGG;IACH,oBAAY,iBAA4B;QAxD/B,yBAAoB,GAAgB,EAAE,CAAA;QAyD9C,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC3C,CAAC;IAlDM,+BAAU,GAAjB;QACC,OAAO,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC;IAED;;;;;;;;OAQG;IACc,6BAAkB,GAAnC,UAAoC,OAA2B,EAAE,IAAwB,EAAE,WAA+B;QACzH,IAAI,OAAO,IAAI,SAAS;YACvB,MAAM,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC1C,IAAI,IAAI,KAAK,SAAS;YACrB,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAA;QACvC,IAAI,WAAW,KAAK,SAAS;YAC5B,MAAM,KAAK,CAAC,2BAA2B,CAAC,CAAA;QACzC,OAAO;YACN,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Ac,GAApB;;;;;4BACiB,qBAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,EAAA;;wBAArD,OAAO,GAAG,SAA2C;wBACrD,WAAW,GAAG,yBAAW,CAAC,YAAY,CAC3C,OAAO,CACP,CAAA;wBACD,sBAAO,WAAW,EAAA;;;;KAClB;IAED,sKAAsK;IAChK,qCAAgB,GAAtB;;;;;4BACmB,qBAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,EAAA;;wBAAzD,SAAS,GAAG,SAA6C;wBACzD,aAAa,GAAG,yBAAW,CAAC,YAAY,CAG5C,SAAS,CAAC,CAAA;wBACZ,sBAAO,aAAa,EAAA;;;;KACpB;IACF,iBAAC;AAAD,CAAC,AApSD,IAoSC"}
\ No newline at end of file
diff --git a/lib/Client/CernerClient.d.ts b/lib/cjs/Client/CernerClient.d.ts
similarity index 100%
rename from lib/Client/CernerClient.d.ts
rename to lib/cjs/Client/CernerClient.d.ts
diff --git a/lib/Client/CernerClient.js b/lib/cjs/Client/CernerClient.js
similarity index 91%
rename from lib/Client/CernerClient.js
rename to lib/cjs/Client/CernerClient.js
index aa98de6..4c70a2f 100644
--- a/lib/Client/CernerClient.js
+++ b/lib/cjs/Client/CernerClient.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
@@ -60,8 +61,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
-import { EMR } from "../Launcher/SmartLaunchHandler";
-import BaseClient from "./BaseClient";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+var SmartLaunchHandler_1 = require("../Launcher/SmartLaunchHandler");
+var BaseClient_1 = __importDefault(require("./BaseClient"));
/**
Represents the CernerClient class, extending the BaseClient.
*/
@@ -73,7 +78,7 @@ var CernerClient = /** @class */ (function (_super) {
*/
function CernerClient(fhirClientDefault) {
var _this = _super.call(this, fhirClientDefault) || this;
- _this.EMR_TYPE = EMR.CERNER;
+ _this.EMR_TYPE = SmartLaunchHandler_1.EMR.CERNER;
/* The `cernerRequestHeaders` property is a constant that represents the headers to be included in the request made by the CernerClient class. In this case, it
specifies that the client accepts the "application/fhir+json" media type. The `readonly` keyword indicates that the property cannot be modified after it is
initialized. */
@@ -83,7 +88,7 @@ var CernerClient = /** @class */ (function (_super) {
return _this;
}
CernerClient.getEndpoints = function () {
- return BaseClient.constructEndpoints(CernerClient.TOKEN_ENDPOINT, CernerClient.R4_ENDPOINT, CernerClient.AUTHORIZE_ENDPOINT);
+ return BaseClient_1.default.constructEndpoints(CernerClient.TOKEN_ENDPOINT, CernerClient.R4_ENDPOINT, CernerClient.AUTHORIZE_ENDPOINT);
};
CernerClient.prototype.getEndpoints = function () {
throw new Error("Method not implemented.");
@@ -133,6 +138,6 @@ var CernerClient = /** @class */ (function (_super) {
CernerClient.TOKEN_ENDPOINT = "https://authorization.cerner.com/tenants/ec2458f2-1e24-41c8-b71b-0e701af7583d/protocols/oauth2/profiles/smart-v1/token";
CernerClient.R4_ENDPOINT = "https://fhir-ehr-code.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d";
return CernerClient;
-}(BaseClient));
-export default CernerClient;
+}(BaseClient_1.default));
+exports.default = CernerClient;
//# sourceMappingURL=CernerClient.js.map
\ No newline at end of file
diff --git a/lib/cjs/Client/CernerClient.js.map b/lib/cjs/Client/CernerClient.js.map
new file mode 100644
index 0000000..376438a
--- /dev/null
+++ b/lib/cjs/Client/CernerClient.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"CernerClient.js","sourceRoot":"","sources":["../../../src/Client/CernerClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
\ No newline at end of file
diff --git a/lib/Client/ClientFactory.d.ts b/lib/cjs/Client/ClientFactory.d.ts
similarity index 69%
rename from lib/Client/ClientFactory.d.ts
rename to lib/cjs/Client/ClientFactory.d.ts
index f6f54ea..a7d0341 100644
--- a/lib/Client/ClientFactory.d.ts
+++ b/lib/cjs/Client/ClientFactory.d.ts
@@ -1,5 +1,7 @@
-import SubClient from "../FhirClient";
+///
import BaseClient from "./BaseClient";
+import { ServerResponse, IncomingMessage } from "http";
+import { FhirClientConfig } from "../types";
export declare enum LAUNCH {
EMR = 0,
STANDALONE = 1,
@@ -21,7 +23,16 @@ export default class ClientFactory {
* of `LAUNCH.EMR`.
* @returns a Promise that resolves to an instance of the `BaseClient` class.
*/
- createEMRClient(launchType?: LAUNCH, fhirClient?: SubClient): Promise;
+ createEMRClient(launchType: LAUNCH.EMR | LAUNCH.STANDALONE): Promise;
+ /**
+ * The function `createEMRClientBackend` creates an EMR client based on the specified launch type.
+ * @param {IncomingMessage} req - The `req` parameter is an incoming message object that represents the request made by the client.
+ * @param {ServerResponse} res - The `res` parameter is a server response object that represents the response sent by the server.
+ * @param {FhirClientConfig} serverConfig - The `serverConfig` parameter is an object that contains the configuration for the FHIR client. It includes the server URL, token response, client ID, and token URI.
+ * @returns a Promise that resolves to an instance of the `BaseClient` class.
+ */
+ createEMRClientBackend(req: IncomingMessage, res: ServerResponse, serverConfig: FhirClientConfig): Promise;
+ private createSmarterFhirClient;
/**
* The function creates a default FHIR client based on the launch type.
* @param {LAUNCH} launchType - The `launchType` parameter is an enum type called `LAUNCH`. It represents the type of launch for the FHIR client. There are two
diff --git a/lib/Client/ClientFactory.js b/lib/cjs/Client/ClientFactory.js
similarity index 56%
rename from lib/Client/ClientFactory.js
rename to lib/cjs/Client/ClientFactory.js
index 370fcbd..09c7686 100644
--- a/lib/Client/ClientFactory.js
+++ b/lib/cjs/Client/ClientFactory.js
@@ -1,3 +1,27 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
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) {
@@ -34,17 +58,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
-import * as FHIR from "fhirclient";
-import { EMR, instanceOfEmr } from "../Launcher/SmartLaunchHandler";
-import CernerClient from "./CernerClient";
-import EpicClient from "./EpicClient";
-import SmartHealthClient from "./SmartHealthClient";
-export var LAUNCH;
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.LAUNCH = void 0;
+var fhirclient_1 = __importStar(require("fhirclient")), FHIR = fhirclient_1;
+var SmartLaunchHandler_1 = require("../Launcher/SmartLaunchHandler");
+var CernerClient_1 = __importDefault(require("./CernerClient"));
+var EpicClient_1 = __importDefault(require("./EpicClient"));
+var SmartHealthClient_1 = __importDefault(require("./SmartHealthClient"));
+var LAUNCH;
(function (LAUNCH) {
LAUNCH[LAUNCH["EMR"] = 0] = "EMR";
LAUNCH[LAUNCH["STANDALONE"] = 1] = "STANDALONE";
LAUNCH[LAUNCH["BACKEND"] = 2] = "BACKEND";
-})(LAUNCH || (LAUNCH = {}));
+})(LAUNCH || (exports.LAUNCH = LAUNCH = {}));
/**
* The function checks if an object is an instance of the JWT class by verifying if it has a client_id property.
* @param {unknown} object - The `object` parameter is of type `unknown`, which means it can be any type.
@@ -70,21 +99,21 @@ var ClientFactory = /** @class */ (function () {
}
if (isClient(clientOrToken)) {
if (clientOrToken.state.serverUrl.includes("cerner")) {
- return EMR.CERNER;
+ return SmartLaunchHandler_1.EMR.CERNER;
}
if (clientOrToken.state.serverUrl.includes("smarthealthit")) {
- return EMR.SMART;
+ return SmartLaunchHandler_1.EMR.SMART;
}
if (clientOrToken.state.serverUrl.includes("epic")) {
- return EMR.EPIC;
+ return SmartLaunchHandler_1.EMR.EPIC;
}
}
else {
if ("epic.eci" in clientOrToken) {
- return EMR.EPIC;
+ return SmartLaunchHandler_1.EMR.EPIC;
}
}
- return EMR.NONE;
+ return SmartLaunchHandler_1.EMR.NONE;
};
/**
* The function `createEMRClient` creates an EMR client based on the specified launch type.
@@ -92,40 +121,58 @@ var ClientFactory = /** @class */ (function () {
* of `LAUNCH.EMR`.
* @returns a Promise that resolves to an instance of the `BaseClient` class.
*/
- ClientFactory.prototype.createEMRClient = function (launchType, fhirClient) {
- if (launchType === void 0) { launchType = LAUNCH.EMR; }
+ ClientFactory.prototype.createEMRClient = function (launchType) {
+ return __awaiter(this, void 0, void 0, function () {
+ var fhirClient;
+ return __generator(this, function (_a) {
+ switch (_a.label) {
+ case 0: return [4 /*yield*/, this.createDefaultFhirClient(launchType)];
+ case 1:
+ fhirClient = _a.sent();
+ return [4 /*yield*/, this.createSmarterFhirClient(fhirClient)];
+ case 2: return [2 /*return*/, _a.sent()];
+ }
+ });
+ });
+ };
+ /**
+ * The function `createEMRClientBackend` creates an EMR client based on the specified launch type.
+ * @param {IncomingMessage} req - The `req` parameter is an incoming message object that represents the request made by the client.
+ * @param {ServerResponse} res - The `res` parameter is a server response object that represents the response sent by the server.
+ * @param {FhirClientConfig} serverConfig - The `serverConfig` parameter is an object that contains the configuration for the FHIR client. It includes the server URL, token response, client ID, and token URI.
+ * @returns a Promise that resolves to an instance of the `BaseClient` class.
+ */
+ ClientFactory.prototype.createEMRClientBackend = function (req, res, serverConfig) {
+ return __awaiter(this, void 0, void 0, function () {
+ var fhirClient;
+ return __generator(this, function (_a) {
+ fhirClient = (0, fhirclient_1.default)(req, res).client({
+ serverUrl: serverConfig.serverUrl,
+ tokenResponse: serverConfig.tokenResponse,
+ clientId: serverConfig.clientId,
+ tokenUri: serverConfig.tokenUri
+ });
+ return [2 /*return*/, this.createSmarterFhirClient(fhirClient)];
+ });
+ });
+ };
+ ClientFactory.prototype.createSmarterFhirClient = function (fhirClient) {
return __awaiter(this, void 0, void 0, function () {
- var defaultFhirClient, _a, emrType;
- return __generator(this, function (_b) {
- switch (_b.label) {
- case 0:
- if (launchType === LAUNCH.BACKEND) {
- if (!fhirClient)
- throw new Error("FhirClient must be passed as a param for Backend Authentication");
- }
- if (!(fhirClient !== null && fhirClient !== void 0)) return [3 /*break*/, 1];
- _a = fhirClient;
- return [3 /*break*/, 3];
- case 1: return [4 /*yield*/, this.createDefaultFhirClient(launchType)];
- case 2:
- _a = _b.sent();
- _b.label = 3;
- case 3:
- defaultFhirClient = _a;
- emrType = this.getEMRType(defaultFhirClient);
- switch (emrType) {
- case EMR.EPIC:
- return [2 /*return*/, new EpicClient(defaultFhirClient)];
- case EMR.CERNER:
- return [2 /*return*/, new CernerClient(defaultFhirClient)];
- case EMR.SMART:
- return [2 /*return*/, new SmartHealthClient(defaultFhirClient)];
- case EMR.NONE:
- default:
- throw new Error("Unsupported provider for EMR Client creation");
- }
- return [2 /*return*/];
+ var emrType;
+ return __generator(this, function (_a) {
+ emrType = this.getEMRType(fhirClient);
+ switch (emrType) {
+ case SmartLaunchHandler_1.EMR.EPIC:
+ return [2 /*return*/, new EpicClient_1.default(fhirClient)];
+ case SmartLaunchHandler_1.EMR.CERNER:
+ return [2 /*return*/, new CernerClient_1.default(fhirClient)];
+ case SmartLaunchHandler_1.EMR.SMART:
+ return [2 /*return*/, new SmartHealthClient_1.default(fhirClient)];
+ case SmartLaunchHandler_1.EMR.NONE:
+ default:
+ throw new Error("Unsupported provider for EMR Client creation");
}
+ return [2 /*return*/];
});
});
};
@@ -151,12 +198,12 @@ var ClientFactory = /** @class */ (function () {
};
ClientFactory.prototype.getEmrEndpoints = function (object) {
switch (this.getEmrTypeFromObject(object)) {
- case EMR.EPIC:
- return EpicClient.getEndpoints();
- case EMR.CERNER:
- return CernerClient.getEndpoints();
- case EMR.SMART:
- case EMR.NONE:
+ case SmartLaunchHandler_1.EMR.EPIC:
+ return EpicClient_1.default.getEndpoints();
+ case SmartLaunchHandler_1.EMR.CERNER:
+ return CernerClient_1.default.getEndpoints();
+ case SmartLaunchHandler_1.EMR.SMART:
+ case SmartLaunchHandler_1.EMR.NONE:
default:
throw new Error('EMR type not defined.');
}
@@ -171,11 +218,11 @@ var ClientFactory = /** @class */ (function () {
ClientFactory.prototype.getEmrTypeFromObject = function (object) {
if (instanceOfJWT(object))
return this.getEMRType(object);
- if (instanceOfEmr(object))
+ if ((0, SmartLaunchHandler_1.instanceOfEmr)(object))
return object;
throw new Error('Invalid object type.');
};
return ClientFactory;
}());
-export default ClientFactory;
+exports.default = ClientFactory;
//# sourceMappingURL=ClientFactory.js.map
\ No newline at end of file
diff --git a/lib/cjs/Client/ClientFactory.js.map b/lib/cjs/Client/ClientFactory.js.map
new file mode 100644
index 0000000..0a7892e
--- /dev/null
+++ b/lib/cjs/Client/ClientFactory.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"ClientFactory.js","sourceRoot":"","sources":["../../../src/Client/ClientFactory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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MAAM,CAAC,UAAU;wBACrB,sBAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAA;oBAC3B;wBACC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;gBAC/D,CAAC;;;;KACD;IAUO,uCAAe,GAAvB,UAAwB,MAAe;QACtC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,KAAK,wBAAG,CAAC,IAAI;gBACZ,OAAO,oBAAU,CAAC,YAAY,EAAE,CAAA;YACjC,KAAK,wBAAG,CAAC,MAAM;gBACd,OAAO,sBAAY,CAAC,YAAY,EAAE,CAAA;YACnC,KAAK,wBAAG,CAAC,KAAK,CAAC;YACf,KAAK,wBAAG,CAAC,IAAI,CAAC;YACd;gBACC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;QAC1C,CAAC;IACF,CAAC;IAGD;;;;;;OAMG;IACK,4CAAoB,GAA5B,UAA6B,MAAe;QAC3C,IAAI,aAAa,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACzD,IAAI,IAAA,kCAAa,EAAC,MAAM,CAAC;YAAE,OAAQ,MAAc,CAAA;QACjD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACxC,CAAC;IAEF,oBAAC;AAAD,CAAC,AA/HD,IA+HC"}
\ No newline at end of file
diff --git a/lib/Client/EpicClient.d.ts b/lib/cjs/Client/EpicClient.d.ts
similarity index 100%
rename from lib/Client/EpicClient.d.ts
rename to lib/cjs/Client/EpicClient.d.ts
diff --git a/lib/Client/EpicClient.js b/lib/cjs/Client/EpicClient.js
similarity index 88%
rename from lib/Client/EpicClient.js
rename to lib/cjs/Client/EpicClient.js
index fcb536f..1fe8f92 100644
--- a/lib/Client/EpicClient.js
+++ b/lib/cjs/Client/EpicClient.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
@@ -49,8 +50,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
-import { EMR } from "../Launcher/SmartLaunchHandler";
-import BaseClient from "./BaseClient";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+var SmartLaunchHandler_1 = require("../Launcher/SmartLaunchHandler");
+var BaseClient_1 = __importDefault(require("./BaseClient"));
/**
Represents the EpicClient class, extending the BaseClient.
*/
@@ -62,7 +67,7 @@ var EpicClient = /** @class */ (function (_super) {
*/
function EpicClient(fhirClientDefault) {
var _this = _super.call(this, fhirClientDefault) || this;
- _this.EMR_TYPE = EMR.EPIC;
+ _this.EMR_TYPE = SmartLaunchHandler_1.EMR.EPIC;
/* The `epicCreateHeaders` property is defining the headers that will be used when making a create request to the Epic FHIR server. In this case, it sets the
`Prefer` header to `"return=representation"`, which indicates that the server should return the created resource in the response. */
_this.epicCreateHeaders = {
@@ -71,7 +76,7 @@ var EpicClient = /** @class */ (function (_super) {
return _this;
}
EpicClient.getEndpoints = function () {
- return BaseClient.constructEndpoints(EpicClient.TOKEN_ENDPOINT, EpicClient.R4_ENDPOINT, EpicClient.AUTHORIZE_ENDPOINT);
+ return BaseClient_1.default.constructEndpoints(EpicClient.TOKEN_ENDPOINT, EpicClient.R4_ENDPOINT, EpicClient.AUTHORIZE_ENDPOINT);
};
EpicClient.prototype.getEndpoints = function () {
return EpicClient.getEndpoints();
@@ -87,6 +92,6 @@ var EpicClient = /** @class */ (function (_super) {
EpicClient.TOKEN_ENDPOINT = "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token";
EpicClient.R4_ENDPOINT = "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4";
return EpicClient;
-}(BaseClient));
-export default EpicClient;
+}(BaseClient_1.default));
+exports.default = EpicClient;
//# sourceMappingURL=EpicClient.js.map
\ No newline at end of file
diff --git a/lib/cjs/Client/EpicClient.js.map b/lib/cjs/Client/EpicClient.js.map
new file mode 100644
index 0000000..0ceb369
--- /dev/null
+++ b/lib/cjs/Client/EpicClient.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"EpicClient.js","sourceRoot":"","sources":["../../../src/Client/EpicClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qEAAoD;AAEpD,4DAAwD;AAGxD;;GAEG;AACH;IAAwC,8BAAU;IAmBjD;;;OAGG;IACH,oBAAY,iBAA4B;QACvC,YAAA,MAAK,YAAC,iBAAiB,CAAC,SAAA;QAvBzB,cAAQ,GAAQ,wBAAG,CAAC,IAAI,CAAA;QAaxB;wIACmI;QAC1H,uBAAiB,GAAgB;YACzC,MAAM,EAAE,uBAAuB;SAC/B,CAAA;;IAOD,CAAC;IAnBM,uBAAY,GAAnB;QACC,OAAO,oBAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,cAAc,EAAE,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAA;IACvH,CAAC;IAED,iCAAY,GAAZ;QACC,OAAO,UAAU,CAAC,YAAY,EAAE,CAAA;IACjC,CAAC;IAeK,2BAAM,GAAZ,UAAmD,QAAW,EAC7D,SAAkB,EAClB,WAAoB;;;gBACpB,sBAAO,gBAAK,CAAC,MAAM,YAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAE,EAAA;;;KAClG;IA7Be,6BAAkB,GAAG,gEAAgE,AAAnE,CAAmE;IACrF,yBAAc,GAAG,4DAA4D,AAA/D,CAA+D;IAC7E,sBAAW,GAAG,2DAA2D,AAA9D,CAA8D;IA4B1F,iBAAC;CAAA,AAhCD,CAAwC,oBAAU,GAgCjD;kBAhCoB,UAAU"}
\ No newline at end of file
diff --git a/lib/Client/SmartHealthClient.d.ts b/lib/cjs/Client/SmartHealthClient.d.ts
similarity index 100%
rename from lib/Client/SmartHealthClient.d.ts
rename to lib/cjs/Client/SmartHealthClient.d.ts
diff --git a/lib/Client/SmartHealthClient.js b/lib/cjs/Client/SmartHealthClient.js
similarity index 71%
rename from lib/Client/SmartHealthClient.js
rename to lib/cjs/Client/SmartHealthClient.js
index 64f9174..eb97aa5 100644
--- a/lib/Client/SmartHealthClient.js
+++ b/lib/cjs/Client/SmartHealthClient.js
@@ -1,3 +1,4 @@
+"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
@@ -13,8 +14,12 @@ var __extends = (this && this.__extends) || (function () {
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
-import { EMR } from "../Launcher/SmartLaunchHandler";
-import BaseClient from "./BaseClient";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+var SmartLaunchHandler_1 = require("../Launcher/SmartLaunchHandler");
+var BaseClient_1 = __importDefault(require("./BaseClient"));
/**
Represents the SmartHealthClient class, extending the BaseClient.
*/
@@ -26,11 +31,11 @@ var SmartHealthClient = /** @class */ (function (_super) {
*/
function SmartHealthClient(fhirClientDefault) {
var _this = _super.call(this, fhirClientDefault) || this;
- _this.EMR_TYPE = EMR.SMART;
+ _this.EMR_TYPE = SmartLaunchHandler_1.EMR.SMART;
return _this;
}
SmartHealthClient.getEndpoints = function () {
- return BaseClient.constructEndpoints(SmartHealthClient.TOKEN_ENDPOINT, SmartHealthClient.R4_ENDPOINT, SmartHealthClient.AUTHORIZE_ENDPOINT);
+ return BaseClient_1.default.constructEndpoints(SmartHealthClient.TOKEN_ENDPOINT, SmartHealthClient.R4_ENDPOINT, SmartHealthClient.AUTHORIZE_ENDPOINT);
};
SmartHealthClient.prototype.getEndpoints = function () {
return SmartHealthClient.getEndpoints();
@@ -39,6 +44,6 @@ var SmartHealthClient = /** @class */ (function (_super) {
SmartHealthClient.TOKEN_ENDPOINT = "https://launch.smarthealthit.org/v/r4/auth/token";
SmartHealthClient.R4_ENDPOINT = "https://launch.smarthealthit.org/v/r4/fhir";
return SmartHealthClient;
-}(BaseClient));
-export default SmartHealthClient;
+}(BaseClient_1.default));
+exports.default = SmartHealthClient;
//# sourceMappingURL=SmartHealthClient.js.map
\ No newline at end of file
diff --git a/lib/cjs/Client/SmartHealthClient.js.map b/lib/cjs/Client/SmartHealthClient.js.map
new file mode 100644
index 0000000..5be1247
--- /dev/null
+++ b/lib/cjs/Client/SmartHealthClient.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"SmartHealthClient.js","sourceRoot":"","sources":["../../../src/Client/SmartHealthClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,qEAAoD;AACpD,4DAAwD;AAGxD;;GAEG;AACH;IAA+C,qCAAU;IAcxD;;;KAGI;IACJ,2BAAY,iBAA4B;QACvC,YAAA,MAAK,YAAC,iBAAiB,CAAC,SAAA;QAlBhB,cAAQ,GAAQ,wBAAG,CAAC,KAAK,CAAA;;IAmBlC,CAAC;IAdM,8BAAY,GAAnB;QACC,OAAO,oBAAU,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,WAAW,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAA;IAC5I,CAAC;IAED,wCAAY,GAAZ;QACC,OAAO,iBAAiB,CAAC,YAAY,EAAE,CAAA;IACxC,CAAC;IAVe,oCAAkB,GAAG,sDAAsD,AAAzD,CAAyD;IAC3E,gCAAc,GAAG,kDAAkD,AAArD,CAAqD;IACnE,6BAAW,GAAG,4CAA4C,AAA/C,CAA+C;IAiB3E,wBAAC;CAAA,AArBD,CAA+C,oBAAU,GAqBxD;kBArBoB,iBAAiB"}
\ No newline at end of file
diff --git a/lib/FhirClient.d.ts b/lib/cjs/FhirClient.d.ts
similarity index 100%
rename from lib/FhirClient.d.ts
rename to lib/cjs/FhirClient.d.ts
diff --git a/lib/cjs/FhirClient.js b/lib/cjs/FhirClient.js
new file mode 100644
index 0000000..9b08973
--- /dev/null
+++ b/lib/cjs/FhirClient.js
@@ -0,0 +1,8 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+var Client_1 = __importDefault(require("fhirclient/lib/Client"));
+exports.default = Client_1.default;
+//# sourceMappingURL=FhirClient.js.map
\ No newline at end of file
diff --git a/lib/cjs/FhirClient.js.map b/lib/cjs/FhirClient.js.map
new file mode 100644
index 0000000..1934ff5
--- /dev/null
+++ b/lib/cjs/FhirClient.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"FhirClient.js","sourceRoot":"","sources":["../../src/FhirClient.ts"],"names":[],"mappings":";;;;;AAAA,iEAA2C;AAG3C,kBAAe,gBAAM,CAAC"}
\ No newline at end of file
diff --git a/lib/Launcher/Config.d.ts b/lib/cjs/Launcher/Config.d.ts
similarity index 100%
rename from lib/Launcher/Config.d.ts
rename to lib/cjs/Launcher/Config.d.ts
diff --git a/lib/cjs/Launcher/Config.js b/lib/cjs/Launcher/Config.js
new file mode 100644
index 0000000..94631b8
--- /dev/null
+++ b/lib/cjs/Launcher/Config.js
@@ -0,0 +1,115 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.cerner = void 0;
+/**
+ * Launch configuration for Cerner.
+ * @constant {LaunchConfig}
+ */
+exports.cerner = {
+ scopes: [
+ // "pr_account",
+ // "pr_allergyintolerance",
+ // "pr_appointment",
+ // "pr_binary",
+ // "pr_careplan",
+ // "pr_careteam",
+ // "pr_chargeitem",
+ // "pr_communication",
+ // "pr_condition",
+ // "pr_consent",
+ // "pr_coverage",
+ // "pr_device",
+ // "pr_documentreference",
+ // "pr_encounter",
+ // "pr_familymemberhistory",
+ // "pr_goal",
+ // "pr_immunization",
+ // "pr_medicationrequest",
+ // "pr_nutritionorder",
+ // "pr_observation",
+ // "pr_patient",
+ // "pr_person",
+ // "pr_procedure",
+ // "pr_provenance",
+ // "pr_questionnaire",
+ // "pr_questionnaireresponse",
+ // "pr_relatedperson",
+ // "pr_schedule",
+ // "pr_servicerequest",
+ // "pr_slot",
+ // "pw_allergyintolerance",
+ // "pw_appointment",
+ // "pw_basic",
+ // "pw_binary",
+ // "pw_communication",
+ // "pw_condition",
+ // "pw_coverage",
+ // "pw_documentreference",
+ // "pw_encounter",
+ // "pw_familymemberhistory",
+ // "pw_immunization",
+ // "pw_medicationrequest",
+ // "pw_observation",
+ // "pw_patient",
+ // "pw_procedure",
+ // "pw_provenance",
+ // "pw_questionnaireresponse",
+ // "pw_relatedperson",
+ // "pw_slot",
+ // "ur_account",
+ "ur_allergyintolerance",
+ // "ur_appointment",
+ // "ur_binary",
+ // "ur_careplan",
+ // "ur_careteam",
+ // "ur_chargeitem",
+ // "ur_communication",
+ "ur_condition",
+ // "ur_consent",
+ // "ur_coverage",
+ // "ur_device",
+ "ur_documentreference",
+ "ur_encounter",
+ "ur_familymemberhistory",
+ // "ur_goal",
+ "ur_immunization",
+ "ur_location",
+ "ur_medicationrequest",
+ // "ur_nutritionorder",
+ "ur_observation",
+ "ur_organization",
+ "ur_patient",
+ "ur_person",
+ "ur_practitioner",
+ "ur_procedure",
+ // "ur_provenance",
+ "ur_questionnaire",
+ "ur_questionnaireresponse",
+ // "ur_relatedperson",
+ // "ur_schedule",
+ "ur_servicerequest",
+ // "ur_slot",
+ "uw_allergyintolerance",
+ // "uw_appointment",
+ // "uw_binary",
+ // "uw_basic",
+ "uw_communication",
+ "uw_condition",
+ "uw_coverage",
+ "uw_documentreference",
+ "uw_encounter",
+ "uw_familymemberhistory",
+ "uw_immunization",
+ "uw_medicationrequest",
+ "uw_observation",
+ "uw_organization",
+ "uw_patient",
+ "uw_practitioner",
+ "uw_procedure",
+ // "uw_provenance",
+ "uw_questionnaireresponse",
+ "uw_relatedperson",
+ // "uw_slot"
+ ],
+};
+//# sourceMappingURL=Config.js.map
\ No newline at end of file
diff --git a/lib/cjs/Launcher/Config.js.map b/lib/cjs/Launcher/Config.js.map
new file mode 100644
index 0000000..b11504b
--- /dev/null
+++ b/lib/cjs/Launcher/Config.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"Config.js","sourceRoot":"","sources":["../../../src/Launcher/Config.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACU,QAAA,MAAM,GAAiB;IAClC,MAAM,EAAE;QACN,gBAAgB;QAChB,2BAA2B;QAC3B,oBAAoB;QACpB,eAAe;QACf,iBAAiB;QACjB,iBAAiB;QACjB,mBAAmB;QACnB,sBAAsB;QACtB,kBAAkB;QAClB,gBAAgB;QAChB,iBAAiB;QACjB,eAAe;QACf,0BAA0B;QAC1B,kBAAkB;QAClB,4BAA4B;QAC5B,aAAa;QACb,qBAAqB;QACrB,0BAA0B;QAC1B,uBAAuB;QACvB,oBAAoB;QACpB,gBAAgB;QAChB,eAAe;QACf,kBAAkB;QAClB,mBAAmB;QACnB,sBAAsB;QACtB,8BAA8B;QAC9B,sBAAsB;QACtB,iBAAiB;QACjB,uBAAuB;QACvB,aAAa;QACb,2BAA2B;QAC3B,oBAAoB;QACpB,cAAc;QACd,eAAe;QACf,sBAAsB;QACtB,kBAAkB;QAClB,iBAAiB;QACjB,0BAA0B;QAC1B,kBAAkB;QAClB,4BAA4B;QAC5B,qBAAqB;QACrB,0BAA0B;QAC1B,oBAAoB;QACpB,gBAAgB;QAChB,kBAAkB;QAClB,mBAAmB;QACnB,8BAA8B;QAC9B,sBAAsB;QACtB,aAAa;QACb,gBAAgB;QAChB,uBAAuB;QACvB,oBAAoB;QACpB,eAAe;QACf,iBAAiB;QACjB,iBAAiB;QACjB,mBAAmB;QACnB,sBAAsB;QACtB,cAAc;QACd,gBAAgB;QAChB,iBAAiB;QACjB,eAAe;QACf,sBAAsB;QACtB,cAAc;QACd,wBAAwB;QACxB,aAAa;QACb,iBAAiB;QACjB,aAAa;QACb,sBAAsB;QACtB,uBAAuB;QACvB,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,WAAW;QACX,iBAAiB;QACjB,cAAc;QACd,mBAAmB;QACnB,kBAAkB;QAClB,0BAA0B;QAC1B,sBAAsB;QACtB,iBAAiB;QACjB,mBAAmB;QACnB,aAAa;QACb,uBAAuB;QACvB,oBAAoB;QACpB,eAAe;QACf,cAAc;QACd,kBAAkB;QAClB,cAAc;QACd,aAAa;QACb,sBAAsB;QACtB,cAAc;QACd,wBAAwB;QACxB,iBAAiB;QACjB,sBAAsB;QACtB,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,iBAAiB;QACjB,cAAc;QACd,mBAAmB;QACnB,0BAA0B;QAC1B,kBAAkB;QAClB,YAAY;KACb;CACF,CAAC"}
\ No newline at end of file
diff --git a/lib/Launcher/SmartLaunchHandler.d.ts b/lib/cjs/Launcher/SmartLaunchHandler.d.ts
similarity index 100%
rename from lib/Launcher/SmartLaunchHandler.d.ts
rename to lib/cjs/Launcher/SmartLaunchHandler.d.ts
diff --git a/lib/Launcher/SmartLaunchHandler.js b/lib/cjs/Launcher/SmartLaunchHandler.js
similarity index 83%
rename from lib/Launcher/SmartLaunchHandler.js
rename to lib/cjs/Launcher/SmartLaunchHandler.js
index 839c216..d7a8c1c 100644
--- a/lib/Launcher/SmartLaunchHandler.js
+++ b/lib/cjs/Launcher/SmartLaunchHandler.js
@@ -1,3 +1,27 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
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) {
@@ -43,45 +67,52 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
}
return to.concat(ar || Array.prototype.slice.call(from));
};
-import * as FHIR from "fhirclient";
-import CernerClient from "../Client/CernerClient";
-import { LAUNCH } from "../Client/ClientFactory";
-import EpicClient from "../Client/EpicClient";
-import { cerner } from "./Config";
-import scopes from "./scopes.json";
-export var EMR;
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.getEndpointsForEmr = exports.instanceOfEmr = exports.EMR = void 0;
+var FHIR = __importStar(require("fhirclient"));
+var CernerClient_1 = __importDefault(require("../Client/CernerClient"));
+var ClientFactory_1 = require("../Client/ClientFactory");
+var EpicClient_1 = __importDefault(require("../Client/EpicClient"));
+var Config_1 = require("./Config");
+var scopes_json_1 = __importDefault(require("./scopes.json"));
+var EMR;
(function (EMR) {
EMR["CERNER"] = "cerner";
EMR["EPIC"] = "epic";
EMR["SMART"] = "smart";
EMR["NONE"] = "none";
-})(EMR || (EMR = {}));
+})(EMR || (exports.EMR = EMR = {}));
/**
* The function `instanceOfEmr` checks if an object is an instance of the EMR enum.
* @param {unknown} object - The `object` parameter is of type `unknown`, which means it can be any type.
* @returns a boolean value.
*/
-export function instanceOfEmr(object) {
+function instanceOfEmr(object) {
return Object.values(EMR).includes(object);
}
+exports.instanceOfEmr = instanceOfEmr;
/**
* The function `getEndpointsForEmr` returns the endpoints for a given EMR type, such as Epic, Cerner, or SMART.
* @param {EMR} emrType - The `emrType` parameter is of type `EMR`, which is an enumeration representing different types of Electronic Medical Record (EMR)
* systems. The possible values for `emrType` are `EMR.EPIC`, `EMR.CERNER`, `EMR.SMART`,
* @returns an object of type EMR_ENDPOINTS.
*/
-export function getEndpointsForEmr(emrType) {
+function getEndpointsForEmr(emrType) {
switch (emrType) {
case EMR.EPIC:
- return EpicClient.getEndpoints();
+ return EpicClient_1.default.getEndpoints();
case EMR.CERNER:
- return CernerClient.getEndpoints();
+ return CernerClient_1.default.getEndpoints();
case EMR.SMART:
case EMR.NONE:
default:
throw new Error("Endpoints not found for EMR type: ".concat(emrType));
}
}
+exports.getEndpointsForEmr = getEndpointsForEmr;
/**
* Represents the SmartLaunchHandler class.
*/
@@ -108,11 +139,11 @@ var SmartLaunchHandler = /** @class */ (function () {
return __awaiter(this, void 0, void 0, function () {
var defaultScopes, scope, redirect_uri;
return __generator(this, function (_a) {
- if (launchType === LAUNCH.BACKEND) {
+ if (launchType === ClientFactory_1.LAUNCH.BACKEND) {
throw new Error("This doesn't work for backend launch");
}
defaultScopes = [
- launchType === LAUNCH.STANDALONE ? "launch/practitioner" : "launch",
+ launchType === ClientFactory_1.LAUNCH.STANDALONE ? "launch/practitioner" : "launch",
"online_access",
"openid",
"fhirUser",
@@ -173,7 +204,7 @@ var SmartLaunchHandler = /** @class */ (function () {
return __awaiter(this, void 0, void 0, function () {
var additionalScopes;
return __generator(this, function (_a) {
- additionalScopes = cerner.scopes.map(function (name) { return scopes[name]; });
+ additionalScopes = Config_1.cerner.scopes.map(function (name) { return scopes_json_1.default[name]; });
return [2 /*return*/, this.launchEMR(redirect, iss, launchType, additionalScopes)];
});
});
@@ -183,12 +214,12 @@ var SmartLaunchHandler = /** @class */ (function () {
* @returns {Promise} - A promise resolving to void.
*/
SmartLaunchHandler.prototype.authorizeEMR = function (launchType, redirectPath) {
- if (launchType === void 0) { launchType = LAUNCH.EMR; }
+ if (launchType === void 0) { launchType = ClientFactory_1.LAUNCH.EMR; }
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
- if (!(launchType === LAUNCH.BACKEND)) return [3 /*break*/, 1];
+ if (!(launchType === ClientFactory_1.LAUNCH.BACKEND)) return [3 /*break*/, 1];
throw new Error("Direct Backend Authorization not supported yet.");
case 1: return [4 /*yield*/, this.executeWebLaunch(launchType, redirectPath)];
case 2: return [2 /*return*/, _a.sent()];
@@ -267,5 +298,5 @@ var SmartLaunchHandler = /** @class */ (function () {
};
return SmartLaunchHandler;
}());
-export default SmartLaunchHandler;
+exports.default = SmartLaunchHandler;
//# sourceMappingURL=SmartLaunchHandler.js.map
\ No newline at end of file
diff --git a/lib/cjs/Launcher/SmartLaunchHandler.js.map b/lib/cjs/Launcher/SmartLaunchHandler.js.map
new file mode 100644
index 0000000..e63981c
--- /dev/null
+++ b/lib/cjs/Launcher/SmartLaunchHandler.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"SmartLaunchHandler.js","sourceRoot":"","sources":["../../../src/Launcher/SmartLaunchHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAmC;AAEnC,wEAAkD;AAClD,yDAAiD;AACjD,oEAA8C;AAC9C,mCAAkC;AAClC,8DAAmC;AAEnC,IAAY,GAKX;AALD,WAAY,GAAG;IACb,wBAAiB,CAAA;IACjB,oBAAa,CAAA;IACb,sBAAe,CAAA;IACf,oBAAa,CAAA;AACf,CAAC,EALW,GAAG,mBAAH,GAAG,QAKd;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,MAAe;IAC3C,OAAO,MAAM,C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UAAU,CAAC,EAAA;;wBAAzD,SAAyD,CAAA;wBACzD,wBAAM;4BAEN,wBAAM;;;;;KAEX;IAED;;;;;OAKG;IACH,uCAAU,GAAV,UAAW,GAAY;;QACrB,IAAI,GAAG,EAAE,CAAC;YACR,IAAM,WAAW,GAAG,UAAC,OAAY,IAAK,OAAA,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAArB,CAAqB,CAAC;YAC5D,IAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpC,OAAO,MAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,mCAAI,GAAG,CAAC,IAAI,CAAC;QAChD,CAAC;QACD,IAAM,OAAO,GAAI,OAAO,CAAC,GAAG,CAAC,kBAA6B,CAAC,WAAW,EAAS,CAAA;QAC/E,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,yFAAyF,CAAC,CAAA;QACxH,OAAO,OAAO,CAAA;IAChB,CAAC;IACH,yBAAC;AAAD,CAAC,AAjMD,IAiMC"}
\ No newline at end of file
diff --git a/lib/Launcher/scopes.json b/lib/cjs/Launcher/scopes.json
similarity index 100%
rename from lib/Launcher/scopes.json
rename to lib/cjs/Launcher/scopes.json
diff --git a/lib/Resource/transformer.d.ts b/lib/cjs/Resource/transformer.d.ts
similarity index 100%
rename from lib/Resource/transformer.d.ts
rename to lib/cjs/Resource/transformer.d.ts
diff --git a/lib/Resource/transformer.js b/lib/cjs/Resource/transformer.js
similarity index 92%
rename from lib/Resource/transformer.js
rename to lib/cjs/Resource/transformer.js
index 512562a..9ca0622 100644
--- a/lib/Resource/transformer.js
+++ b/lib/cjs/Resource/transformer.js
@@ -1,3 +1,4 @@
+"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -9,11 +10,13 @@ var __assign = (this && this.__assign) || function () {
};
return __assign.apply(this, arguments);
};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.Transformer = void 0;
/**
Represents the Transformer namespace for resource transformation.
@namespace Transformer
*/
-export var Transformer;
+var Transformer;
(function (Transformer) {
/**
* Converts a resource to the FHIR client type.
@@ -54,5 +57,5 @@ export var Transformer;
return transformedResource;
}
Transformer.toR4FhirType = toR4FhirType;
-})(Transformer || (Transformer = {}));
+})(Transformer || (exports.Transformer = Transformer = {}));
//# sourceMappingURL=transformer.js.map
\ No newline at end of file
diff --git a/lib/cjs/Resource/transformer.js.map b/lib/cjs/Resource/transformer.js.map
new file mode 100644
index 0000000..7a2eb38
--- /dev/null
+++ b/lib/cjs/Resource/transformer.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"transformer.js","sourceRoot":"","sources":["../../../src/Resource/transformer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA;;;EAGE;AACF,IAAiB,WAAW,CAmE3B;AAnED,WAAiB,WAAW;IAC1B;;;;;OAKG;IACH,SAAgB,gBAAgB,CAC9B,gBAAmB;QAGnB,IAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAkB,CAAC;QAC5E,IAAM,mBAAmB,yBACpB,oBAAoB,CAAC,MAAM,CAC5B,+BAA+B,CAAI,gBAAgB,CAAC,EACpD,EAAE,CACH,KACD,YAAY,EAAE,gBAAgB,CAAC,cAAc,CAAC,GAC/C,CAAC;QACF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAbe,4BAAgB,mBAa/B,CAAA;IAED;;;;;;OAMG;IACH,SAAS,+BAA+B,CAGtC,gBAAmB;QAOnB,OAAO,UAAC,CAAC,EAAE,CAAC;;YAAK,OAAA,uBACZ,CAAC,gBACH,CAAC,IAAG,gBAAgB,CAAC,CAAC,CAAC,OACxB;QAHe,CAGf,CAAC;IACL,CAAC;IAEH;;;;OAIG;IACD,SAAgB,YAAY,CAC1B,gBAA2B;QAG3B,IAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAkB,CAAC;QAC5E,IAAM,mBAAmB,yBACpB,oBAAoB,CAAC,MAAM,CAC5B,UAAC,CAAC,EAAE,CAAC;;YAAK,OAAA,uBACL,CAAC,gBACH,CAAC,IAAG,gBAAgB,CAAC,CAAC,CAAC,OACxB;QAHQ,CAGR,EACF,EAAE,CACH,KACD,YAAY,EAAE,gBAAgB,CAAC,cAAc,CAAC,GAC/C,CAAC;QACF,OAAO,mBAA8B,CAAC;IACxC,CAAC;IAhBe,wBAAY,eAgB3B,CAAA;AACH,CAAC,EAnEgB,WAAW,2BAAX,WAAW,QAmE3B"}
\ No newline at end of file
diff --git a/lib/index.d.ts b/lib/cjs/index.d.ts
similarity index 100%
rename from lib/index.d.ts
rename to lib/cjs/index.d.ts
diff --git a/lib/cjs/index.js b/lib/cjs/index.js
new file mode 100644
index 0000000..a1b2851
--- /dev/null
+++ b/lib/cjs/index.js
@@ -0,0 +1,38 @@
+"use strict";
+var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.LAUNCH = exports.EMR = exports.BaseClient = exports.SmartLaunchHandler = exports.ClientFactory = void 0;
+var ClientFactory_1 = __importStar(require("./Client/ClientFactory"));
+exports.ClientFactory = ClientFactory_1.default;
+Object.defineProperty(exports, "LAUNCH", { enumerable: true, get: function () { return ClientFactory_1.LAUNCH; } });
+var SmartLaunchHandler_1 = __importStar(require("./Launcher/SmartLaunchHandler"));
+exports.SmartLaunchHandler = SmartLaunchHandler_1.default;
+Object.defineProperty(exports, "EMR", { enumerable: true, get: function () { return SmartLaunchHandler_1.EMR; } });
+var BaseClient_1 = __importDefault(require("./Client/BaseClient"));
+exports.BaseClient = BaseClient_1.default;
+//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/lib/cjs/index.js.map b/lib/cjs/index.js.map
new file mode 100644
index 0000000..1c3f70d
--- /dev/null
+++ b/lib/cjs/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAA6D;AAGpD,wBAHF,uBAAa,CAGE;AAAuC,uFAHtC,sBAAM,OAGsC;AAFnE,kFAAsE;AAE9C,6BAFjB,4BAAkB,CAEiB;AAAc,oFAF5B,wBAAG,OAE4B;AAD3D,mEAA6C;AACD,qBADrC,oBAAU,CACqC"}
\ No newline at end of file
diff --git a/lib/types.d.ts b/lib/cjs/types.d.ts
similarity index 84%
rename from lib/types.d.ts
rename to lib/cjs/types.d.ts
index 7559c0f..a3b3bd7 100644
--- a/lib/types.d.ts
+++ b/lib/cjs/types.d.ts
@@ -57,3 +57,16 @@ export type Author = {
export type UserReadResult = SubClient["user"]["read"] extends (requestOptions?: infer O) => Promise ? O extends {
includeResponse: true;
} ? R extends Promise ? T : never : R : never;
+/**
+ * The FhirClientConfig interface represents the configuration for the FHIR client.
+ * @property {string} serverUrl - The server URL for the FHIR client.
+ * @property {string} tokenUri - The token URI for the FHIR client.
+ * @property {FhirClientTypes.TokenResponse} tokenResponse - The token response for the FHIR client.
+ * @property {string} clientId - The client ID for the FHIR client.
+ */
+export interface FhirClientConfig {
+ serverUrl: string;
+ tokenUri: string;
+ tokenResponse: FhirClientTypes.TokenResponse;
+ clientId: string;
+}
diff --git a/lib/cjs/types.js b/lib/cjs/types.js
new file mode 100644
index 0000000..11e638d
--- /dev/null
+++ b/lib/cjs/types.js
@@ -0,0 +1,3 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+//# sourceMappingURL=types.js.map
\ No newline at end of file
diff --git a/lib/cjs/types.js.map b/lib/cjs/types.js.map
new file mode 100644
index 0000000..7b5fff8
--- /dev/null
+++ b/lib/cjs/types.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/lib/esm/Client/BaseClient.d.ts b/lib/esm/Client/BaseClient.d.ts
new file mode 100644
index 0000000..5946272
--- /dev/null
+++ b/lib/esm/Client/BaseClient.d.ts
@@ -0,0 +1,147 @@
+import * as R4 from "fhir/r4";
+import SubClient, { FhirClientTypes } from "../FhirClient";
+import { EMR } from "../Launcher/SmartLaunchHandler";
+import { Author, FhirClientResourceWithRequiredType, GenericContext, R4ResourceWithRequiredType } from "../types";
+/**
+ * The EMR_ENDPOINTS type represents an object with two properties, "token" and "r4", both of which are URLs.
+ * @property {URL} token - A URL that represents the endpoint for accessing the token service in an EMR (Electronic Medical Record) system.
+ * @property {URL} r4 - The "r4" property in the EMR_ENDPOINTS type represents a URL that is used to access the R4 version of an EMR (Electronic Medical Record)
+ * endpoint.
+ */
+export type EMR_ENDPOINTS = {
+ token: URL;
+ r4: URL;
+ auth: URL;
+};
+/**
+Represents the BaseClient abstract class.
+*/
+export default abstract class BaseClient {
+ readonly fhirClientDefault: SubClient;
+ readonly defaultCreateHeaders: HeadersInit;
+ abstract readonly EMR_TYPE: EMR;
+ static readonly AUTHORIZE_ENDPOINT: string | undefined;
+ static readonly TOKEN_ENDPOINT: string | undefined;
+ static readonly R4_ENDPOINT: string | undefined;
+ abstract getEndpoints(): EMR_ENDPOINTS;
+ getEMRType(): EMR;
+ /**
+ * The function constructs and returns an object containing three endpoints (token, r4, and auth) based on the provided tokenEP, r4EP, and authorizeEP values.
+ * @param {string | undefined} tokenEP - The `tokenEP` parameter is a string that represents the token endpoint. This endpoint is used to obtain an access token
+ * for authentication and authorization purposes.
+ * @param {string | undefined} r4EP - The `r4EP` parameter is the endpoint URL for the R4 API. It is used to make requests to the R4 API.
+ * @param {string | undefined} authorizeEP - The `authorizeEP` parameter is the endpoint URL for the authorization server. It is used for initiating the
+ * authorization process and obtaining an authorization code or access token.
+ * @returns An object with three properties: "token", "r4", and "auth". Each property is assigned a new URL object based on the corresponding input parameters.
+ */
+ protected static constructEndpoints(tokenEP: string | undefined, r4EP: string | undefined, authorizeEP: string | undefined): {
+ token: URL;
+ r4: URL;
+ auth: URL;
+ };
+ /**
+ * Fetch options for create operation headers.
+ * @private
+ * @readonly
+ * @type {FhirClientTypes.FetchOptions}
+ */
+ protected createHeaders(additionalCreateHeaders: HeadersInit): FhirClientTypes.FetchOptions;
+ /**
+ * Creates an instance of BaseClient.
+ * @param {SubClient} fhirClientDefault - The default FHIR client to use.
+ */
+ constructor(fhirClientDefault: SubClient);
+ /**
+ * Gets the ID from an object with ID.
+ * @private
+ * @param {T} objectWithId - The object with ID.
+ * @returns {Promise} - A promise resolving to the ID.
+ * @throws {Error} - Throws an error if the ID is not found.
+ */
+ private getIDfromObject;
+ /**
+ * Creates a patient subject.
+ * @private
+ * @returns {Promise} - A promise resolving to the patient subject.
+ */
+ private createPatientSubject;
+ /**
+ * The function creates a reference to an Encounter object by retrieving its ID from a FHIR client.
+ * @returns An object is being returned with a property "reference" that has a value of `Encounter/`.
+ */
+ private createEncounterReference;
+ /**
+ * The function creates an array of encounter references asynchronously.
+ * @returns An array containing the result of the `createEncounterReference` function, which is awaited.
+ */
+ private createEncounterReferenceArray;
+ /**
+ * The function "createPeriod" creates a period object with the same start and end date.
+ * @param {string} start - The start parameter is a string that represents the start date or time of a period.
+ * @returns An object of type R4.Period is being returned.
+ */
+ private createPeriod;
+ /**
+ * The createContext function creates a context object with an encounter reference array and a period.
+ * @returns The function `createContext` is returning an object with a property `context` which contains the values of `encounter` and `period`.
+ */
+ private createContext;
+ /**
+ * The function creates an array of author references using the user ID obtained from the FHIR client.
+ * @returns an object with an "author" property, which is an array containing an object with a "reference" property. The value of the "reference" property is a
+ * string in the format "Practitioner/{userID}".
+ */
+ createReferenceArrayAuthor(): Promise;
+ /**
+ * Hydrates a resource with subject and encounter context.
+ * @param {T} resource - The resource to hydrate.
+ * @returns {Promise} - A promise resolving to the hydrated resource.
+ */
+ hydrateResource(resource: T, patientId?: string, encounterId?: string): Promise;
+ /**
+ * The function creates a resource of type T, transforms it to a FhirClientType, hydrates it, sends a create request to the FhirClientDefault, transforms the
+ * result back to type T, and returns it.
+ * @param {T} resource - The `resource` parameter is the FHIR resource object that you want to create. It should be an object that conforms to the R4 (Release 4)
+ * FHIR specification and has a required `resourceType` property.
+ * @param [additionalHeaders] - The `additionalHeaders` parameter is an optional object that represents additional headers to be included in the HTTP request when
+ * creating a resource. It is of type `FhirClientTypes.FetchOptions`.
+ * @returns a Promise of type T, which is the same type as the input resource.
+ */
+ create(resource: T, patientId?: string, encounterId?: string, additionalHeaders?: FhirClientTypes.FetchOptions): Promise;
+ createHydratedResource(hydratedResource: Omit, "resourceType"> & Required, "resourceType">> & {
+ context?: GenericContext;
+ subject?: R4.Reference | undefined;
+ }, additionalHeaders?: FhirClientTypes.FetchOptions | undefined): Promise;
+ /**
+ * The function `requestResource` asynchronously requests a resource using a specified resource ID and optional request options.
+ * @param {string} resourceID - The resourceID parameter is a string that represents the ID of the resource you want to request. It could be the URL or identifier
+ * of the resource you want to retrieve.
+ * @param {RequestInit} [requestOptions] - The `requestOptions` parameter is an optional object that contains additional options for the HTTP request. It can
+ * include properties such as headers, method, body, etc.
+ * @returns a resource of type R4.Resource.
+ */
+ requestResource(resourceID: string, requestOptions?: RequestInit): Promise;
+ /**
+ * The function `getUserRead` is a private asynchronous function that retrieves user data using the `read` method of the `fhirClientDefault` object and returns a
+ * `UserReadResult` promise.
+ * @returns a Promise that resolves to a UserReadResult object.
+ */
+ private getUserRead;
+ /**
+ * The function `getPractitionerRead` retrieves a user and checks if they are a practitioner, then converts the user to an R4 Practitioner if they are, otherwise
+ * it throws an error.
+ * @param {UserReadResult} user - The `user` parameter is of type `UserReadResult`, which is a result object returned from the `getUserRead()` function. It
+ * represents a user resource in the FHIR format.
+ * @returns a Promise that resolves to a FHIR R4 Practitioner resource.
+ */
+ getPractitionerRead(): Promise;
+ /**
+ * The function `getPatientRead` retrieves a patient record from a FHIR server and transforms it into an R4.Patient object.
+ * @returns a Promise that resolves to an instance of the R4.Patient type.
+ */
+ getPatientRead(): Promise;
+ getEncounterRead(): Promise;
+}
diff --git a/lib/esm/Client/BaseClient.js b/lib/esm/Client/BaseClient.js
new file mode 100644
index 0000000..324a809
--- /dev/null
+++ b/lib/esm/Client/BaseClient.js
@@ -0,0 +1,270 @@
+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());
+ });
+};
+import { Transformer } from "../Resource/transformer";
+/**
+Represents the BaseClient abstract class.
+*/
+export default class BaseClient {
+ getEMRType() {
+ return this.EMR_TYPE;
+ }
+ /**
+ * The function constructs and returns an object containing three endpoints (token, r4, and auth) based on the provided tokenEP, r4EP, and authorizeEP values.
+ * @param {string | undefined} tokenEP - The `tokenEP` parameter is a string that represents the token endpoint. This endpoint is used to obtain an access token
+ * for authentication and authorization purposes.
+ * @param {string | undefined} r4EP - The `r4EP` parameter is the endpoint URL for the R4 API. It is used to make requests to the R4 API.
+ * @param {string | undefined} authorizeEP - The `authorizeEP` parameter is the endpoint URL for the authorization server. It is used for initiating the
+ * authorization process and obtaining an authorization code or access token.
+ * @returns An object with three properties: "token", "r4", and "auth". Each property is assigned a new URL object based on the corresponding input parameters.
+ */
+ static constructEndpoints(tokenEP, r4EP, authorizeEP) {
+ if (tokenEP == undefined)
+ throw Error('Token Endpoint not defined');
+ if (r4EP === undefined)
+ throw Error('R4 Endpoint not defined');
+ if (authorizeEP === undefined)
+ throw Error('Auth Endpoint not defined');
+ return {
+ token: new URL(tokenEP),
+ r4: new URL(r4EP),
+ auth: new URL(authorizeEP)
+ };
+ }
+ /**
+ * Fetch options for create operation headers.
+ * @private
+ * @readonly
+ * @type {FhirClientTypes.FetchOptions}
+ */
+ createHeaders(additionalCreateHeaders) {
+ return {
+ headers: Object.assign(Object.assign({}, this.defaultCreateHeaders), additionalCreateHeaders),
+ };
+ }
+ /**
+ * Creates an instance of BaseClient.
+ * @param {SubClient} fhirClientDefault - The default FHIR client to use.
+ */
+ constructor(fhirClientDefault) {
+ this.defaultCreateHeaders = {};
+ this.fhirClientDefault = fhirClientDefault;
+ }
+ /**
+ * Gets the ID from an object with ID.
+ * @private
+ * @param {T} objectWithId - The object with ID.
+ * @returns {Promise} - A promise resolving to the ID.
+ * @throws {Error} - Throws an error if the ID is not found.
+ */
+ getIDfromObject(objectWithId) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const id = yield objectWithId.id;
+ if (!id) {
+ console.error(objectWithId);
+ throw new Error(`id not found`);
+ }
+ return id;
+ });
+ }
+ /**
+ * Creates a patient subject.
+ * @private
+ * @returns {Promise} - A promise resolving to the patient subject.
+ */
+ createPatientSubject(patientIdParam) {
+ return __awaiter(this, void 0, void 0, function* () {
+ console.log(patientIdParam);
+ const patientID = patientIdParam == undefined ? yield this.getIDfromObject(this.fhirClientDefault.patient) : patientIdParam;
+ return {
+ subject: {
+ reference: `Patient/${patientID}`,
+ },
+ };
+ });
+ }
+ /**
+ * The function creates a reference to an Encounter object by retrieving its ID from a FHIR client.
+ * @returns An object is being returned with a property "reference" that has a value of `Encounter/`.
+ */
+ createEncounterReference(encounterIdParam) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const encounterID = encounterIdParam == undefined ? yield this.getIDfromObject(this.fhirClientDefault.encounter) : encounterIdParam;
+ return {
+ reference: `Encounter/${encounterID}`,
+ };
+ });
+ }
+ /**
+ * The function creates an array of encounter references asynchronously.
+ * @returns An array containing the result of the `createEncounterReference` function, which is awaited.
+ */
+ createEncounterReferenceArray(encounterIdParam) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return [yield this.createEncounterReference(encounterIdParam)];
+ });
+ }
+ /**
+ * The function "createPeriod" creates a period object with the same start and end date.
+ * @param {string} start - The start parameter is a string that represents the start date or time of a period.
+ * @returns An object of type R4.Period is being returned.
+ */
+ createPeriod(start) {
+ return {
+ start: start,
+ end: start,
+ };
+ }
+ /**
+ * The createContext function creates a context object with an encounter reference array and a period.
+ * @returns The function `createContext` is returning an object with a property `context` which contains the values of `encounter` and `period`.
+ */
+ createContext(encounterIdParam) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const encounter = yield this.createEncounterReferenceArray(encounterIdParam);
+ const currentDateString = new Date().toISOString();
+ const period = this.createPeriod(currentDateString);
+ return {
+ context: {
+ encounter: encounter,
+ period: period,
+ },
+ };
+ });
+ }
+ /**
+ * The function creates an array of author references using the user ID obtained from the FHIR client.
+ * @returns an object with an "author" property, which is an array containing an object with a "reference" property. The value of the "reference" property is a
+ * string in the format "Practitioner/{userID}".
+ */
+ createReferenceArrayAuthor() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const userID = yield this.getIDfromObject(this.fhirClientDefault.user);
+ return {
+ author: [
+ {
+ reference: `Practitioner/${userID}`,
+ },
+ ],
+ };
+ });
+ }
+ /**
+ * Hydrates a resource with subject and encounter context.
+ * @param {T} resource - The resource to hydrate.
+ * @returns {Promise} - A promise resolving to the hydrated resource.
+ */
+ hydrateResource(resource, patientId, encounterId) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return Object.assign(Object.assign(Object.assign({}, resource), ("subject" in resource ? {} : yield this.createPatientSubject(patientId))), ("encounter" in resource ? {} : yield this.createContext(encounterId)));
+ });
+ }
+ /**
+ * The function creates a resource of type T, transforms it to a FhirClientType, hydrates it, sends a create request to the FhirClientDefault, transforms the
+ * result back to type T, and returns it.
+ * @param {T} resource - The `resource` parameter is the FHIR resource object that you want to create. It should be an object that conforms to the R4 (Release 4)
+ * FHIR specification and has a required `resourceType` property.
+ * @param [additionalHeaders] - The `additionalHeaders` parameter is an optional object that represents additional headers to be included in the HTTP request when
+ * creating a resource. It is of type `FhirClientTypes.FetchOptions`.
+ * @returns a Promise of type T, which is the same type as the input resource.
+ */
+ create(resource, patientId, encounterId, additionalHeaders) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const transformedResource = Transformer.toFhirClientType(resource);
+ const hydratedResource = yield this.hydrateResource(transformedResource, patientId, encounterId);
+ const resultResource = yield this.createHydratedResource(hydratedResource, additionalHeaders);
+ const resultAsR4 = Transformer.toR4FhirType(resultResource);
+ return resultAsR4;
+ });
+ }
+ createHydratedResource(hydratedResource, additionalHeaders) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return yield this.fhirClientDefault
+ .create(hydratedResource, Object.assign({}, (additionalHeaders ? additionalHeaders : {})))
+ .then((resource) => {
+ if (!resource.resourceType) {
+ return resource.body;
+ }
+ if (!resource.resourceType) {
+ console.log(resource);
+ throw new Error(`Resource ${resource}, must have a resource type.`);
+ }
+ return resource;
+ })
+ .catch((reason) => {
+ throw new Error("It failed with:" + reason);
+ });
+ });
+ }
+ /**
+ * The function `requestResource` asynchronously requests a resource using a specified resource ID and optional request options.
+ * @param {string} resourceID - The resourceID parameter is a string that represents the ID of the resource you want to request. It could be the URL or identifier
+ * of the resource you want to retrieve.
+ * @param {RequestInit} [requestOptions] - The `requestOptions` parameter is an optional object that contains additional options for the HTTP request. It can
+ * include properties such as headers, method, body, etc.
+ * @returns a resource of type R4.Resource.
+ */
+ requestResource(resourceID, requestOptions) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const resultResource = yield this.fhirClientDefault.request(Object.assign({ url: resourceID }, (requestOptions ? { headers: requestOptions.headers } : {})));
+ return resultResource;
+ });
+ }
+ /**
+ * The function `getUserRead` is a private asynchronous function that retrieves user data using the `read` method of the `fhirClientDefault` object and returns a
+ * `UserReadResult` promise.
+ * @returns a Promise that resolves to a UserReadResult object.
+ */
+ getUserRead() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const user = yield this.fhirClientDefault.user.read();
+ return user;
+ });
+ }
+ /**
+ * The function `getPractitionerRead` retrieves a user and checks if they are a practitioner, then converts the user to an R4 Practitioner if they are, otherwise
+ * it throws an error.
+ * @param {UserReadResult} user - The `user` parameter is of type `UserReadResult`, which is a result object returned from the `getUserRead()` function. It
+ * represents a user resource in the FHIR format.
+ * @returns a Promise that resolves to a FHIR R4 Practitioner resource.
+ */
+ getPractitionerRead() {
+ return __awaiter(this, void 0, void 0, function* () {
+ function isPractitioner(user) {
+ return user.resourceType == "Practitioner";
+ }
+ const user = yield this.getUserRead();
+ if (isPractitioner(user)) {
+ const userInR4 = Transformer.toR4FhirType(user);
+ return userInR4;
+ }
+ throw new Error("User is Not a Practitioner");
+ });
+ }
+ /**
+ * The function `getPatientRead` retrieves a patient record from a FHIR server and transforms it into an R4.Patient object.
+ * @returns a Promise that resolves to an instance of the R4.Patient type.
+ */
+ getPatientRead() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const patient = yield this.fhirClientDefault.patient.read();
+ const patientInR4 = Transformer.toR4FhirType(patient);
+ return patientInR4;
+ });
+ }
+ /* The `getEncounterRead` function is an asynchronous function that retrieves an encounter record from a FHIR server and transforms it into an R4.Encounter object. */
+ getEncounterRead() {
+ return __awaiter(this, void 0, void 0, function* () {
+ const encounter = yield this.fhirClientDefault.encounter.read();
+ const encounterInR4 = Transformer.toR4FhirType(encounter);
+ return encounterInR4;
+ });
+ }
+}
+//# sourceMappingURL=BaseClient.js.map
\ No newline at end of file
diff --git a/lib/esm/Client/BaseClient.js.map b/lib/esm/Client/BaseClient.js.map
new file mode 100644
index 0000000..8ab2f28
--- /dev/null
+++ b/lib/esm/Client/BaseClient.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"BaseClient.js","sourceRoot":"","sources":["../../../src/Client/BaseClient.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAsBrD;;EAEE;AACF,MAAM,CAAC,OAAO,OAAgB,UAAU;IAUhC,UAAU;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC;IAED;;;;;;;;OAQG;IACO,MAAM,CAAC,kBAAkB,CAAC,OAA2B,EAAE,IAAwB,EAAE,WAA+B;QACzH,IAAI,OAAO,IAAI,SAAS;YACvB,MAAM,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC1C,IAAI,IAAI,KAAK,SAAS;YACrB,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAA;QACvC,IAAI,WAAW,KAAK,SAAS;YAC5B,MAAM,KAAK,CAAC,2BAA2B,CAAC,CAAA;QACzC,OAAO;YACN,KAAK,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC;YACvB,EAAE,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC;YACjB,IAAI,EAAE,IAAI,GAAG,CAAC,WAAW,CAAC;SAC1B,CAAA;IACF,CAAC;IAED;;;;;OAKG;IACO,aAAa,CACtB,uBAAoC;QAEpC,OAAO;YACN,OAAO,kCACH,IAAI,CAAC,oBAAoB,GACzB,uBAAuB,CAC1B;SACD,CAAA;IACF,CAAC;IAED;;;OAGG;IACH,YAAY,iBAA4B;QAx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AA;QACrC,CAAC;KAAA;IAED;;;;OAIG;IACW,WAAW;;YACxB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;YACrD,OAAO,IAAI,CAAA;QACZ,CAAC;KAAA;IAED;;;;;;OAMG;IACG,mBAAmB;;YACxB,SAAS,cAAc,CACtB,IAAoB;gBAEpB,OAAO,IAAI,CAAC,YAAY,IAAI,cAAc,CAAA;YAC3C,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;YACrC,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1B,MAAM,QAAQ,GAAG,WAAW,CAAC,YAAY,CACxC,IAAI,CACJ,CAAA;gBACD,OAAO,QAAQ,CAAA;YAChB,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC9C,CAAC;KAAA;IAED;;;OAGG;IACG,cAAc;;YACnB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;YAC3D,MAAM,WAAW,GAAG,WAAW,CAAC,YAAY,CAC3C,OAAO,CACP,CAAA;YACD,OAAO,WAAW,CAAA;QACnB,CAAC;KAAA;IAED,sKAAsK;IAChK,gBAAgB;;YACrB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;YAC/D,MAAM,aAAa,GAAG,WAAW,CAAC,YAAY,CAG5C,SAAS,CAAC,CAAA;YACZ,OAAO,aAAa,CAAA;QACrB,CAAC;KAAA;CACD"}
\ No newline at end of file
diff --git a/lib/esm/Client/CernerClient.d.ts b/lib/esm/Client/CernerClient.d.ts
new file mode 100644
index 0000000..6de005d
--- /dev/null
+++ b/lib/esm/Client/CernerClient.d.ts
@@ -0,0 +1,37 @@
+import SubClient from "../FhirClient";
+import { EMR } from "../Launcher/SmartLaunchHandler";
+import { FhirClientResourceWithRequiredType } from "../types";
+import BaseClient, { EMR_ENDPOINTS } from "./BaseClient";
+/**
+Represents the CernerClient class, extending the BaseClient.
+*/
+export default class CernerClient extends BaseClient {
+ EMR_TYPE: EMR;
+ static readonly AUTHORIZE_ENDPOINT = "https://authorization.cerner.com/tenants/ec2458f2-1e24-41c8-b71b-0e701af7583d/protocols/oauth2/profiles/smart-v1/personas/provider/authorize";
+ static readonly TOKEN_ENDPOINT = "https://authorization.cerner.com/tenants/ec2458f2-1e24-41c8-b71b-0e701af7583d/protocols/oauth2/profiles/smart-v1/token";
+ static readonly R4_ENDPOINT = "https://fhir-ehr-code.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d";
+ static getEndpoints(): EMR_ENDPOINTS;
+ getEndpoints(): EMR_ENDPOINTS;
+ readonly cernerRequestHeaders: HeadersInit;
+ /**
+ * Creates an instance of CernerClient.
+ * @param {SubClient} fhirClientDefault - The default FHIR client to use.
+ */
+ constructor(fhirClientDefault: SubClient);
+ /**
+ * Hydrates a resource with subject and encounter context.
+ * @param {T} resource - The resource to hydrate.
+ * @returns {Promise} - A promise resolving to the hydrated resource.
+ */
+ hydrateResource(resource: T): Promise;
+ /**
+ * The function `requestResource` is an asynchronous function that makes a request for a resource using a resource ID and Cerner request headers.
+ * @param {string} resourceID - The resourceID parameter is a string that represents the ID of the resource that you want to request.
+ * @returns The `requestResource` function is returning a promise.
+ */
+ requestResource(resourceID: string): Promise;
+}
diff --git a/lib/esm/Client/CernerClient.js b/lib/esm/Client/CernerClient.js
new file mode 100644
index 0000000..dae3f44
--- /dev/null
+++ b/lib/esm/Client/CernerClient.js
@@ -0,0 +1,70 @@
+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());
+ });
+};
+import { EMR } from "../Launcher/SmartLaunchHandler";
+import BaseClient from "./BaseClient";
+/**
+Represents the CernerClient class, extending the BaseClient.
+*/
+class CernerClient extends BaseClient {
+ static getEndpoints() {
+ return BaseClient.constructEndpoints(CernerClient.TOKEN_ENDPOINT, CernerClient.R4_ENDPOINT, CernerClient.AUTHORIZE_ENDPOINT);
+ }
+ getEndpoints() {
+ throw new Error("Method not implemented.");
+ }
+ /**
+ * Creates an instance of CernerClient.
+ * @param {SubClient} fhirClientDefault - The default FHIR client to use.
+ */
+ constructor(fhirClientDefault) {
+ super(fhirClientDefault);
+ this.EMR_TYPE = EMR.CERNER;
+ /* The `cernerRequestHeaders` property is a constant that represents the headers to be included in the request made by the CernerClient class. In this case, it
+ specifies that the client accepts the "application/fhir+json" media type. The `readonly` keyword indicates that the property cannot be modified after it is
+ initialized. */
+ this.cernerRequestHeaders = {
+ Accept: "application/fhir+json",
+ };
+ }
+ /**
+ * Hydrates a resource with subject and encounter context.
+ * @param {T} resource - The resource to hydrate.
+ * @returns {Promise} - A promise resolving to the hydrated resource.
+ */
+ hydrateResource(resource) {
+ const _super = Object.create(null, {
+ hydrateResource: { get: () => super.hydrateResource },
+ createReferenceArrayAuthor: { get: () => super.createReferenceArrayAuthor }
+ });
+ return __awaiter(this, void 0, void 0, function* () {
+ return Object.assign(Object.assign({}, (yield _super.hydrateResource.call(this, resource))), ("author" in resource ? {} : yield _super.createReferenceArrayAuthor.call(this)));
+ });
+ }
+ /**
+ * The function `requestResource` is an asynchronous function that makes a request for a resource using a resource ID and Cerner request headers.
+ * @param {string} resourceID - The resourceID parameter is a string that represents the ID of the resource that you want to request.
+ * @returns The `requestResource` function is returning a promise.
+ */
+ requestResource(resourceID) {
+ const _super = Object.create(null, {
+ requestResource: { get: () => super.requestResource }
+ });
+ return __awaiter(this, void 0, void 0, function* () {
+ return _super.requestResource.call(this, resourceID, {
+ headers: this.cernerRequestHeaders,
+ });
+ });
+ }
+}
+CernerClient.AUTHORIZE_ENDPOINT = "https://authorization.cerner.com/tenants/ec2458f2-1e24-41c8-b71b-0e701af7583d/protocols/oauth2/profiles/smart-v1/personas/provider/authorize";
+CernerClient.TOKEN_ENDPOINT = "https://authorization.cerner.com/tenants/ec2458f2-1e24-41c8-b71b-0e701af7583d/protocols/oauth2/profiles/smart-v1/token";
+CernerClient.R4_ENDPOINT = "https://fhir-ehr-code.cerner.com/r4/ec2458f2-1e24-41c8-b71b-0e701af7583d";
+export default CernerClient;
+//# sourceMappingURL=CernerClient.js.map
\ No newline at end of file
diff --git a/lib/esm/Client/CernerClient.js.map b/lib/esm/Client/CernerClient.js.map
new file mode 100644
index 0000000..17d0ee6
--- /dev/null
+++ b/lib/esm/Client/CernerClient.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"CernerClient.js","sourceRoot":"","sources":["../../../src/Client/CernerClient.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAErD,OAAO,UAA6B,MAAM,cAAc,CAAC;AAEzD;;EAEE;AACF,MAAqB,YAAa,SAAQ,UAAU;IAMlD,MAAM,CAAC,YAAY;QACjB,OAAO,UAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,cAAc,EAAE,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC,kBAAkB,CAAC,CAAA;IAC9H,CAAC;IACD,YAAY;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAQD;;;OAGG;IACH,YAAY,iBAA4B;QACtC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAvB3B,aAAQ,GAAQ,GAAG,CAAC,MAAM,CAAA;QAY1B;;qBAEa;QACJ,yBAAoB,GAAgB;YAC3C,MAAM,EAAE,uBAAuB;SAChC,CAAC;IAOF,CAAC;IAED;;;;OAIG;IACG,eAAe,CACnB,QAAW;;;;;;YAEX,uCACK,CAAC,MAAM,OAAM,eAAe,YAAC,QAAQ,CAAC,CAAC,GACvC,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,OAAM,0BAA0B,WAAE,CAAC,EACzE;QACJ,CAAC;KAAA;IAED;;;;OAIG;IACG,eAAe,CAAC,UAAkB;;;;;YACtC,OAAO,OAAM,eAAe,YAAC,UAAU,EAAE;gBACvC,OAAO,EAAE,IAAI,CAAC,oBAAoB;aACnC,EAAE;QACL,CAAC;KAAA;;AAhDe,+BAAkB,GAAG,8IAA8I,AAAjJ,CAAiJ;AACnK,2BAAc,GAAG,wHAAwH,AAA3H,CAA2H;AACzI,wBAAW,GAAG,0EAA0E,AAA7E,CAA6E;eAJrF,YAAY"}
\ No newline at end of file
diff --git a/lib/esm/Client/ClientFactory.d.ts b/lib/esm/Client/ClientFactory.d.ts
new file mode 100644
index 0000000..a7d0341
--- /dev/null
+++ b/lib/esm/Client/ClientFactory.d.ts
@@ -0,0 +1,58 @@
+///
+import BaseClient from "./BaseClient";
+import { ServerResponse, IncomingMessage } from "http";
+import { FhirClientConfig } from "../types";
+export declare enum LAUNCH {
+ EMR = 0,
+ STANDALONE = 1,
+ BACKEND = 2
+}
+/**
+Represents the ClientFactory class for creating EMR clients.
+*/
+export default class ClientFactory {
+ /**
+ * The function `getEMRType` determines the type of Electronic Medical Record (EMR) based on the provided client or token.
+ * @param {SubClient | JWT} client - The parameter `clientOrToken` can be either a `SubClient` object or a JWT (JSON Web Token).
+ * @returns the type of Electronic Medical Record (EMR) based on the input parameter. The possible return values are EMR.CERNER, EMR.SMART, EMR.EPIC, or EMR.NONE.
+ */
+ private getEMRType;
+ /**
+ * The function `createEMRClient` creates an EMR client based on the specified launch type.
+ * @param {LAUNCH} launchType - The `launchType` parameter is an optional parameter of type `LAUNCH` that specifies the type of EMR launch. It has a default value
+ * of `LAUNCH.EMR`.
+ * @returns a Promise that resolves to an instance of the `BaseClient` class.
+ */
+ createEMRClient(launchType: LAUNCH.EMR | LAUNCH.STANDALONE): Promise;
+ /**
+ * The function `createEMRClientBackend` creates an EMR client based on the specified launch type.
+ * @param {IncomingMessage} req - The `req` parameter is an incoming message object that represents the request made by the client.
+ * @param {ServerResponse} res - The `res` parameter is a server response object that represents the response sent by the server.
+ * @param {FhirClientConfig} serverConfig - The `serverConfig` parameter is an object that contains the configuration for the FHIR client. It includes the server URL, token response, client ID, and token URI.
+ * @returns a Promise that resolves to an instance of the `BaseClient` class.
+ */
+ createEMRClientBackend(req: IncomingMessage, res: ServerResponse, serverConfig: FhirClientConfig): Promise;
+ private createSmarterFhirClient;
+ /**
+ * The function creates a default FHIR client based on the launch type.
+ * @param {LAUNCH} launchType - The `launchType` parameter is an enum type called `LAUNCH`. It represents the type of launch for the FHIR client. There are two
+ * possible values for `LAUNCH`:
+ * @returns a Promise that resolves to a SubClient object.
+ */
+ private createDefaultFhirClient;
+ /**
+ * The function `getEmrEndpoints` returns the endpoints based on the EMR type obtained from the JWT.
+ * @param {JWT} jwt - The "jwt" parameter is a JSON Web Token (JWT) that is used for authentication and authorization purposes. It contains information about the
+ * user and their permissions.
+ * @returns an object of type EMR_ENDPOINTS.
+ */
+ private getEmrEndpoints;
+ /**
+ * The function `getEmrTypeFromObject` takes an object as input and returns the corresponding EMR type if the object is of type JWT or EMR, otherwise it throws an
+ * error.
+ * @param {unknown} object - The `object` parameter is of type `unknown`, which means it can be any type. It is used as input to determine the EMR (Electronic
+ * Medical Record) type. The function checks if the `object` is an instance of JWT (JSON Web Token) or EMR, and returns
+ * @returns an EMR (Electronic Medical Record) object.
+ */
+ private getEmrTypeFromObject;
+}
diff --git a/lib/esm/Client/ClientFactory.js b/lib/esm/Client/ClientFactory.js
new file mode 100644
index 0000000..912e631
--- /dev/null
+++ b/lib/esm/Client/ClientFactory.js
@@ -0,0 +1,150 @@
+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());
+ });
+};
+import smart, * as FHIR from "fhirclient";
+import { EMR, instanceOfEmr } from "../Launcher/SmartLaunchHandler";
+import CernerClient from "./CernerClient";
+import EpicClient from "./EpicClient";
+import SmartHealthClient from "./SmartHealthClient";
+export var LAUNCH;
+(function (LAUNCH) {
+ LAUNCH[LAUNCH["EMR"] = 0] = "EMR";
+ LAUNCH[LAUNCH["STANDALONE"] = 1] = "STANDALONE";
+ LAUNCH[LAUNCH["BACKEND"] = 2] = "BACKEND";
+})(LAUNCH || (LAUNCH = {}));
+/**
+ * The function checks if an object is an instance of the JWT class by verifying if it has a client_id property.
+ * @param {unknown} object - The `object` parameter is of type `unknown`, which means it can be any type.
+ * @returns a boolean value.
+ */
+function instanceOfJWT(object) {
+ return object.client_id !== undefined;
+}
+/**
+Represents the ClientFactory class for creating EMR clients.
+*/
+export default class ClientFactory {
+ /**
+ * The function `getEMRType` determines the type of Electronic Medical Record (EMR) based on the provided client or token.
+ * @param {SubClient | JWT} client - The parameter `clientOrToken` can be either a `SubClient` object or a JWT (JSON Web Token).
+ * @returns the type of Electronic Medical Record (EMR) based on the input parameter. The possible return values are EMR.CERNER, EMR.SMART, EMR.EPIC, or EMR.NONE.
+ */
+ getEMRType(clientOrToken) {
+ function isClient(input) {
+ return input.state.serverUrl !== undefined;
+ }
+ if (isClient(clientOrToken)) {
+ if (clientOrToken.state.serverUrl.includes("cerner")) {
+ return EMR.CERNER;
+ }
+ if (clientOrToken.state.serverUrl.includes("smarthealthit")) {
+ return EMR.SMART;
+ }
+ if (clientOrToken.state.serverUrl.includes("epic")) {
+ return EMR.EPIC;
+ }
+ }
+ else {
+ if ("epic.eci" in clientOrToken) {
+ return EMR.EPIC;
+ }
+ }
+ return EMR.NONE;
+ }
+ /**
+ * The function `createEMRClient` creates an EMR client based on the specified launch type.
+ * @param {LAUNCH} launchType - The `launchType` parameter is an optional parameter of type `LAUNCH` that specifies the type of EMR launch. It has a default value
+ * of `LAUNCH.EMR`.
+ * @returns a Promise that resolves to an instance of the `BaseClient` class.
+ */
+ createEMRClient(launchType) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const fhirClient = yield this.createDefaultFhirClient(launchType);
+ return yield this.createSmarterFhirClient(fhirClient);
+ });
+ }
+ /**
+ * The function `createEMRClientBackend` creates an EMR client based on the specified launch type.
+ * @param {IncomingMessage} req - The `req` parameter is an incoming message object that represents the request made by the client.
+ * @param {ServerResponse} res - The `res` parameter is a server response object that represents the response sent by the server.
+ * @param {FhirClientConfig} serverConfig - The `serverConfig` parameter is an object that contains the configuration for the FHIR client. It includes the server URL, token response, client ID, and token URI.
+ * @returns a Promise that resolves to an instance of the `BaseClient` class.
+ */
+ createEMRClientBackend(req, res, serverConfig) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const fhirClient = smart(req, res).client({
+ serverUrl: serverConfig.serverUrl,
+ tokenResponse: serverConfig.tokenResponse,
+ clientId: serverConfig.clientId,
+ tokenUri: serverConfig.tokenUri
+ });
+ return this.createSmarterFhirClient(fhirClient);
+ });
+ }
+ createSmarterFhirClient(fhirClient) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const emrType = this.getEMRType(fhirClient);
+ switch (emrType) {
+ case EMR.EPIC:
+ return new EpicClient(fhirClient);
+ case EMR.CERNER:
+ return new CernerClient(fhirClient);
+ case EMR.SMART:
+ return new SmartHealthClient(fhirClient);
+ case EMR.NONE:
+ default:
+ throw new Error("Unsupported provider for EMR Client creation");
+ }
+ });
+ }
+ /**
+ * The function creates a default FHIR client based on the launch type.
+ * @param {LAUNCH} launchType - The `launchType` parameter is an enum type called `LAUNCH`. It represents the type of launch for the FHIR client. There are two
+ * possible values for `LAUNCH`:
+ * @returns a Promise that resolves to a SubClient object.
+ */
+ createDefaultFhirClient(launchType) {
+ return __awaiter(this, void 0, void 0, function* () {
+ switch (launchType) {
+ case LAUNCH.EMR:
+ case LAUNCH.STANDALONE:
+ return FHIR.oauth2.ready();
+ default:
+ throw new Error("Unsupported provider for standalone launch");
+ }
+ });
+ }
+ getEmrEndpoints(object) {
+ switch (this.getEmrTypeFromObject(object)) {
+ case EMR.EPIC:
+ return EpicClient.getEndpoints();
+ case EMR.CERNER:
+ return CernerClient.getEndpoints();
+ case EMR.SMART:
+ case EMR.NONE:
+ default:
+ throw new Error('EMR type not defined.');
+ }
+ }
+ /**
+ * The function `getEmrTypeFromObject` takes an object as input and returns the corresponding EMR type if the object is of type JWT or EMR, otherwise it throws an
+ * error.
+ * @param {unknown} object - The `object` parameter is of type `unknown`, which means it can be any type. It is used as input to determine the EMR (Electronic
+ * Medical Record) type. The function checks if the `object` is an instance of JWT (JSON Web Token) or EMR, and returns
+ * @returns an EMR (Electronic Medical Record) object.
+ */
+ getEmrTypeFromObject(object) {
+ if (instanceOfJWT(object))
+ return this.getEMRType(object);
+ if (instanceOfEmr(object))
+ return object;
+ throw new Error('Invalid object type.');
+ }
+}
+//# sourceMappingURL=ClientFactory.js.map
\ No newline at end of file
diff --git a/lib/esm/Client/ClientFactory.js.map b/lib/esm/Client/ClientFactory.js.map
new file mode 100644
index 0000000..1a096bf
--- /dev/null
+++ b/lib/esm/Client/ClientFactory.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"ClientFactory.js","sourceRoot":"","sources":["../../../src/Client/ClientFactory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,MAAM,YAAY,CAAA;AAEzC,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAEnE,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E,CAAA;gBAC3B;oBACC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;YAC/D,CAAC;QACF,CAAC;KAAA;IAUO,eAAe,CAAC,MAAe;QACtC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,KAAK,GAAG,CAAC,IAAI;gBACZ,OAAO,UAAU,CAAC,YAAY,EAAE,CAAA;YACjC,KAAK,GAAG,CAAC,MAAM;gBACd,OAAO,YAAY,CAAC,YAAY,EAAE,CAAA;YACnC,KAAK,GAAG,CAAC,KAAK,CAAC;YACf,KAAK,GAAG,CAAC,IAAI,CAAC;YACd;gBACC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;QAC1C,CAAC;IACF,CAAC;IAGD;;;;;;OAMG;IACK,oBAAoB,CAAC,MAAe;QAC3C,IAAI,aAAa,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACzD,IAAI,aAAa,CAAC,MAAM,CAAC;YAAE,OAAQ,MAAc,CAAA;QACjD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACxC,CAAC;CAED"}
\ No newline at end of file
diff --git a/lib/esm/Client/EpicClient.d.ts b/lib/esm/Client/EpicClient.d.ts
new file mode 100644
index 0000000..26d3f1d
--- /dev/null
+++ b/lib/esm/Client/EpicClient.d.ts
@@ -0,0 +1,22 @@
+import SubClient from "../FhirClient";
+import { EMR } from "../Launcher/SmartLaunchHandler";
+import { R4ResourceWithRequiredType } from "../types";
+import BaseClient, { EMR_ENDPOINTS } from "./BaseClient";
+/**
+ Represents the EpicClient class, extending the BaseClient.
+ */
+export default class EpicClient extends BaseClient {
+ EMR_TYPE: EMR;
+ static readonly AUTHORIZE_ENDPOINT = "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/authorize";
+ static readonly TOKEN_ENDPOINT = "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token";
+ static readonly R4_ENDPOINT = "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4";
+ static getEndpoints(): EMR_ENDPOINTS;
+ getEndpoints(): EMR_ENDPOINTS;
+ readonly epicCreateHeaders: HeadersInit;
+ /**
+ * Creates an instance of EpicClient.
+ * @param {SubClient} fhirClientDefault - The default FHIR client to use.
+ */
+ constructor(fhirClientDefault: SubClient);
+ create(resource: T, patientId?: string, encounterId?: string): Promise;
+}
diff --git a/lib/esm/Client/EpicClient.js b/lib/esm/Client/EpicClient.js
new file mode 100644
index 0000000..0a98b60
--- /dev/null
+++ b/lib/esm/Client/EpicClient.js
@@ -0,0 +1,48 @@
+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());
+ });
+};
+import { EMR } from "../Launcher/SmartLaunchHandler";
+import BaseClient from "./BaseClient";
+/**
+ Represents the EpicClient class, extending the BaseClient.
+ */
+class EpicClient extends BaseClient {
+ static getEndpoints() {
+ return BaseClient.constructEndpoints(EpicClient.TOKEN_ENDPOINT, EpicClient.R4_ENDPOINT, EpicClient.AUTHORIZE_ENDPOINT);
+ }
+ getEndpoints() {
+ return EpicClient.getEndpoints();
+ }
+ /**
+ * Creates an instance of EpicClient.
+ * @param {SubClient} fhirClientDefault - The default FHIR client to use.
+ */
+ constructor(fhirClientDefault) {
+ super(fhirClientDefault);
+ this.EMR_TYPE = EMR.EPIC;
+ /* The `epicCreateHeaders` property is defining the headers that will be used when making a create request to the Epic FHIR server. In this case, it sets the
+ `Prefer` header to `"return=representation"`, which indicates that the server should return the created resource in the response. */
+ this.epicCreateHeaders = {
+ Prefer: "return=representation",
+ };
+ }
+ create(resource, patientId, encounterId) {
+ const _super = Object.create(null, {
+ create: { get: () => super.create }
+ });
+ return __awaiter(this, void 0, void 0, function* () {
+ return _super.create.call(this, resource, patientId, encounterId, this.createHeaders(this.epicCreateHeaders));
+ });
+ }
+}
+EpicClient.AUTHORIZE_ENDPOINT = "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/authorize";
+EpicClient.TOKEN_ENDPOINT = "https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token";
+EpicClient.R4_ENDPOINT = "https://fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4";
+export default EpicClient;
+//# sourceMappingURL=EpicClient.js.map
\ No newline at end of file
diff --git a/lib/esm/Client/EpicClient.js.map b/lib/esm/Client/EpicClient.js.map
new file mode 100644
index 0000000..7509517
--- /dev/null
+++ b/lib/esm/Client/EpicClient.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"EpicClient.js","sourceRoot":"","sources":["../../../src/Client/EpicClient.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAA;AAEpD,OAAO,UAA6B,MAAM,cAAc,CAAA;AAGxD;;GAEG;AACH,MAAqB,UAAW,SAAQ,UAAU;IAMjD,MAAM,CAAC,YAAY;QAClB,OAAO,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,cAAc,EAAE,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAA;IACvH,CAAC;IAED,YAAY;QACX,OAAO,UAAU,CAAC,YAAY,EAAE,CAAA;IACjC,CAAC;IAOD;;;OAGG;IACH,YAAY,iBAA4B;QACvC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAvBzB,aAAQ,GAAQ,GAAG,CAAC,IAAI,CAAA;QAaxB;wIACmI;QAC1H,sBAAiB,GAAgB;YACzC,MAAM,EAAE,uBAAuB;SAC/B,CAAA;IAOD,CAAC;IAEK,MAAM,CAAuC,QAAW,EAC7D,SAAkB,EAClB,WAAoB;;;;;YACpB,OAAO,OAAM,MAAM,YAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;QACnG,CAAC;KAAA;;AA7Be,6BAAkB,GAAG,gEAAgE,AAAnE,CAAmE;AACrF,yBAAc,GAAG,4DAA4D,AAA/D,CAA+D;AAC7E,sBAAW,GAAG,2DAA2D,AAA9D,CAA8D;eAJrE,UAAU"}
\ No newline at end of file
diff --git a/lib/esm/Client/SmartHealthClient.d.ts b/lib/esm/Client/SmartHealthClient.d.ts
new file mode 100644
index 0000000..0f5cb3d
--- /dev/null
+++ b/lib/esm/Client/SmartHealthClient.d.ts
@@ -0,0 +1,19 @@
+import SubClient from "../FhirClient";
+import { EMR } from "../Launcher/SmartLaunchHandler";
+import BaseClient, { EMR_ENDPOINTS } from "./BaseClient";
+/**
+ Represents the SmartHealthClient class, extending the BaseClient.
+ */
+export default class SmartHealthClient extends BaseClient {
+ readonly EMR_TYPE: EMR;
+ static readonly AUTHORIZE_ENDPOINT = "https://launch.smarthealthit.org/v/r4/auth/authorize";
+ static readonly TOKEN_ENDPOINT = "https://launch.smarthealthit.org/v/r4/auth/token";
+ static readonly R4_ENDPOINT = "https://launch.smarthealthit.org/v/r4/fhir";
+ static getEndpoints(): EMR_ENDPOINTS;
+ getEndpoints(): EMR_ENDPOINTS;
+ /**
+ * Creates an instance of SmartHealthClient.
+ * @param {SubClient} fhirClientDefault - The default FHIR client to use.
+ */
+ constructor(fhirClientDefault: SubClient);
+}
diff --git a/lib/esm/Client/SmartHealthClient.js b/lib/esm/Client/SmartHealthClient.js
new file mode 100644
index 0000000..76f0337
--- /dev/null
+++ b/lib/esm/Client/SmartHealthClient.js
@@ -0,0 +1,26 @@
+import { EMR } from "../Launcher/SmartLaunchHandler";
+import BaseClient from "./BaseClient";
+/**
+ Represents the SmartHealthClient class, extending the BaseClient.
+ */
+class SmartHealthClient extends BaseClient {
+ static getEndpoints() {
+ return BaseClient.constructEndpoints(SmartHealthClient.TOKEN_ENDPOINT, SmartHealthClient.R4_ENDPOINT, SmartHealthClient.AUTHORIZE_ENDPOINT);
+ }
+ getEndpoints() {
+ return SmartHealthClient.getEndpoints();
+ }
+ /**
+ * Creates an instance of SmartHealthClient.
+ * @param {SubClient} fhirClientDefault - The default FHIR client to use.
+ */
+ constructor(fhirClientDefault) {
+ super(fhirClientDefault);
+ this.EMR_TYPE = EMR.SMART;
+ }
+}
+SmartHealthClient.AUTHORIZE_ENDPOINT = "https://launch.smarthealthit.org/v/r4/auth/authorize";
+SmartHealthClient.TOKEN_ENDPOINT = "https://launch.smarthealthit.org/v/r4/auth/token";
+SmartHealthClient.R4_ENDPOINT = "https://launch.smarthealthit.org/v/r4/fhir";
+export default SmartHealthClient;
+//# sourceMappingURL=SmartHealthClient.js.map
\ No newline at end of file
diff --git a/lib/esm/Client/SmartHealthClient.js.map b/lib/esm/Client/SmartHealthClient.js.map
new file mode 100644
index 0000000..da41afa
--- /dev/null
+++ b/lib/esm/Client/SmartHealthClient.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"SmartHealthClient.js","sourceRoot":"","sources":["../../../src/Client/SmartHealthClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAA;AACpD,OAAO,UAA6B,MAAM,cAAc,CAAA;AAGxD;;GAEG;AACH,MAAqB,iBAAkB,SAAQ,UAAU;IAMxD,MAAM,CAAC,YAAY;QAClB,OAAO,UAAU,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,WAAW,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAA;IAC5I,CAAC;IAED,YAAY;QACX,OAAO,iBAAiB,CAAC,YAAY,EAAE,CAAA;IACxC,CAAC;IAED;;;KAGI;IACJ,YAAY,iBAA4B;QACvC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAlBhB,aAAQ,GAAQ,GAAG,CAAC,KAAK,CAAA;IAmBlC,CAAC;;AAlBe,oCAAkB,GAAG,sDAAsD,AAAzD,CAAyD;AAC3E,gCAAc,GAAG,kDAAkD,AAArD,CAAqD;AACnE,6BAAW,GAAG,4CAA4C,AAA/C,CAA+C;eAJtD,iBAAiB"}
\ No newline at end of file
diff --git a/lib/esm/FhirClient.d.ts b/lib/esm/FhirClient.d.ts
new file mode 100644
index 0000000..8d211bf
--- /dev/null
+++ b/lib/esm/FhirClient.d.ts
@@ -0,0 +1,4 @@
+import Client from 'fhirclient/lib/Client';
+import type { fhirclient } from 'fhirclient/lib/types.js';
+export { fhirclient as FhirClientTypes };
+export default Client;
diff --git a/lib/FhirClient.js b/lib/esm/FhirClient.js
similarity index 100%
rename from lib/FhirClient.js
rename to lib/esm/FhirClient.js
diff --git a/lib/esm/FhirClient.js.map b/lib/esm/FhirClient.js.map
new file mode 100644
index 0000000..04fda8f
--- /dev/null
+++ b/lib/esm/FhirClient.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"FhirClient.js","sourceRoot":"","sources":["../../src/FhirClient.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAG3C,eAAe,MAAM,CAAC"}
\ No newline at end of file
diff --git a/lib/esm/Launcher/Config.d.ts b/lib/esm/Launcher/Config.d.ts
new file mode 100644
index 0000000..b165fc8
--- /dev/null
+++ b/lib/esm/Launcher/Config.d.ts
@@ -0,0 +1,13 @@
+/**
+Represents the LaunchConfig interface for launch configuration.
+@interface
+*/
+interface LaunchConfig {
+ scopes: string[];
+}
+/**
+ * Launch configuration for Cerner.
+ * @constant {LaunchConfig}
+ */
+export declare const cerner: LaunchConfig;
+export {};
diff --git a/lib/Launcher/Config.js b/lib/esm/Launcher/Config.js
similarity index 98%
rename from lib/Launcher/Config.js
rename to lib/esm/Launcher/Config.js
index 8936449..87f57f1 100644
--- a/lib/Launcher/Config.js
+++ b/lib/esm/Launcher/Config.js
@@ -2,7 +2,7 @@
* Launch configuration for Cerner.
* @constant {LaunchConfig}
*/
-export var cerner = {
+export const cerner = {
scopes: [
// "pr_account",
// "pr_allergyintolerance",
diff --git a/lib/esm/Launcher/Config.js.map b/lib/esm/Launcher/Config.js.map
new file mode 100644
index 0000000..1aff0cc
--- /dev/null
+++ b/lib/esm/Launcher/Config.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"Config.js","sourceRoot":"","sources":["../../../src/Launcher/Config.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAiB;IAClC,MAAM,EAAE;QACN,gBAAgB;QAChB,2BAA2B;QAC3B,oBAAoB;QACpB,eAAe;QACf,iBAAiB;QACjB,iBAAiB;QACjB,mBAAmB;QACnB,sBAAsB;QACtB,kBAAkB;QAClB,gBAAgB;QAChB,iBAAiB;QACjB,eAAe;QACf,0BAA0B;QAC1B,kBAAkB;QAClB,4BAA4B;QAC5B,aAAa;QACb,qBAAqB;QACrB,0BAA0B;QAC1B,uBAAuB;QACvB,oBAAoB;QACpB,gBAAgB;QAChB,eAAe;QACf,kBAAkB;QAClB,mBAAmB;QACnB,sBAAsB;QACtB,8BAA8B;QAC9B,sBAAsB;QACtB,iBAAiB;QACjB,uBAAuB;QACvB,aAAa;QACb,2BAA2B;QAC3B,oBAAoB;QACpB,cAAc;QACd,eAAe;QACf,sBAAsB;QACtB,kBAAkB;QAClB,iBAAiB;QACjB,0BAA0B;QAC1B,kBAAkB;QAClB,4BAA4B;QAC5B,qBAAqB;QACrB,0BAA0B;QAC1B,oBAAoB;QACpB,gBAAgB;QAChB,kBAAkB;QAClB,mBAAmB;QACnB,8BAA8B;QAC9B,sBAAsB;QACtB,aAAa;QACb,gBAAgB;QAChB,uBAAuB;QACvB,oBAAoB;QACpB,eAAe;QACf,iBAAiB;QACjB,iBAAiB;QACjB,mBAAmB;QACnB,sBAAsB;QACtB,cAAc;QACd,gBAAgB;QAChB,iBAAiB;QACjB,eAAe;QACf,sBAAsB;QACtB,cAAc;QACd,wBAAwB;QACxB,aAAa;QACb,iBAAiB;QACjB,aAAa;QACb,sBAAsB;QACtB,uBAAuB;QACvB,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,WAAW;QACX,iBAAiB;QACjB,cAAc;QACd,mBAAmB;QACnB,kBAAkB;QAClB,0BAA0B;QAC1B,sBAAsB;QACtB,iBAAiB;QACjB,mBAAmB;QACnB,aAAa;QACb,uBAAuB;QACvB,oBAAoB;QACpB,eAAe;QACf,cAAc;QACd,kBAAkB;QAClB,cAAc;QACd,aAAa;QACb,sBAAsB;QACtB,cAAc;QACd,wBAAwB;QACxB,iBAAiB;QACjB,sBAAsB;QACtB,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,iBAAiB;QACjB,cAAc;QACd,mBAAmB;QACnB,0BAA0B;QAC1B,kBAAkB;QAClB,YAAY;KACb;CACF,CAAC"}
\ No newline at end of file
diff --git a/lib/esm/Launcher/SmartLaunchHandler.d.ts b/lib/esm/Launcher/SmartLaunchHandler.d.ts
new file mode 100644
index 0000000..e02d798
--- /dev/null
+++ b/lib/esm/Launcher/SmartLaunchHandler.d.ts
@@ -0,0 +1,93 @@
+import { EMR_ENDPOINTS } from "../Client/BaseClient";
+import { LAUNCH } from "../Client/ClientFactory";
+export declare enum EMR {
+ CERNER = "cerner",
+ EPIC = "epic",
+ SMART = "smart",
+ NONE = "none"
+}
+/**
+ * The function `instanceOfEmr` checks if an object is an instance of the EMR enum.
+ * @param {unknown} object - The `object` parameter is of type `unknown`, which means it can be any type.
+ * @returns a boolean value.
+ */
+export declare function instanceOfEmr(object: unknown): object is EMR;
+/**
+* The function `getEndpointsForEmr` returns the endpoints for a given EMR type, such as Epic, Cerner, or SMART.
+* @param {EMR} emrType - The `emrType` parameter is of type `EMR`, which is an enumeration representing different types of Electronic Medical Record (EMR)
+* systems. The possible values for `emrType` are `EMR.EPIC`, `EMR.CERNER`, `EMR.SMART`,
+* @returns an object of type EMR_ENDPOINTS.
+*/
+export declare function getEndpointsForEmr(emrType: EMR): EMR_ENDPOINTS;
+/**
+ * Represents the SmartLaunchHandler class.
+ */
+export default class SmartLaunchHandler {
+ /**
+ * The client ID for the SmartLaunchHandler.
+ * @readonly
+ */
+ readonly clientID: string;
+ readonly clientSecret?: string;
+ /**
+ * Creates an instance of SmartLaunchHandler.
+ * @param {string} clientID - The client ID to use for authorization.
+ */
+ constructor(clientID: string, clientSecret?: string);
+ /**
+ * Launches an EMR application.
+ * @param {string} clientId - The client ID to use for authorization.
+ * @param {string} redirect - The redirect URI to use for authorization.
+ * @param {string} iss - The issuer for authorization.
+ * @param {LAUNCH} launchType - The type of launch.
+ * @param {string[]} emrSpecificScopes - Additional scopes specific to the EMR.
+ * @param {string} clientSecret - The client secret for authorization.
+ * @returns {Promise} - A promise resolving to the authorization response or void.
+ */
+ private launchEMR;
+ /**
+ * Launches the Epic EMR application.
+ * @param {string} clientId - The client ID to use for authorization.
+ * @param {string} redirect - The redirect URI to use for authorization.
+ * @param {string} iss - The issuer for authorization.
+ * @param {LAUNCH} launchType - The type of launch.
+ * @returns {Promise} - A promise resolving to the authorization response or void.
+ */
+ epicLaunch(redirect: string, iss: string, launchType: LAUNCH): Promise;
+ /**
+ * Launches the SMART Health IT EMR application.
+ * @param {string} clientId - The client ID to use for authorization.
+ * @param {string} redirect - The redirect URI to use for authorization.
+ * @param {string} iss - The issuer for authorization.
+ * @param {LAUNCH} launchType - The type of launch.
+ * @returns {Promise} - A promise resolving to the authorization response or void.
+ */
+ smartHealthITLaunch(redirect: string, iss: string, launchType: LAUNCH): Promise;
+ /**
+ * Launches the Cerner EMR application.
+ * @param {string} clientId - The client ID to use for authorization.
+ * @param {string} redirect - The redirect URI to use for authorization.
+ * @param {string} iss - The issuer for authorization.
+ * @param {LAUNCH} launchType - The type of launch.
+ * @returns {Promise} - A promise resolving to the authorization response or void.
+ */
+ cernerLaunch(redirect: string, iss: string, launchType: LAUNCH): Promise;
+ /**
+ * Authorizes the EMR based on the current URL query parameters.
+ * @returns {Promise} - A promise resolving to void.
+ */
+ authorizeEMR(launchType?: LAUNCH, redirectPath?: string): Promise;
+ /**
+ * The function `executeEMRLaunch` checks the URL parameters for an "iss" value, determines the EMR type based on the "iss" value, and then launches the
+ * corresponding EMR system.
+ * @returns nothing (undefined).
+ */
+ private executeWebLaunch;
+ /**
+ * The function `getEMRType` takes a string `iss` and returns the corresponding EMR type based on whether the string includes any of the EMR types.
+ * @param {string} iss - The `iss` parameter is a string that represents the issuer of an Electronic Medical Record (EMR).
+ * @returns the EMR type that matches the input string `iss`. If a matching EMR type is found, it is returned. If no matching EMR type is found, the function
+ * returns `EMR.NONE`.
+ */
+ getEMRType(iss?: string): EMR;
+}
diff --git a/lib/esm/Launcher/SmartLaunchHandler.js b/lib/esm/Launcher/SmartLaunchHandler.js
new file mode 100644
index 0000000..541cb07
--- /dev/null
+++ b/lib/esm/Launcher/SmartLaunchHandler.js
@@ -0,0 +1,204 @@
+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());
+ });
+};
+import * as FHIR from "fhirclient";
+import CernerClient from "../Client/CernerClient";
+import { LAUNCH } from "../Client/ClientFactory";
+import EpicClient from "../Client/EpicClient";
+import { cerner } from "./Config";
+import scopes from "./scopes.json";
+export var EMR;
+(function (EMR) {
+ EMR["CERNER"] = "cerner";
+ EMR["EPIC"] = "epic";
+ EMR["SMART"] = "smart";
+ EMR["NONE"] = "none";
+})(EMR || (EMR = {}));
+/**
+ * The function `instanceOfEmr` checks if an object is an instance of the EMR enum.
+ * @param {unknown} object - The `object` parameter is of type `unknown`, which means it can be any type.
+ * @returns a boolean value.
+ */
+export function instanceOfEmr(object) {
+ return Object.values(EMR).includes(object);
+}
+/**
+* The function `getEndpointsForEmr` returns the endpoints for a given EMR type, such as Epic, Cerner, or SMART.
+* @param {EMR} emrType - The `emrType` parameter is of type `EMR`, which is an enumeration representing different types of Electronic Medical Record (EMR)
+* systems. The possible values for `emrType` are `EMR.EPIC`, `EMR.CERNER`, `EMR.SMART`,
+* @returns an object of type EMR_ENDPOINTS.
+*/
+export function getEndpointsForEmr(emrType) {
+ switch (emrType) {
+ case EMR.EPIC:
+ return EpicClient.getEndpoints();
+ case EMR.CERNER:
+ return CernerClient.getEndpoints();
+ case EMR.SMART:
+ case EMR.NONE:
+ default:
+ throw new Error(`Endpoints not found for EMR type: ${emrType}`);
+ }
+}
+/**
+ * Represents the SmartLaunchHandler class.
+ */
+export default class SmartLaunchHandler {
+ /**
+ * Creates an instance of SmartLaunchHandler.
+ * @param {string} clientID - The client ID to use for authorization.
+ */
+ constructor(clientID, clientSecret) {
+ this.clientID = clientID;
+ this.clientSecret = clientSecret;
+ }
+ /**
+ * Launches an EMR application.
+ * @param {string} clientId - The client ID to use for authorization.
+ * @param {string} redirect - The redirect URI to use for authorization.
+ * @param {string} iss - The issuer for authorization.
+ * @param {LAUNCH} launchType - The type of launch.
+ * @param {string[]} emrSpecificScopes - Additional scopes specific to the EMR.
+ * @param {string} clientSecret - The client secret for authorization.
+ * @returns {Promise} - A promise resolving to the authorization response or void.
+ */
+ launchEMR(redirect, iss, launchType, emrSpecificScopes) {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (launchType === LAUNCH.BACKEND) {
+ throw new Error("This doesn't work for backend launch");
+ }
+ const defaultScopes = [
+ launchType === LAUNCH.STANDALONE ? "launch/practitioner" : "launch",
+ "online_access",
+ "openid",
+ "fhirUser",
+ ];
+ const scope = [...defaultScopes, ...emrSpecificScopes].join(" ");
+ const redirect_uri = redirect !== null && redirect !== void 0 ? redirect : "";
+ return FHIR.oauth2.authorize({
+ client_id: this.clientID,
+ iss: iss,
+ redirect_uri: redirect_uri,
+ scope: scope,
+ clientSecret: this.clientSecret,
+ });
+ });
+ }
+ /**
+ * Launches the Epic EMR application.
+ * @param {string} clientId - The client ID to use for authorization.
+ * @param {string} redirect - The redirect URI to use for authorization.
+ * @param {string} iss - The issuer for authorization.
+ * @param {LAUNCH} launchType - The type of launch.
+ * @returns {Promise} - A promise resolving to the authorization response or void.
+ */
+ epicLaunch(redirect, iss, launchType) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const emrSpecificScopes = [];
+ return this.launchEMR(redirect, iss, launchType, emrSpecificScopes);
+ });
+ }
+ /**
+ * Launches the SMART Health IT EMR application.
+ * @param {string} clientId - The client ID to use for authorization.
+ * @param {string} redirect - The redirect URI to use for authorization.
+ * @param {string} iss - The issuer for authorization.
+ * @param {LAUNCH} launchType - The type of launch.
+ * @returns {Promise} - A promise resolving to the authorization response or void.
+ */
+ smartHealthITLaunch(redirect, iss, launchType) {
+ return __awaiter(this, void 0, void 0, function* () {
+ return this.launchEMR(redirect, iss, launchType, []);
+ });
+ }
+ /**
+ * Launches the Cerner EMR application.
+ * @param {string} clientId - The client ID to use for authorization.
+ * @param {string} redirect - The redirect URI to use for authorization.
+ * @param {string} iss - The issuer for authorization.
+ * @param {LAUNCH} launchType - The type of launch.
+ * @returns {Promise} - A promise resolving to the authorization response or void.
+ */
+ cernerLaunch(redirect, iss, launchType) {
+ return __awaiter(this, void 0, void 0, function* () {
+ const additionalScopes = cerner.scopes.map((name) => scopes[name]);
+ return this.launchEMR(redirect, iss, launchType, additionalScopes);
+ });
+ }
+ /**
+ * Authorizes the EMR based on the current URL query parameters.
+ * @returns {Promise} - A promise resolving to void.
+ */
+ authorizeEMR(launchType = LAUNCH.EMR, redirectPath) {
+ return __awaiter(this, void 0, void 0, function* () {
+ if (launchType === LAUNCH.BACKEND) {
+ throw new Error(`Direct Backend Authorization not supported yet.`);
+ }
+ else {
+ return yield this.executeWebLaunch(launchType, redirectPath);
+ }
+ });
+ }
+ /**
+ * The function `executeEMRLaunch` checks the URL parameters for an "iss" value, determines the EMR type based on the "iss" value, and then launches the
+ * corresponding EMR system.
+ * @returns nothing (undefined).
+ */
+ executeWebLaunch(launchType, redirectPath) {
+ var _a;
+ return __awaiter(this, void 0, void 0, function* () {
+ const queryString = window.location.search;
+ const origin = window.location.origin;
+ const redirect = origin + (redirectPath
+ ? redirectPath.startsWith('/')
+ ? redirectPath
+ : '/' + redirectPath
+ : '');
+ const urlParams = new URLSearchParams(queryString);
+ const iss = (_a = urlParams.get("iss")) !== null && _a !== void 0 ? _a : undefined;
+ if (!iss)
+ throw new Error("Iss Search parameter must be provided as part of EMR Web Launch");
+ const emrType = this.getEMRType(iss);
+ if (emrType === EMR.NONE || !emrType)
+ throw new Error('EMR type cannot be inferred from the ISS');
+ switch (emrType) {
+ case EMR.EPIC:
+ yield this.epicLaunch(redirect, iss, launchType);
+ break;
+ case EMR.CERNER:
+ yield this.cernerLaunch(redirect, iss, launchType);
+ break;
+ case EMR.SMART:
+ yield this.smartHealthITLaunch(redirect, iss, launchType);
+ break;
+ default:
+ break;
+ }
+ });
+ }
+ /**
+ * The function `getEMRType` takes a string `iss` and returns the corresponding EMR type based on whether the string includes any of the EMR types.
+ * @param {string} iss - The `iss` parameter is a string that represents the issuer of an Electronic Medical Record (EMR).
+ * @returns the EMR type that matches the input string `iss`. If a matching EMR type is found, it is returned. If no matching EMR type is found, the function
+ * returns `EMR.NONE`.
+ */
+ getEMRType(iss) {
+ var _a;
+ if (iss) {
+ const isEMROfType = (emrType) => iss.includes(emrType);
+ const emrTypes = Object.values(EMR);
+ return (_a = emrTypes.find(isEMROfType)) !== null && _a !== void 0 ? _a : EMR.NONE;
+ }
+ const emrType = process.env.REACT_APP_EMR_TYPE.toLowerCase();
+ if (!emrType)
+ throw new Error('EMR type cannot be inferred. You must provide the emrType explicitly as an env variable');
+ return emrType;
+ }
+}
+//# sourceMappingURL=SmartLaunchHandler.js.map
\ No newline at end of file
diff --git a/lib/esm/Launcher/SmartLaunchHandler.js.map b/lib/esm/Launcher/SmartLaunchHandler.js.map
new file mode 100644
index 0000000..710518b
--- /dev/null
+++ b/lib/esm/Launcher/SmartLaunchHandler.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"SmartLaunchHandler.js","sourceRoot":"","sources":["../../../src/Launcher/SmartLaunchHandler.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AAEnC,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,MAAM,MAAM,eAAe,CAAC;AAEnC,MAAM,CAAN,IAAY,GAKX;AALD,WAAY,GAAG;IACb,wBAAiB,CAAA;IACjB,oBAAa,CAAA;IACb,sBAAe,CAAA;IACf,oBAAa,CAAA;AACf,CAAC,EALW,GAAG,KAAH,GAAG,QAKd;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAE,MAAwB,CAAC,CAAA;AAC/D,CAAC;AAED;;;;;EAKE;AACF,MAAM,UAAU,kBAAkB,CAAC,OAAY;IAC7C,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,GAAG,CAAC,IAAI;YACX,OAAO,UAAU,CAAC,YAAY,EAAE,CAAA;QAClC,KAAK,GAAG,CAAC,MAAM;YACb,OAAO,YAAY,CAAC,YAAY,EAAE,CAAA;QACpC,KAAK,GAAG,CAAC,KAAK,CAAC;QACf,KAAK,GAAG,CAAC,IAAI,CAAC;QACd;YACE,MAAM,IAAI,KAAK,CAAC,qCAAqC,O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AI,KAAK,CAAC,yFAAyF,CAAC,CAAA;QACxH,OAAO,OAAO,CAAA;IAChB,CAAC;CACF"}
\ No newline at end of file
diff --git a/lib/esm/Launcher/scopes.json b/lib/esm/Launcher/scopes.json
new file mode 100644
index 0000000..642f6fe
--- /dev/null
+++ b/lib/esm/Launcher/scopes.json
@@ -0,0 +1,105 @@
+{
+ "pr_account": "patient/Account.read",
+ "pr_allergyintolerance": "patient/AllergyIntolerance.read",
+ "pr_appointment": "patient/Appointment.read",
+ "pr_binary": "patient/Binary.read",
+ "pr_careplan": "patient/CarePlan.read",
+ "pr_careteam": "patient/CareTeam.read",
+ "pr_chargeitem": "patient/ChargeItem.read",
+ "pr_communication": "patient/Communication.read",
+ "pr_condition": "patient/Condition.read",
+ "pr_consent": "patient/Consent.read",
+ "pr_coverage": "patient/Coverage.read",
+ "pr_device": "patient/Device.read",
+ "pr_documentreference": "patient/DocumentReference.read",
+ "pr_encounter": "patient/Encounter.read",
+ "pr_familymemberhistory": "patient/FamilyMemberHistory.read",
+ "pr_goal": "patient/Goal.read",
+ "pr_immunization": "patient/Immunization.read",
+ "pr_medicationrequest": "patient/MedicationRequest.read",
+ "pr_nutritionorder": "patient/NutritionOrder.read",
+ "pr_observation": "patient/Observation.read",
+ "pr_patient": "patient/Patient.read",
+ "pr_person": "patient/Person.read",
+ "pr_procedure": "patient/Procedure.read",
+ "pr_provenance": "patient/Provenance.read",
+ "pr_questionnaire": "patient/Questionnaire.read",
+ "pr_questionnaireresponse": "patient/QuestionnaireResponse.read",
+ "pr_relatedperson": "patient/RelatedPerson.read",
+ "pr_schedule": "patient/Schedule.read",
+ "pr_servicerequest": "patient/ServiceRequest.read",
+ "pr_slot": "patient/Slot.read",
+ "pw_allergyintolerance": "patient/AllergyIntolerance.write",
+ "pw_appointment": "patient/Appointment.write",
+ "pw_basic": "patient/Basic.write",
+ "pw_binary": "patient/Binary.write",
+ "pw_communication": "patient/Communication.write",
+ "pw_condition": "patient/Condition.write",
+ "pw_coverage": "patient/Coverage.write",
+ "pw_documentreference": "patient/DocumentReference.write",
+ "pw_encounter": "patient/Encounter.write",
+ "pw_familymemberhistory": "patient/FamilyMemberHistory.write",
+ "pw_immunization": "patient/Immunization.write",
+ "pw_medicationrequest": "patient/MedicationRequest.write",
+ "pw_observation": "patient/Observation.write",
+ "pw_patient": "patient/Patient.write",
+ "pw_procedure": "patient/Procedure.write",
+ "pw_provenance": "patient/Provenance.write",
+ "pw_questionnaireresponse": "patient/QuestionnaireResponse.write",
+ "pw_relatedperson": "patient/RelatedPerson.write",
+ "pw_slot": "patient/Slot.write",
+ "ur_account": "user/Account.read",
+ "ur_allergyintolerance": "user/AllergyIntolerance.read",
+ "ur_appointment": "user/Appointment.read",
+ "ur_binary": "user/Binary.read",
+ "ur_careplan": "user/CarePlan.read",
+ "ur_careteam": "user/CareTeam.read",
+ "ur_chargeitem": "user/ChargeItem.read",
+ "ur_communication": "user/Communication.read",
+ "ur_condition": "user/Condition.read",
+ "ur_consent": "user/Consent.read",
+ "ur_coverage": "user/Coverage.read",
+ "ur_device": "user/Device.read",
+ "ur_documentreference": "user/DocumentReference.read",
+ "ur_encounter": "user/Encounter.read",
+ "ur_familymemberhistory": "user/FamilyMemberHistory.read",
+ "ur_goal": "user/Goal.read",
+ "ur_immunization": "user/Immunization.read",
+ "ur_location": "user/Location.read",
+ "ur_medicationrequest": "user/MedicationRequest.read",
+ "ur_nutritionorder": "user/NutritionOrder.read",
+ "ur_observation": "user/Observation.read",
+ "ur_organization": "user/Organization.read",
+ "ur_patient": "user/Patient.read",
+ "ur_person": "user/Person.read",
+ "ur_practitioner": "user/Practitioner.read",
+ "ur_procedure": "user/Procedure.read",
+ "ur_provenance": "user/Provenance.read",
+ "ur_questionnaire": "user/Questionnaire.read",
+ "ur_questionnaireresponse": "user/QuestionnaireResponse.read",
+ "ur_relatedperson": "user/RelatedPerson.read",
+ "ur_schedule": "user/Schedule.read",
+ "ur_servicerequest": "user/ServiceRequest.read",
+ "ur_slot": "user/Slot.read",
+ "uw_allergyintolerance": "user/AllergyIntolerance.write",
+ "uw_appointment": "user/Appointment.write",
+ "uw_binary": "user/Binary.write",
+ "uw_basic": "user/Basic.write",
+ "uw_communication": "user/Communication.write",
+ "uw_condition": "user/Condition.write",
+ "uw_coverage": "user/Coverage.write",
+ "uw_documentreference": "user/DocumentReference.write",
+ "uw_encounter": "user/Encounter.write",
+ "uw_familymemberhistory": "user/FamilyMemberHistory.write",
+ "uw_immunization": "user/Immunization.write",
+ "uw_medicationrequest": "user/MedicationRequest.write",
+ "uw_observation": "user/Observation.write",
+ "uw_organization": "user/Organization.write",
+ "uw_patient": "user/Patient.write",
+ "uw_practitioner": "user/Practitioner.write",
+ "uw_procedure": "user/Procedure.write",
+ "uw_provenance": "user/Provenance.write",
+ "uw_questionnaireresponse": "user/QuestionnaireResponse.write",
+ "uw_relatedperson": "user/RelatedPerson.write",
+ "uw_slot": "user/Slot.write"
+}
diff --git a/lib/esm/Resource/transformer.d.ts b/lib/esm/Resource/transformer.d.ts
new file mode 100644
index 0000000..f4419f3
--- /dev/null
+++ b/lib/esm/Resource/transformer.d.ts
@@ -0,0 +1,20 @@
+import { FhirClientResourceWithRequiredType, R4ResourceWithRequiredType } from "../types";
+/**
+Represents the Transformer namespace for resource transformation.
+@namespace Transformer
+*/
+export declare namespace Transformer {
+ /**
+ * Converts a resource to the FHIR client type.
+ * @param {T} originalResource - The original resource to convert.
+ * @returns {FhirClientResourceWithRequiredType} - The converted resource in the FHIR client type.
+ * @template T - The original resource type.
+ */
+ function toFhirClientType(originalResource: T): FhirClientResourceWithRequiredType;
+ /**
+ * The function `toR4FhirType` converts a resource object from one type to another in a FHIR R4 format.
+ * @param {FROM_TYPE} originalResource - The originalResource parameter is of type FROM_TYPE, which is a FhirClientResourceWithRequiredType.
+ * @returns a transformed resource of type TO_TYPE.
+ */
+ function toR4FhirType(originalResource: FROM_TYPE): TO_TYPE;
+}
diff --git a/lib/esm/Resource/transformer.js b/lib/esm/Resource/transformer.js
new file mode 100644
index 0000000..aea3609
--- /dev/null
+++ b/lib/esm/Resource/transformer.js
@@ -0,0 +1,41 @@
+/**
+Represents the Transformer namespace for resource transformation.
+@namespace Transformer
+*/
+export var Transformer;
+(function (Transformer) {
+ /**
+ * Converts a resource to the FHIR client type.
+ * @param {T} originalResource - The original resource to convert.
+ * @returns {FhirClientResourceWithRequiredType} - The converted resource in the FHIR client type.
+ * @template T - The original resource type.
+ */
+ function toFhirClientType(originalResource) {
+ const originalResourceKeys = Object.keys(originalResource);
+ const transformedResource = Object.assign(Object.assign({}, originalResourceKeys.reduce(convertKeysToFhirClientResource(originalResource), {})), { resourceType: originalResource["resourceType"] });
+ return transformedResource;
+ }
+ Transformer.toFhirClientType = toFhirClientType;
+ /**
+ * Converts the keys of a resource to the FHIR client resource type.
+ * @private
+ * @param {T} originalResource - The original resource.
+ * @returns {(previousValue: {}, currentValue: keyof T, currentIndex: number, array: (keyof T)[]) => {}} - A reducer function to convert keys to the FHIR client resource type.
+ * @template T - The original resource type.
+ */
+ function convertKeysToFhirClientResource(originalResource) {
+ return (a, v) => (Object.assign(Object.assign({}, a), { [v]: originalResource[v] }));
+ }
+ /**
+ * The function `toR4FhirType` converts a resource object from one type to another in a FHIR R4 format.
+ * @param {FROM_TYPE} originalResource - The originalResource parameter is of type FROM_TYPE, which is a FhirClientResourceWithRequiredType.
+ * @returns a transformed resource of type TO_TYPE.
+ */
+ function toR4FhirType(originalResource) {
+ const originalResourceKeys = Object.keys(originalResource);
+ const transformedResource = Object.assign(Object.assign({}, originalResourceKeys.reduce((a, v) => (Object.assign(Object.assign({}, a), { [v]: originalResource[v] })), {})), { resourceType: originalResource["resourceType"] });
+ return transformedResource;
+ }
+ Transformer.toR4FhirType = toR4FhirType;
+})(Transformer || (Transformer = {}));
+//# sourceMappingURL=transformer.js.map
\ No newline at end of file
diff --git a/lib/esm/Resource/transformer.js.map b/lib/esm/Resource/transformer.js.map
new file mode 100644
index 0000000..74ab08c
--- /dev/null
+++ b/lib/esm/Resource/transformer.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"transformer.js","sourceRoot":"","sources":["../../../src/Resource/transformer.ts"],"names":[],"mappings":"AAKA;;;EAGE;AACF,MAAM,KAAW,WAAW,CAmE3B;AAnED,WAAiB,WAAW;IAC1B;;;;;OAKG;IACH,SAAgB,gBAAgB,CAC9B,gBAAmB;QAGnB,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAkB,CAAC;QAC5E,MAAM,mBAAmB,mCACpB,oBAAoB,CAAC,MAAM,CAC5B,+BAA+B,CAAI,gBAAgB,CAAC,EACpD,EAAE,CACH,KACD,YAAY,EAAE,gBAAgB,CAAC,cAAc,CAAC,GAC/C,CAAC;QACF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAbe,4BAAgB,mBAa/B,CAAA;IAED;;;;;;OAMG;IACH,SAAS,+BAA+B,CAGtC,gBAAmB;QAOnB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,iCACZ,CAAC,KACJ,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,IACxB,CAAC;IACL,CAAC;IAEH;;;;OAIG;IACD,SAAgB,YAAY,CAC1B,gBAA2B;QAG3B,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAkB,CAAC;QAC5E,MAAM,mBAAmB,mCACpB,oBAAoB,CAAC,MAAM,CAC5B,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,iCACL,CAAC,KACJ,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,IACxB,EACF,EAAE,CACH,KACD,YAAY,EAAE,gBAAgB,CAAC,cAAc,CAAC,GAC/C,CAAC;QACF,OAAO,mBAA8B,CAAC;IACxC,CAAC;IAhBe,wBAAY,eAgB3B,CAAA;AACH,CAAC,EAnEgB,WAAW,KAAX,WAAW,QAmE3B"}
\ No newline at end of file
diff --git a/lib/esm/index.d.ts b/lib/esm/index.d.ts
new file mode 100644
index 0000000..8702c05
--- /dev/null
+++ b/lib/esm/index.d.ts
@@ -0,0 +1,4 @@
+import ClientFactory, { LAUNCH } from "./Client/ClientFactory";
+import SmartLaunchHandler, { EMR } from "./Launcher/SmartLaunchHandler";
+import BaseClient from "./Client/BaseClient";
+export { ClientFactory, SmartLaunchHandler, BaseClient, EMR, LAUNCH };
diff --git a/lib/index.js b/lib/esm/index.js
similarity index 100%
rename from lib/index.js
rename to lib/esm/index.js
diff --git a/lib/esm/index.js.map b/lib/esm/index.js.map
new file mode 100644
index 0000000..75bc8d7
--- /dev/null
+++ b/lib/esm/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,EAAE,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAC7D,OAAO,kBAAkB,EAAE,EAAC,GAAG,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAC,CAAC"}
\ No newline at end of file
diff --git a/lib/esm/types.d.ts b/lib/esm/types.d.ts
new file mode 100644
index 0000000..a3b3bd7
--- /dev/null
+++ b/lib/esm/types.d.ts
@@ -0,0 +1,72 @@
+import * as R4 from "fhir/r4";
+import SubClient, { FhirClientTypes } from "./FhirClient";
+/**
+Represents the PartiallyRequired type, which makes specified properties required and the rest optional.
+@typedef {Omit, K> & Required, K>>} PartiallyRequired
+@template T - The original type.
+@template K - The keys to make required.
+*/
+export type PartiallyRequired = Omit, K> & Required, K>>;
+/**
+ * Represents the R4ResourceWithRequiredType type, which is a resource with required resource type.
+ * @typedef {PartiallyRequired} R4ResourceWithRequiredType
+ */
+export type R4ResourceWithRequiredType = PartiallyRequired;
+/**
+ * Represents the FhirClientResourceWithRequiredType type, which is a FHIR client resource with required resource type.
+ * @typedef {PartiallyRequired} FhirClientResourceWithRequiredType
+ */
+export type FhirClientResourceWithRequiredType = PartiallyRequired;
+/**
+ * Represents the ObjectWithID type, which can be either a patient or an encounter from the FHIR client.
+ */
+export type ObjectWithID = SubClient["patient" | "encounter" | "user"];
+/**
+ * The above type defines a generic subject with a reference to a resource.
+ * @property subject - The `subject` property is of type `R4.Reference`.
+ */
+export type GenericSubject = {
+ subject: R4.Reference;
+};
+/**
+ * The GenericEncounter type is an object that contains an array of R4.Reference objects named "encounter".
+ * @property {R4.Reference[]} encounter - The `encounter` property is an array of `R4.Reference` objects.
+ */
+export type GenericEncounter = {
+ encounter: R4.Reference[];
+};
+export type GenericContext = R4.DocumentReference["context"];
+/**
+ * The above type defines an object with a property called "author" which is an array of R4.Reference objects.
+ * @property {R4.Reference[]} author - An array of references to authors. Each reference is of type R4.Reference.
+ */
+export type Author = {
+ author: R4.Reference[];
+};
+/**
+ * Represents the result of a user read operation for a SubClient.
+ * This type is a conditional type that extracts the response type from the function return type.
+ * If the function returns a Promise, it resolves to the inferred type 'T'.
+ * If the 'includeResponse' property is present in the request options, it returns the inferred type 'T'.
+ * Otherwise, it returns the inferred type 'R'.
+ *
+ * @template O - Type of the request options.
+ * @template R - Type of the original Promise return type.
+ * @template T - Inferred type from the Promise.
+ */
+export type UserReadResult = SubClient["user"]["read"] extends (requestOptions?: infer O) => Promise ? O extends {
+ includeResponse: true;
+} ? R extends Promise ? T : never : R : never;
+/**
+ * The FhirClientConfig interface represents the configuration for the FHIR client.
+ * @property {string} serverUrl - The server URL for the FHIR client.
+ * @property {string} tokenUri - The token URI for the FHIR client.
+ * @property {FhirClientTypes.TokenResponse} tokenResponse - The token response for the FHIR client.
+ * @property {string} clientId - The client ID for the FHIR client.
+ */
+export interface FhirClientConfig {
+ serverUrl: string;
+ tokenUri: string;
+ tokenResponse: FhirClientTypes.TokenResponse;
+ clientId: string;
+}
diff --git a/lib/types.js b/lib/esm/types.js
similarity index 100%
rename from lib/types.js
rename to lib/esm/types.js
diff --git a/lib/esm/types.js.map b/lib/esm/types.js.map
new file mode 100644
index 0000000..7b5fff8
--- /dev/null
+++ b/lib/esm/types.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/lib/index.js.map b/lib/index.js.map
deleted file mode 100644
index ab0d577..0000000
--- a/lib/index.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,EAAE,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAC7D,OAAO,kBAAkB,EAAE,EAAC,GAAG,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAC,CAAC"}
\ No newline at end of file
diff --git a/lib/types.js.map b/lib/types.js.map
deleted file mode 100644
index c768b79..0000000
--- a/lib/types.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 85e8ad1..fdc0f69 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@topologyhealth/smarterfhir",
- "version": "0.3.3",
+ "version": "0.4.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@topologyhealth/smarterfhir",
- "version": "0.3.3",
+ "version": "0.4.0",
"license": "Apache-2.0",
"dependencies": {
"ansi-regex": "^5.0.1",
@@ -8644,6 +8644,17 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/is-fullwidth-code-point": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
+ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
+ "dev": true,
+ "optional": true,
+ "peer": true,
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/is-generator-function": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz",
@@ -9003,9 +9014,9 @@
"peer": true
},
"node_modules/jose": {
- "version": "4.15.4",
- "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.4.tgz",
- "integrity": "sha512-W+oqK4H+r5sITxfxpSU+MMdr/YSWGvgZMQDIsNoBDGGy4i7GBPTtvFKibQzW06n3U3TqHjhvBJsirShsEJ6eeQ==",
+ "version": "4.15.5",
+ "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.5.tgz",
+ "integrity": "sha512-jc7BFxgKPKi94uOvEmzlSWFFe2+vASyXaKUpdQKatWAESU2MWjDfFf0fdfc83CDKcA5QecabZeNLyfhe3yKNkg==",
"dev": true,
"funding": {
"url": "https://github.com/sponsors/panva"
@@ -11520,17 +11531,6 @@
"node": ">=8"
}
},
- "node_modules/string-width/node_modules/is-fullwidth-code-point": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
- "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
- "dev": true,
- "optional": true,
- "peer": true,
- "engines": {
- "node": ">=8"
- }
- },
"node_modules/string.prototype.matchall": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.10.tgz",
@@ -11753,9 +11753,9 @@
}
},
"node_modules/tar": {
- "version": "6.2.0",
- "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz",
- "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==",
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz",
+ "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==",
"dev": true,
"optional": true,
"peer": true,
@@ -19350,6 +19350,14 @@
"call-bind": "^1.0.2"
}
},
+ "is-fullwidth-code-point": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
+ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
+ "dev": true,
+ "optional": true,
+ "peer": true
+ },
"is-generator-function": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz",
@@ -19619,9 +19627,9 @@
"peer": true
},
"jose": {
- "version": "4.15.4",
- "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.4.tgz",
- "integrity": "sha512-W+oqK4H+r5sITxfxpSU+MMdr/YSWGvgZMQDIsNoBDGGy4i7GBPTtvFKibQzW06n3U3TqHjhvBJsirShsEJ6eeQ==",
+ "version": "4.15.5",
+ "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.5.tgz",
+ "integrity": "sha512-jc7BFxgKPKi94uOvEmzlSWFFe2+vASyXaKUpdQKatWAESU2MWjDfFf0fdfc83CDKcA5QecabZeNLyfhe3yKNkg==",
"dev": true
},
"js-base64": {
@@ -21592,16 +21600,6 @@
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
- },
- "dependencies": {
- "is-fullwidth-code-point": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
- "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
- "dev": true,
- "optional": true,
- "peer": true
- }
}
},
"string.prototype.matchall": {
@@ -21775,9 +21773,9 @@
"dev": true
},
"tar": {
- "version": "6.2.0",
- "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz",
- "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==",
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz",
+ "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==",
"dev": true,
"optional": true,
"peer": true,
diff --git a/package.json b/package.json
index 6860f69..fc7a6b1 100644
--- a/package.json
+++ b/package.json
@@ -1,13 +1,15 @@
{
"name": "@topologyhealth/smarterfhir",
- "version": "0.3.5",
+ "version": "0.4.0",
"description": "Library for simplifying all things FHIR and SMART",
- "main": "lib/index.js",
- "types": "lib/index.d.ts",
+ "main": "lib/cjs/index.js",
+ "types": "lib/esm/index.d.ts",
+ "module": "lib/esm/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
- "build": "tsc",
- "build-module": "tsc --module commonjs"
+ "build": "npm run build-module && npm run build-esm",
+ "build-module": "tsc --project tsconfig.json",
+ "build-esm": "tsc --project tsconfig.esm.json"
},
"author": "Josh Liben and Raghavan Chandrabalan",
"keywords": [
diff --git a/src/Client/ClientFactory.ts b/src/Client/ClientFactory.ts
index 22e963e..a521338 100644
--- a/src/Client/ClientFactory.ts
+++ b/src/Client/ClientFactory.ts
@@ -1,10 +1,12 @@
-import * as FHIR from "fhirclient"
+import smart, * as FHIR from "fhirclient"
import SubClient from "../FhirClient"
import { EMR, instanceOfEmr } from "../Launcher/SmartLaunchHandler"
import BaseClient, { EMR_ENDPOINTS } from "./BaseClient"
import CernerClient from "./CernerClient"
import EpicClient from "./EpicClient"
import SmartHealthClient from "./SmartHealthClient"
+import { ServerResponse, IncomingMessage } from "http"
+import { FhirClientConfig } from "../types"
export enum LAUNCH {
EMR,
@@ -73,21 +75,38 @@ export default class ClientFactory {
* of `LAUNCH.EMR`.
* @returns a Promise that resolves to an instance of the `BaseClient` class.
*/
- async createEMRClient(launchType: LAUNCH = LAUNCH.EMR, fhirClient?: SubClient): Promise {
+ async createEMRClient(launchType: LAUNCH.EMR | LAUNCH.STANDALONE): Promise {
+ const fhirClient = await this.createDefaultFhirClient(launchType)
+ return await this.createSmarterFhirClient(fhirClient)
+ }
- if (launchType === LAUNCH.BACKEND) {
- if (!fhirClient) throw new Error(`FhirClient must be passed as a param for Backend Authentication`)
- }
+ /**
+ * The function `createEMRClientBackend` creates an EMR client based on the specified launch type.
+ * @param {IncomingMessage} req - The `req` parameter is an incoming message object that represents the request made by the client.
+ * @param {ServerResponse} res - The `res` parameter is a server response object that represents the response sent by the server.
+ * @param {FhirClientConfig} serverConfig - The `serverConfig` parameter is an object that contains the configuration for the FHIR client. It includes the server URL, token response, client ID, and token URI.
+ * @returns a Promise that resolves to an instance of the `BaseClient` class.
+ */
+ async createEMRClientBackend(req: IncomingMessage, res: ServerResponse, serverConfig: FhirClientConfig): Promise {
+ const fhirClient = smart(req, res).client({
+ serverUrl: serverConfig.serverUrl,
+ tokenResponse: serverConfig.tokenResponse,
+ clientId: serverConfig.clientId,
+ tokenUri: serverConfig.tokenUri
+ });
+
+ return this.createSmarterFhirClient(fhirClient)
+ }
- const defaultFhirClient = fhirClient ?? await this.createDefaultFhirClient(launchType)
- const emrType = this.getEMRType(defaultFhirClient)
+ private async createSmarterFhirClient(fhirClient: SubClient) {
+ const emrType = this.getEMRType(fhirClient)
switch (emrType) {
case EMR.EPIC:
- return new EpicClient(defaultFhirClient)
+ return new EpicClient(fhirClient)
case EMR.CERNER:
- return new CernerClient(defaultFhirClient)
+ return new CernerClient(fhirClient)
case EMR.SMART:
- return new SmartHealthClient(defaultFhirClient)
+ return new SmartHealthClient(fhirClient)
case EMR.NONE:
default:
throw new Error("Unsupported provider for EMR Client creation")
diff --git a/src/types.ts b/src/types.ts
index c2219a2..b3b1f49 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -72,4 +72,18 @@ export type UserReadResult = SubClient["user"]["read"] extends (
? T
: never
: R
- : never;
\ No newline at end of file
+ : never;
+
+/**
+ * The FhirClientConfig interface represents the configuration for the FHIR client.
+ * @property {string} serverUrl - The server URL for the FHIR client.
+ * @property {string} tokenUri - The token URI for the FHIR client.
+ * @property {FhirClientTypes.TokenResponse} tokenResponse - The token response for the FHIR client.
+ * @property {string} clientId - The client ID for the FHIR client.
+ */
+export interface FhirClientConfig {
+ serverUrl: string;
+ tokenUri: string;
+ tokenResponse: FhirClientTypes.TokenResponse;
+ clientId: string;
+}
\ No newline at end of file
diff --git a/tsconfig.esm.json b/tsconfig.esm.json
new file mode 100644
index 0000000..381fb92
--- /dev/null
+++ b/tsconfig.esm.json
@@ -0,0 +1,9 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "target": "es6",
+ "module": "ES2015",
+ "outDir": "./lib/esm",
+ "declaration": true
+ }
+}
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index 48ba12f..00b1702 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,13 +1,15 @@
{
"compilerOptions": {
"target": "es5",
- "module": "es6",
+ "module": "CommonJS",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"allowJs": true,
+ "esModuleInterop": true,
"resolveJsonModule": true,
"declaration": true,
- "outDir": "./lib",
+ "rootDir": "./src",
+ "outDir": "./lib/cjs",
"sourceMap": true,
"strict": true,
"lib": [