@haste-health/fhir-types 0.12.1

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/generated/r4b/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import * as r4 from "./generated/r4/types.js";
2
+ import * as r4b from "./generated/r4b/types.js";
3
+ export type R4 = "4.0";
4
+ export type R4B = "4.3";
5
+ export declare const R4: R4;
6
+ export declare const R4B: R4B;
7
+ export declare const FHIR_VERSIONS_SUPPORTED: [R4, R4B];
8
+ export type FHIR_VERSION = (typeof FHIR_VERSIONS_SUPPORTED)[number];
9
+ type ResourceTypeMap = {
10
+ [R4]: r4.ResourceType;
11
+ [R4B]: r4b.ResourceType;
12
+ };
13
+ export type ResourceType<Version extends (typeof FHIR_VERSIONS_SUPPORTED)[number]> = ResourceTypeMap[Version];
14
+ export type AllResourceTypes = ResourceType<FHIR_VERSION>;
15
+ export type Resource<Version extends (typeof FHIR_VERSIONS_SUPPORTED)[number], Type extends AllResourceTypes> = Version extends R4 ? Type extends r4.ResourceType ? r4.AResource<Type> : never : Version extends R4B ? Type extends r4b.ResourceType ? r4b.AResource<Type> : never : never;
16
+ export type DataType<Version extends (typeof FHIR_VERSIONS_SUPPORTED)[number]> = Version extends R4 ? r4.DataType : Version extends R4B ? r4b.DataType : never;
17
+ export type AllDataTypes = r4.DataType | r4b.DataType;
18
+ export type Data<Version extends (typeof FHIR_VERSIONS_SUPPORTED)[number], Type extends AllDataTypes> = Version extends R4 ? Type extends r4.DataType ? r4.AData<Type> : never : Version extends R4B ? Type extends r4b.DataType ? r4b.AData<Type> : never : never;
19
+ export {};
@@ -0,0 +1,5 @@
1
+ export const R4 = "4.0";
2
+ export const R4B = "4.3";
3
+ export const FHIR_VERSIONS_SUPPORTED = [R4, R4B];
4
+ // ------------------------------------------------------------------------------------------------
5
+ //# sourceMappingURL=versions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,EAAE,GAAO,KAAK,CAAC;AAC5B,MAAM,CAAC,MAAM,GAAG,GAAQ,KAAK,CAAC;AAE9B,MAAM,CAAC,MAAM,uBAAuB,GAAc,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;AAgD5D,mGAAmG"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@haste-health/fhir-types",
3
+ "version": "0.12.1",
4
+ "homepage": "https://haste.health",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/HasteHealth/HasteHealth.git"
8
+ },
9
+ "description": "",
10
+ "type": "module",
11
+ "scripts": {
12
+ "generate-r4": "pnpm node ../cli/lib/hastehealth.js generate types-artifacts --version=4.0 --output=./src/generated/r4 && pnpm build",
13
+ "generate-r4b": "pnpm node ../cli/lib/hastehealth.js generate types-artifacts --version=4.3 --output=./src/generated/r4b && pnpm build",
14
+ "generate": "pnpm generate-r4 && pnpm generate-r4b",
15
+ "build": "tsc",
16
+ "publish": "pnpm build && pnpm npm publish --access public --tolerate-republish"
17
+ },
18
+ "types": "lib/r4/types.d.ts",
19
+ "keywords": [],
20
+ "author": "",
21
+ "license": "ISC",
22
+ "exports": {
23
+ "./versions": "./lib/versions.js",
24
+ "./lib/generated/r4/types": "./lib/generated/r4/types.js",
25
+ "./lib/generated/r4/sets": "./lib/generated/r4/sets.js",
26
+ "./lib/generated/r4b/types": "./lib/generated/r4b/types.js",
27
+ "./lib/generated/r4b/sets": "./lib/generated/r4b/sets.js",
28
+ "./lib/versions": "./lib/versions.js",
29
+ "./r4/sets": "./lib/generated/r4/sets.js",
30
+ "./r4/types": "./lib/generated/r4/types.js",
31
+ "./r4b/sets": "./lib/generated/r4b/sets.js",
32
+ "./r4b/types": "./lib/generated/r4b/types.js"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^22.15.17",
36
+ "typescript": "5.9.2"
37
+ },
38
+ "files": [
39
+ "readme.md",
40
+ "types/**",
41
+ "lib/**",
42
+ "src/**"
43
+ ]
44
+ }
package/readme.md ADDED
@@ -0,0 +1,103 @@
1
+ # FHIR Typescript Types
2
+
3
+ Typescript types generated off of FHIR StructureDefinitions.
4
+
5
+ ## Usage
6
+
7
+ ```typescript
8
+ import { Observation, Patient, id } from "@haste-health/fhir-types/r4/types";
9
+
10
+ const patient: Patient = {
11
+ name: [
12
+ {
13
+ use: "official",
14
+ given: ["Eve"],
15
+ family: "Williams",
16
+ },
17
+ ],
18
+ active: true,
19
+ gender: "female",
20
+ address: [
21
+ {
22
+ use: "home",
23
+ line: ["2222 Home Street"],
24
+ },
25
+ ],
26
+ telecom: [
27
+ {
28
+ use: "work",
29
+ value: "555-555-2003",
30
+ system: "phone",
31
+ },
32
+ ],
33
+ birthDate: "1973-05-31",
34
+ identifier: [
35
+ {
36
+ type: {
37
+ coding: [
38
+ {
39
+ code: "SS",
40
+ system: "http://terminology.hl7.org/CodeSystem/v2-0203",
41
+ },
42
+ ],
43
+ },
44
+ value: "444222222",
45
+ system: "http://hl7.org/fhir/sid/us-ssn",
46
+ },
47
+ ],
48
+ resourceType: "Patient",
49
+ managingOrganization: {
50
+ reference: "Organization/hl7",
51
+ },
52
+ };
53
+ ```
54
+
55
+ ## Sets
56
+
57
+ Sets can be used to determine whether a type is a resource, primitive or complex type.
58
+ These are utilities that can be useful
59
+
60
+ | name | description |
61
+ | -------------- | ---------------------------------------------------------------- |
62
+ | resourceTypes | String set of FHIR resource types |
63
+ | complexTypes | String set of FHIR complex types (HumanName, Identifier etc...). |
64
+ | primitiveTypes | String set of FHIR primitive types (string, id, decimal etc...). |
65
+
66
+ ### Usage
67
+
68
+ ```typescript
69
+ import {
70
+ primitiveTypes,
71
+ resourceTypes,
72
+ } from "@haste-health/fhir-types/r4/sets";
73
+
74
+ function isPrimitiveType(type: string) {
75
+ returnprimitiveTypes.has(type);
76
+ }
77
+ function isResourceType(type: string) {
78
+ returnresourceTypes.has(type);
79
+ }
80
+ ```
81
+
82
+ ## Utility Types
83
+
84
+ Various utility types generally used for Typescript generic functions.
85
+
86
+ | Name | Description |
87
+ | ------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
88
+ | ResourceType | One of the resourcetypes, ie "Patient", "Observation". |
89
+ | AResource | Generic type with an argument of ResourceType, when passed in, returns an instance of ResourceType IE AResource\<"Patient"\> = Patient |
90
+ | Resource | An instance of one of the resource types |
91
+
92
+ ### Example
93
+
94
+ Pulled from @haste-health/client this example passes in an argument of ResourceType
95
+ which is a string of only allowed ResourceTypes and using AResource returns an object in conformance with the type passed in.
96
+
97
+ ```typescript
98
+ read<T extends ResourceType>(
99
+ ctx: CTX,
100
+ resourceType: T,
101
+ id: id
102
+ ): Promise<AResource<T> | undefined>;
103
+ ```
@@ -0,0 +1,6 @@
1
+ export const resourceTypes: Set<string> = new Set(["Resource","Account","ActivityDefinition","AdverseEvent","AllergyIntolerance","Appointment","AppointmentResponse","AuditEvent","Basic","Binary","BiologicallyDerivedProduct","BodyStructure","Bundle","CapabilityStatement","CarePlan","CareTeam","CatalogEntry","ChargeItem","ChargeItemDefinition","Claim","ClaimResponse","ClinicalImpression","CodeSystem","Communication","CommunicationRequest","CompartmentDefinition","Composition","ConceptMap","Condition","Consent","Contract","Coverage","CoverageEligibilityRequest","CoverageEligibilityResponse","DetectedIssue","Device","DeviceDefinition","DeviceMetric","DeviceRequest","DeviceUseStatement","DiagnosticReport","DocumentManifest","DocumentReference","DomainResource","EffectEvidenceSynthesis","Encounter","Endpoint","EnrollmentRequest","EnrollmentResponse","EpisodeOfCare","EventDefinition","Evidence","EvidenceVariable","ExampleScenario","ExplanationOfBenefit","FamilyMemberHistory","Flag","Goal","GraphDefinition","Group","GuidanceResponse","HealthcareService","ImagingStudy","Immunization","ImmunizationEvaluation","ImmunizationRecommendation","ImplementationGuide","InsurancePlan","Invoice","Library","Linkage","List","Location","Measure","MeasureReport","Media","Medication","MedicationAdministration","MedicationDispense","MedicationKnowledge","MedicationRequest","MedicationStatement","MedicinalProduct","MedicinalProductAuthorization","MedicinalProductContraindication","MedicinalProductIndication","MedicinalProductIngredient","MedicinalProductInteraction","MedicinalProductManufactured","MedicinalProductPackaged","MedicinalProductPharmaceutical","MedicinalProductUndesirableEffect","MessageDefinition","MessageHeader","MolecularSequence","NamingSystem","NutritionOrder","Observation","ObservationDefinition","OperationDefinition","OperationOutcome","Organization","OrganizationAffiliation","Parameters","Patient","PaymentNotice","PaymentReconciliation","Person","PlanDefinition","Practitioner","PractitionerRole","Procedure","Provenance","Questionnaire","QuestionnaireResponse","RelatedPerson","RequestGroup","ResearchDefinition","ResearchElementDefinition","ResearchStudy","ResearchSubject","RiskAssessment","RiskEvidenceSynthesis","Schedule","SearchParameter","ServiceRequest","Slot","Specimen","SpecimenDefinition","StructureDefinition","StructureMap","Subscription","Substance","SubstanceNucleicAcid","SubstancePolymer","SubstanceProtein","SubstanceReferenceInformation","SubstanceSourceMaterial","SubstanceSpecification","SupplyDelivery","SupplyRequest","Task","TerminologyCapabilities","TestReport","TestScript","ValueSet","VerificationResult","VisionPrescription","AccessPolicyV2","ClientApplication","IdentityProvider","Membership","Project","User"])
2
+
3
+ export const complexTypes: Set<string> = new Set(["Element","BackboneElement","Address","Age","Annotation","Attachment","CodeableConcept","Coding","ContactDetail","ContactPoint","Contributor","Count","DataRequirement","Distance","Dosage","Duration","ElementDefinition","Expression","Extension","HumanName","Identifier","MarketingStatus","Meta","Money","Narrative","ParameterDefinition","Period","Population","ProdCharacteristic","ProductShelfLife","Quantity","Range","Ratio","Reference","RelatedArtifact","SampledData","Signature","SubstanceAmount","Timing","TriggerDefinition","UsageContext"])
4
+
5
+ export const primitiveTypes: Set<string> = new Set(["base64Binary","boolean","canonical","code","date","dateTime","decimal","id","instant","integer","markdown","oid","positiveInt","string","time","unsignedInt","uri","url","uuid","xhtml"])
6
+