@medplum/core 0.2.0 → 0.4.0
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/README.md +32 -26
- package/dist/cjs/index.js +1769 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/index.min.js +16 -0
- package/dist/cjs/index.min.js.map +1 -0
- package/dist/esm/index.js +1721 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.min.js +16 -0
- package/dist/esm/index.min.js.map +1 -0
- package/dist/{cache.d.ts → types/cache.d.ts} +1 -0
- package/dist/{client.d.ts → types/client.d.ts} +115 -61
- package/dist/{crypto.d.ts → types/crypto.d.ts} +0 -0
- package/dist/{eventtarget.d.ts → types/eventtarget.d.ts} +0 -0
- package/dist/{format.d.ts → types/format.d.ts} +1 -1
- package/dist/{index.d.ts → types/index.d.ts} +0 -2
- package/dist/types/jwt.d.ts +5 -0
- package/dist/{outcomes.d.ts → types/outcomes.d.ts} +7 -2
- package/dist/{search.d.ts → types/search.d.ts} +3 -0
- package/dist/{searchparams.d.ts → types/searchparams.d.ts} +2 -1
- package/dist/{storage.d.ts → types/storage.d.ts} +0 -0
- package/dist/{types.d.ts → types/types.d.ts} +18 -4
- package/dist/{utils.d.ts → types/utils.d.ts} +1 -1
- package/package.json +14 -9
- package/rollup.config.js +36 -0
- package/dist/cache.js +0 -38
- package/dist/cache.js.map +0 -1
- package/dist/cache.test.d.ts +0 -1
- package/dist/cache.test.js +0 -29
- package/dist/cache.test.js.map +0 -1
- package/dist/client.js +0 -530
- package/dist/client.js.map +0 -1
- package/dist/client.test.d.ts +0 -1
- package/dist/client.test.js +0 -382
- package/dist/client.test.js.map +0 -1
- package/dist/crypto.js +0 -22
- package/dist/crypto.js.map +0 -1
- package/dist/eventtarget.js +0 -39
- package/dist/eventtarget.js.map +0 -1
- package/dist/eventtarget.test.d.ts +0 -1
- package/dist/eventtarget.test.js +0 -44
- package/dist/eventtarget.test.js.map +0 -1
- package/dist/fhir/AccessPolicy.d.ts +0 -75
- package/dist/fhir/AccessPolicy.js +0 -7
- package/dist/fhir/AccessPolicy.js.map +0 -1
- package/dist/fhir/Account.d.ts +0 -247
- package/dist/fhir/Account.js +0 -7
- package/dist/fhir/Account.js.map +0 -1
- package/dist/fhir/ActivityDefinition.d.ts +0 -500
- package/dist/fhir/ActivityDefinition.js +0 -7
- package/dist/fhir/ActivityDefinition.js.map +0 -1
- package/dist/fhir/Address.d.ts +0 -75
- package/dist/fhir/Address.js +0 -7
- package/dist/fhir/Address.js.map +0 -1
- package/dist/fhir/AdverseEvent.d.ts +0 -303
- package/dist/fhir/AdverseEvent.js +0 -7
- package/dist/fhir/AdverseEvent.js.map +0 -1
- package/dist/fhir/Age.d.ts +0 -47
- package/dist/fhir/Age.js +0 -7
- package/dist/fhir/Age.js.map +0 -1
- package/dist/fhir/AllergyIntolerance.d.ts +0 -283
- package/dist/fhir/AllergyIntolerance.js +0 -7
- package/dist/fhir/AllergyIntolerance.js.map +0 -1
- package/dist/fhir/Annotation.d.ts +0 -42
- package/dist/fhir/Annotation.js +0 -7
- package/dist/fhir/Annotation.js.map +0 -1
- package/dist/fhir/Appointment.d.ts +0 -284
- package/dist/fhir/Appointment.js +0 -7
- package/dist/fhir/Appointment.js.map +0 -1
- package/dist/fhir/AppointmentResponse.d.ts +0 -131
- package/dist/fhir/AppointmentResponse.js +0 -7
- package/dist/fhir/AppointmentResponse.js.map +0 -1
- package/dist/fhir/Attachment.d.ts +0 -58
- package/dist/fhir/Attachment.js +0 -7
- package/dist/fhir/Attachment.js.map +0 -1
- package/dist/fhir/AuditEvent.d.ts +0 -458
- package/dist/fhir/AuditEvent.js +0 -7
- package/dist/fhir/AuditEvent.js.map +0 -1
- package/dist/fhir/Basic.d.ts +0 -110
- package/dist/fhir/Basic.js +0 -7
- package/dist/fhir/Basic.js.map +0 -1
- package/dist/fhir/Binary.d.ts +0 -59
- package/dist/fhir/Binary.js +0 -7
- package/dist/fhir/Binary.js.map +0 -1
- package/dist/fhir/BiologicallyDerivedProduct.d.ts +0 -358
- package/dist/fhir/BiologicallyDerivedProduct.js +0 -7
- package/dist/fhir/BiologicallyDerivedProduct.js.map +0 -1
- package/dist/fhir/BodyStructure.d.ts +0 -119
- package/dist/fhir/BodyStructure.js +0 -7
- package/dist/fhir/BodyStructure.js.map +0 -1
- package/dist/fhir/Bot.d.ts +0 -49
- package/dist/fhir/Bot.js +0 -7
- package/dist/fhir/Bot.js.map +0 -1
- package/dist/fhir/Bundle.d.ts +0 -379
- package/dist/fhir/Bundle.js +0 -7
- package/dist/fhir/Bundle.js.map +0 -1
- package/dist/fhir/CapabilityStatement.d.ts +0 -1044
- package/dist/fhir/CapabilityStatement.js +0 -7
- package/dist/fhir/CapabilityStatement.js.map +0 -1
- package/dist/fhir/CarePlan.d.ts +0 -446
- package/dist/fhir/CarePlan.js +0 -7
- package/dist/fhir/CarePlan.js.map +0 -1
- package/dist/fhir/CareTeam.d.ts +0 -211
- package/dist/fhir/CareTeam.js +0 -7
- package/dist/fhir/CareTeam.js.map +0 -1
- package/dist/fhir/CatalogEntry.d.ts +0 -195
- package/dist/fhir/CatalogEntry.js +0 -7
- package/dist/fhir/CatalogEntry.js.map +0 -1
- package/dist/fhir/ChargeItem.d.ts +0 -287
- package/dist/fhir/ChargeItem.js +0 -7
- package/dist/fhir/ChargeItem.js.map +0 -1
- package/dist/fhir/ChargeItemDefinition.d.ts +0 -401
- package/dist/fhir/ChargeItemDefinition.js +0 -7
- package/dist/fhir/ChargeItemDefinition.js.map +0 -1
- package/dist/fhir/Claim.d.ts +0 -1092
- package/dist/fhir/Claim.js +0 -7
- package/dist/fhir/Claim.js.map +0 -1
- package/dist/fhir/ClaimResponse.d.ts +0 -1040
- package/dist/fhir/ClaimResponse.js +0 -7
- package/dist/fhir/ClaimResponse.js.map +0 -1
- package/dist/fhir/ClientApplication.d.ts +0 -46
- package/dist/fhir/ClientApplication.js +0 -7
- package/dist/fhir/ClientApplication.js.map +0 -1
- package/dist/fhir/ClinicalImpression.d.ts +0 -306
- package/dist/fhir/ClinicalImpression.js +0 -7
- package/dist/fhir/ClinicalImpression.js.map +0 -1
- package/dist/fhir/CodeSystem.d.ts +0 -541
- package/dist/fhir/CodeSystem.js +0 -7
- package/dist/fhir/CodeSystem.js.map +0 -1
- package/dist/fhir/CodeableConcept.d.ts +0 -33
- package/dist/fhir/CodeableConcept.js +0 -7
- package/dist/fhir/CodeableConcept.js.map +0 -1
- package/dist/fhir/Coding.d.ts +0 -50
- package/dist/fhir/Coding.js +0 -7
- package/dist/fhir/Coding.js.map +0 -1
- package/dist/fhir/Communication.d.ts +0 -264
- package/dist/fhir/Communication.js +0 -7
- package/dist/fhir/Communication.js.map +0 -1
- package/dist/fhir/CommunicationRequest.d.ts +0 -261
- package/dist/fhir/CommunicationRequest.js +0 -7
- package/dist/fhir/CommunicationRequest.js.map +0 -1
- package/dist/fhir/CompartmentDefinition.d.ts +0 -217
- package/dist/fhir/CompartmentDefinition.js +0 -7
- package/dist/fhir/CompartmentDefinition.js.map +0 -1
- package/dist/fhir/Composition.d.ts +0 -429
- package/dist/fhir/Composition.js +0 -7
- package/dist/fhir/Composition.js.map +0 -1
- package/dist/fhir/ConceptMap.d.ts +0 -518
- package/dist/fhir/ConceptMap.js +0 -7
- package/dist/fhir/ConceptMap.js.map +0 -1
- package/dist/fhir/Condition.d.ts +0 -326
- package/dist/fhir/Condition.js +0 -7
- package/dist/fhir/Condition.js.map +0 -1
- package/dist/fhir/Consent.d.ts +0 -460
- package/dist/fhir/Consent.js +0 -7
- package/dist/fhir/Consent.js.map +0 -1
- package/dist/fhir/ContactDetail.d.ts +0 -31
- package/dist/fhir/ContactDetail.js +0 -7
- package/dist/fhir/ContactDetail.js.map +0 -1
- package/dist/fhir/ContactPoint.d.ts +0 -47
- package/dist/fhir/ContactPoint.js +0 -7
- package/dist/fhir/ContactPoint.js.map +0 -1
- package/dist/fhir/Contract.d.ts +0 -1452
- package/dist/fhir/Contract.js +0 -7
- package/dist/fhir/Contract.js.map +0 -1
- package/dist/fhir/Contributor.d.ts +0 -37
- package/dist/fhir/Contributor.js +0 -7
- package/dist/fhir/Contributor.js.map +0 -1
- package/dist/fhir/Count.d.ts +0 -49
- package/dist/fhir/Count.js +0 -7
- package/dist/fhir/Count.js.map +0 -1
- package/dist/fhir/Coverage.d.ts +0 -327
- package/dist/fhir/Coverage.js +0 -7
- package/dist/fhir/Coverage.js.map +0 -1
- package/dist/fhir/CoverageEligibilityRequest.d.ts +0 -404
- package/dist/fhir/CoverageEligibilityRequest.js +0 -7
- package/dist/fhir/CoverageEligibilityRequest.js.map +0 -1
- package/dist/fhir/CoverageEligibilityResponse.d.ts +0 -434
- package/dist/fhir/CoverageEligibilityResponse.js +0 -7
- package/dist/fhir/CoverageEligibilityResponse.js.map +0 -1
- package/dist/fhir/DataRequirement.d.ts +0 -239
- package/dist/fhir/DataRequirement.js +0 -7
- package/dist/fhir/DataRequirement.js.map +0 -1
- package/dist/fhir/DetectedIssue.d.ts +0 -252
- package/dist/fhir/DetectedIssue.js +0 -7
- package/dist/fhir/DetectedIssue.js.map +0 -1
- package/dist/fhir/Device.d.ts +0 -493
- package/dist/fhir/Device.js +0 -7
- package/dist/fhir/Device.js.map +0 -1
- package/dist/fhir/DeviceDefinition.d.ts +0 -486
- package/dist/fhir/DeviceDefinition.js +0 -7
- package/dist/fhir/DeviceDefinition.js.map +0 -1
- package/dist/fhir/DeviceMetric.d.ts +0 -199
- package/dist/fhir/DeviceMetric.js +0 -7
- package/dist/fhir/DeviceMetric.js.map +0 -1
- package/dist/fhir/DeviceRequest.d.ts +0 -296
- package/dist/fhir/DeviceRequest.js +0 -7
- package/dist/fhir/DeviceRequest.js.map +0 -1
- package/dist/fhir/DeviceUseStatement.d.ts +0 -168
- package/dist/fhir/DeviceUseStatement.js +0 -7
- package/dist/fhir/DeviceUseStatement.js.map +0 -1
- package/dist/fhir/DiagnosticReport.d.ts +0 -254
- package/dist/fhir/DiagnosticReport.js +0 -7
- package/dist/fhir/DiagnosticReport.js.map +0 -1
- package/dist/fhir/Distance.d.ts +0 -47
- package/dist/fhir/Distance.js +0 -7
- package/dist/fhir/Distance.js.map +0 -1
- package/dist/fhir/DocumentManifest.d.ts +0 -196
- package/dist/fhir/DocumentManifest.js +0 -7
- package/dist/fhir/DocumentManifest.js.map +0 -1
- package/dist/fhir/DocumentReference.d.ts +0 -349
- package/dist/fhir/DocumentReference.js +0 -7
- package/dist/fhir/DocumentReference.js.map +0 -1
- package/dist/fhir/Dosage.d.ts +0 -152
- package/dist/fhir/Dosage.js +0 -7
- package/dist/fhir/Dosage.js.map +0 -1
- package/dist/fhir/Duration.d.ts +0 -46
- package/dist/fhir/Duration.js +0 -7
- package/dist/fhir/Duration.js.map +0 -1
- package/dist/fhir/EffectEvidenceSynthesis.d.ts +0 -591
- package/dist/fhir/EffectEvidenceSynthesis.js +0 -7
- package/dist/fhir/EffectEvidenceSynthesis.js.map +0 -1
- package/dist/fhir/Element.d.ts +0 -21
- package/dist/fhir/Element.js +0 -7
- package/dist/fhir/Element.js.map +0 -1
- package/dist/fhir/ElementDefinition.d.ts +0 -2701
- package/dist/fhir/ElementDefinition.js +0 -7
- package/dist/fhir/ElementDefinition.js.map +0 -1
- package/dist/fhir/Encounter.d.ts +0 -558
- package/dist/fhir/Encounter.js +0 -7
- package/dist/fhir/Encounter.js.map +0 -1
- package/dist/fhir/Endpoint.d.ts +0 -140
- package/dist/fhir/Endpoint.js +0 -7
- package/dist/fhir/Endpoint.js.map +0 -1
- package/dist/fhir/EnrollmentRequest.d.ts +0 -113
- package/dist/fhir/EnrollmentRequest.js +0 -7
- package/dist/fhir/EnrollmentRequest.js.map +0 -1
- package/dist/fhir/EnrollmentResponse.d.ts +0 -117
- package/dist/fhir/EnrollmentResponse.js +0 -7
- package/dist/fhir/EnrollmentResponse.js.map +0 -1
- package/dist/fhir/EpisodeOfCare.d.ts +0 -246
- package/dist/fhir/EpisodeOfCare.js +0 -7
- package/dist/fhir/EpisodeOfCare.js.map +0 -1
- package/dist/fhir/EventDefinition.d.ts +0 -253
- package/dist/fhir/EventDefinition.js +0 -7
- package/dist/fhir/EventDefinition.js.map +0 -1
- package/dist/fhir/Evidence.d.ts +0 -252
- package/dist/fhir/Evidence.js +0 -7
- package/dist/fhir/Evidence.js.map +0 -1
- package/dist/fhir/EvidenceVariable.d.ts +0 -370
- package/dist/fhir/EvidenceVariable.js +0 -7
- package/dist/fhir/EvidenceVariable.js.map +0 -1
- package/dist/fhir/ExampleScenario.d.ts +0 -628
- package/dist/fhir/ExampleScenario.js +0 -7
- package/dist/fhir/ExampleScenario.js.map +0 -1
- package/dist/fhir/ExplanationOfBenefit.d.ts +0 -1841
- package/dist/fhir/ExplanationOfBenefit.js +0 -7
- package/dist/fhir/ExplanationOfBenefit.js.map +0 -1
- package/dist/fhir/Expression.d.ts +0 -45
- package/dist/fhir/Expression.js +0 -7
- package/dist/fhir/Expression.js.map +0 -1
- package/dist/fhir/Extension.d.ts +0 -306
- package/dist/fhir/Extension.js +0 -7
- package/dist/fhir/Extension.js.map +0 -1
- package/dist/fhir/FamilyMemberHistory.d.ts +0 -306
- package/dist/fhir/FamilyMemberHistory.js +0 -7
- package/dist/fhir/FamilyMemberHistory.js.map +0 -1
- package/dist/fhir/Flag.d.ts +0 -132
- package/dist/fhir/Flag.js +0 -7
- package/dist/fhir/Flag.js.map +0 -1
- package/dist/fhir/Goal.d.ts +0 -299
- package/dist/fhir/Goal.js +0 -7
- package/dist/fhir/Goal.js.map +0 -1
- package/dist/fhir/GraphDefinition.d.ts +0 -350
- package/dist/fhir/GraphDefinition.js +0 -7
- package/dist/fhir/GraphDefinition.js.map +0 -1
- package/dist/fhir/Group.d.ts +0 -271
- package/dist/fhir/Group.js +0 -7
- package/dist/fhir/Group.js.map +0 -1
- package/dist/fhir/GuidanceResponse.d.ts +0 -196
- package/dist/fhir/GuidanceResponse.js +0 -7
- package/dist/fhir/GuidanceResponse.js.map +0 -1
- package/dist/fhir/HealthcareService.d.ts +0 -356
- package/dist/fhir/HealthcareService.js +0 -7
- package/dist/fhir/HealthcareService.js.map +0 -1
- package/dist/fhir/HumanName.d.ts +0 -58
- package/dist/fhir/HumanName.js +0 -7
- package/dist/fhir/HumanName.js.map +0 -1
- package/dist/fhir/Identifier.d.ts +0 -53
- package/dist/fhir/Identifier.js +0 -7
- package/dist/fhir/Identifier.js.map +0 -1
- package/dist/fhir/ImagingStudy.d.ts +0 -407
- package/dist/fhir/ImagingStudy.js +0 -7
- package/dist/fhir/ImagingStudy.js.map +0 -1
- package/dist/fhir/Immunization.d.ts +0 -444
- package/dist/fhir/Immunization.js +0 -7
- package/dist/fhir/Immunization.js.map +0 -1
- package/dist/fhir/ImmunizationEvaluation.d.ts +0 -149
- package/dist/fhir/ImmunizationEvaluation.js +0 -7
- package/dist/fhir/ImmunizationEvaluation.js.map +0 -1
- package/dist/fhir/ImmunizationRecommendation.d.ts +0 -254
- package/dist/fhir/ImmunizationRecommendation.js +0 -7
- package/dist/fhir/ImmunizationRecommendation.js.map +0 -1
- package/dist/fhir/ImplementationGuide.d.ts +0 -824
- package/dist/fhir/ImplementationGuide.js +0 -7
- package/dist/fhir/ImplementationGuide.js.map +0 -1
- package/dist/fhir/InsurancePlan.d.ts +0 -624
- package/dist/fhir/InsurancePlan.js +0 -7
- package/dist/fhir/InsurancePlan.js.map +0 -1
- package/dist/fhir/Invoice.d.ts +0 -346
- package/dist/fhir/Invoice.js +0 -7
- package/dist/fhir/Invoice.js.map +0 -1
- package/dist/fhir/JsonWebKey.d.ts +0 -99
- package/dist/fhir/JsonWebKey.js +0 -7
- package/dist/fhir/JsonWebKey.js.map +0 -1
- package/dist/fhir/Library.d.ts +0 -277
- package/dist/fhir/Library.js +0 -7
- package/dist/fhir/Library.js.map +0 -1
- package/dist/fhir/Linkage.d.ts +0 -146
- package/dist/fhir/Linkage.js +0 -7
- package/dist/fhir/Linkage.js.map +0 -1
- package/dist/fhir/List.d.ts +0 -200
- package/dist/fhir/List.js +0 -7
- package/dist/fhir/List.js.map +0 -1
- package/dist/fhir/Location.d.ts +0 -277
- package/dist/fhir/Location.js +0 -7
- package/dist/fhir/Location.js.map +0 -1
- package/dist/fhir/Login.d.ts +0 -119
- package/dist/fhir/Login.js +0 -7
- package/dist/fhir/Login.js.map +0 -1
- package/dist/fhir/MarketingStatus.d.ts +0 -82
- package/dist/fhir/MarketingStatus.js +0 -7
- package/dist/fhir/MarketingStatus.js.map +0 -1
- package/dist/fhir/Measure.d.ts +0 -620
- package/dist/fhir/Measure.js +0 -7
- package/dist/fhir/Measure.js.map +0 -1
- package/dist/fhir/MeasureReport.d.ts +0 -463
- package/dist/fhir/MeasureReport.js +0 -7
- package/dist/fhir/MeasureReport.js.map +0 -1
- package/dist/fhir/Media.d.ts +0 -205
- package/dist/fhir/Media.js +0 -7
- package/dist/fhir/Media.js.map +0 -1
- package/dist/fhir/Medication.d.ts +0 -230
- package/dist/fhir/Medication.js +0 -7
- package/dist/fhir/Medication.js.map +0 -1
- package/dist/fhir/MedicationAdministration.d.ts +0 -352
- package/dist/fhir/MedicationAdministration.js +0 -7
- package/dist/fhir/MedicationAdministration.js.map +0 -1
- package/dist/fhir/MedicationDispense.d.ts +0 -343
- package/dist/fhir/MedicationDispense.js +0 -7
- package/dist/fhir/MedicationDispense.js.map +0 -1
- package/dist/fhir/MedicationKnowledge.d.ts +0 -992
- package/dist/fhir/MedicationKnowledge.js +0 -7
- package/dist/fhir/MedicationKnowledge.js.map +0 -1
- package/dist/fhir/MedicationRequest.d.ts +0 -481
- package/dist/fhir/MedicationRequest.js +0 -7
- package/dist/fhir/MedicationRequest.js.map +0 -1
- package/dist/fhir/MedicationStatement.d.ts +0 -228
- package/dist/fhir/MedicationStatement.js +0 -7
- package/dist/fhir/MedicationStatement.js.map +0 -1
- package/dist/fhir/MedicinalProduct.d.ts +0 -453
- package/dist/fhir/MedicinalProduct.js +0 -7
- package/dist/fhir/MedicinalProduct.js.map +0 -1
- package/dist/fhir/MedicinalProductAuthorization.d.ts +0 -271
- package/dist/fhir/MedicinalProductAuthorization.js +0 -7
- package/dist/fhir/MedicinalProductAuthorization.js.map +0 -1
- package/dist/fhir/MedicinalProductContraindication.d.ts +0 -170
- package/dist/fhir/MedicinalProductContraindication.js +0 -7
- package/dist/fhir/MedicinalProductContraindication.js.map +0 -1
- package/dist/fhir/MedicinalProductIndication.d.ts +0 -179
- package/dist/fhir/MedicinalProductIndication.js +0 -7
- package/dist/fhir/MedicinalProductIndication.js.map +0 -1
- package/dist/fhir/MedicinalProductIngredient.d.ts +0 -336
- package/dist/fhir/MedicinalProductIngredient.js +0 -7
- package/dist/fhir/MedicinalProductIngredient.js.map +0 -1
- package/dist/fhir/MedicinalProductInteraction.d.ts +0 -158
- package/dist/fhir/MedicinalProductInteraction.js +0 -7
- package/dist/fhir/MedicinalProductInteraction.js.map +0 -1
- package/dist/fhir/MedicinalProductManufactured.d.ts +0 -113
- package/dist/fhir/MedicinalProductManufactured.js +0 -7
- package/dist/fhir/MedicinalProductManufactured.js.map +0 -1
- package/dist/fhir/MedicinalProductPackaged.d.ts +0 -259
- package/dist/fhir/MedicinalProductPackaged.js +0 -7
- package/dist/fhir/MedicinalProductPackaged.js.map +0 -1
- package/dist/fhir/MedicinalProductPharmaceutical.d.ts +0 -331
- package/dist/fhir/MedicinalProductPharmaceutical.js +0 -7
- package/dist/fhir/MedicinalProductPharmaceutical.js.map +0 -1
- package/dist/fhir/MedicinalProductUndesirableEffect.d.ts +0 -101
- package/dist/fhir/MedicinalProductUndesirableEffect.js +0 -7
- package/dist/fhir/MedicinalProductUndesirableEffect.js.map +0 -1
- package/dist/fhir/MessageDefinition.d.ts +0 -330
- package/dist/fhir/MessageDefinition.js +0 -7
- package/dist/fhir/MessageDefinition.js.map +0 -1
- package/dist/fhir/MessageHeader.d.ts +0 -323
- package/dist/fhir/MessageHeader.js +0 -7
- package/dist/fhir/MessageHeader.js.map +0 -1
- package/dist/fhir/Meta.d.ts +0 -75
- package/dist/fhir/Meta.js +0 -7
- package/dist/fhir/Meta.js.map +0 -1
- package/dist/fhir/MolecularSequence.d.ts +0 -760
- package/dist/fhir/MolecularSequence.js +0 -7
- package/dist/fhir/MolecularSequence.js.map +0 -1
- package/dist/fhir/Money.d.ts +0 -29
- package/dist/fhir/Money.js +0 -7
- package/dist/fhir/Money.js.map +0 -1
- package/dist/fhir/NamingSystem.d.ts +0 -218
- package/dist/fhir/NamingSystem.js +0 -7
- package/dist/fhir/NamingSystem.js.map +0 -1
- package/dist/fhir/Narrative.d.ts +0 -32
- package/dist/fhir/Narrative.js +0 -7
- package/dist/fhir/Narrative.js.map +0 -1
- package/dist/fhir/NutritionOrder.d.ts +0 -566
- package/dist/fhir/NutritionOrder.js +0 -7
- package/dist/fhir/NutritionOrder.js.map +0 -1
- package/dist/fhir/Observation.d.ts +0 -520
- package/dist/fhir/Observation.js +0 -7
- package/dist/fhir/Observation.js.map +0 -1
- package/dist/fhir/ObservationDefinition.d.ts +0 -278
- package/dist/fhir/ObservationDefinition.js +0 -7
- package/dist/fhir/ObservationDefinition.js.map +0 -1
- package/dist/fhir/OperationDefinition.d.ts +0 -468
- package/dist/fhir/OperationDefinition.js +0 -7
- package/dist/fhir/OperationDefinition.js.map +0 -1
- package/dist/fhir/OperationOutcome.d.ts +0 -160
- package/dist/fhir/OperationOutcome.js +0 -7
- package/dist/fhir/OperationOutcome.js.map +0 -1
- package/dist/fhir/Organization.d.ts +0 -184
- package/dist/fhir/Organization.js +0 -7
- package/dist/fhir/Organization.js.map +0 -1
- package/dist/fhir/OrganizationAffiliation.d.ts +0 -145
- package/dist/fhir/OrganizationAffiliation.js +0 -7
- package/dist/fhir/OrganizationAffiliation.js.map +0 -1
- package/dist/fhir/ParameterDefinition.d.ts +0 -57
- package/dist/fhir/ParameterDefinition.js +0 -7
- package/dist/fhir/ParameterDefinition.js.map +0 -1
- package/dist/fhir/Parameters.d.ts +0 -319
- package/dist/fhir/Parameters.js +0 -7
- package/dist/fhir/Parameters.js.map +0 -1
- package/dist/fhir/PasswordChangeRequest.d.ts +0 -51
- package/dist/fhir/PasswordChangeRequest.js +0 -7
- package/dist/fhir/PasswordChangeRequest.js.map +0 -1
- package/dist/fhir/Patient.d.ts +0 -342
- package/dist/fhir/Patient.js +0 -7
- package/dist/fhir/Patient.js.map +0 -1
- package/dist/fhir/PaymentNotice.d.ts +0 -135
- package/dist/fhir/PaymentNotice.js +0 -7
- package/dist/fhir/PaymentNotice.js.map +0 -1
- package/dist/fhir/PaymentReconciliation.d.ts +0 -280
- package/dist/fhir/PaymentReconciliation.js +0 -7
- package/dist/fhir/PaymentReconciliation.js.map +0 -1
- package/dist/fhir/Period.d.ts +0 -32
- package/dist/fhir/Period.js +0 -7
- package/dist/fhir/Period.js.map +0 -1
- package/dist/fhir/Person.d.ts +0 -175
- package/dist/fhir/Person.js +0 -7
- package/dist/fhir/Person.js.map +0 -1
- package/dist/fhir/PlanDefinition.d.ts +0 -837
- package/dist/fhir/PlanDefinition.js +0 -7
- package/dist/fhir/PlanDefinition.js.map +0 -1
- package/dist/fhir/Population.d.ts +0 -62
- package/dist/fhir/Population.js +0 -7
- package/dist/fhir/Population.js.map +0 -1
- package/dist/fhir/Practitioner.d.ts +0 -191
- package/dist/fhir/Practitioner.js +0 -7
- package/dist/fhir/Practitioner.js.map +0 -1
- package/dist/fhir/PractitionerRole.d.ts +0 -259
- package/dist/fhir/PractitionerRole.js +0 -7
- package/dist/fhir/PractitionerRole.js.map +0 -1
- package/dist/fhir/Procedure.d.ts +0 -372
- package/dist/fhir/Procedure.js +0 -7
- package/dist/fhir/Procedure.js.map +0 -1
- package/dist/fhir/ProdCharacteristic.d.ts +0 -112
- package/dist/fhir/ProdCharacteristic.js +0 -7
- package/dist/fhir/ProdCharacteristic.js.map +0 -1
- package/dist/fhir/ProductShelfLife.d.ts +0 -70
- package/dist/fhir/ProductShelfLife.js +0 -7
- package/dist/fhir/ProductShelfLife.js.map +0 -1
- package/dist/fhir/Project.d.ts +0 -43
- package/dist/fhir/Project.js +0 -7
- package/dist/fhir/Project.js.map +0 -1
- package/dist/fhir/ProjectMembership.d.ts +0 -66
- package/dist/fhir/ProjectMembership.js +0 -7
- package/dist/fhir/ProjectMembership.js.map +0 -1
- package/dist/fhir/Provenance.d.ts +0 -258
- package/dist/fhir/Provenance.js +0 -7
- package/dist/fhir/Provenance.js.map +0 -1
- package/dist/fhir/Quantity.d.ts +0 -46
- package/dist/fhir/Quantity.js +0 -7
- package/dist/fhir/Quantity.js.map +0 -1
- package/dist/fhir/Questionnaire.d.ts +0 -603
- package/dist/fhir/Questionnaire.js +0 -7
- package/dist/fhir/Questionnaire.js.map +0 -1
- package/dist/fhir/QuestionnaireResponse.d.ts +0 -313
- package/dist/fhir/QuestionnaireResponse.js +0 -7
- package/dist/fhir/QuestionnaireResponse.js.map +0 -1
- package/dist/fhir/Range.d.ts +0 -30
- package/dist/fhir/Range.js +0 -7
- package/dist/fhir/Range.js.map +0 -1
- package/dist/fhir/Ratio.d.ts +0 -30
- package/dist/fhir/Ratio.js +0 -7
- package/dist/fhir/Ratio.js.map +0 -1
- package/dist/fhir/Reference.d.ts +0 -67
- package/dist/fhir/Reference.js +0 -7
- package/dist/fhir/Reference.js.map +0 -1
- package/dist/fhir/RefreshToken.d.ts +0 -45
- package/dist/fhir/RefreshToken.js +0 -7
- package/dist/fhir/RefreshToken.js.map +0 -1
- package/dist/fhir/RelatedArtifact.d.ts +0 -57
- package/dist/fhir/RelatedArtifact.js +0 -7
- package/dist/fhir/RelatedArtifact.js.map +0 -1
- package/dist/fhir/RelatedPerson.d.ts +0 -190
- package/dist/fhir/RelatedPerson.js +0 -7
- package/dist/fhir/RelatedPerson.js.map +0 -1
- package/dist/fhir/RequestGroup.d.ts +0 -434
- package/dist/fhir/RequestGroup.js +0 -7
- package/dist/fhir/RequestGroup.js.map +0 -1
- package/dist/fhir/ResearchDefinition.d.ts +0 -291
- package/dist/fhir/ResearchDefinition.js +0 -7
- package/dist/fhir/ResearchDefinition.js.map +0 -1
- package/dist/fhir/ResearchElementDefinition.d.ts +0 -431
- package/dist/fhir/ResearchElementDefinition.js +0 -7
- package/dist/fhir/ResearchElementDefinition.js.map +0 -1
- package/dist/fhir/ResearchStudy.d.ts +0 -318
- package/dist/fhir/ResearchStudy.js +0 -7
- package/dist/fhir/ResearchStudy.js.map +0 -1
- package/dist/fhir/ResearchSubject.d.ts +0 -119
- package/dist/fhir/ResearchSubject.js +0 -7
- package/dist/fhir/ResearchSubject.js.map +0 -1
- package/dist/fhir/Resource.d.ts +0 -156
- package/dist/fhir/Resource.js +0 -7
- package/dist/fhir/Resource.js.map +0 -1
- package/dist/fhir/RiskAssessment.d.ts +0 -246
- package/dist/fhir/RiskAssessment.js +0 -7
- package/dist/fhir/RiskAssessment.js.map +0 -1
- package/dist/fhir/RiskEvidenceSynthesis.d.ts +0 -530
- package/dist/fhir/RiskEvidenceSynthesis.js +0 -7
- package/dist/fhir/RiskEvidenceSynthesis.js.map +0 -1
- package/dist/fhir/SampledData.d.ts +0 -62
- package/dist/fhir/SampledData.js +0 -7
- package/dist/fhir/SampledData.js.map +0 -1
- package/dist/fhir/Schedule.d.ts +0 -129
- package/dist/fhir/Schedule.js +0 -7
- package/dist/fhir/Schedule.js.map +0 -1
- package/dist/fhir/SearchParameter.d.ts +0 -277
- package/dist/fhir/SearchParameter.js +0 -7
- package/dist/fhir/SearchParameter.js.map +0 -1
- package/dist/fhir/ServiceRequest.d.ts +0 -309
- package/dist/fhir/ServiceRequest.js +0 -7
- package/dist/fhir/ServiceRequest.js.map +0 -1
- package/dist/fhir/Signature.d.ts +0 -71
- package/dist/fhir/Signature.js +0 -7
- package/dist/fhir/Signature.js.map +0 -1
- package/dist/fhir/Slot.d.ts +0 -134
- package/dist/fhir/Slot.js +0 -7
- package/dist/fhir/Slot.js.map +0 -1
- package/dist/fhir/Specimen.d.ts +0 -366
- package/dist/fhir/Specimen.js +0 -7
- package/dist/fhir/Specimen.js.map +0 -1
- package/dist/fhir/SpecimenDefinition.d.ts +0 -363
- package/dist/fhir/SpecimenDefinition.js +0 -7
- package/dist/fhir/SpecimenDefinition.js.map +0 -1
- package/dist/fhir/StructureDefinition.d.ts +0 -438
- package/dist/fhir/StructureDefinition.js +0 -7
- package/dist/fhir/StructureDefinition.js.map +0 -1
- package/dist/fhir/StructureMap.d.ts +0 -904
- package/dist/fhir/StructureMap.js +0 -7
- package/dist/fhir/StructureMap.js.map +0 -1
- package/dist/fhir/Subscription.d.ts +0 -172
- package/dist/fhir/Subscription.js +0 -7
- package/dist/fhir/Subscription.js.map +0 -1
- package/dist/fhir/Substance.d.ts +0 -213
- package/dist/fhir/Substance.js +0 -7
- package/dist/fhir/Substance.js.map +0 -1
- package/dist/fhir/SubstanceAmount.d.ts +0 -115
- package/dist/fhir/SubstanceAmount.js +0 -7
- package/dist/fhir/SubstanceAmount.js.map +0 -1
- package/dist/fhir/SubstanceNucleicAcid.d.ts +0 -309
- package/dist/fhir/SubstanceNucleicAcid.js +0 -7
- package/dist/fhir/SubstanceNucleicAcid.js.map +0 -1
- package/dist/fhir/SubstancePolymer.d.ts +0 -405
- package/dist/fhir/SubstancePolymer.js +0 -7
- package/dist/fhir/SubstancePolymer.js.map +0 -1
- package/dist/fhir/SubstanceProtein.d.ts +0 -218
- package/dist/fhir/SubstanceProtein.js +0 -7
- package/dist/fhir/SubstanceProtein.js.map +0 -1
- package/dist/fhir/SubstanceReferenceInformation.d.ts +0 -330
- package/dist/fhir/SubstanceReferenceInformation.js +0 -7
- package/dist/fhir/SubstanceReferenceInformation.js.map +0 -1
- package/dist/fhir/SubstanceSourceMaterial.d.ts +0 -521
- package/dist/fhir/SubstanceSourceMaterial.js +0 -7
- package/dist/fhir/SubstanceSourceMaterial.js.map +0 -1
- package/dist/fhir/SubstanceSpecification.d.ts +0 -827
- package/dist/fhir/SubstanceSpecification.js +0 -7
- package/dist/fhir/SubstanceSpecification.js.map +0 -1
- package/dist/fhir/SupplyDelivery.d.ts +0 -205
- package/dist/fhir/SupplyDelivery.js +0 -7
- package/dist/fhir/SupplyDelivery.js.map +0 -1
- package/dist/fhir/SupplyRequest.d.ts +0 -237
- package/dist/fhir/SupplyRequest.js +0 -7
- package/dist/fhir/SupplyRequest.js.map +0 -1
- package/dist/fhir/Task.d.ts +0 -807
- package/dist/fhir/Task.js +0 -7
- package/dist/fhir/Task.js.map +0 -1
- package/dist/fhir/TerminologyCapabilities.d.ts +0 -716
- package/dist/fhir/TerminologyCapabilities.js +0 -7
- package/dist/fhir/TerminologyCapabilities.js.map +0 -1
- package/dist/fhir/TestReport.d.ts +0 -549
- package/dist/fhir/TestReport.js +0 -7
- package/dist/fhir/TestReport.js.map +0 -1
- package/dist/fhir/TestScript.d.ts +0 -1184
- package/dist/fhir/TestScript.js +0 -7
- package/dist/fhir/TestScript.js.map +0 -1
- package/dist/fhir/Timing.d.ts +0 -178
- package/dist/fhir/Timing.js +0 -7
- package/dist/fhir/Timing.js.map +0 -1
- package/dist/fhir/TriggerDefinition.d.ts +0 -65
- package/dist/fhir/TriggerDefinition.js +0 -7
- package/dist/fhir/TriggerDefinition.js.map +0 -1
- package/dist/fhir/UsageContext.d.ts +0 -61
- package/dist/fhir/UsageContext.js +0 -7
- package/dist/fhir/UsageContext.js.map +0 -1
- package/dist/fhir/User.d.ts +0 -45
- package/dist/fhir/User.js +0 -7
- package/dist/fhir/User.js.map +0 -1
- package/dist/fhir/ValueSet.d.ts +0 -725
- package/dist/fhir/ValueSet.js +0 -7
- package/dist/fhir/ValueSet.js.map +0 -1
- package/dist/fhir/VerificationResult.d.ts +0 -340
- package/dist/fhir/VerificationResult.js +0 -7
- package/dist/fhir/VerificationResult.js.map +0 -1
- package/dist/fhir/VisionPrescription.d.ts +0 -264
- package/dist/fhir/VisionPrescription.js +0 -7
- package/dist/fhir/VisionPrescription.js.map +0 -1
- package/dist/fhir/index.d.ts +0 -196
- package/dist/fhir/index.js +0 -213
- package/dist/fhir/index.js.map +0 -1
- package/dist/fhirpath/functions.d.ts +0 -6
- package/dist/fhirpath/functions.js +0 -349
- package/dist/fhirpath/functions.js.map +0 -1
- package/dist/fhirpath/functions.test.d.ts +0 -1
- package/dist/fhirpath/functions.test.js +0 -162
- package/dist/fhirpath/functions.test.js.map +0 -1
- package/dist/fhirpath/index.d.ts +0 -2
- package/dist/fhirpath/index.js +0 -15
- package/dist/fhirpath/index.js.map +0 -1
- package/dist/fhirpath/parse.d.ts +0 -10
- package/dist/fhirpath/parse.js +0 -285
- package/dist/fhirpath/parse.js.map +0 -1
- package/dist/fhirpath/parse.test.d.ts +0 -1
- package/dist/fhirpath/parse.test.js +0 -239
- package/dist/fhirpath/parse.test.js.map +0 -1
- package/dist/fhirpath/tokenize.d.ts +0 -13
- package/dist/fhirpath/tokenize.js +0 -43
- package/dist/fhirpath/tokenize.js.map +0 -1
- package/dist/fhirpath/tokenize.test.d.ts +0 -1
- package/dist/fhirpath/tokenize.test.js +0 -69
- package/dist/fhirpath/tokenize.test.js.map +0 -1
- package/dist/fhirpath/utils.d.ts +0 -13
- package/dist/fhirpath/utils.js +0 -34
- package/dist/fhirpath/utils.js.map +0 -1
- package/dist/fhirpath/utils.test.d.ts +0 -1
- package/dist/fhirpath/utils.test.js +0 -22
- package/dist/fhirpath/utils.test.js.map +0 -1
- package/dist/format.js +0 -56
- package/dist/format.js.map +0 -1
- package/dist/format.test.d.ts +0 -1
- package/dist/format.test.js +0 -127
- package/dist/format.test.js.map +0 -1
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/index.test.d.ts +0 -1
- package/dist/index.test.js +0 -11
- package/dist/index.test.js.map +0 -1
- package/dist/jwt.d.ts +0 -5
- package/dist/jwt.js +0 -28
- package/dist/jwt.js.map +0 -1
- package/dist/outcomes.js +0 -140
- package/dist/outcomes.js.map +0 -1
- package/dist/outcomes.test.d.ts +0 -1
- package/dist/outcomes.test.js +0 -38
- package/dist/outcomes.test.js.map +0 -1
- package/dist/search.js +0 -120
- package/dist/search.js.map +0 -1
- package/dist/search.test.d.ts +0 -1
- package/dist/search.test.js +0 -72
- package/dist/search.test.js.map +0 -1
- package/dist/searchparams.js +0 -127
- package/dist/searchparams.js.map +0 -1
- package/dist/searchparams.test.d.ts +0 -1
- package/dist/searchparams.test.js +0 -129
- package/dist/searchparams.test.js.map +0 -1
- package/dist/storage.js +0 -91
- package/dist/storage.js.map +0 -1
- package/dist/storage.test.d.ts +0 -1
- package/dist/storage.test.js +0 -50
- package/dist/storage.test.js.map +0 -1
- package/dist/types.js +0 -169
- package/dist/types.js.map +0 -1
- package/dist/utils.js +0 -234
- package/dist/utils.js.map +0 -1
- package/dist/utils.test.d.ts +0 -1
- package/dist/utils.test.js +0 -148
- package/dist/utils.test.js.map +0 -1
package/dist/types.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPropertyDisplayName = exports.buildTypeName = exports.indexStructureDefinition = exports.PropertyType = void 0;
|
|
4
|
-
const utils_1 = require("./utils");
|
|
5
|
-
/**
|
|
6
|
-
* List of property types.
|
|
7
|
-
* http://www.hl7.org/fhir/valueset-defined-types.html
|
|
8
|
-
* The list here includes additions found from StructureDefinition resources.
|
|
9
|
-
*/
|
|
10
|
-
var PropertyType;
|
|
11
|
-
(function (PropertyType) {
|
|
12
|
-
PropertyType["Address"] = "Address";
|
|
13
|
-
PropertyType["Age"] = "Age";
|
|
14
|
-
PropertyType["Annotation"] = "Annotation";
|
|
15
|
-
PropertyType["Attachment"] = "Attachment";
|
|
16
|
-
PropertyType["BackboneElement"] = "BackboneElement";
|
|
17
|
-
PropertyType["CodeableConcept"] = "CodeableConcept";
|
|
18
|
-
PropertyType["Coding"] = "Coding";
|
|
19
|
-
PropertyType["ContactDetail"] = "ContactDetail";
|
|
20
|
-
PropertyType["ContactPoint"] = "ContactPoint";
|
|
21
|
-
PropertyType["Contributor"] = "Contributor";
|
|
22
|
-
PropertyType["Count"] = "Count";
|
|
23
|
-
PropertyType["DataRequirement"] = "DataRequirement";
|
|
24
|
-
PropertyType["Distance"] = "Distance";
|
|
25
|
-
PropertyType["Dosage"] = "Dosage";
|
|
26
|
-
PropertyType["Duration"] = "Duration";
|
|
27
|
-
PropertyType["Expression"] = "Expression";
|
|
28
|
-
PropertyType["Extension"] = "Extension";
|
|
29
|
-
PropertyType["HumanName"] = "HumanName";
|
|
30
|
-
PropertyType["Identifier"] = "Identifier";
|
|
31
|
-
PropertyType["MarketingStatus"] = "MarketingStatus";
|
|
32
|
-
PropertyType["Meta"] = "Meta";
|
|
33
|
-
PropertyType["Money"] = "Money";
|
|
34
|
-
PropertyType["Narrative"] = "Narrative";
|
|
35
|
-
PropertyType["ParameterDefinition"] = "ParameterDefinition";
|
|
36
|
-
PropertyType["Period"] = "Period";
|
|
37
|
-
PropertyType["Population"] = "Population";
|
|
38
|
-
PropertyType["ProdCharacteristic"] = "ProdCharacteristic";
|
|
39
|
-
PropertyType["ProductShelfLife"] = "ProductShelfLife";
|
|
40
|
-
PropertyType["Quantity"] = "Quantity";
|
|
41
|
-
PropertyType["Range"] = "Range";
|
|
42
|
-
PropertyType["Ratio"] = "Ratio";
|
|
43
|
-
PropertyType["Reference"] = "Reference";
|
|
44
|
-
PropertyType["RelatedArtifact"] = "RelatedArtifact";
|
|
45
|
-
PropertyType["Resource"] = "Resource";
|
|
46
|
-
PropertyType["SampledData"] = "SampledData";
|
|
47
|
-
PropertyType["Signature"] = "Signature";
|
|
48
|
-
PropertyType["SubstanceAmount"] = "SubstanceAmount";
|
|
49
|
-
PropertyType["SystemString"] = "http://hl7.org/fhirpath/System.String";
|
|
50
|
-
PropertyType["Timing"] = "Timing";
|
|
51
|
-
PropertyType["TriggerDefinition"] = "TriggerDefinition";
|
|
52
|
-
PropertyType["UsageContext"] = "UsageContext";
|
|
53
|
-
PropertyType["base64Binary"] = "base64Binary";
|
|
54
|
-
PropertyType["boolean"] = "boolean";
|
|
55
|
-
PropertyType["canonical"] = "canonical";
|
|
56
|
-
PropertyType["code"] = "code";
|
|
57
|
-
PropertyType["date"] = "date";
|
|
58
|
-
PropertyType["dateTime"] = "dateTime";
|
|
59
|
-
PropertyType["decimal"] = "decimal";
|
|
60
|
-
PropertyType["id"] = "id";
|
|
61
|
-
PropertyType["instant"] = "instant";
|
|
62
|
-
PropertyType["integer"] = "integer";
|
|
63
|
-
PropertyType["markdown"] = "markdown";
|
|
64
|
-
PropertyType["oid"] = "oid";
|
|
65
|
-
PropertyType["positiveInt"] = "positiveInt";
|
|
66
|
-
PropertyType["string"] = "string";
|
|
67
|
-
PropertyType["time"] = "time";
|
|
68
|
-
PropertyType["unsignedInt"] = "unsignedInt";
|
|
69
|
-
PropertyType["uri"] = "uri";
|
|
70
|
-
PropertyType["url"] = "url";
|
|
71
|
-
PropertyType["uuid"] = "uuid";
|
|
72
|
-
})(PropertyType = exports.PropertyType || (exports.PropertyType = {}));
|
|
73
|
-
/**
|
|
74
|
-
* Indexes a StructureDefinition for fast lookup.
|
|
75
|
-
* See comments on IndexedStructureDefinition for more details.
|
|
76
|
-
* @param structureDefinition The original StructureDefinition.
|
|
77
|
-
* @return An indexed IndexedStructureDefinition.
|
|
78
|
-
*/
|
|
79
|
-
function indexStructureDefinition(structureDefinition, output) {
|
|
80
|
-
const typeName = structureDefinition.name;
|
|
81
|
-
if (!typeName) {
|
|
82
|
-
throw new Error('Invalid StructureDefinition');
|
|
83
|
-
}
|
|
84
|
-
if (!output) {
|
|
85
|
-
output = {
|
|
86
|
-
types: {}
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
output.types[typeName] = {
|
|
90
|
-
display: typeName,
|
|
91
|
-
description: structureDefinition.description,
|
|
92
|
-
properties: {}
|
|
93
|
-
};
|
|
94
|
-
const elements = structureDefinition.snapshot?.element;
|
|
95
|
-
if (elements) {
|
|
96
|
-
// Filter out any elements missing path or type
|
|
97
|
-
const filtered = elements.filter(e => e.path !== typeName && e.path); // && e.type && e.type.length > 0);
|
|
98
|
-
// First pass, build types
|
|
99
|
-
filtered.forEach(element => indexType(output, element));
|
|
100
|
-
// Second pass, build properties
|
|
101
|
-
filtered.forEach(element => indexProperty(output, element));
|
|
102
|
-
}
|
|
103
|
-
return output;
|
|
104
|
-
}
|
|
105
|
-
exports.indexStructureDefinition = indexStructureDefinition;
|
|
106
|
-
/**
|
|
107
|
-
* Indexes TypeSchema from an ElementDefinition.
|
|
108
|
-
* In the common case, there will be many ElementDefinition instances per TypeSchema.
|
|
109
|
-
* Only the first occurrence is saved.
|
|
110
|
-
* @param output The work-in-progress IndexedStructureDefinition.
|
|
111
|
-
* @param element The input ElementDefinition.
|
|
112
|
-
*/
|
|
113
|
-
function indexType(output, element) {
|
|
114
|
-
const path = element.path;
|
|
115
|
-
const typeCode = element.type?.[0]?.code;
|
|
116
|
-
if (typeCode !== 'Element' && typeCode !== 'BackboneElement') {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
const parts = path.split('.');
|
|
120
|
-
const typeName = buildTypeName(parts);
|
|
121
|
-
if (!(typeName in output.types)) {
|
|
122
|
-
output.types[typeName] = {
|
|
123
|
-
display: typeName,
|
|
124
|
-
description: element.definition,
|
|
125
|
-
parentType: buildTypeName(parts.slice(0, parts.length - 1)),
|
|
126
|
-
properties: {}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Indexes PropertySchema from an ElementDefinition.
|
|
132
|
-
* @param output The work-in-progress IndexedStructureDefinition.
|
|
133
|
-
* @param element The input ElementDefinition.
|
|
134
|
-
*/
|
|
135
|
-
function indexProperty(output, element) {
|
|
136
|
-
const path = element.path;
|
|
137
|
-
const parts = path.split('.');
|
|
138
|
-
if (parts.length === 1) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const typeName = buildTypeName(parts.slice(0, parts.length - 1));
|
|
142
|
-
const typeSchema = output.types[typeName];
|
|
143
|
-
const key = parts[parts.length - 1];
|
|
144
|
-
typeSchema.properties[key] = element;
|
|
145
|
-
}
|
|
146
|
-
function buildTypeName(components) {
|
|
147
|
-
return components.map(utils_1.capitalize).join('');
|
|
148
|
-
}
|
|
149
|
-
exports.buildTypeName = buildTypeName;
|
|
150
|
-
function getPropertyDisplayName(property) {
|
|
151
|
-
// Get the property name, which is the remainder after the last period
|
|
152
|
-
// For example, for path "Patient.birthDate"
|
|
153
|
-
// the property name is "birthDate"
|
|
154
|
-
const propertyName = property.path.split('.').pop();
|
|
155
|
-
// Split by capital letters
|
|
156
|
-
// Capitalize the first letter of each word
|
|
157
|
-
// Join together with spaces in between
|
|
158
|
-
// Then normalize whitespace to single space character
|
|
159
|
-
// For example, for property name "birthDate",
|
|
160
|
-
// the display name is "Birth Date".
|
|
161
|
-
return propertyName
|
|
162
|
-
.split(/(?=[A-Z])/)
|
|
163
|
-
.map(utils_1.capitalize)
|
|
164
|
-
.join(' ')
|
|
165
|
-
.replace('_', ' ')
|
|
166
|
-
.replace(/\s+/g, ' ');
|
|
167
|
-
}
|
|
168
|
-
exports.getPropertyDisplayName = getPropertyDisplayName;
|
|
169
|
-
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AACA,mCAAqC;AAErC;;;;GAIG;AACH,IAAY,YA6DX;AA7DD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,2BAAW,CAAA;IACX,yCAAyB,CAAA;IACzB,yCAAyB,CAAA;IACzB,mDAAmC,CAAA;IACnC,mDAAmC,CAAA;IACnC,iCAAiB,CAAA;IACjB,+CAA+B,CAAA;IAC/B,6CAA6B,CAAA;IAC7B,2CAA2B,CAAA;IAC3B,+BAAe,CAAA;IACf,mDAAmC,CAAA;IACnC,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,qCAAqB,CAAA;IACrB,yCAAyB,CAAA;IACzB,uCAAuB,CAAA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C;SAClB,GAAG,CAAC,kBAAU,CAAC;SACf,IAAI,CAAC,GAAG,CAAC;SACT,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;SACjB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC1B,CAAC;AAlBD,wDAkBC","sourcesContent":["import { ElementDefinition, SearchParameter, StructureDefinition } from './fhir';\nimport { capitalize } from './utils';\n\n/**\n * List of property types.\n * http://www.hl7.org/fhir/valueset-defined-types.html\n * The list here includes additions found from StructureDefinition resources.\n */\nexport enum PropertyType {\n Address = 'Address',\n Age = 'Age',\n Annotation = 'Annotation',\n Attachment = 'Attachment',\n BackboneElement = 'BackboneElement',\n CodeableConcept = 'CodeableConcept',\n Coding = 'Coding',\n ContactDetail = 'ContactDetail',\n ContactPoint = 'ContactPoint',\n Contributor = 'Contributor',\n Count = 'Count',\n DataRequirement = 'DataRequirement',\n Distance = 'Distance',\n Dosage = 'Dosage',\n Duration = 'Duration',\n Expression = 'Expression',\n Extension = 'Extension',\n HumanName = 'HumanName',\n Identifier = 'Identifier',\n MarketingStatus = 'MarketingStatus',\n Meta = 'Meta',\n Money = 'Money',\n Narrative = 'Narrative',\n ParameterDefinition = 'ParameterDefinition',\n Period = 'Period',\n Population = 'Population',\n ProdCharacteristic = 'ProdCharacteristic',\n ProductShelfLife = 'ProductShelfLife',\n Quantity = 'Quantity',\n Range = 'Range',\n Ratio = 'Ratio',\n Reference = 'Reference',\n RelatedArtifact = 'RelatedArtifact',\n Resource = 'Resource',\n SampledData = 'SampledData',\n Signature = 'Signature',\n SubstanceAmount = 'SubstanceAmount',\n SystemString = 'http://hl7.org/fhirpath/System.String',\n Timing = 'Timing',\n TriggerDefinition = 'TriggerDefinition',\n UsageContext = 'UsageContext',\n base64Binary = 'base64Binary',\n boolean = 'boolean',\n canonical = 'canonical',\n code = 'code',\n date = 'date',\n dateTime = 'dateTime',\n decimal = 'decimal',\n id = 'id',\n instant = 'instant',\n integer = 'integer',\n markdown = 'markdown',\n oid = 'oid',\n positiveInt = 'positiveInt',\n string = 'string',\n time = 'time',\n unsignedInt = 'unsignedInt',\n uri = 'uri',\n url = 'url',\n uuid = 'uuid',\n}\n\n/**\n * An IndexedStructureDefinition is a lookup-optimized version of a StructureDefinition.\n *\n * StructureDefinition resources contain schema information for other resource types.\n * These schemas can be used to automatically generate user interface elements for\n * resources.\n *\n * However, a StructureDefinition resource is not optimized for realtime lookups. All\n * resource types, sub types, and property definitions are stored in a flat array of\n * ElementDefinition objects. Therefore, to lookup the schema for a property (i.e., \"Patient.name\")\n * requires a linear scan of all ElementDefinition objects\n *\n * A StructureDefinition resource contains information about one or more types.\n * For example, the \"Patient\" StructureDefinition includes \"Patient\", \"Patient_Contact\",\n * \"Patient_Communication\", and \"Patient_Link\". This is inefficient.\n *\n * Instead, we create an indexed version of the StructureDefinition, called IndexedStructureDefinition.\n * In an IndexedStructureDefinition, retrieving a property definition is a hashtable lookup.\n *\n * The hierarchy is:\n * IndexedStructureDefinition - top level for one resource type\n * TypeSchema - one per resource type and all contained BackboneElements\n * PropertySchema - one per property/field\n */\nexport interface IndexedStructureDefinition {\n types: { [resourceType: string]: TypeSchema };\n}\n\n/**\n * An indexed TypeSchema.\n *\n * Example: The IndexedStructureDefinition for \"Patient\" would include the following TypeSchemas:\n * 1) Patient\n * 2) Patient_Contact\n * 3) Patient_Communication\n * 4) Patient_Link\n */\nexport interface TypeSchema {\n display: string;\n properties: { [name: string]: ElementDefinition };\n searchParams?: SearchParameter[];\n description?: string;\n parentType?: string;\n}\n\n/**\n * Indexes a StructureDefinition for fast lookup.\n * See comments on IndexedStructureDefinition for more details.\n * @param structureDefinition The original StructureDefinition.\n * @return An indexed IndexedStructureDefinition.\n */\nexport function indexStructureDefinition(structureDefinition: StructureDefinition, output?: IndexedStructureDefinition): IndexedStructureDefinition {\n const typeName = structureDefinition.name;\n if (!typeName) {\n throw new Error('Invalid StructureDefinition');\n }\n\n if (!output) {\n output = {\n types: {}\n } as IndexedStructureDefinition;\n }\n\n output.types[typeName] = {\n display: typeName,\n description: structureDefinition.description,\n properties: {}\n };\n\n const elements = structureDefinition.snapshot?.element;\n if (elements) {\n // Filter out any elements missing path or type\n const filtered = elements.filter(e => e.path !== typeName && e.path);// && e.type && e.type.length > 0);\n\n // First pass, build types\n filtered.forEach(element => indexType(output as IndexedStructureDefinition, element));\n\n // Second pass, build properties\n filtered.forEach(element => indexProperty(output as IndexedStructureDefinition, element));\n }\n\n return output;\n}\n\n/**\n * Indexes TypeSchema from an ElementDefinition.\n * In the common case, there will be many ElementDefinition instances per TypeSchema.\n * Only the first occurrence is saved.\n * @param output The work-in-progress IndexedStructureDefinition.\n * @param element The input ElementDefinition.\n */\nfunction indexType(output: IndexedStructureDefinition, element: ElementDefinition): void {\n const path = element.path as string;\n const typeCode = element.type?.[0]?.code;\n if (typeCode !== 'Element' && typeCode !== 'BackboneElement') {\n return;\n }\n const parts = path.split('.');\n const typeName = buildTypeName(parts);\n if (!(typeName in output.types)) {\n output.types[typeName] = {\n display: typeName,\n description: element.definition,\n parentType: buildTypeName(parts.slice(0, parts.length - 1)),\n properties: {}\n };\n }\n}\n\n/**\n * Indexes PropertySchema from an ElementDefinition.\n * @param output The work-in-progress IndexedStructureDefinition.\n * @param element The input ElementDefinition.\n */\nfunction indexProperty(output: IndexedStructureDefinition, element: ElementDefinition): void {\n const path = element.path as string;\n const parts = path.split('.');\n if (parts.length === 1) {\n return;\n }\n const typeName = buildTypeName(parts.slice(0, parts.length - 1));\n const typeSchema = output.types[typeName];\n const key = parts[parts.length - 1];\n typeSchema.properties[key] = element;\n}\n\nexport function buildTypeName(components: string[]): string {\n return components.map(capitalize).join('');\n}\n\nexport function getPropertyDisplayName(property: ElementDefinition): string {\n // Get the property name, which is the remainder after the last period\n // For example, for path \"Patient.birthDate\"\n // the property name is \"birthDate\"\n const propertyName = (property.path as string).split('.').pop() as string;\n\n // Split by capital letters\n // Capitalize the first letter of each word\n // Join together with spaces in between\n // Then normalize whitespace to single space character\n // For example, for property name \"birthDate\",\n // the display name is \"Birth Date\".\n return propertyName\n .split(/(?=[A-Z])/)\n .map(capitalize)\n .join(' ')\n .replace('_', ' ')\n .replace(/\\s+/g, ' ');\n}\n"]}
|
package/dist/utils.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLowerCase = exports.capitalize = exports.arrayBufferToBase64 = exports.arrayBufferToHex = exports.deepEquals = exports.stringify = exports.getDateProperty = exports.getImageSrc = exports.getDisplayString = exports.isProfileResource = exports.getReferenceString = exports.createReference = void 0;
|
|
4
|
-
const format_1 = require("./format");
|
|
5
|
-
/**
|
|
6
|
-
* Creates a reference resource.
|
|
7
|
-
* @param resource The FHIR reesource.
|
|
8
|
-
* @returns A reference resource.
|
|
9
|
-
*/
|
|
10
|
-
function createReference(resource) {
|
|
11
|
-
const reference = getReferenceString(resource);
|
|
12
|
-
const display = getDisplayString(resource);
|
|
13
|
-
return (display === reference) ? { reference } : { reference, display };
|
|
14
|
-
}
|
|
15
|
-
exports.createReference = createReference;
|
|
16
|
-
/**
|
|
17
|
-
* Returns a reference string for a resource.
|
|
18
|
-
* @param resource The FHIR resource.
|
|
19
|
-
* @returns A reference string of the form resourceType/id.
|
|
20
|
-
*/
|
|
21
|
-
function getReferenceString(resource) {
|
|
22
|
-
return resource.resourceType + '/' + resource.id;
|
|
23
|
-
}
|
|
24
|
-
exports.getReferenceString = getReferenceString;
|
|
25
|
-
/**
|
|
26
|
-
* Returns true if the resource is a "ProfileResource".
|
|
27
|
-
* @param resource The FHIR resource.
|
|
28
|
-
* @returns True if the resource is a "ProfileResource".
|
|
29
|
-
*/
|
|
30
|
-
function isProfileResource(resource) {
|
|
31
|
-
return resource.resourceType === 'Patient' ||
|
|
32
|
-
resource.resourceType === 'Practitioner' ||
|
|
33
|
-
resource.resourceType === 'RelatedPerson';
|
|
34
|
-
}
|
|
35
|
-
exports.isProfileResource = isProfileResource;
|
|
36
|
-
/**
|
|
37
|
-
* Returns a display string for the resource.
|
|
38
|
-
* @param resource The input resource.
|
|
39
|
-
* @return Human friendly display string.
|
|
40
|
-
*/
|
|
41
|
-
function getDisplayString(resource) {
|
|
42
|
-
if (isProfileResource(resource)) {
|
|
43
|
-
const profileName = getProfileResourceDisplayString(resource);
|
|
44
|
-
if (profileName) {
|
|
45
|
-
return profileName;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (resource.resourceType === 'Device') {
|
|
49
|
-
const deviceName = getDeviceDisplayString(resource);
|
|
50
|
-
if (deviceName) {
|
|
51
|
-
return deviceName;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const simpleName = resource.name;
|
|
55
|
-
if (simpleName && typeof simpleName === 'string') {
|
|
56
|
-
return simpleName;
|
|
57
|
-
}
|
|
58
|
-
return getReferenceString(resource);
|
|
59
|
-
}
|
|
60
|
-
exports.getDisplayString = getDisplayString;
|
|
61
|
-
/**
|
|
62
|
-
* Returns a display string for a profile resource if one is found.
|
|
63
|
-
* @param resource The profile resource.
|
|
64
|
-
* @returns The display name if one is found.
|
|
65
|
-
*/
|
|
66
|
-
function getProfileResourceDisplayString(resource) {
|
|
67
|
-
const names = resource.name;
|
|
68
|
-
if (names && names.length > 0) {
|
|
69
|
-
return (0, format_1.formatHumanName)(names[0]);
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Returns a display string for a device resource if one is found.
|
|
75
|
-
* @param device The device resource.
|
|
76
|
-
* @returns The display name if one is found.
|
|
77
|
-
*/
|
|
78
|
-
function getDeviceDisplayString(device) {
|
|
79
|
-
const names = device.deviceName;
|
|
80
|
-
if (names && names.length > 0) {
|
|
81
|
-
return names[0].name;
|
|
82
|
-
}
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Returns an image URL for the resource, if one is available.
|
|
87
|
-
* @param resource The input resource.
|
|
88
|
-
* @returns The image URL for the resource or undefined.
|
|
89
|
-
*/
|
|
90
|
-
function getImageSrc(resource) {
|
|
91
|
-
if (isProfileResource(resource)) {
|
|
92
|
-
const photos = resource.photo;
|
|
93
|
-
if (photos) {
|
|
94
|
-
for (const photo of photos) {
|
|
95
|
-
if (photo.url && photo.contentType && photo.contentType.startsWith('image/')) {
|
|
96
|
-
return photo.url;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
exports.getImageSrc = getImageSrc;
|
|
104
|
-
/**
|
|
105
|
-
* Returns a Date property as a Date.
|
|
106
|
-
* When working with JSON objects, Dates are often serialized as ISO-8601 strings.
|
|
107
|
-
* When that happens, we need to safely convert to a proper Date object.
|
|
108
|
-
* @param date The date property value, which could be a string or a Date object.
|
|
109
|
-
* @returns A Date object.
|
|
110
|
-
*/
|
|
111
|
-
function getDateProperty(date) {
|
|
112
|
-
return date ? new Date(date) : undefined;
|
|
113
|
-
}
|
|
114
|
-
exports.getDateProperty = getDateProperty;
|
|
115
|
-
/**
|
|
116
|
-
* FHIR JSON stringify.
|
|
117
|
-
* Removes properties with empty string values.
|
|
118
|
-
* Removes objects with zero properties.
|
|
119
|
-
* See: https://www.hl7.org/fhir/json.html
|
|
120
|
-
* @param value The input value.
|
|
121
|
-
* @param pretty Optional flag to pretty-print the JSON.
|
|
122
|
-
* @returns The resulting JSON string.
|
|
123
|
-
*/
|
|
124
|
-
function stringify(value, pretty) {
|
|
125
|
-
return JSON.stringify(value, stringifyReplacer, pretty ? 2 : undefined);
|
|
126
|
-
}
|
|
127
|
-
exports.stringify = stringify;
|
|
128
|
-
/**
|
|
129
|
-
* Evaluates JSON key/value pairs for FHIR JSON stringify.
|
|
130
|
-
* Removes properties with empty string values.
|
|
131
|
-
* Removes objects with zero properties.
|
|
132
|
-
* Replaces any key/value pair of key "__key" with value undefined.
|
|
133
|
-
* This function can be used as the 2nd argument to stringify to remove __key properties.
|
|
134
|
-
* We add __key properties to array elements to improve React render performance.
|
|
135
|
-
* @param {string} k Property key.
|
|
136
|
-
* @param {*} v Property value.
|
|
137
|
-
*/
|
|
138
|
-
function stringifyReplacer(k, v) {
|
|
139
|
-
return (k === '__key' || isEmpty(v)) ? undefined : v;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Returns true if the value is empty (null, undefined, empty string, or empty object).
|
|
143
|
-
* @param v Any value.
|
|
144
|
-
* @returns True if the value is an empty string or an empty object.
|
|
145
|
-
*/
|
|
146
|
-
function isEmpty(v) {
|
|
147
|
-
if (v === null || v === undefined) {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
const t = typeof v;
|
|
151
|
-
return (t === 'string' && v === '') || (t === 'object' && Object.keys(v).length === 0);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Resource equality.
|
|
155
|
-
* Ignores meta.versionId and meta.lastUpdated.
|
|
156
|
-
* See: https://dmitripavlutin.com/how-to-compare-objects-in-javascript/#4-deep-equality
|
|
157
|
-
* @param object1 The first object.
|
|
158
|
-
* @param object2 The second object.
|
|
159
|
-
* @returns True if the objects are equal.
|
|
160
|
-
*/
|
|
161
|
-
function deepEquals(object1, object2, path) {
|
|
162
|
-
let keys1 = Object.keys(object1);
|
|
163
|
-
let keys2 = Object.keys(object2);
|
|
164
|
-
if (path === 'meta') {
|
|
165
|
-
keys1 = keys1.filter(k => k !== 'versionId' && k !== 'lastUpdated');
|
|
166
|
-
keys2 = keys2.filter(k => k !== 'versionId' && k !== 'lastUpdated');
|
|
167
|
-
}
|
|
168
|
-
if (keys1.length !== keys2.length) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
for (const key of keys1) {
|
|
172
|
-
const val1 = object1[key];
|
|
173
|
-
const val2 = object2[key];
|
|
174
|
-
if (isObject(val1) && isObject(val2)) {
|
|
175
|
-
if (!deepEquals(val1, val2, key)) {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
if (val1 !== val2) {
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
exports.deepEquals = deepEquals;
|
|
188
|
-
function isObject(object) {
|
|
189
|
-
return object !== null && typeof object === 'object';
|
|
190
|
-
}
|
|
191
|
-
// Precompute hex octets
|
|
192
|
-
// See: https://stackoverflow.com/a/55200387
|
|
193
|
-
const byteToHex = [];
|
|
194
|
-
for (let n = 0; n < 256; n++) {
|
|
195
|
-
byteToHex.push(n.toString(16).padStart(2, '0'));
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Converts an ArrayBuffer to hex string.
|
|
199
|
-
* See: https://stackoverflow.com/a/55200387
|
|
200
|
-
* @param arrayBuffer The input array buffer.
|
|
201
|
-
* @returns The resulting hex string.
|
|
202
|
-
*/
|
|
203
|
-
function arrayBufferToHex(arrayBuffer) {
|
|
204
|
-
const bytes = new Uint8Array(arrayBuffer);
|
|
205
|
-
const result = new Array(bytes.length);
|
|
206
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
207
|
-
result[i] = byteToHex[bytes[i]];
|
|
208
|
-
}
|
|
209
|
-
return result.join('');
|
|
210
|
-
}
|
|
211
|
-
exports.arrayBufferToHex = arrayBufferToHex;
|
|
212
|
-
/**
|
|
213
|
-
* Converts an ArrayBuffer to a base-64 encoded string.
|
|
214
|
-
* @param arrayBuffer The input array buffer.
|
|
215
|
-
* @returns The base-64 encoded string.
|
|
216
|
-
*/
|
|
217
|
-
function arrayBufferToBase64(arrayBuffer) {
|
|
218
|
-
const bytes = new Uint8Array(arrayBuffer);
|
|
219
|
-
const result = [];
|
|
220
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
221
|
-
result[i] = String.fromCharCode(bytes[i]);
|
|
222
|
-
}
|
|
223
|
-
return window.btoa(result.join(''));
|
|
224
|
-
}
|
|
225
|
-
exports.arrayBufferToBase64 = arrayBufferToBase64;
|
|
226
|
-
function capitalize(word) {
|
|
227
|
-
return word.charAt(0).toUpperCase() + word.substr(1);
|
|
228
|
-
}
|
|
229
|
-
exports.capitalize = capitalize;
|
|
230
|
-
function isLowerCase(c) {
|
|
231
|
-
return c === c.toLowerCase();
|
|
232
|
-
}
|
|
233
|
-
exports.isLowerCase = isLowerCase;
|
|
234
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,qCAA2C;AAI3C;;;;GAIG;AACH,SAAgB,eAAe,CAAqB,QAAW;IAC7D,MAAM,SAAS,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC3C,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAC1E,CAAC;AAJD,0CAIC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,QAAkB;IACnD,OAAO,QAAQ,CAAC,YAAY,GAAG,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC;AACnD,CAAC;AAFD,gDAEC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,QAAkB;IAClD,OAAO,QAAQ,CAAC,YAAY,KAAK,SAAS;QACxC,QAAQ,CAAC,YAAY,KAAK,cAAc;QACxC,QAAQ,CAAC,YAAY,KAAK,eAAe,CAAC;AAC9C,CAAC;AAJD,8CAIC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,QAAkB;IACjD,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE;QAC/B,MAAM,WAAW,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AK,CAAC,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC;AAFD,kCAEC","sourcesContent":["import { Device, Patient, Practitioner, Reference, RelatedPerson, Resource } from './fhir';\nimport { formatHumanName } from './format';\n\nexport type ProfileResource = Patient | Practitioner | RelatedPerson;\n\n/**\n * Creates a reference resource.\n * @param resource The FHIR reesource.\n * @returns A reference resource.\n */\nexport function createReference<T extends Resource>(resource: T): Reference<T> {\n const reference = getReferenceString(resource);\n const display = getDisplayString(resource);\n return (display === reference) ? { reference } : { reference, display };\n}\n\n/**\n * Returns a reference string for a resource.\n * @param resource The FHIR resource.\n * @returns A reference string of the form resourceType/id.\n */\nexport function getReferenceString(resource: Resource): string {\n return resource.resourceType + '/' + resource.id;\n}\n\n/**\n * Returns true if the resource is a \"ProfileResource\".\n * @param resource The FHIR resource.\n * @returns True if the resource is a \"ProfileResource\".\n */\nexport function isProfileResource(resource: Resource): boolean {\n return resource.resourceType === 'Patient' ||\n resource.resourceType === 'Practitioner' ||\n resource.resourceType === 'RelatedPerson';\n}\n\n/**\n * Returns a display string for the resource.\n * @param resource The input resource.\n * @return Human friendly display string.\n */\nexport function getDisplayString(resource: Resource): string {\n if (isProfileResource(resource)) {\n const profileName = getProfileResourceDisplayString(resource as ProfileResource);\n if (profileName) {\n return profileName;\n }\n }\n if (resource.resourceType === 'Device') {\n const deviceName = getDeviceDisplayString(resource);\n if (deviceName) {\n return deviceName;\n }\n }\n const simpleName = (resource as any).name;\n if (simpleName && typeof simpleName === 'string') {\n return simpleName;\n }\n return getReferenceString(resource);\n}\n\n/**\n * Returns a display string for a profile resource if one is found.\n * @param resource The profile resource.\n * @returns The display name if one is found.\n */\nfunction getProfileResourceDisplayString(resource: ProfileResource): string | undefined {\n const names = resource.name;\n if (names && names.length > 0) {\n return formatHumanName(names[0]);\n }\n return undefined;\n}\n\n/**\n * Returns a display string for a device resource if one is found.\n * @param device The device resource.\n * @returns The display name if one is found.\n */\nfunction getDeviceDisplayString(device: Device): string | undefined {\n const names = device.deviceName;\n if (names && names.length > 0) {\n return names[0].name;\n }\n return undefined;\n}\n\n/**\n * Returns an image URL for the resource, if one is available.\n * @param resource The input resource.\n * @returns The image URL for the resource or undefined.\n */\nexport function getImageSrc(resource: Resource): string | undefined {\n if (isProfileResource(resource)) {\n const photos = (resource as ProfileResource).photo;\n if (photos) {\n for (const photo of photos) {\n if (photo.url && photo.contentType && photo.contentType.startsWith('image/')) {\n return photo.url;\n }\n }\n }\n }\n return undefined;\n}\n\n/**\n * Returns a Date property as a Date.\n * When working with JSON objects, Dates are often serialized as ISO-8601 strings.\n * When that happens, we need to safely convert to a proper Date object.\n * @param date The date property value, which could be a string or a Date object.\n * @returns A Date object.\n */\nexport function getDateProperty(date: string | undefined): Date | undefined {\n return date ? new Date(date) : undefined;\n}\n\n/**\n * FHIR JSON stringify.\n * Removes properties with empty string values.\n * Removes objects with zero properties.\n * See: https://www.hl7.org/fhir/json.html\n * @param value The input value.\n * @param pretty Optional flag to pretty-print the JSON.\n * @returns The resulting JSON string.\n */\nexport function stringify(value: any, pretty?: boolean): string {\n return JSON.stringify(value, stringifyReplacer, pretty ? 2 : undefined);\n}\n\n/**\n * Evaluates JSON key/value pairs for FHIR JSON stringify.\n * Removes properties with empty string values.\n * Removes objects with zero properties.\n * Replaces any key/value pair of key \"__key\" with value undefined.\n * This function can be used as the 2nd argument to stringify to remove __key properties.\n * We add __key properties to array elements to improve React render performance.\n * @param {string} k Property key.\n * @param {*} v Property value.\n */\nfunction stringifyReplacer(k: string, v: any): any {\n return (k === '__key' || isEmpty(v)) ? undefined : v;\n}\n\n/**\n * Returns true if the value is empty (null, undefined, empty string, or empty object).\n * @param v Any value.\n * @returns True if the value is an empty string or an empty object.\n */\nfunction isEmpty(v: any): boolean {\n if (v === null || v === undefined) {\n return true;\n }\n const t = typeof v;\n return (t === 'string' && v === '') || (t === 'object' && Object.keys(v).length === 0);\n}\n\n/**\n * Resource equality.\n * Ignores meta.versionId and meta.lastUpdated.\n * See: https://dmitripavlutin.com/how-to-compare-objects-in-javascript/#4-deep-equality\n * @param object1 The first object.\n * @param object2 The second object.\n * @returns True if the objects are equal.\n */\nexport function deepEquals(object1: any, object2: any, path?: string): boolean {\n let keys1 = Object.keys(object1);\n let keys2 = Object.keys(object2);\n if (path === 'meta') {\n keys1 = keys1.filter(k => k !== 'versionId' && k !== 'lastUpdated');\n keys2 = keys2.filter(k => k !== 'versionId' && k !== 'lastUpdated');\n }\n if (keys1.length !== keys2.length) {\n return false;\n }\n for (const key of keys1) {\n const val1 = object1[key];\n const val2 = object2[key];\n if (isObject(val1) && isObject(val2)) {\n if (!deepEquals(val1, val2, key)) {\n return false;\n }\n } else {\n if (val1 !== val2) {\n return false;\n }\n }\n }\n return true;\n}\n\nfunction isObject(object: any): boolean {\n return object !== null && typeof object === 'object';\n}\n\n// Precompute hex octets\n// See: https://stackoverflow.com/a/55200387\nconst byteToHex: string[] = [];\nfor (let n = 0; n < 256; n++) {\n byteToHex.push(n.toString(16).padStart(2, '0'));\n}\n\n/**\n * Converts an ArrayBuffer to hex string.\n * See: https://stackoverflow.com/a/55200387\n * @param arrayBuffer The input array buffer.\n * @returns The resulting hex string.\n */\nexport function arrayBufferToHex(arrayBuffer: ArrayBuffer): string {\n const bytes = new Uint8Array(arrayBuffer);\n const result: string[] = new Array(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n result[i] = byteToHex[bytes[i]];\n }\n return result.join('');\n}\n\n/**\n * Converts an ArrayBuffer to a base-64 encoded string.\n * @param arrayBuffer The input array buffer.\n * @returns The base-64 encoded string.\n */\nexport function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string {\n const bytes = new Uint8Array(arrayBuffer);\n const result: string[] = [];\n for (let i = 0; i < bytes.length; i++) {\n result[i] = String.fromCharCode(bytes[i]);\n }\n return window.btoa(result.join(''));\n}\n\nexport function capitalize(word: string): string {\n return word.charAt(0).toUpperCase() + word.substr(1);\n}\n\nexport function isLowerCase(c: string): boolean {\n return c === c.toLowerCase();\n}\n"]}
|
package/dist/utils.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils.test.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("./utils");
|
|
4
|
-
if (typeof btoa === 'undefined') {
|
|
5
|
-
global.btoa = function (str) {
|
|
6
|
-
return Buffer.from(str).toString('base64');
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
describe('Core Utils', () => {
|
|
10
|
-
test('Create reference', () => {
|
|
11
|
-
expect((0, utils_1.createReference)({
|
|
12
|
-
resourceType: 'Patient',
|
|
13
|
-
id: '123',
|
|
14
|
-
name: [{
|
|
15
|
-
given: ['Alice'],
|
|
16
|
-
family: 'Smith'
|
|
17
|
-
}]
|
|
18
|
-
})).toMatchObject({
|
|
19
|
-
reference: 'Patient/123',
|
|
20
|
-
display: 'Alice Smith'
|
|
21
|
-
});
|
|
22
|
-
expect((0, utils_1.createReference)({
|
|
23
|
-
resourceType: 'Device', id: '123'
|
|
24
|
-
})).toMatchObject({
|
|
25
|
-
reference: 'Device/123'
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
test('isProfileResource', () => {
|
|
29
|
-
expect((0, utils_1.isProfileResource)({ resourceType: 'Patient' })).toEqual(true);
|
|
30
|
-
expect((0, utils_1.isProfileResource)({ resourceType: 'Practitioner' })).toEqual(true);
|
|
31
|
-
expect((0, utils_1.isProfileResource)({ resourceType: 'RelatedPerson' })).toEqual(true);
|
|
32
|
-
expect((0, utils_1.isProfileResource)({ resourceType: 'Observation' })).toEqual(false);
|
|
33
|
-
});
|
|
34
|
-
test('getDisplayString', () => {
|
|
35
|
-
expect((0, utils_1.getDisplayString)({ resourceType: 'Patient', name: [{ family: 'Smith' }] })).toEqual('Smith');
|
|
36
|
-
expect((0, utils_1.getDisplayString)({ resourceType: 'Patient', id: '123', name: [] })).toEqual('Patient/123');
|
|
37
|
-
expect((0, utils_1.getDisplayString)({ resourceType: 'Observation', id: '123' })).toEqual('Observation/123');
|
|
38
|
-
expect((0, utils_1.getDisplayString)({ resourceType: 'ClientApplication', id: '123' })).toEqual('ClientApplication/123');
|
|
39
|
-
expect((0, utils_1.getDisplayString)({ resourceType: 'ClientApplication', id: '123', name: 'foo' })).toEqual('foo');
|
|
40
|
-
expect((0, utils_1.getDisplayString)({ resourceType: 'Device', deviceName: [{ name: 'Foo' }] })).toEqual('Foo');
|
|
41
|
-
expect((0, utils_1.getDisplayString)({ resourceType: 'Device', id: '123', deviceName: [{}] })).toEqual('Device/123');
|
|
42
|
-
expect((0, utils_1.getDisplayString)({ resourceType: 'Device', id: '123', deviceName: [] })).toEqual('Device/123');
|
|
43
|
-
});
|
|
44
|
-
test('getImageSrc', () => {
|
|
45
|
-
expect((0, utils_1.getImageSrc)({ resourceType: 'Observation' })).toBeUndefined();
|
|
46
|
-
expect((0, utils_1.getImageSrc)({ resourceType: 'Patient' })).toBeUndefined();
|
|
47
|
-
expect((0, utils_1.getImageSrc)({ resourceType: 'Patient', photo: [] })).toBeUndefined();
|
|
48
|
-
expect((0, utils_1.getImageSrc)({ resourceType: 'Patient', photo: [{}] })).toBeUndefined();
|
|
49
|
-
expect((0, utils_1.getImageSrc)({
|
|
50
|
-
resourceType: 'Patient',
|
|
51
|
-
photo: [{
|
|
52
|
-
url: 'http://abc/xyz.txt',
|
|
53
|
-
contentType: 'text/plain'
|
|
54
|
-
}]
|
|
55
|
-
})).toBeUndefined();
|
|
56
|
-
expect((0, utils_1.getImageSrc)({
|
|
57
|
-
resourceType: 'Patient',
|
|
58
|
-
photo: [{
|
|
59
|
-
contentType: 'image/jpeg'
|
|
60
|
-
}]
|
|
61
|
-
})).toBeUndefined();
|
|
62
|
-
expect((0, utils_1.getImageSrc)({
|
|
63
|
-
resourceType: 'Patient',
|
|
64
|
-
photo: [{
|
|
65
|
-
url: 'http://abc/xyz.jpg',
|
|
66
|
-
contentType: 'image/jpeg'
|
|
67
|
-
}]
|
|
68
|
-
})).toEqual('http://abc/xyz.jpg');
|
|
69
|
-
});
|
|
70
|
-
test('Convert ArrayBuffer to hex string', () => {
|
|
71
|
-
const input = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
|
72
|
-
const output = (0, utils_1.arrayBufferToHex)(input);
|
|
73
|
-
expect(output).toBe('000102030405060708090a');
|
|
74
|
-
});
|
|
75
|
-
test('Convert ArrayBuffer to base-64 encoded string', () => {
|
|
76
|
-
const input = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
|
77
|
-
const output = (0, utils_1.arrayBufferToBase64)(input);
|
|
78
|
-
expect(output).toBe('AAECAwQFBgcICQo=');
|
|
79
|
-
});
|
|
80
|
-
test('Get date property', () => {
|
|
81
|
-
expect((0, utils_1.getDateProperty)(undefined)).toBeUndefined();
|
|
82
|
-
expect((0, utils_1.getDateProperty)('')).toBeUndefined();
|
|
83
|
-
expect((0, utils_1.getDateProperty)('2020-01-01')).toEqual(new Date('2020-01-01'));
|
|
84
|
-
});
|
|
85
|
-
test('Stringify', () => {
|
|
86
|
-
expect((0, utils_1.stringify)(null)).toBeUndefined();
|
|
87
|
-
expect((0, utils_1.stringify)(undefined)).toBeUndefined();
|
|
88
|
-
expect((0, utils_1.stringify)('foo')).toEqual('"foo"');
|
|
89
|
-
expect((0, utils_1.stringify)({ x: 'y' })).toEqual('{"x":"y"}');
|
|
90
|
-
expect((0, utils_1.stringify)({ x: 123 })).toEqual('{"x":123}');
|
|
91
|
-
expect((0, utils_1.stringify)({ x: undefined })).toEqual('{}');
|
|
92
|
-
expect((0, utils_1.stringify)({ x: null })).toEqual('{}');
|
|
93
|
-
expect((0, utils_1.stringify)({ x: {} })).toEqual('{}');
|
|
94
|
-
expect((0, utils_1.stringify)({ x: { y: 'z' } })).toEqual('{"x":{"y":"z"}}');
|
|
95
|
-
expect((0, utils_1.stringify)({ x: 2 }, true)).toEqual('{\n "x": 2\n}');
|
|
96
|
-
});
|
|
97
|
-
test('Deep equals', () => {
|
|
98
|
-
// Numbers
|
|
99
|
-
expect((0, utils_1.deepEquals)({ value: 0 }, { value: 0 })).toEqual(true);
|
|
100
|
-
expect((0, utils_1.deepEquals)({ value: 0 }, { value: 1 })).toEqual(false);
|
|
101
|
-
expect((0, utils_1.deepEquals)({ value: 0 }, { value: true })).toEqual(false);
|
|
102
|
-
expect((0, utils_1.deepEquals)({ value: 0 }, { value: 'x' })).toEqual(false);
|
|
103
|
-
expect((0, utils_1.deepEquals)({ value: 0 }, { value: {} })).toEqual(false);
|
|
104
|
-
// Booleans
|
|
105
|
-
expect((0, utils_1.deepEquals)({ value: true }, { value: true })).toEqual(true);
|
|
106
|
-
expect((0, utils_1.deepEquals)({ value: true }, { value: false })).toEqual(false);
|
|
107
|
-
expect((0, utils_1.deepEquals)({ value: true }, { value: 0 })).toEqual(false);
|
|
108
|
-
expect((0, utils_1.deepEquals)({ value: true }, { value: 'x' })).toEqual(false);
|
|
109
|
-
expect((0, utils_1.deepEquals)({ value: true }, { value: {} })).toEqual(false);
|
|
110
|
-
// Strings
|
|
111
|
-
expect((0, utils_1.deepEquals)({ value: 'x' }, { value: 'x' })).toEqual(true);
|
|
112
|
-
expect((0, utils_1.deepEquals)({ value: 'x' }, { value: 'y' })).toEqual(false);
|
|
113
|
-
expect((0, utils_1.deepEquals)({ value: 'x' }, { value: 0 })).toEqual(false);
|
|
114
|
-
expect((0, utils_1.deepEquals)({ value: 'x' }, { value: true })).toEqual(false);
|
|
115
|
-
expect((0, utils_1.deepEquals)({ value: 'x' }, { value: {} })).toEqual(false);
|
|
116
|
-
// Objects
|
|
117
|
-
expect((0, utils_1.deepEquals)({ value: {} }, { value: {} })).toEqual(true);
|
|
118
|
-
expect((0, utils_1.deepEquals)({ value: { x: 1 } }, { value: { x: 1 } })).toEqual(true);
|
|
119
|
-
expect((0, utils_1.deepEquals)({ value: { x: 1, y: '2' } }, { value: { x: 1, y: '2' } })).toEqual(true);
|
|
120
|
-
expect((0, utils_1.deepEquals)({ value: { x: 1, y: '2' } }, { value: { y: '2', x: 1 } })).toEqual(true);
|
|
121
|
-
expect((0, utils_1.deepEquals)({ value: { x: 1, y: '2', z: { n: 1 } } }, { value: { x: 1, y: '2', z: { n: 1 } } })).toEqual(true);
|
|
122
|
-
expect((0, utils_1.deepEquals)({ value: { x: 1, y: '2', z: { n: 1 } } }, { value: { y: '2', x: 1, z: { n: 1 } } })).toEqual(true);
|
|
123
|
-
expect((0, utils_1.deepEquals)({ value: { x: 1 } }, { value: { x: 2 } })).toEqual(false);
|
|
124
|
-
expect((0, utils_1.deepEquals)({ value: { x: 1 } }, { value: { y: 1 } })).toEqual(false);
|
|
125
|
-
// Arrays
|
|
126
|
-
expect((0, utils_1.deepEquals)({ value: [] }, { value: [] })).toEqual(true);
|
|
127
|
-
expect((0, utils_1.deepEquals)({ value: [1, 2, 3] }, { value: [1, 2, 3] })).toEqual(true);
|
|
128
|
-
expect((0, utils_1.deepEquals)({ value: [] }, { value: [1] })).toEqual(false);
|
|
129
|
-
expect((0, utils_1.deepEquals)({ value: [1, 2, 3] }, { value: [1, 2] })).toEqual(false);
|
|
130
|
-
expect((0, utils_1.deepEquals)({ value: [] }, { value: [true] })).toEqual(false);
|
|
131
|
-
expect((0, utils_1.deepEquals)({ value: [] }, { value: [{}] })).toEqual(false);
|
|
132
|
-
// Resources
|
|
133
|
-
expect((0, utils_1.deepEquals)({ resourceType: 'Patient' }, { resourceType: 'Patient' })).toEqual(true);
|
|
134
|
-
expect((0, utils_1.deepEquals)({ resourceType: 'Patient' }, { resourceType: 'Observation' })).toEqual(false);
|
|
135
|
-
expect((0, utils_1.deepEquals)({ resourceType: 'Patient' }, { resourceType: 'Patient', x: 'y' })).toEqual(false);
|
|
136
|
-
expect((0, utils_1.deepEquals)({ resourceType: 'Patient', x: 'y' }, { resourceType: 'Patient' })).toEqual(false);
|
|
137
|
-
expect((0, utils_1.deepEquals)({ resourceType: 'Patient', meta: { versionId: '1' } }, { resourceType: 'Patient', meta: { versionId: '1' } })).toEqual(true);
|
|
138
|
-
expect((0, utils_1.deepEquals)({ resourceType: 'Patient', meta: { lastUpdated: '1' } }, { resourceType: 'Patient', meta: { lastUpdated: '1' } })).toEqual(true);
|
|
139
|
-
});
|
|
140
|
-
test('Capitalize', () => {
|
|
141
|
-
expect((0, utils_1.capitalize)('foo')).toEqual('Foo');
|
|
142
|
-
});
|
|
143
|
-
test('isLowerCase', () => {
|
|
144
|
-
expect((0, utils_1.isLowerCase)('a')).toEqual(true);
|
|
145
|
-
expect((0, utils_1.isLowerCase)('A')).toEqual(false);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
//# sourceMappingURL=utils.test.js.map
|