@smile-cdr/fhirts 2.2.3 → 2.2.4
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/CHANGELOG.md +6 -0
- package/GETTINGSTARTED.md +86 -39
- package/dist/FHIR-R3.d.ts +35 -1
- package/dist/FHIR-R3.js +5 -2
- package/package.json +1 -1
- package/src/FHIR-R3.ts +36 -1
package/CHANGELOG.md
CHANGED
package/GETTINGSTARTED.md
CHANGED
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
## Setting Up Your First FHIR Resource
|
|
4
4
|
|
|
5
|
-
FHIR.ts offers both classes & interfaces for various FHIR resources - which one(s) you choose to use will depend on what your use case is.
|
|
6
5
|
|
|
7
|
-
> At the moment, the fhirR3 library only supports classes
|
|
6
|
+
> NOTE: At the moment, the fhirR3 library only supports classes
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
#### Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Class and Interface usage](#models-usage)
|
|
11
|
+
- [Resource Narrowing](#resource-narrowing)
|
|
12
|
+
- [Utilities](#utilities)
|
|
13
|
+
- [PatchUtils](#patchutils)
|
|
14
|
+
- [QueryBuilder](#querybuilder)
|
|
15
|
+
- [BundleUtils](#bundleutilities)
|
|
16
|
+
- [ResourceUtils](#resourceutilities)
|
|
17
|
+
- [Bundle Utilities (static BundleUtils)](#bundleutilities)
|
|
18
|
+
- [Resource Utilities (static ResourceUtils)](#resourceutilities)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Class and Interface usage
|
|
10
22
|
|
|
11
23
|
```js
|
|
12
24
|
|
|
@@ -51,29 +63,8 @@ let patient: fhirR5.Patient = {
|
|
|
51
63
|
|
|
52
64
|
Fields in FHIR.ts have strict typing to them. For example, in `Patient`, you can only select a `gender` that's in the list of accepted values.
|
|
53
65
|
|
|
54
|
-
## Example
|
|
55
|
-
|
|
56
|
-
Here's an example of setting up a `Patient` resource in R4 using classes:
|
|
57
|
-
|
|
58
|
-
```js
|
|
59
|
-
import { fhirR4 } from '@smile-cdr/fhirts';
|
|
60
|
-
|
|
61
|
-
const patient = new fhirR4.Patient();
|
|
62
|
-
const identifer = new fhirR4.Identifier();
|
|
63
|
-
const humanName = new fhirR4.HumanName();
|
|
64
|
-
|
|
65
|
-
humanName.family = 'Doe'
|
|
66
|
-
humanName.given = ['John', 'Edward'];
|
|
67
|
-
|
|
68
|
-
identifer.system = 'https://smilecdr.com';
|
|
69
|
-
identifer.value = '123';
|
|
70
|
-
|
|
71
|
-
patient.resourceType = 'Patient';
|
|
72
|
-
patient.identifier = [identifer];
|
|
73
|
-
patient.name = [humanName]
|
|
74
|
-
```
|
|
75
66
|
|
|
76
|
-
|
|
67
|
+
### Resource Narrowing
|
|
77
68
|
|
|
78
69
|
When working with Resources from a Bundle, by investigating the values and properties of those Resources Typescript will automatically infer the correct type. For example take the following code:
|
|
79
70
|
```js
|
|
@@ -85,17 +76,73 @@ function getResourceType(resource:Resource){
|
|
|
85
76
|
```
|
|
86
77
|
If you try writing this out you will see that the variable `resource` inside the `if` block is of type `CarePlan`. This was inferred automatically using the `if` condition (since as per the specification the only resources which can have `resourceType:"CarePlan"` are `CarePlan` resources).
|
|
87
78
|
|
|
88
|
-
|
|
79
|
+
Read more about resource narrowing here : https://www.typescriptlang.org/docs/handbook/2/narrowing.html
|
|
89
80
|
|
|
90
|
-
|
|
81
|
+
### Utilities
|
|
82
|
+
|
|
83
|
+
- There are 4 new utilities available :
|
|
91
84
|
- BundleUtilities
|
|
92
85
|
- ResourceUtilities
|
|
86
|
+
- PatchUtilities
|
|
87
|
+
- QueryBuilder
|
|
93
88
|
- All of the above mentioned classes are currently in preliminary phase and will be refined in future as per needs.
|
|
94
89
|
- The above utlity classes include common functionalities used by front end applications using FHIR.
|
|
95
|
-
- All utilities functions are static right now, so, no need for instantiating classes. **Note: This is subject to change in future**
|
|
96
90
|
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
#### PatchUtils
|
|
92
|
+
- Published in `v2.2.0`.
|
|
93
|
+
- Example usage demonstrated below.
|
|
94
|
+
```js
|
|
95
|
+
import { PatchUtils } from '@smile-cdr/fhirts';
|
|
96
|
+
|
|
97
|
+
const patchUtils = new PatchUtils();
|
|
98
|
+
// returns patch parameters
|
|
99
|
+
const patchParameters = patchUtils.createDeleteParameters("Patient.identifier[3]").getPatchParameters();
|
|
100
|
+
console.log(patchParameters)
|
|
101
|
+
// console logs
|
|
102
|
+
/*
|
|
103
|
+
* {
|
|
104
|
+
"resourceType": "Parameters",
|
|
105
|
+
"parameter": [
|
|
106
|
+
{
|
|
107
|
+
"name": "operation",
|
|
108
|
+
"part": [
|
|
109
|
+
{
|
|
110
|
+
"name": "type",
|
|
111
|
+
"valueCode": "delete"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "path",
|
|
115
|
+
"valueString": "Patient.identifier[3]"
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
*
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### QueryBuilder
|
|
125
|
+
- Published in `v2.1.2`.
|
|
126
|
+
- Example usage demonstrated below.
|
|
127
|
+
```js
|
|
128
|
+
import { QueryBuilder } from '@smile-cdr/fhirts';
|
|
129
|
+
|
|
130
|
+
const queryBuilder = new QueryBuilder();
|
|
131
|
+
// returns encoded url
|
|
132
|
+
const query = queryBuilder.setBaseResource("Observation")
|
|
133
|
+
.revincludeAll()
|
|
134
|
+
.include("based-on")
|
|
135
|
+
.sort("status", SORT_ORDER.ASCENDING)
|
|
136
|
+
.getCompleteUrl();
|
|
137
|
+
console.log(query)
|
|
138
|
+
// console logs
|
|
139
|
+
// "Observation?_revinclude=*&_include=Observation%3Abased-on&_sort=status"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
#### BundleUtils
|
|
144
|
+
- Published in `v2.1.0`.
|
|
145
|
+
- Example usage demonstrated below.
|
|
99
146
|
```js
|
|
100
147
|
import { BundleUtils } from '@smile-cdr/fhirts';
|
|
101
148
|
|
|
@@ -106,12 +153,12 @@ const claimsList = bundleUtils.getResourcesFromBundle(Bundle.entry, 'Claim');
|
|
|
106
153
|
const resource = bundleUtils.getResourceFromBundle(Bundle.entry, '123');
|
|
107
154
|
```
|
|
108
155
|
|
|
109
|
-
#### ResourceUtils
|
|
156
|
+
#### ResourceUtils
|
|
157
|
+
- Published in `v2.1.0`.
|
|
158
|
+
- Example usage demonstrated below.
|
|
110
159
|
```js
|
|
111
160
|
import { ResourceUtils } from '@smile-cdr/fhirts';
|
|
112
161
|
const resourceUtils = new ResourceUtils();
|
|
113
|
-
// returns deserialized Patient resource
|
|
114
|
-
const deserializedPatientResource = resourceUtils.deserializeResource(jsonPatientPayload, new Patient());
|
|
115
162
|
|
|
116
163
|
// returns Patient.gender
|
|
117
164
|
const patientGender = resourceUtils.getResourceProperty(jsonPatientPayload, 'gender');
|
|
@@ -133,8 +180,9 @@ const references = resourceUtils.getAllReferencesFromResource(resourcePayload);
|
|
|
133
180
|
|
|
134
181
|
|
|
135
182
|
|
|
136
|
-
|
|
137
|
-
|
|
183
|
+
#### BundleUtilities
|
|
184
|
+
- Published in `v2.0.0`.
|
|
185
|
+
- Example usage demonstrated below.
|
|
138
186
|
```js
|
|
139
187
|
import { BundleUtilities } from '@smile-cdr/fhirts';
|
|
140
188
|
|
|
@@ -142,13 +190,12 @@ import { BundleUtilities } from '@smile-cdr/fhirts';
|
|
|
142
190
|
const claimsList = BundleUtilities.getResourcesFromBundle(Bundle.entry, 'Claim');
|
|
143
191
|
```
|
|
144
192
|
|
|
145
|
-
#### ResourceUtilities
|
|
193
|
+
#### ResourceUtilities
|
|
194
|
+
- Published in `v2.0.0`.
|
|
195
|
+
- Example usage demonstrated below.
|
|
146
196
|
```js
|
|
147
197
|
import { ResourceUtilities } from '@smile-cdr/fhirts';
|
|
148
198
|
|
|
149
|
-
// returns deserialized Patient resource
|
|
150
|
-
const deserializedPatientResource = ResourceUtilities.deserializeResource(jsonPatientPayload, new Patient());
|
|
151
|
-
|
|
152
199
|
// returns Patient.gender
|
|
153
200
|
const patientGender = ResourceUtilities.getResourceProperty(jsonPatientPayload, 'gender');
|
|
154
201
|
|
package/dist/FHIR-R3.d.ts
CHANGED
|
@@ -655,6 +655,40 @@ export declare class ProcessRequest extends BaseResource {
|
|
|
655
655
|
provider: Reference;
|
|
656
656
|
request: Reference;
|
|
657
657
|
}
|
|
658
|
+
export declare class Condition extends BaseResource {
|
|
659
|
+
resourceType: "Condition";
|
|
660
|
+
identifier?: Identifier[];
|
|
661
|
+
clinicalStatus?: "active" | "recurrence" | "inactive" | "remission" | "resolved";
|
|
662
|
+
verificationStatus?: "provisional" | "differential" | "confirmed" | "refuted" | "entered-in-error" | "unknown";
|
|
663
|
+
category?: CodeableConcept[];
|
|
664
|
+
severity?: CodeableConcept;
|
|
665
|
+
code?: CodeableConcept;
|
|
666
|
+
bodySite?: CodeableConcept[];
|
|
667
|
+
subject: Reference;
|
|
668
|
+
context?: Reference;
|
|
669
|
+
onsetDateTime?: string | Date;
|
|
670
|
+
onsetAge?: Age;
|
|
671
|
+
onsetPeriod?: Period;
|
|
672
|
+
onsetRange?: Range;
|
|
673
|
+
onsetString?: string;
|
|
674
|
+
abatementDateTime?: string | Date;
|
|
675
|
+
abatementAge?: Age;
|
|
676
|
+
abatementBoolean?: boolean;
|
|
677
|
+
abatementPeriod?: Period;
|
|
678
|
+
abatementRange?: Range;
|
|
679
|
+
abatementString?: string;
|
|
680
|
+
assertedDate?: string | Date;
|
|
681
|
+
asserter?: Reference;
|
|
682
|
+
stage?: {
|
|
683
|
+
summary?: CodeableConcept;
|
|
684
|
+
assessment?: Reference[];
|
|
685
|
+
};
|
|
686
|
+
evidence?: {
|
|
687
|
+
code?: CodeableConcept[];
|
|
688
|
+
detail?: Reference[];
|
|
689
|
+
}[];
|
|
690
|
+
note?: Annotation[];
|
|
691
|
+
}
|
|
658
692
|
export declare class Encounter extends BaseResource {
|
|
659
693
|
resourceType: "Encounter";
|
|
660
694
|
identifier: Identifier[];
|
|
@@ -1185,5 +1219,5 @@ export declare class ValueSetContains extends BackboneElement {
|
|
|
1185
1219
|
designation?: ValueSetDesignation[];
|
|
1186
1220
|
contains?: ValueSetContains[];
|
|
1187
1221
|
}
|
|
1188
|
-
export type Resource = AllergyIntolerance | ClinicalImpression | Schedule | HealthcareService | Bundle | AuditEvent | CommunicationRequest | Immunization | Observation | Device | Practitioner | PractitionerRole | ProcedureRequest | Task | Communication | CarePlan | EpisodeOfCare | CareTeam | Encounter | ProcessRequest | Account | Location | Organization | AppointmentResponse | Appointment | QuestionnaireResponse | Questionnaire | Slot | Patient | DocumentReference | ValueSet;
|
|
1222
|
+
export type Resource = AllergyIntolerance | ClinicalImpression | Condition | Schedule | HealthcareService | Bundle | AuditEvent | CommunicationRequest | Immunization | Observation | Device | Practitioner | PractitionerRole | ProcedureRequest | Task | Communication | CarePlan | EpisodeOfCare | CareTeam | Encounter | ProcessRequest | Account | Location | Organization | AppointmentResponse | Appointment | QuestionnaireResponse | Questionnaire | Slot | Patient | DocumentReference | ValueSet;
|
|
1189
1223
|
export {};
|
package/dist/FHIR-R3.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Restriction = exports.SampledData = exports.Output = exports.Input = exports.Range = exports.Ratio = exports.Component = exports.Timing = exports.Activity = exports.EncounterParticipant = exports.Participant = exports.ReferenceRange = exports.Context = exports.ContextRelated = exports.Annotation = exports.FHIROption = exports.Answer = exports.EnableWhen = exports.Network = exports.Payload = exports.Identifier = exports.Reference = exports.ContactDetail = exports.ContactPoint = exports.Contact = exports.PatientCommunication = exports.Link = exports.Content = exports.Qualification = exports.Attachment = exports.VaccinationProtocol = exports.ImmunizationReaction = exports.ImmunizationExplaination = exports.PractitionerForImmunization = exports.UsageContext = exports.Quantity = exports.Period = exports.CodeableConcept = exports.Meta = exports.Address = exports.Extension = exports.HumanName = exports.DoseCoding = exports.Coding = exports.Code = exports.Narrative = exports.BaseResource = exports.DomainResource = exports.BackboneElement = exports.FHIRElement = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.ValueSetContains = exports.ValueSetParameter = exports.ValueSetExpansion = exports.ValueSetFilter = exports.ValueSetDesignation = exports.ValueSetConcept = exports.ValueSetInclude = exports.ValueSetCompose = exports.ValueSet = exports.Age = exports.AllergyIntoleranceReaction = exports.AllergyIntolerance = void 0;
|
|
4
|
+
exports.ClinicalImpressionInvestigation = exports.ClinicalImpression = exports.Slot = exports.Schedule = exports.HealthcareService = exports.Bundle = exports.AuditEvent = exports.CommunicationRequest = exports.Immunization = exports.Observation = exports.Device = exports.Practitioner = exports.PractitionerRole = exports.ProcedureRequest = exports.Task = exports.Communication = exports.CarePlan = exports.EpisodeOfCare = exports.CareTeam = exports.CareTeamParticipant = exports.Encounter = exports.Condition = exports.ProcessRequest = exports.Account = exports.Location = exports.Organization = exports.AppointmentResponse = exports.Appointment = exports.DocumentReference = exports.Patient = exports.Questionnaire = exports.QuestionnaireResponse = exports.Udi = exports.Entity = exports.EntityDetail = exports.Source = exports.Agent = exports.Item = exports.QuestionnaireResponseItem = exports.Requester = exports.Position = exports.ActivityDetail = exports.BundleEntry = exports.BundleResponse = exports.BundleRequest = exports.Search = exports.BundleSignature = exports.BundleLink = exports.NotAvailable = exports.AvailableTime = void 0;
|
|
5
|
+
exports.ValueSetContains = exports.ValueSetParameter = exports.ValueSetExpansion = exports.ValueSetFilter = exports.ValueSetDesignation = exports.ValueSetConcept = exports.ValueSetInclude = exports.ValueSetCompose = exports.ValueSet = exports.Age = exports.AllergyIntoleranceReaction = exports.AllergyIntolerance = exports.ClinicalImpressionFinding = void 0;
|
|
6
6
|
/* This is base class from which other elements are derived */
|
|
7
7
|
class FHIRElement {
|
|
8
8
|
}
|
|
@@ -314,6 +314,9 @@ exports.Account = Account;
|
|
|
314
314
|
class ProcessRequest extends BaseResource {
|
|
315
315
|
}
|
|
316
316
|
exports.ProcessRequest = ProcessRequest;
|
|
317
|
+
class Condition extends BaseResource {
|
|
318
|
+
}
|
|
319
|
+
exports.Condition = Condition;
|
|
317
320
|
class Encounter extends BaseResource {
|
|
318
321
|
}
|
|
319
322
|
exports.Encounter = Encounter;
|
package/package.json
CHANGED
package/src/FHIR-R3.ts
CHANGED
|
@@ -809,6 +809,41 @@ export class ProcessRequest extends BaseResource {
|
|
|
809
809
|
request: Reference;
|
|
810
810
|
}
|
|
811
811
|
|
|
812
|
+
export class Condition extends BaseResource {
|
|
813
|
+
resourceType: "Condition";
|
|
814
|
+
identifier?: Identifier[];
|
|
815
|
+
clinicalStatus?: "active" | "recurrence" | "inactive" | "remission" | "resolved";
|
|
816
|
+
verificationStatus?: "provisional" | "differential" | "confirmed" | "refuted" | "entered-in-error" | "unknown";
|
|
817
|
+
category?: CodeableConcept[];
|
|
818
|
+
severity?: CodeableConcept;
|
|
819
|
+
code?: CodeableConcept;
|
|
820
|
+
bodySite?: CodeableConcept[];
|
|
821
|
+
subject: Reference;
|
|
822
|
+
context?: Reference;
|
|
823
|
+
onsetDateTime?: string | Date;
|
|
824
|
+
onsetAge?: Age;
|
|
825
|
+
onsetPeriod?: Period;
|
|
826
|
+
onsetRange?: Range;
|
|
827
|
+
onsetString?: string;
|
|
828
|
+
abatementDateTime?: string | Date;
|
|
829
|
+
abatementAge?: Age;
|
|
830
|
+
abatementBoolean?: boolean;
|
|
831
|
+
abatementPeriod?: Period;
|
|
832
|
+
abatementRange?: Range;
|
|
833
|
+
abatementString?: string;
|
|
834
|
+
assertedDate?: string | Date;
|
|
835
|
+
asserter?: Reference;
|
|
836
|
+
stage?: {
|
|
837
|
+
summary?: CodeableConcept;
|
|
838
|
+
assessment?: Reference[];
|
|
839
|
+
};
|
|
840
|
+
evidence?: {
|
|
841
|
+
code?: CodeableConcept[];
|
|
842
|
+
detail?: Reference[];
|
|
843
|
+
}[];
|
|
844
|
+
note?: Annotation[]
|
|
845
|
+
}
|
|
846
|
+
|
|
812
847
|
export class Encounter extends BaseResource {
|
|
813
848
|
resourceType: "Encounter";
|
|
814
849
|
identifier: Identifier[];
|
|
@@ -1376,4 +1411,4 @@ export class ValueSetContains extends BackboneElement {
|
|
|
1376
1411
|
}
|
|
1377
1412
|
|
|
1378
1413
|
|
|
1379
|
-
export type Resource = AllergyIntolerance | ClinicalImpression | Schedule | HealthcareService | Bundle | AuditEvent | CommunicationRequest | Immunization | Observation | Device | Practitioner | PractitionerRole | ProcedureRequest | Task | Communication | CarePlan | EpisodeOfCare | CareTeam | Encounter | ProcessRequest | Account | Location | Organization | AppointmentResponse | Appointment | QuestionnaireResponse | Questionnaire | Slot | Patient | DocumentReference | ValueSet;
|
|
1414
|
+
export type Resource = AllergyIntolerance | ClinicalImpression | Condition | Schedule | HealthcareService | Bundle | AuditEvent | CommunicationRequest | Immunization | Observation | Device | Practitioner | PractitionerRole | ProcedureRequest | Task | Communication | CarePlan | EpisodeOfCare | CareTeam | Encounter | ProcessRequest | Account | Location | Organization | AppointmentResponse | Appointment | QuestionnaireResponse | Questionnaire | Slot | Patient | DocumentReference | ValueSet;
|