Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export class observation_bodyweightProfile {
}

setEffectiveDateTime (value: string) : this {
this.clearEffective();
Object.assign(this.resource, { effectiveDateTime: value });
return this;
}
Expand All @@ -151,6 +152,7 @@ export class observation_bodyweightProfile {
}

setEffectivePeriod (value: Period) : this {
this.clearEffective();
Object.assign(this.resource, { effectivePeriod: value });
return this;
}
Expand All @@ -164,6 +166,11 @@ export class observation_bodyweightProfile {
return this;
}

clearEffective () : void {
delete this.resource.effectiveDateTime;
delete this.resource.effectivePeriod;
}

// Extensions
// Slices
public setVSCat (input?: Observation_bodyweight_Category_VSCatSliceFlat | CodeableConcept): this {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export class observation_bpProfile {
}

setEffectiveDateTime (value: string) : this {
this.clearEffective();
Object.assign(this.resource, { effectiveDateTime: value });
return this;
}
Expand All @@ -186,6 +187,7 @@ export class observation_bpProfile {
}

setEffectivePeriod (value: Period) : this {
this.clearEffective();
Object.assign(this.resource, { effectivePeriod: value });
return this;
}
Expand All @@ -199,6 +201,11 @@ export class observation_bpProfile {
return this;
}

clearEffective () : void {
delete this.resource.effectiveDateTime;
delete this.resource.effectivePeriod;
}

// Extensions
// Slices
public setVSCat (input?: Observation_bp_Category_VSCatSliceFlat | CodeableConcept): this {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export class observation_vitalsignsProfile {
}

setEffectiveDateTime (value: string) : this {
this.clearEffective();
Object.assign(this.resource, { effectiveDateTime: value });
return this;
}
Expand All @@ -154,10 +155,16 @@ export class observation_vitalsignsProfile {
}

setEffectivePeriod (value: Period) : this {
this.clearEffective();
Object.assign(this.resource, { effectivePeriod: value });
return this;
}

clearEffective () : void {
delete this.resource.effectiveDateTime;
delete this.resource.effectivePeriod;
}

// Extensions
// Slices
public setVSCat (input?: Observation_vitalsigns_Category_VSCatSliceFlat | CodeableConcept): this {
Expand Down
25 changes: 24 additions & 1 deletion examples/typescript-r4/profile-bodyweight.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe("slice accessors", () => {
});

describe("choice type accessors", () => {
test("effectiveDateTime and effectivePeriod are independent choices", () => {
test("setting a second effective[x] choice clears the first", () => {
const profile = bodyweightProfile.create({ status: "final", subject: { reference: "Patient/pt-1" } });

expect(profile.getEffectiveDateTime()).toBeUndefined();
Expand All @@ -228,7 +228,30 @@ describe("choice type accessors", () => {
profile.setEffectiveDateTime("2024-01-15");
expect(profile.getEffectiveDateTime()).toBe("2024-01-15");

// effective[x] is polymorphic: a resource may carry at most one variant,
// so switching to a different one must clear the previous value —
// otherwise the resource serialises two mutually-exclusive effective*
// fields and is invalid FHIR.
profile.setEffectivePeriod({ start: "2024-01-15", end: "2024-01-16" });
expect(profile.getEffectivePeriod()).toEqual({ start: "2024-01-15", end: "2024-01-16" });
expect(profile.getEffectiveDateTime()).toBeUndefined();

const resource = profile.toResource();
const effectiveKeys = Object.keys(resource).filter((k) => k.startsWith("effective"));
expect(effectiveKeys).toEqual(["effectivePeriod"]);
});

test("clearEffective() removes whichever effective[x] variant is set", () => {
const profile = bodyweightProfile.create({ status: "final", subject: { reference: "Patient/pt-1" } });

profile.setEffectiveDateTime("2024-01-15");
expect(profile.getEffectiveDateTime()).toBe("2024-01-15");

// The clear helper is public — callers can drop the choice entirely.
profile.clearEffective();

expect(profile.getEffectiveDateTime()).toBeUndefined();
expect(profile.getEffectivePeriod()).toBeUndefined();
expect(Object.keys(profile.toResource()).some((k) => k.startsWith("effective"))).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export class observation_vitalsignsProfile {
}

setEffectiveDateTime (value: string) : this {
this.clearEffective();
Object.assign(this.resource, { effectiveDateTime: value });
return this;
}
Expand All @@ -154,10 +155,16 @@ export class observation_vitalsignsProfile {
}

setEffectivePeriod (value: Period) : this {
this.clearEffective();
Object.assign(this.resource, { effectivePeriod: value });
return this;
}

clearEffective () : void {
delete this.resource.effectiveDateTime;
delete this.resource.effectivePeriod;
}

// Extensions
// Slices
public setVSCat (input?: Observation_vitalsigns_Category_VSCatSliceFlat | CodeableConcept): this {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export class USCoreBloodPressureProfile {
}

setEffectiveDateTime (value: string) : this {
this.clearEffective();
Object.assign(this.resource, { effectiveDateTime: value });
return this;
}
Expand All @@ -189,6 +190,7 @@ export class USCoreBloodPressureProfile {
}

setEffectivePeriod (value: Period) : this {
this.clearEffective();
Object.assign(this.resource, { effectivePeriod: value });
return this;
}
Expand All @@ -198,6 +200,7 @@ export class USCoreBloodPressureProfile {
}

setValueQuantity (value: Quantity) : this {
this.clearValue();
Object.assign(this.resource, { valueQuantity: value });
return this;
}
Expand All @@ -207,6 +210,7 @@ export class USCoreBloodPressureProfile {
}

setValueCodeableConcept (value: CodeableConcept) : this {
this.clearValue();
Object.assign(this.resource, { valueCodeableConcept: value });
return this;
}
Expand All @@ -216,6 +220,7 @@ export class USCoreBloodPressureProfile {
}

setValueString (value: string) : this {
this.clearValue();
Object.assign(this.resource, { valueString: value });
return this;
}
Expand All @@ -225,6 +230,7 @@ export class USCoreBloodPressureProfile {
}

setValueBoolean (value: boolean) : this {
this.clearValue();
Object.assign(this.resource, { valueBoolean: value });
return this;
}
Expand All @@ -234,6 +240,7 @@ export class USCoreBloodPressureProfile {
}

setValueInteger (value: number) : this {
this.clearValue();
Object.assign(this.resource, { valueInteger: value });
return this;
}
Expand All @@ -243,6 +250,7 @@ export class USCoreBloodPressureProfile {
}

setValueRange (value: Range) : this {
this.clearValue();
Object.assign(this.resource, { valueRange: value });
return this;
}
Expand All @@ -252,6 +260,7 @@ export class USCoreBloodPressureProfile {
}

setValueRatio (value: Ratio) : this {
this.clearValue();
Object.assign(this.resource, { valueRatio: value });
return this;
}
Expand All @@ -261,6 +270,7 @@ export class USCoreBloodPressureProfile {
}

setValueSampledData (value: SampledData) : this {
this.clearValue();
Object.assign(this.resource, { valueSampledData: value });
return this;
}
Expand All @@ -270,6 +280,7 @@ export class USCoreBloodPressureProfile {
}

setValueTime (value: string) : this {
this.clearValue();
Object.assign(this.resource, { valueTime: value });
return this;
}
Expand All @@ -279,6 +290,7 @@ export class USCoreBloodPressureProfile {
}

setValueDateTime (value: string) : this {
this.clearValue();
Object.assign(this.resource, { valueDateTime: value });
return this;
}
Expand All @@ -288,10 +300,30 @@ export class USCoreBloodPressureProfile {
}

setValuePeriod (value: Period) : this {
this.clearValue();
Object.assign(this.resource, { valuePeriod: value });
return this;
}

clearEffective () : void {
delete this.resource.effectiveDateTime;
delete this.resource.effectivePeriod;
}

clearValue () : void {
delete this.resource.valueQuantity;
delete this.resource.valueCodeableConcept;
delete this.resource.valueString;
delete this.resource.valueBoolean;
delete this.resource.valueInteger;
delete this.resource.valueRange;
delete this.resource.valueRatio;
delete this.resource.valueSampledData;
delete this.resource.valueTime;
delete this.resource.valueDateTime;
delete this.resource.valuePeriod;
}

// Extensions
// Slices
public setVSCat (input?: USCoreBloodPressureProfile_Category_VSCatSliceFlat | CodeableConcept): this {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export class USCoreBodyWeightProfile {
}

setEffectiveDateTime (value: string) : this {
this.clearEffective();
Object.assign(this.resource, { effectiveDateTime: value });
return this;
}
Expand All @@ -154,6 +155,7 @@ export class USCoreBodyWeightProfile {
}

setEffectivePeriod (value: Period) : this {
this.clearEffective();
Object.assign(this.resource, { effectivePeriod: value });
return this;
}
Expand All @@ -163,6 +165,7 @@ export class USCoreBodyWeightProfile {
}

setValueQuantity (value: Quantity) : this {
this.clearValue();
Object.assign(this.resource, { valueQuantity: value });
return this;
}
Expand All @@ -172,6 +175,7 @@ export class USCoreBodyWeightProfile {
}

setValueCodeableConcept (value: CodeableConcept) : this {
this.clearValue();
Object.assign(this.resource, { valueCodeableConcept: value });
return this;
}
Expand All @@ -181,6 +185,7 @@ export class USCoreBodyWeightProfile {
}

setValueString (value: string) : this {
this.clearValue();
Object.assign(this.resource, { valueString: value });
return this;
}
Expand All @@ -190,6 +195,7 @@ export class USCoreBodyWeightProfile {
}

setValueBoolean (value: boolean) : this {
this.clearValue();
Object.assign(this.resource, { valueBoolean: value });
return this;
}
Expand All @@ -199,6 +205,7 @@ export class USCoreBodyWeightProfile {
}

setValueInteger (value: number) : this {
this.clearValue();
Object.assign(this.resource, { valueInteger: value });
return this;
}
Expand All @@ -208,6 +215,7 @@ export class USCoreBodyWeightProfile {
}

setValueRange (value: Range) : this {
this.clearValue();
Object.assign(this.resource, { valueRange: value });
return this;
}
Expand All @@ -217,6 +225,7 @@ export class USCoreBodyWeightProfile {
}

setValueRatio (value: Ratio) : this {
this.clearValue();
Object.assign(this.resource, { valueRatio: value });
return this;
}
Expand All @@ -226,6 +235,7 @@ export class USCoreBodyWeightProfile {
}

setValueSampledData (value: SampledData) : this {
this.clearValue();
Object.assign(this.resource, { valueSampledData: value });
return this;
}
Expand All @@ -235,6 +245,7 @@ export class USCoreBodyWeightProfile {
}

setValueTime (value: string) : this {
this.clearValue();
Object.assign(this.resource, { valueTime: value });
return this;
}
Expand All @@ -244,6 +255,7 @@ export class USCoreBodyWeightProfile {
}

setValueDateTime (value: string) : this {
this.clearValue();
Object.assign(this.resource, { valueDateTime: value });
return this;
}
Expand All @@ -253,10 +265,30 @@ export class USCoreBodyWeightProfile {
}

setValuePeriod (value: Period) : this {
this.clearValue();
Object.assign(this.resource, { valuePeriod: value });
return this;
}

clearEffective () : void {
delete this.resource.effectiveDateTime;
delete this.resource.effectivePeriod;
}

clearValue () : void {
delete this.resource.valueQuantity;
delete this.resource.valueCodeableConcept;
delete this.resource.valueString;
delete this.resource.valueBoolean;
delete this.resource.valueInteger;
delete this.resource.valueRange;
delete this.resource.valueRatio;
delete this.resource.valueSampledData;
delete this.resource.valueTime;
delete this.resource.valueDateTime;
delete this.resource.valuePeriod;
}

// Extensions
// Slices
public setVSCat (input?: USCoreBodyWeightProfile_Category_VSCatSliceFlat | CodeableConcept): this {
Expand Down
Loading
Loading