Skip to content

Commit 630949f

Browse files
committed
fix: Add snapshot test for compliant US Core Patient resource
Adds gender, birthDate, and toMatchSnapshot() to the patient demo test to capture a fully valid US Core Patient with extensions.
1 parent a3bf7f2 commit 630949f

2 files changed

Lines changed: 84 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
2+
3+
exports[`demo three ways to set an extension: flat input, profile instance, raw Extension 1`] = `
4+
{
5+
"birthDate": "1985-03-15",
6+
"extension": [
7+
{
8+
"extension": [
9+
{
10+
"url": "ombCategory",
11+
"valueCoding": {
12+
"code": "2106-3",
13+
"display": "White",
14+
"system": "urn:oid:2.16.840.1.113883.6.238",
15+
},
16+
},
17+
{
18+
"url": "text",
19+
"valueString": "White",
20+
},
21+
],
22+
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
23+
},
24+
{
25+
"extension": [
26+
{
27+
"url": "ombCategory",
28+
"valueCoding": {
29+
"code": "2135-2",
30+
"display": "Hispanic or Latino",
31+
},
32+
},
33+
{
34+
"url": "detailed",
35+
"valueCoding": {
36+
"code": "2148-5",
37+
"display": "Mexican",
38+
},
39+
},
40+
{
41+
"url": "text",
42+
"valueString": "Mexican",
43+
},
44+
],
45+
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
46+
},
47+
{
48+
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-individual-sex",
49+
"valueCoding": {
50+
"code": "female",
51+
"display": "Female",
52+
},
53+
},
54+
],
55+
"gender": "female",
56+
"identifier": [
57+
{
58+
"system": "http://hospital.example.org/mrn",
59+
"value": "MRN-12345",
60+
},
61+
],
62+
"meta": {
63+
"profile": [
64+
"http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient",
65+
],
66+
},
67+
"name": [
68+
{
69+
"family": "Garcia",
70+
"given": [
71+
"Maria",
72+
"Elena",
73+
],
74+
},
75+
],
76+
"resourceType": "Patient",
77+
}
78+
`;

examples/typescript-us-core/profile-patient.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,17 @@ describe("demo", () => {
4747
};
4848
patient.setSex(sexExtension);
4949

50+
// gender and birthDate are must-support base Patient fields — set directly on the resource
51+
Object.assign(patient.toResource(), { gender: "female", birthDate: "1985-03-15" });
52+
5053
expect(patient.validate().errors).toEqual([]);
54+
expect(patient.toResource()).toMatchSnapshot();
5155
expect(patient.toResource()).toEqual({
5256
resourceType: "Patient",
5357
identifier: [{ system: "http://hospital.example.org/mrn", value: "MRN-12345" }],
5458
name: [{ family: "Garcia", given: ["Maria", "Elena"] }],
59+
gender: "female",
60+
birthDate: "1985-03-15",
5561
meta: { profile: ["http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient"] },
5662
extension: [
5763
{

0 commit comments

Comments
 (0)