@medplum/agent 2.1.12 → 2.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +61 -48
- package/installer.nsi +33 -29
- package/package.json +7 -5
- package/src/main.ts +17 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -3675,7 +3675,7 @@ function hn(r4) {
|
|
|
3675
3675
|
function yn(r4) {
|
|
3676
3676
|
let e = r4.name;
|
|
3677
3677
|
if (e && e.length > 0)
|
|
3678
|
-
return
|
|
3678
|
+
return be(e[0]);
|
|
3679
3679
|
}
|
|
3680
3680
|
function gn(r4) {
|
|
3681
3681
|
let e = r4.deviceName;
|
|
@@ -3698,12 +3698,12 @@ function zt(r4, e) {
|
|
|
3698
3698
|
return JSON.stringify(r4, xn, e ? 2 : void 0);
|
|
3699
3699
|
}
|
|
3700
3700
|
function xn(r4, e) {
|
|
3701
|
-
return !Tn(r4) &&
|
|
3701
|
+
return !Tn(r4) && S(e) ? void 0 : e;
|
|
3702
3702
|
}
|
|
3703
3703
|
function Tn(r4) {
|
|
3704
3704
|
return !!/\d+$/.exec(r4);
|
|
3705
3705
|
}
|
|
3706
|
-
function
|
|
3706
|
+
function S(r4) {
|
|
3707
3707
|
if (r4 == null)
|
|
3708
3708
|
return true;
|
|
3709
3709
|
let e = typeof r4;
|
|
@@ -3733,7 +3733,7 @@ function P(r4) {
|
|
|
3733
3733
|
var ot = (r4) => new Promise((e) => {
|
|
3734
3734
|
setTimeout(e, r4);
|
|
3735
3735
|
});
|
|
3736
|
-
function
|
|
3736
|
+
function be(r4, e) {
|
|
3737
3737
|
let t = [];
|
|
3738
3738
|
return r4.prefix && e?.prefix !== false && t.push(...r4.prefix), r4.given && t.push(...r4.given), r4.family && t.push(r4.family), r4.suffix && e?.suffix !== false && t.push(...r4.suffix), r4.use && (e?.all || e?.use) && t.push("[" + r4.use + "]"), t.length === 0 && r4.text ? r4.text : t.join(" ").trim();
|
|
3739
3739
|
}
|
|
@@ -3752,7 +3752,7 @@ function l(r4) {
|
|
|
3752
3752
|
return [{ type: u.boolean, value: r4 }];
|
|
3753
3753
|
}
|
|
3754
3754
|
function T(r4) {
|
|
3755
|
-
return r4 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r4) ? { type: u.integer, value: r4 } : typeof r4 == "number" ? { type: u.decimal, value: r4 } : typeof r4 == "boolean" ? { type: u.boolean, value: r4 } : typeof r4 == "string" ? { type: u.string, value: r4 } :
|
|
3755
|
+
return r4 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r4) ? { type: u.integer, value: r4 } : typeof r4 == "number" ? { type: u.decimal, value: r4 } : typeof r4 == "boolean" ? { type: u.boolean, value: r4 } : typeof r4 == "string" ? { type: u.string, value: r4 } : R(r4) ? { type: u.Quantity, value: r4 } : N(r4) ? { type: r4.resourceType, value: r4 } : { type: u.BackboneElement, value: r4 };
|
|
3756
3756
|
}
|
|
3757
3757
|
function L(r4) {
|
|
3758
3758
|
return r4.length === 0 ? false : !!r4[0].value;
|
|
@@ -3786,7 +3786,7 @@ function $n(r4, e, t) {
|
|
|
3786
3786
|
}
|
|
3787
3787
|
}
|
|
3788
3788
|
let s = r4.value["_" + e];
|
|
3789
|
-
if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? cr(a ?? {}, s[c2]) : a) : i2 = cr(i2 ?? {}, s)), !
|
|
3789
|
+
if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? cr(a ?? {}, s[c2]) : a) : i2 = cr(i2 ?? {}, s)), !S(i2))
|
|
3790
3790
|
return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => or(a, o)) : or(i2, o);
|
|
3791
3791
|
}
|
|
3792
3792
|
function or(r4, e) {
|
|
@@ -3807,7 +3807,7 @@ function jn(r4, e) {
|
|
|
3807
3807
|
break;
|
|
3808
3808
|
}
|
|
3809
3809
|
}
|
|
3810
|
-
if (!
|
|
3810
|
+
if (!S(n))
|
|
3811
3811
|
return Array.isArray(n) ? n.map(T) : T(n);
|
|
3812
3812
|
}
|
|
3813
3813
|
function Pe(r4) {
|
|
@@ -3831,14 +3831,14 @@ function ut(r4, e) {
|
|
|
3831
3831
|
}
|
|
3832
3832
|
function ur(r4, e) {
|
|
3833
3833
|
let t = r4.value?.valueOf(), n = e.value?.valueOf();
|
|
3834
|
-
return typeof t == "number" && typeof n == "number" ? l(Math.abs(t - n) < 1e-8) :
|
|
3834
|
+
return typeof t == "number" && typeof n == "number" ? l(Math.abs(t - n) < 1e-8) : R(t) && R(n) ? l(lr(t, n)) : l(typeof t == "object" && typeof n == "object" ? dt(r4, e) : t === n);
|
|
3835
3835
|
}
|
|
3836
3836
|
function lt(r4, e) {
|
|
3837
3837
|
return r4.length === 0 && e.length === 0 ? l(true) : r4.length !== e.length ? l(false) : (r4.sort(sr), e.sort(sr), l(r4.every((t, n) => L(Qn(t, e[n])))));
|
|
3838
3838
|
}
|
|
3839
3839
|
function Qn(r4, e) {
|
|
3840
3840
|
let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
|
|
3841
|
-
return typeof s == "number" && typeof a == "number" ? l(Math.abs(s - a) < 0.01) :
|
|
3841
|
+
return typeof s == "number" && typeof a == "number" ? l(Math.abs(s - a) < 0.01) : R(s) && R(a) ? l(lr(s, a)) : l(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? dt({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
|
|
3842
3842
|
}
|
|
3843
3843
|
function sr(r4, e) {
|
|
3844
3844
|
let t = r4.value?.valueOf(), n = e.value?.valueOf();
|
|
@@ -3863,7 +3863,7 @@ function Ae(r4, e) {
|
|
|
3863
3863
|
case "Period":
|
|
3864
3864
|
return Hn(t);
|
|
3865
3865
|
case "Quantity":
|
|
3866
|
-
return
|
|
3866
|
+
return R(t);
|
|
3867
3867
|
default:
|
|
3868
3868
|
return typeof t == "object" && t?.resourceType === e;
|
|
3869
3869
|
}
|
|
@@ -3871,7 +3871,7 @@ function Ae(r4, e) {
|
|
|
3871
3871
|
function Hn(r4) {
|
|
3872
3872
|
return !!(r4 && typeof r4 == "object" && "start" in r4);
|
|
3873
3873
|
}
|
|
3874
|
-
function
|
|
3874
|
+
function R(r4) {
|
|
3875
3875
|
return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
|
|
3876
3876
|
}
|
|
3877
3877
|
function lr(r4, e) {
|
|
@@ -3935,11 +3935,11 @@ function Wn(r4) {
|
|
|
3935
3935
|
let e;
|
|
3936
3936
|
return r4.details?.text ? r4.diagnostics ? e = `${r4.details.text} (${r4.diagnostics})` : e = r4.details.text : r4.diagnostics ? e = r4.diagnostics : e = "Unknown error", r4.expression?.length && (e += ` (${r4.expression.join(", ")})`), e;
|
|
3937
3937
|
}
|
|
3938
|
-
function
|
|
3938
|
+
function Et(r4) {
|
|
3939
3939
|
return new Tt(r4).parse();
|
|
3940
3940
|
}
|
|
3941
3941
|
var Q = nr(ir);
|
|
3942
|
-
function
|
|
3942
|
+
function Sr(r4) {
|
|
3943
3943
|
let e = Array.isArray(r4) ? r4 : r4.entry?.map((t) => t.resource) ?? [];
|
|
3944
3944
|
for (let t of e)
|
|
3945
3945
|
Gn(t);
|
|
@@ -3949,12 +3949,12 @@ function Gn(r4) {
|
|
|
3949
3949
|
throw new Error("Failed loading StructureDefinition from bundle");
|
|
3950
3950
|
if (r4.resourceType !== "StructureDefinition")
|
|
3951
3951
|
return;
|
|
3952
|
-
let e =
|
|
3952
|
+
let e = Et(r4);
|
|
3953
3953
|
Q[r4.name] = e;
|
|
3954
3954
|
for (let t of e.innerTypes)
|
|
3955
3955
|
t.parentType = e, Q[t.name] = t;
|
|
3956
3956
|
}
|
|
3957
|
-
function
|
|
3957
|
+
function br(r4) {
|
|
3958
3958
|
return !!Q[r4];
|
|
3959
3959
|
}
|
|
3960
3960
|
function Pr(r4) {
|
|
@@ -4048,7 +4048,7 @@ var Tt = class {
|
|
|
4048
4048
|
}
|
|
4049
4049
|
parseElementDefinition(e) {
|
|
4050
4050
|
let t = vr(e.max), n = e.base?.max ? vr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
|
|
4051
|
-
return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? vt(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed:
|
|
4051
|
+
return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? vt(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: Er(I(i2, "fixed")), pattern: Er(I(i2, "pattern")), binding: e.binding };
|
|
4052
4052
|
}
|
|
4053
4053
|
};
|
|
4054
4054
|
function vr(r4) {
|
|
@@ -4063,8 +4063,8 @@ function Jn(r4, e) {
|
|
|
4063
4063
|
function ee(r4, e) {
|
|
4064
4064
|
return !r4 || !e ? false : e.startsWith(r4 + ".") || e === r4;
|
|
4065
4065
|
}
|
|
4066
|
-
function
|
|
4067
|
-
return Array.isArray(r4) && r4.length > 0 ? r4[0] :
|
|
4066
|
+
function Er(r4) {
|
|
4067
|
+
return Array.isArray(r4) && r4.length > 0 ? r4[0] : S(r4) ? void 0 : r4;
|
|
4068
4068
|
}
|
|
4069
4069
|
function Yn(r4) {
|
|
4070
4070
|
let e = r4.slicing?.discriminator;
|
|
@@ -4075,7 +4075,7 @@ function Xn(r4) {
|
|
|
4075
4075
|
return e?.startsWith(`Base StructureDefinition for ${r4.name} Type: `) && (e = e.substring(`Base StructureDefinition for ${r4.name} Type: `.length)), e;
|
|
4076
4076
|
}
|
|
4077
4077
|
var u = { Address: "Address", Age: "Age", Annotation: "Annotation", Attachment: "Attachment", BackboneElement: "BackboneElement", CodeableConcept: "CodeableConcept", Coding: "Coding", ContactDetail: "ContactDetail", ContactPoint: "ContactPoint", Contributor: "Contributor", Count: "Count", DataRequirement: "DataRequirement", Distance: "Distance", Dosage: "Dosage", Duration: "Duration", Expression: "Expression", Extension: "Extension", HumanName: "HumanName", Identifier: "Identifier", MarketingStatus: "MarketingStatus", Meta: "Meta", Money: "Money", Narrative: "Narrative", ParameterDefinition: "ParameterDefinition", Period: "Period", Population: "Population", ProdCharacteristic: "ProdCharacteristic", ProductShelfLife: "ProductShelfLife", Quantity: "Quantity", Range: "Range", Ratio: "Ratio", Reference: "Reference", RelatedArtifact: "RelatedArtifact", SampledData: "SampledData", Signature: "Signature", SubstanceAmount: "SubstanceAmount", SystemString: "http://hl7.org/fhirpath/System.String", Timing: "Timing", TriggerDefinition: "TriggerDefinition", UsageContext: "UsageContext", base64Binary: "base64Binary", boolean: "boolean", canonical: "canonical", code: "code", date: "date", dateTime: "dateTime", decimal: "decimal", id: "id", instant: "instant", integer: "integer", markdown: "markdown", oid: "oid", positiveInt: "positiveInt", string: "string", time: "time", unsignedInt: "unsignedInt", uri: "uri", url: "url", uuid: "uuid" };
|
|
4078
|
-
function
|
|
4078
|
+
function Rt(r4) {
|
|
4079
4079
|
for (let e of r4.base ?? []) {
|
|
4080
4080
|
let t = k.types[e];
|
|
4081
4081
|
t || (t = { searchParamsDetails: {} }, k.types[e] = t), t.searchParams || (t.searchParams = { _id: { base: [e], code: "_id", type: "token", expression: e + ".id" }, _lastUpdated: { base: [e], code: "_lastUpdated", type: "date", expression: e + ".meta.lastUpdated" }, _compartment: { base: [e], code: "_compartment", type: "reference", expression: e + ".meta.compartment" }, _profile: { base: [e], code: "_profile", type: "uri", expression: e + ".meta.profile" }, _security: { base: [e], code: "_security", type: "token", expression: e + ".meta.security" }, _source: { base: [e], code: "_source", type: "uri", expression: e + ".meta.source" }, _tag: { base: [e], code: "_tag", type: "token", expression: e + ".meta.tag" } }), t.searchParams[r4.code] = r4;
|
|
@@ -4112,7 +4112,7 @@ function re(r4) {
|
|
|
4112
4112
|
}
|
|
4113
4113
|
}
|
|
4114
4114
|
var ce = () => [];
|
|
4115
|
-
var
|
|
4115
|
+
var E = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.filter((n) => L(t.eval(r4, [n]))).length > 0) : l(e.length > 0), all: (r4, e, t) => l(e.every((n) => L(t.eval(r4, [n])))), allTrue: (r4, e) => {
|
|
4116
4116
|
for (let t of e)
|
|
4117
4117
|
if (!t.value)
|
|
4118
4118
|
return l(false);
|
|
@@ -4137,7 +4137,7 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
|
|
|
4137
4137
|
for (let n of e)
|
|
4138
4138
|
t.some((i2) => i2.value === n.value) || t.push(n);
|
|
4139
4139
|
return t;
|
|
4140
|
-
}, isDistinct: (r4, e) => l(e.length ===
|
|
4140
|
+
}, isDistinct: (r4, e) => l(e.length === E.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => L(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: ce, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
|
|
4141
4141
|
if (e.length > 1)
|
|
4142
4142
|
throw new Error("Expected input length one for single()");
|
|
4143
4143
|
return e.length === 0 ? [] : e.slice(0, 1);
|
|
@@ -4196,37 +4196,37 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
|
|
|
4196
4196
|
return l(false);
|
|
4197
4197
|
}
|
|
4198
4198
|
return [];
|
|
4199
|
-
}, convertsToBoolean: (r4, e) => e.length === 0 ? [] : l(
|
|
4199
|
+
}, convertsToBoolean: (r4, e) => e.length === 0 ? [] : l(E.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
|
|
4200
4200
|
if (e.length === 0)
|
|
4201
4201
|
return [];
|
|
4202
4202
|
let [{ value: t }] = U(e, 1);
|
|
4203
4203
|
return typeof t == "number" ? [{ type: u.integer, value: t }] : typeof t == "string" && /^[+-]?\d+$/.exec(t) ? [{ type: u.integer, value: parseInt(t, 10) }] : typeof t == "boolean" ? [{ type: u.integer, value: t ? 1 : 0 }] : [];
|
|
4204
|
-
}, convertsToInteger: (r4, e) => e.length === 0 ? [] : l(
|
|
4204
|
+
}, convertsToInteger: (r4, e) => e.length === 0 ? [] : l(E.toInteger(r4, e).length === 1), toDate: (r4, e) => {
|
|
4205
4205
|
if (e.length === 0)
|
|
4206
4206
|
return [];
|
|
4207
4207
|
let [{ value: t }] = U(e, 1);
|
|
4208
4208
|
return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.date, value: re(t) }] : [];
|
|
4209
|
-
}, convertsToDate: (r4, e) => e.length === 0 ? [] : l(
|
|
4209
|
+
}, convertsToDate: (r4, e) => e.length === 0 ? [] : l(E.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
|
|
4210
4210
|
if (e.length === 0)
|
|
4211
4211
|
return [];
|
|
4212
4212
|
let [{ value: t }] = U(e, 1);
|
|
4213
4213
|
return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.dateTime, value: re(t) }] : [];
|
|
4214
|
-
}, convertsToDateTime: (r4, e) => e.length === 0 ? [] : l(
|
|
4214
|
+
}, convertsToDateTime: (r4, e) => e.length === 0 ? [] : l(E.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
|
|
4215
4215
|
if (e.length === 0)
|
|
4216
4216
|
return [];
|
|
4217
4217
|
let [{ value: t }] = U(e, 1);
|
|
4218
4218
|
return typeof t == "number" ? [{ type: u.decimal, value: t }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?$/.exec(t) ? [{ type: u.decimal, value: parseFloat(t) }] : typeof t == "boolean" ? [{ type: u.decimal, value: t ? 1 : 0 }] : [];
|
|
4219
|
-
}, convertsToDecimal: (r4, e) => e.length === 0 ? [] : l(
|
|
4219
|
+
}, convertsToDecimal: (r4, e) => e.length === 0 ? [] : l(E.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
|
|
4220
4220
|
if (e.length === 0)
|
|
4221
4221
|
return [];
|
|
4222
4222
|
let [{ value: t }] = U(e, 1);
|
|
4223
|
-
return
|
|
4224
|
-
}, convertsToQuantity: (r4, e) => e.length === 0 ? [] : l(
|
|
4223
|
+
return R(t) ? [{ type: u.Quantity, value: t }] : typeof t == "number" ? [{ type: u.Quantity, value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: u.Quantity, value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: u.Quantity, value: { value: t ? 1 : 0, unit: "1" } }] : [];
|
|
4224
|
+
}, convertsToQuantity: (r4, e) => e.length === 0 ? [] : l(E.toQuantity(r4, e).length === 1), toString: (r4, e) => {
|
|
4225
4225
|
if (e.length === 0)
|
|
4226
4226
|
return [];
|
|
4227
4227
|
let [{ value: t }] = U(e, 1);
|
|
4228
|
-
return t == null ? [] :
|
|
4229
|
-
}, convertsToString: (r4, e) => e.length === 0 ? [] : l(
|
|
4228
|
+
return t == null ? [] : R(t) ? [{ type: u.string, value: `${t.value} '${t.unit}'` }] : [{ type: u.string, value: t.toString() }];
|
|
4229
|
+
}, convertsToString: (r4, e) => e.length === 0 ? [] : l(E.toString(r4, e).length === 1), toTime: (r4, e) => {
|
|
4230
4230
|
if (e.length === 0)
|
|
4231
4231
|
return [];
|
|
4232
4232
|
let [{ value: t }] = U(e, 1);
|
|
@@ -4236,14 +4236,14 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
|
|
|
4236
4236
|
return [{ type: u.time, value: re("T" + n[1]) }];
|
|
4237
4237
|
}
|
|
4238
4238
|
return [];
|
|
4239
|
-
}, convertsToTime: (r4, e) => e.length === 0 ? [] : l(
|
|
4239
|
+
}, convertsToTime: (r4, e) => e.length === 0 ? [] : l(E.toTime(r4, e).length === 1), indexOf: (r4, e, t) => A((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => A((i2, o, s) => {
|
|
4240
4240
|
let a = o, c2 = s ? a + s : i2.length;
|
|
4241
4241
|
return a < 0 || a >= i2.length ? void 0 : i2.substring(a, c2);
|
|
4242
4242
|
}, r4, e, t, n), startsWith: (r4, e, t) => A((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => A((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => A((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => A((t) => t.toUpperCase(), r4, e), lower: (r4, e) => A((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => A((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => A((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => A((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => A((t) => t.length, r4, e), toChars: (r4, e) => A((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => _(Math.abs, r4, e), ceiling: (r4, e) => _(Math.ceil, r4, e), exp: (r4, e) => _(Math.exp, r4, e), floor: (r4, e) => _(Math.floor, r4, e), ln: (r4, e) => _(Math.log, r4, e), log: (r4, e, t) => _((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => _(Math.pow, r4, e, t), round: (r4, e) => _(Math.round, r4, e), sqrt: (r4, e) => _(Math.sqrt, r4, e), truncate: (r4, e) => _((t) => t | 0, r4, e), children: ce, descendants: ce, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: u.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: u.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: u.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
|
|
4243
|
-
let o =
|
|
4243
|
+
let o = E.toDateTime(r4, t.eval(r4, e));
|
|
4244
4244
|
if (o.length === 0)
|
|
4245
4245
|
throw new Error("Invalid start date");
|
|
4246
|
-
let s =
|
|
4246
|
+
let s = E.toDateTime(r4, n.eval(r4, e));
|
|
4247
4247
|
if (s.length === 0)
|
|
4248
4248
|
throw new Error("Invalid end date");
|
|
4249
4249
|
let a = i2.eval(r4, e)[0]?.value;
|
|
@@ -4254,7 +4254,7 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
|
|
|
4254
4254
|
}, is: (r4, e, t) => {
|
|
4255
4255
|
let n = "";
|
|
4256
4256
|
return t instanceof M ? n = t.name : t instanceof H && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: u.boolean, value: Ae(i2, n) })) : [];
|
|
4257
|
-
}, not: (r4, e) =>
|
|
4257
|
+
}, not: (r4, e) => E.toBoolean(r4, e).map((t) => ({ type: u.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
|
|
4258
4258
|
let n = t.value, i2;
|
|
4259
4259
|
if (typeof n == "string")
|
|
4260
4260
|
i2 = n;
|
|
@@ -4292,7 +4292,7 @@ function A(r4, e, t, ...n) {
|
|
|
4292
4292
|
function _(r4, e, t, ...n) {
|
|
4293
4293
|
if (t.length === 0)
|
|
4294
4294
|
return [];
|
|
4295
|
-
let [{ value: i2 }] = U(t, 1), o =
|
|
4295
|
+
let [{ value: i2 }] = U(t, 1), o = R(i2), s = o ? i2.value : i2;
|
|
4296
4296
|
if (typeof s != "number")
|
|
4297
4297
|
throw new Error("Math function cannot be called with non-number");
|
|
4298
4298
|
let a = r4(s, ...n.map((p2) => p2.eval(e, t)[0]?.value)), c2 = o ? u.Quantity : t[0].type, f = o ? { ...i2, value: a } : a;
|
|
@@ -4367,12 +4367,12 @@ var J = class extends $ {
|
|
|
4367
4367
|
super("as", e, t);
|
|
4368
4368
|
}
|
|
4369
4369
|
eval(e, t) {
|
|
4370
|
-
return
|
|
4370
|
+
return E.ofType(e, this.left.eval(e, t), this.right);
|
|
4371
4371
|
}
|
|
4372
4372
|
};
|
|
4373
4373
|
var v = class extends $ {
|
|
4374
4374
|
};
|
|
4375
|
-
var
|
|
4375
|
+
var b = class extends v {
|
|
4376
4376
|
constructor(t, n, i2, o) {
|
|
4377
4377
|
super(t, n, i2);
|
|
4378
4378
|
this.impl = o;
|
|
@@ -4384,8 +4384,8 @@ var R = class extends v {
|
|
|
4384
4384
|
let o = this.right.eval(t, n);
|
|
4385
4385
|
if (o.length !== 1)
|
|
4386
4386
|
return [];
|
|
4387
|
-
let s = i2[0].value, a = o[0].value, c2 =
|
|
4388
|
-
return typeof p2 == "boolean" ? l(p2) :
|
|
4387
|
+
let s = i2[0].value, a = o[0].value, c2 = R(s) ? s.value : s, f = R(a) ? a.value : a, p2 = this.impl(c2, f);
|
|
4388
|
+
return typeof p2 == "boolean" ? l(p2) : R(s) ? [{ type: u.Quantity, value: { ...s, value: p2 } }] : [T(p2)];
|
|
4389
4389
|
}
|
|
4390
4390
|
};
|
|
4391
4391
|
var Fe = class extends $ {
|
|
@@ -4525,7 +4525,7 @@ var B = class {
|
|
|
4525
4525
|
this.args = t;
|
|
4526
4526
|
}
|
|
4527
4527
|
eval(e, t) {
|
|
4528
|
-
let n =
|
|
4528
|
+
let n = E[this.name];
|
|
4529
4529
|
if (!n)
|
|
4530
4530
|
throw new Error("Unrecognized function: " + this.name);
|
|
4531
4531
|
return n(e, t, ...this.args);
|
|
@@ -4580,7 +4580,7 @@ function ai(r4) {
|
|
|
4580
4580
|
return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
|
|
4581
4581
|
}
|
|
4582
4582
|
function de() {
|
|
4583
|
-
return new xe().registerPrefix("String", { parse: (r4, e) => new O({ type: u.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new O({ type: u.dateTime, value: re(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new O({ type: u.Quantity, value: ai(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new O({ type: u.decimal, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new O({ type: u.boolean, value: true }) }).registerPrefix("false", { parse: () => new O({ type: u.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new M(e.value) }).registerPrefix("{}", { parse: () => new De() }).registerPrefix("(", ii).registerInfix("[", oi).registerInfix("(", si).prefix("+", m.UnaryAdd, (r4, e) => new Ne("+", e, (t) => t)).prefix("-", m.UnarySubtract, (r4, e) => new
|
|
4583
|
+
return new xe().registerPrefix("String", { parse: (r4, e) => new O({ type: u.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new O({ type: u.dateTime, value: re(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new O({ type: u.Quantity, value: ai(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new O({ type: u.decimal, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new O({ type: u.boolean, value: true }) }).registerPrefix("false", { parse: () => new O({ type: u.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new M(e.value) }).registerPrefix("{}", { parse: () => new De() }).registerPrefix("(", ii).registerInfix("[", oi).registerInfix("(", si).prefix("+", m.UnaryAdd, (r4, e) => new Ne("+", e, (t) => t)).prefix("-", m.UnarySubtract, (r4, e) => new b("-", e, e, (t, n) => -n)).infixLeft(".", m.Dot, (r4, e, t) => new H(r4, t)).infixLeft("/", m.Divide, (r4, e, t) => new b("/", r4, t, (n, i2) => n / i2)).infixLeft("*", m.Multiply, (r4, e, t) => new b("*", r4, t, (n, i2) => n * i2)).infixLeft("+", m.Add, (r4, e, t) => new b("+", r4, t, (n, i2) => n + i2)).infixLeft("-", m.Subtract, (r4, e, t) => new b("-", r4, t, (n, i2) => n - i2)).infixLeft("|", m.Union, (r4, e, t) => new ne(r4, t)).infixLeft("=", m.Equals, (r4, e, t) => new Le(r4, t)).infixLeft("!=", m.NotEquals, (r4, e, t) => new Me(r4, t)).infixLeft("~", m.Equivalent, (r4, e, t) => new Be(r4, t)).infixLeft("!~", m.NotEquivalent, (r4, e, t) => new qe(r4, t)).infixLeft("<", m.LessThan, (r4, e, t) => new b("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", m.LessThanOrEquals, (r4, e, t) => new b("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", m.GreaterThan, (r4, e, t) => new b(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", m.GreaterThanOrEquals, (r4, e, t) => new b(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", m.Ampersand, (r4, e, t) => new Fe(r4, t)).infixLeft("and", m.And, (r4, e, t) => new $e(r4, t)).infixLeft("as", m.As, (r4, e, t) => new J(r4, t)).infixLeft("contains", m.Contains, (r4, e, t) => new _e(r4, t)).infixLeft("div", m.Divide, (r4, e, t) => new b("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", m.In, (r4, e, t) => new Ue(r4, t)).infixLeft("is", m.Is, (r4, e, t) => new Y(r4, t)).infixLeft("mod", m.Modulo, (r4, e, t) => new b("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", m.Or, (r4, e, t) => new je(r4, t)).infixLeft("xor", m.Xor, (r4, e, t) => new Qe(r4, t)).infixLeft("implies", m.Implies, (r4, e, t) => new He(r4, t));
|
|
4584
4584
|
}
|
|
4585
4585
|
var ci = de();
|
|
4586
4586
|
var kr = ((p2) => (p2.BOOLEAN = "BOOLEAN", p2.NUMBER = "NUMBER", p2.QUANTITY = "QUANTITY", p2.TEXT = "TEXT", p2.REFERENCE = "REFERENCE", p2.CANONICAL = "CANONICAL", p2.DATE = "DATE", p2.DATETIME = "DATETIME", p2.PERIOD = "PERIOD", p2.UUID = "UUID", p2))(kr || {});
|
|
@@ -5095,7 +5095,7 @@ var en = class extends he {
|
|
|
5095
5095
|
return !o || !s ? new w(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
|
|
5096
5096
|
}
|
|
5097
5097
|
requestSchema(t) {
|
|
5098
|
-
if (
|
|
5098
|
+
if (br(t))
|
|
5099
5099
|
return Promise.resolve();
|
|
5100
5100
|
let n = t + "-requestSchema", i2 = this.getCacheEntry(n, void 0);
|
|
5101
5101
|
if (i2)
|
|
@@ -5139,9 +5139,9 @@ var en = class extends he {
|
|
|
5139
5139
|
target
|
|
5140
5140
|
}
|
|
5141
5141
|
}`.replace(/\s+/g, " "), a = await this.graphql(s);
|
|
5142
|
-
|
|
5142
|
+
Sr(a.data.StructureDefinitionList);
|
|
5143
5143
|
for (let c2 of a.data.SearchParameterList)
|
|
5144
|
-
|
|
5144
|
+
Rt(c2);
|
|
5145
5145
|
})());
|
|
5146
5146
|
return this.setCacheEntry(n, o), o;
|
|
5147
5147
|
}
|
|
@@ -5497,6 +5497,9 @@ var en = class extends he {
|
|
|
5497
5497
|
async fhircastPublish(t, n, i2, o) {
|
|
5498
5498
|
return Wr(n) ? this.post(`/fhircast/STU3/${t}`, Ft(t, n, i2, o), C.JSON) : (Gr(n), this.post(`/fhircast/STU3/${t}`, Ft(t, n, i2), C.JSON));
|
|
5499
5499
|
}
|
|
5500
|
+
async fhircastGetContext(t) {
|
|
5501
|
+
return this.get(`/fhircast/STU3/${t}`);
|
|
5502
|
+
}
|
|
5500
5503
|
async invite(t, n) {
|
|
5501
5504
|
return this.post("admin/projects/" + t + "/invite", n);
|
|
5502
5505
|
}
|
|
@@ -5962,14 +5965,24 @@ var AgentHl7ChannelConnection = class {
|
|
|
5962
5965
|
this.hl7Connection.close();
|
|
5963
5966
|
}
|
|
5964
5967
|
};
|
|
5965
|
-
|
|
5966
|
-
if (
|
|
5968
|
+
async function main(argv) {
|
|
5969
|
+
if (argv.length < 6) {
|
|
5967
5970
|
console.log("Usage: node medplum-agent.js <baseUrl> <clientId> <clientSecret> <agentId>");
|
|
5968
5971
|
process.exit(1);
|
|
5969
5972
|
}
|
|
5970
|
-
const [_node, _script, baseUrl, clientId, clientSecret, agentId] =
|
|
5973
|
+
const [_node, _script, baseUrl, clientId, clientSecret, agentId] = argv;
|
|
5971
5974
|
const medplum = new en({ baseUrl, clientId });
|
|
5972
|
-
medplum.startClientLogin(clientId, clientSecret)
|
|
5975
|
+
await medplum.startClientLogin(clientId, clientSecret);
|
|
5976
|
+
const app = new App(medplum, agentId);
|
|
5977
|
+
await app.start();
|
|
5978
|
+
process.on("SIGINT", () => {
|
|
5979
|
+
console.log("\ngracefully shutting down from SIGINT (Crtl-C)");
|
|
5980
|
+
app.stop();
|
|
5981
|
+
process.exit();
|
|
5982
|
+
});
|
|
5983
|
+
}
|
|
5984
|
+
if (typeof require !== "undefined" && require.main === module) {
|
|
5985
|
+
main(process.argv).catch(console.error);
|
|
5973
5986
|
}
|
|
5974
5987
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5975
5988
|
0 && (module.exports = {
|
package/installer.nsi
CHANGED
|
@@ -39,7 +39,8 @@ Var agentId
|
|
|
39
39
|
# The onInit handler is called when the installer is nearly finished initializing.
|
|
40
40
|
# See: https://nsis.sourceforge.io/Reference/.onInit
|
|
41
41
|
Function .onInit
|
|
42
|
-
$
|
|
42
|
+
ReadRegStr $0 HKLM "SYSTEM\CurrentControlSet\Services\${SERVICE_NAME}" "ImagePath"
|
|
43
|
+
${If} $0 != ""
|
|
43
44
|
StrCpy $alreadyInstalled 1
|
|
44
45
|
${EndIf}
|
|
45
46
|
FunctionEnd
|
|
@@ -124,8 +125,8 @@ Function UpgradeApp
|
|
|
124
125
|
|
|
125
126
|
# Stop the service
|
|
126
127
|
DetailPrint "Stopping service..."
|
|
127
|
-
ExecWait "
|
|
128
|
-
DetailPrint "
|
|
128
|
+
ExecWait "sc.exe stop ${SERVICE_NAME}" $1
|
|
129
|
+
DetailPrint "Exit code $1"
|
|
129
130
|
|
|
130
131
|
# Sleep for 3 seconds to let the service fully stop
|
|
131
132
|
# We cannot write the new version of the exe while the process is running
|
|
@@ -138,7 +139,7 @@ Function UpgradeApp
|
|
|
138
139
|
|
|
139
140
|
# Start the service
|
|
140
141
|
DetailPrint "Starting service..."
|
|
141
|
-
ExecWait "
|
|
142
|
+
ExecWait "sc.exe start ${SERVICE_NAME}" $1
|
|
142
143
|
DetailPrint "Start service returned $1"
|
|
143
144
|
|
|
144
145
|
FunctionEnd
|
|
@@ -154,32 +155,25 @@ Function InstallApp
|
|
|
154
155
|
DetailPrint "Agent ID: $agentId"
|
|
155
156
|
|
|
156
157
|
# Copy the service files to the root directory
|
|
157
|
-
File ..\..\node_modules\node-
|
|
158
|
+
File ..\..\node_modules\node-shawl\bin\shawl-v1.3.0-legal.txt
|
|
159
|
+
File ..\..\node_modules\node-shawl\bin\shawl-v1.3.0-win64.exe
|
|
158
160
|
File dist\medplum-agent-win-x64.exe
|
|
159
161
|
File README.md
|
|
160
162
|
|
|
161
|
-
# Create the
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
FileWrite $9 "<startmode>Automatic</startmode>$\r$\n"
|
|
171
|
-
FileWrite $9 "</service>$\r$\n"
|
|
172
|
-
FileClose $9
|
|
173
|
-
|
|
174
|
-
# Install the service
|
|
175
|
-
DetailPrint "Installing service..."
|
|
176
|
-
ExecWait "winsw.exe install" $1
|
|
177
|
-
DetailPrint "Install returned $1"
|
|
163
|
+
# Create the service
|
|
164
|
+
DetailPrint "Creating service..."
|
|
165
|
+
ExecWait "shawl-v1.3.0-win64.exe add --name $\"${SERVICE_NAME}$\" -- $\"$INSTDIR\medplum-agent-win-x64.exe$\" $\"$baseUrl$\" $\"$clientId$\" $\"$clientSecret$\" $\"$agentId$\"" $1
|
|
166
|
+
DetailPrint "Exit code $1"
|
|
167
|
+
|
|
168
|
+
# Set service description
|
|
169
|
+
DetailPrint "Setting service description..."
|
|
170
|
+
ExecWait "sc.exe description $\"${SERVICE_NAME}$\" $\"Securely connects local devices to ${COMPANY_NAME} cloud$\"" $1
|
|
171
|
+
DetailPrint "Exit code $1"
|
|
178
172
|
|
|
179
173
|
# Start the service
|
|
180
174
|
DetailPrint "Starting service..."
|
|
181
|
-
ExecWait "
|
|
182
|
-
DetailPrint "
|
|
175
|
+
ExecWait "sc.exe start $\"${SERVICE_NAME}$\"" $1
|
|
176
|
+
DetailPrint "Exit code $1"
|
|
183
177
|
|
|
184
178
|
# Create the uninstaller
|
|
185
179
|
DetailPrint "Creating the uninstaller..."
|
|
@@ -203,11 +197,20 @@ FunctionEnd
|
|
|
203
197
|
# Start the uninstaller
|
|
204
198
|
Section Uninstall
|
|
205
199
|
|
|
206
|
-
#
|
|
207
|
-
DetailPrint "
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
200
|
+
# Stop the service
|
|
201
|
+
DetailPrint "Stopping service..."
|
|
202
|
+
ExecWait "sc.exe stop ${SERVICE_NAME}" $1
|
|
203
|
+
DetailPrint "Exit code $1"
|
|
204
|
+
|
|
205
|
+
# Sleep for 3 seconds to let the service fully stop
|
|
206
|
+
# We cannot delete the file until the service is fully stopped
|
|
207
|
+
DetailPrint "Sleeping..."
|
|
208
|
+
Sleep 3000
|
|
209
|
+
|
|
210
|
+
# Deleting the service
|
|
211
|
+
DetailPrint "Deleting service..."
|
|
212
|
+
ExecWait "sc.exe delete ${SERVICE_NAME}" $1
|
|
213
|
+
DetailPrint "Exit code $1"
|
|
211
214
|
|
|
212
215
|
# Get out of the service directory so we can delete it
|
|
213
216
|
SetOutPath "$PROGRAMFILES64"
|
|
@@ -219,6 +222,7 @@ Section Uninstall
|
|
|
219
222
|
RMDir /r /REBOOTOK "$INSTDIR"
|
|
220
223
|
|
|
221
224
|
# Unregister the program
|
|
225
|
+
DeleteRegKey HKLM "SYSTEM\CurrentControlSet\Services\${SERVICE_NAME}"
|
|
222
226
|
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${SERVICE_NAME}"
|
|
223
227
|
|
|
224
228
|
SectionEnd
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medplum/agent",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.14",
|
|
4
4
|
"description": "Medplum Agent",
|
|
5
5
|
"homepage": "https://www.medplum.com/",
|
|
6
6
|
"repository": {
|
|
@@ -13,22 +13,24 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"agent": "ts-node src/main.ts",
|
|
15
15
|
"build": "npm run clean && tsc && node esbuild.mjs",
|
|
16
|
+
"build:exe": "pkg ./dist/cjs/index.cjs --targets node18-win-x64 --output dist/medplum-agent-win-x64.exe --options no-warnings",
|
|
17
|
+
"build:installer": "makensis installer.nsi",
|
|
18
|
+
"build:all": "npm run build && npm run build:exe && npm run build:installer",
|
|
16
19
|
"clean": "rimraf dist",
|
|
17
|
-
"installer": "makensis installer.nsi",
|
|
18
|
-
"package": "pkg ./dist/cjs/index.cjs --targets node18-win-x64 --output dist/medplum-agent-win-x64.exe --options no-warnings",
|
|
19
20
|
"test": "jest"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"@medplum/core": "*",
|
|
23
24
|
"@medplum/hl7": "*",
|
|
25
|
+
"node-shawl": "1.3.0",
|
|
24
26
|
"node-windows": "1.0.0-beta.8",
|
|
25
27
|
"ws": "8.14.2"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"@medplum/fhirtypes": "*",
|
|
29
31
|
"@medplum/mock": "*",
|
|
30
|
-
"@types/node-windows": "0.1.
|
|
31
|
-
"@types/ws": "8.5.
|
|
32
|
+
"@types/node-windows": "0.1.6",
|
|
33
|
+
"@types/ws": "8.5.9",
|
|
32
34
|
"mock-socket": "9.3.1",
|
|
33
35
|
"pkg": "5.8.1"
|
|
34
36
|
},
|
package/src/main.ts
CHANGED
|
@@ -219,16 +219,26 @@ export class AgentHl7ChannelConnection {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
|
|
223
|
-
if (
|
|
222
|
+
async function main(argv: string[]): Promise<void> {
|
|
223
|
+
if (argv.length < 6) {
|
|
224
224
|
console.log('Usage: node medplum-agent.js <baseUrl> <clientId> <clientSecret> <agentId>');
|
|
225
225
|
process.exit(1);
|
|
226
226
|
}
|
|
227
|
+
const [_node, _script, baseUrl, clientId, clientSecret, agentId] = argv;
|
|
227
228
|
|
|
228
|
-
const [_node, _script, baseUrl, clientId, clientSecret, agentId] = process.argv;
|
|
229
229
|
const medplum = new MedplumClient({ baseUrl, clientId });
|
|
230
|
-
medplum
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
await medplum.startClientLogin(clientId, clientSecret);
|
|
231
|
+
|
|
232
|
+
const app = new App(medplum, agentId);
|
|
233
|
+
await app.start();
|
|
234
|
+
|
|
235
|
+
process.on('SIGINT', () => {
|
|
236
|
+
console.log('\ngracefully shutting down from SIGINT (Crtl-C)');
|
|
237
|
+
app.stop();
|
|
238
|
+
process.exit();
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (typeof require !== 'undefined' && require.main === module) {
|
|
243
|
+
main(process.argv).catch(console.error);
|
|
234
244
|
}
|