-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfhir-client.js
17572 lines (14668 loc) · 474 KB
/
fhir-client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["fhir"] = factory();
else
root["fhir"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
(function() {
var mkFhir = __webpack_require__(1);
var jquery = window['_jQuery'] || window['jQuery'];
var defer = function(){
pr = jquery.Deferred();
pr.promise = pr.promise();
return pr;
};
var adapter = {
defer: defer,
http: function(args) {
var ret = jquery.Deferred();
var opts = {
type: args.method,
url: args.url,
headers: args.headers,
dataType: "json",
contentType: "application/json",
data: args.data || args.params,
withCredentials: args.credentials === 'include',
};
jquery.ajax(opts)
.done(function(data, status, xhr) {ret.resolve({data: data, status: status, headers: xhr.getResponseHeader, config: args});})
.fail(function(err) {ret.reject({error: err, data: err, config: args});});
return ret.promise();
}
};
var fhir = function(config) {
return mkFhir(config, adapter);
};
fhir.defer = defer;
module.exports = fhir;
}).call(this);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
(function() {
var utils = __webpack_require__(2);
var M = __webpack_require__(5);
var query = __webpack_require__(6);
var auth = __webpack_require__(7);
var transport = __webpack_require__(9);
var errors = __webpack_require__(10);
var config = __webpack_require__(11);
var bundle = __webpack_require__(12);
var pt = __webpack_require__(13);
var refs = __webpack_require__(14);
var url = __webpack_require__(15);
var decorate = __webpack_require__(16);
var cache = {};
var fhir = function(cfg, adapter){
var Middleware = M.Middleware;
var $$Attr = M.$$Attr;
var $$Method = function(m){ return $$Attr('method', m);};
var $$Header = function(h,v) {return $$Attr('headers.' + h, v);};
var $Errors = Middleware(errors);
var Defaults = Middleware(config(cfg, adapter))
.and($Errors)
.and(auth.$Basic)
.and(auth.$Bearer)
.and(auth.$Credentials)
.and(transport.$JsonData)
.and($$Header('Accept', 'application/json'))
.and($$Header('Content-Type', 'application/json'));
var GET = Defaults.and($$Method('GET'));
var POST = Defaults.and($$Method('POST'));
var PUT = Defaults.and($$Method('PUT'));
var DELETE = Defaults.and($$Method('DELETE'));
var http = transport.Http(cfg, adapter);
var Path = url.Path;
var BaseUrl = Path(cfg.baseUrl);
var resourceTypePath = BaseUrl.slash(":type || :resource.resourceType");
var searchPath = resourceTypePath;
var resourceTypeHxPath = resourceTypePath.slash("_history");
var resourcePath = resourceTypePath.slash(":id || :resource.id");
var resourceHxPath = resourcePath.slash("_history");
var vreadPath = resourceHxPath.slash(":versionId || :resource.meta.versionId");
var resourceVersionPath = resourceHxPath.slash(":versionId || :resource.meta.versionId");
var ReturnHeader = $$Header('Prefer', 'return=representation');
var $Paging = Middleware(query.$Paging);
return decorate({
conformance: GET.and(BaseUrl.slash("metadata")).end(http),
document: POST.and(BaseUrl.slash("Document")).end(http),
profile: GET.and(BaseUrl.slash("Profile").slash(":type")).end(http),
transaction: POST.and(BaseUrl).end(http),
history: GET.and(BaseUrl.slash("_history")).and($Paging).end(http),
typeHistory: GET.and(resourceTypeHxPath).and($Paging).end(http),
resourceHistory: GET.and(resourceHxPath).and($Paging).end(http),
read: GET.and(pt.$WithPatient).and(resourcePath).end(http),
vread: GET.and(vreadPath).end(http),
"delete": DELETE.and(resourcePath).and(ReturnHeader).end(http),
create: POST.and(resourceTypePath).and(ReturnHeader).end(http),
validate: POST.and(resourceTypePath.slash("_validate")).end(http),
search: GET.and(resourceTypePath).and(pt.$WithPatient).and(query.$SearchParams).and($Paging).end(http),
update: PUT.and(resourcePath).and(ReturnHeader).end(http),
nextPage: GET.and(bundle.$$BundleLinkUrl("next")).end(http),
prevPage: GET.and(bundle.$$BundleLinkUrl("prev")).end(http),
resolve: GET.and(refs.resolve).end(http)
}, adapter);
};
module.exports = fhir;
}).call(this);
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
(function() {
var merge = __webpack_require__(3);
var RTRIM = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
var trim = function(text) {
return text ? text.toString().replace(RTRIM, "") : "";
};
exports.trim = trim;
var addKey = function(acc, str) {
var pair, val;
if (!str) {
return null;
}
pair = str.split("=").map(trim);
val = pair[1].replace(/(^"|"$)/g, '');
if (val) {
acc[pair[0]] = val;
}
return acc;
};
var type = function(obj) {
var classToType;
if (obj == null && obj === undefined) {
return String(obj);
}
classToType = {
'[object Boolean]': 'boolean',
'[object Number]': 'number',
'[object String]': 'string',
'[object Function]': 'function',
'[object Array]': 'array',
'[object Date]': 'date',
'[object RegExp]': 'regexp',
'[object Object]': 'object'
};
return classToType[Object.prototype.toString.call(obj)];
};
exports.type = type;
var assertArray = function(a) {
if (type(a) !== 'array') {
throw 'not array';
}
return a;
};
exports.assertArray = assertArray;
var assertObject = function(a) {
if (type(a) !== 'object') {
throw 'not object';
}
return a;
};
exports.assertObject = assertObject;
var reduceMap = function(m, fn, acc) {
var k, v;
acc || (acc = []);
assertObject(m);
return ((function() {
var results;
results = [];
for (k in m) {
v = m[k];
results.push([k, v]);
}
return results;
})()).reduce(fn, acc);
};
exports.reduceMap = reduceMap;
var identity = function(x) {return x;};
exports.identity = identity;
var argsArray = function() {
return Array.prototype.slice.call(arguments)
};
exports.argsArray = argsArray;
var mergeLists = function() {
var reduce;
reduce = function(merged, nextMap) {
var k, ret, v;
ret = merge(true, merged);
for (k in nextMap) {
v = nextMap[k];
ret[k] = (ret[k] || []).concat(v);
}
return ret;
};
return argsArray.apply(null, arguments).reduce(reduce, {});
};
exports.mergeLists = mergeLists;
var absoluteUrl = function(baseUrl, ref) {
if (!ref.match(/https?:\/\/./)) {
return baseUrl + "/" + ref;
} else {
return ref;
}
};
exports.absoluteUrl = absoluteUrl;
var relativeUrl = function(baseUrl, ref) {
if (ref.slice(ref, baseUrl.length + 1) === baseUrl + "/") {
return ref.slice(baseUrl.length + 1);
} else {
return ref;
}
};
exports.relativeUrl = relativeUrl;
exports.resourceIdToUrl = function(id, baseUrl, type) {
baseUrl = baseUrl.replace(/\/$/, '');
id = id.replace(/^\//, '');
if (id.indexOf('/') < 0) {
return baseUrl + "/" + type + "/" + id;
} else if (id.indexOf(baseUrl) !== 0) {
return baseUrl + "/" + id;
} else {
return id;
}
};
var walk = function(inner, outer, data, context) {
var keysToMap, remapped;
switch (type(data)) {
case 'array':
return outer(data.map(function(item) {
return inner(item, [data, context]);
}), context);
case 'object':
keysToMap = function(acc, arg) {
var k, v;
k = arg[0], v = arg[1];
acc[k] = inner(v, [data].concat(context));
return acc;
};
remapped = reduceMap(data, keysToMap, {});
return outer(remapped, context);
default:
return outer(data, context);
}
};
exports.walk = walk;
var postwalk = function(f, data, context) {
if (!data) {
return function(data, context) {
return postwalk(f, data, context);
};
} else {
return walk(postwalk(f), f, data, context);
}
};
exports.postwalk = postwalk;
}).call(this);
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module) {/*!
* @name JavaScript/NodeJS Merge v1.1.3
* @author yeikos
* @repository https://github.com/yeikos/js.merge
* Copyright 2014 yeikos - MIT license
* https://raw.github.com/yeikos/js.merge/master/LICENSE
*/
;(function(isNode) {
function merge() {
var items = Array.prototype.slice.call(arguments),
result = items.shift(),
deep = (result === true),
size = items.length,
item, index, key;
if (deep || typeOf(result) !== 'object')
result = {};
for (index=0;index<size;++index)
if (typeOf(item = items[index]) === 'object')
for (key in item)
result[key] = deep ? clone(item[key]) : item[key];
return result;
}
function clone(input) {
var output = input,
type = typeOf(input),
index, size;
if (type === 'array') {
output = [];
size = input.length;
for (index=0;index<size;++index)
output[index] = clone(input[index]);
} else if (type === 'object') {
output = {};
for (index in input)
output[index] = clone(input[index]);
}
return output;
}
function typeOf(input) {
return ({}).toString.call(input).match(/\s([\w]+)/)[1].toLowerCase();
}
if (isNode) {
module.exports = merge;
} else {
window.merge = merge;
}
})(typeof module === 'object' && module && typeof module.exports === 'object' && module.exports);
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)(module)))
/***/ },
/* 4 */
/***/ function(module, exports) {
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
module.children = [];
module.webpackPolyfill = 1;
}
return module;
}
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
(function() {
var utils = __webpack_require__(2);
var id = function(x){return x;};
var constantly = function(x){return function(){return x;};};
var mwComposition = function(mw1, mw2){
return function(h){ return mw1(mw2(h)); };
};
var Middleware = function(mw){
mw.and = function(nmw){
return Middleware(mwComposition(mw, nmw));
};
mw.end = function(h){
return mw(h);
};
return mw;
};
// generate wm from function
exports.$$Simple = function(f){
return function(h){
return function(args){
return h(f(args));
};
};
};
var setAttr = function(args, attr, value){
var path = attr.split('.');
var obj = args;
for(var i = 0; i < (path.length - 1); i++){
var k = path[i];
obj = args[k];
if(!obj){
obj = {};
args[k] = obj;
}
}
obj[path[path.length - 1]] = value;
return args;
};
// generate wm from function
exports.$$Attr = function(attr, fn){
return Middleware(function(h){
return function(args) {
var value = null;
if(utils.type(fn) == 'function'){
value = fn(args);
} else {
value = fn;
}
if(value == null && value == undefined){
return h(args);
}else {
return h(setAttr(args, attr, value));
}
};
});
};
var Attribute = function(attr, fn){
return Middleware(function(h){
return function(args) {
args[attr] = fn(args);
return h(args);
};
});
};
var Method = function(method){
return Attribute('method', constantly(method));
};
exports.Middleware = Middleware;
exports.Attribute = Attribute;
exports.Method = Method;
}).call(this);
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
(function() {
var utils = __webpack_require__(2);
var type = utils.type;
var assertArray = utils.assertArray;
var assertObject = utils.assertObject;
var reduceMap = utils.reduceMap;
var identity = utils.identity;
var OPERATORS = {
$gt: 'gt',
$lt: 'lt',
$lte: 'lte',
$gte: 'gte'
};
var MODIFIERS = {
$asc: ':asc',
$desc: ':desc',
$exact: ':exact',
$missing: ':missing',
$null: ':missing',
$text: ':text'
};
var isOperator = function(v) {
return v.indexOf('$') === 0;
};
var expandParam = function(k, v) {
return reduceMap(v, function(acc, arg) {
var kk, o, res, vv;
kk = arg[0], vv = arg[1];
return acc.concat(kk === '$and' ? assertArray(vv).reduce((function(a, vvv) {
return a.concat(linearizeOne(k, vvv));
}), []) : kk === '$type' ? [] : isOperator(kk) ? (o = {
param: k
}, kk === '$or' ? o.value = vv : (OPERATORS[kk] ? o.operator = OPERATORS[kk] : void 0, MODIFIERS[kk] ? o.modifier = MODIFIERS[kk] : void 0, type(vv) === 'object' && vv.$or ? o.value = vv.$or : o.value = [vv]), [o]) : (v.$type ? res = ":" + v.$type : void 0, linearizeOne("" + k + (res || '') + "." + kk, vv)));
});
};
var handleSort = function(xs) {
var i, len, results, x;
assertArray(xs);
results = [];
for (i = 0, len = xs.length; i < len; i++) {
x = xs[i];
switch (type(x)) {
case 'array':
results.push({
param: '_sort',
value: x[0],
modifier: ":" + x[1]
});
break;
case 'string':
results.push({
param: '_sort',
value: x
});
break;
default:
results.push(void 0);
}
}
return results;
};
var handleInclude = function(includes) {
return reduceMap(includes, function(acc, arg) {
var k, v;
k = arg[0], v = arg[1];
return acc.concat((function() {
switch (type(v)) {
case 'array':
return v.map(function(x) {
return {
param: '_include',
value: k + "." + x
};
});
case 'string':
return [
{
param: '_include',
value: k + "." + v
}
];
}
})());
});
};
var linearizeOne = function(k, v) {
if (k === '$sort') {
return handleSort(v);
} else if (k === '$include') {
return handleInclude(v);
} else {
switch (type(v)) {
case 'object':
return expandParam(k, v);
case 'string':
return [
{
param: k,
value: [v]
}
];
case 'number':
return [
{
param: k,
value: [v]
}
];
case 'array':
return [
{
param: k,
value: [v.join("|")]
}
];
default:
throw "could not linearizeParams " + (type(v));
}
}
};
var linearizeParams = function(query) {
return reduceMap(query, function(acc, arg) {
var k, v;
k = arg[0], v = arg[1];
return acc.concat(linearizeOne(k, v));
});
};
var buildSearchParams = function(query) {
var p, ps;
ps = (function() {
var i, len, ref, results;
ref = linearizeParams(query);
results = [];
for (i = 0, len = ref.length; i < len; i++) {
p = ref[i];
results.push([p.param, p.modifier, '=', p.operator, encodeURIComponent(p.value)].filter(identity).join(''));
}
return results;
})();
return ps.join("&");
};
exports._query = linearizeParams;
exports.query = buildSearchParams;
var mw = __webpack_require__(5);
exports.$SearchParams = mw.$$Attr('url', function(args){
var url = args.url;
if(args.query){
var queryStr = buildSearchParams(args.query);
return url + "?" + queryStr;
}
return url;
});
exports.$Paging = function(h){
return function(args){
var params = args.params || {};
if(args.since){params._since = args.since;}
if(args.count){params._count = args.count;}
args.params = params;
return h(args);
};
};
}).call(this);
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
(function() {
var mw = __webpack_require__(5);
var btoa = __webpack_require__(8).btoa;
exports.$Basic = mw.$$Attr('headers.Authorization', function(args){
if(args.auth && args.auth.user && args.auth.pass){
return "Basic " + btoa(args.auth.user + ":" + args.auth.pass);
}
});
exports.$Bearer = mw.$$Attr('headers.Authorization', function(args){
if(args.auth && args.auth.bearer){
return "Bearer " + args.auth.bearer;
}
});
var credentials;
// this first middleware sets the credentials attribute to empty, so
// adapters cannot use it directly, thus enforcing a valid value to be parsed in.
exports.$Credentials = mw.Middleware(mw.$$Attr('credentials', function(args){
// Assign value for later checking
credentials = args.credentials
// Needs to return non-null and not-undefined
// in order for value to be (un)set
return '';
})).and(mw.$$Attr('credentials', function(args){
// check credentials for valid options, valid for fetch
if(['same-origin', 'include'].indexOf(credentials) > -1 ){
return credentials;
}
}));
}).call(this);
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
;(function () {
var object = true ? exports : this; // #8: web workers
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
function InvalidCharacterError(message) {
this.message = message;
}
InvalidCharacterError.prototype = new Error;
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
// encoder
// [https://gist.github.com/999166] by [https://github.com/nignag]
object.btoa || (
object.btoa = function (input) {
var str = String(input);
for (
// initialize result and counter
var block, charCode, idx = 0, map = chars, output = '';
// if the next str index does not exist:
// change the mapping table to "="
// check if d has no fractional digits
str.charAt(idx | 0) || (map = '=', idx % 1);
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
) {
charCode = str.charCodeAt(idx += 3/4);
if (charCode > 0xFF) {
throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
}
block = block << 8 | charCode;
}
return output;
});
// decoder
// [https://gist.github.com/1020396] by [https://github.com/atk]
object.atob || (
object.atob = function (input) {
var str = String(input).replace(/=+$/, '');
if (str.length % 4 == 1) {
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
}
for (
// initialize result and counters
var bc = 0, bs, buffer, idx = 0, output = '';
// get next character
buffer = str.charAt(idx++);
// character found in table? initialize bit storage and add its ascii value;
~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
// and if not first of each 4 characters,
// convert the first 8 bits to one ascii character
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
) {
// try to find character in table (0-63, not found => -1)
buffer = chars.indexOf(buffer);
}
return output;
});
}());
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
(function() {
var utils = __webpack_require__(2);
exports.Http = function(cfg, adapter){
return function(args){
if(args.debug){
console.log("\nDEBUG (request):", args.method, args.url, args);
}
var promise = (args.http || adapter.http || cfg.http)(args);
if (args.debug && promise && promise.then){
promise.then(function(x){ console.log("\nDEBUG: (responce)", x);});
}
return promise;
};
};
var toJson = function(x){
return (utils.type(x) == 'object') ? JSON.stringify(x) : x;
};
exports.$JsonData = function(h){
return function(args){
var data = args.bundle || args.data || args.resource;
if(data){
args.data = toJson(data);
}
return h(args);
};
};
}).call(this);
/***/ },
/* 10 */
/***/ function(module, exports) {
module.exports = function(h){
return function(args){
try{
return h(args);
}catch(e){
if(args.debug){
console.log("\nDEBUG: (ERROR in middleware)");
console.log(e.message);
console.log(e.stack);
}
if(!args.defer) {
console.log("\nDEBUG: (ERROR in middleware)");
console.log(e.message);
console.log(e.stack);
throw new Error("I need adapter.defer");
}
var deff = args.defer();
deff.reject(e);
return deff.promise;
}
};
};
/***/ },
/* 11 */
/***/ function(module, exports) {
(function() {
var copyAttr = function(from, to, attr){
var v = from[attr];
if(v && !to[attr]) {to[attr] = v;}
return from;
};
module.exports = function(cfg, adapter){
return function(h){
return function(args){
copyAttr(cfg, args, 'baseUrl');
copyAttr(cfg, args, 'cache');
copyAttr(cfg, args, 'auth');
copyAttr(cfg, args, 'patient');
copyAttr(cfg, args, 'debug');
copyAttr(adapter, args, 'defer');
copyAttr(adapter, args, 'http');
return h(args);
};
};
};
}).call(this);
/***/ },
/* 12 */
/***/ function(module, exports) {
exports.$$BundleLinkUrl = function(rel){
return function(h) {
return function(args){
var matched = function(x){return x.relation && x.relation === rel;};
var res = args.bundle && (args.bundle.link || []).filter(matched)[0];
if(res && res.url){
args.url = res.url;
args.data = null;
return h(args);
}
else{
throw new Error("No " + rel + " link found in bundle");
}
};
};
};
/***/ },
/* 13 */
/***/ function(module, exports, __webpack_require__) {
(function() {
var mw = __webpack_require__(5);
// List of resources with 'patient' or 'subject' properties (as of FHIR DSTU2 1.0.0)
var targets = [
"Account",
"AllergyIntolerance",
"BodySite",
"CarePlan",
"Claim",
"ClinicalImpression",
"Communication",
"CommunicationRequest",
"Composition",
"Condition",
"Contract",
"DetectedIssue",
"Device",
"DeviceUseRequest",
"DeviceUseStatement",
"DiagnosticOrder",
"DiagnosticReport",
"DocumentManifest",
"DocumentReference",
"Encounter",
"EnrollmentRequest",
"EpisodeOfCare",
"FamilyMemberHistory",
"Flag",
"Goal",
"ImagingObjectSelection",
"ImagingStudy",
"Immunization",
"ImmunizationRecommendation",
"List",