├── .editorconfig ├── .github └── workflows │ ├── ReleasePublish.yaml │ ├── build-and-test.yml │ └── docs.yaml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── GeoPol.xml ├── LICENSE ├── README.md ├── SECURITY.md ├── THIRDPARTYNOTICES.md ├── docfx ├── .gitignore ├── api │ ├── .gitignore │ └── index.md ├── articles │ ├── blazorui.md │ ├── cli.md │ ├── extending.md │ ├── intro.md │ ├── languages.md │ ├── test.md │ └── toc.yml ├── docfx.json ├── index.md └── toc.yml ├── fhir-codegen.props ├── fhir-codegen.sln ├── fhirVersions └── .gitignore ├── languageInput ├── TypeScript2 │ ├── additional-files │ │ └── README.md │ └── insertions │ │ ├── BundleEntry.ts │ │ ├── HumanName.ts │ │ └── Reference.ts └── TypeScriptSdk │ ├── additional-files │ └── fhir │ │ ├── FhirBase.ts │ │ ├── FhirPrimitive.ts │ │ └── FhirPrimitiveSimple.ts │ ├── insertions │ ├── BackboneElement.ts │ ├── BundleEntry.ts │ ├── CodeableConcept.ts │ ├── DomainResource.ts │ ├── Extension.ts │ ├── FhirElement.ts │ ├── HumanName.ts │ ├── Reference_DSTU2_R3.ts │ ├── Reference_R4.ts │ └── fhir.ts │ └── replacement-files │ └── fhir │ ├── FhirBase64Binary.ts │ ├── FhirBoolean.ts │ ├── FhirCanonical.ts │ ├── FhirCode.ts │ ├── FhirDate.ts │ ├── FhirDateTime.ts │ ├── FhirDecimal.ts │ ├── FhirId.ts │ ├── FhirIdSimple.ts │ ├── FhirInstant.ts │ ├── FhirInteger.ts │ ├── FhirInteger64.ts │ ├── FhirMarkdown.ts │ ├── FhirOid.ts │ ├── FhirPositiveInt.ts │ ├── FhirString.ts │ ├── FhirTime.ts │ ├── FhirUnsignedInt.ts │ ├── FhirUri.ts │ ├── FhirUriSimple.ts │ ├── FhirUrl.ts │ ├── FhirUuid.ts │ └── FhirXhtml.ts ├── src ├── Microsoft.Health.Fhir.CodeGen.Tests │ ├── CrossVersionResolver.cs │ ├── CrossVersionTests.cs │ ├── Extensions │ │ ├── DirectoryContentsAttribute.cs │ │ ├── FileDataAttribute.cs │ │ └── FileNameAttribute.cs │ ├── FhirPackageTests.cs │ ├── FromFailures │ │ └── ParseTests.cs │ ├── GenerationTests.cs │ ├── GlobalUsings.cs │ ├── Microsoft.Health.Fhir.CodeGen.Tests.csproj │ ├── PackagesTests.cs │ ├── Playlists │ │ ├── GenInfoTests.playlist │ │ └── GenTsTests.playlist │ ├── TestCommon.cs │ ├── TestData │ │ ├── Generated │ │ │ ├── Info-R2.txt │ │ │ ├── Info-R3.txt │ │ │ ├── Info-R4.txt │ │ │ ├── Info-R4B.txt │ │ │ ├── Info-R5.txt │ │ │ ├── OpenApi-R4-Inline-Detailed-Candle-Filtered.yaml │ │ │ ├── OpenApi-R4-Inline-Names-Candle-Filtered.yaml │ │ │ ├── OpenApi-R4-Inline-None-Candle-Filtered.json │ │ │ ├── OpenApi-R4-Inline-None-Candle-Filtered.yaml │ │ │ ├── TypeScript-R2.ts │ │ │ ├── TypeScript-R3.ts │ │ │ ├── TypeScript-R4.ts │ │ │ ├── TypeScript-R4B.ts │ │ │ └── TypeScript-R5.ts │ │ ├── Hashes │ │ │ ├── CSharpFirely2-R3-Satellite.json │ │ │ ├── CSharpFirely2-R4-Satellite.json │ │ │ ├── CSharpFirely2-R4B-Satellite.json │ │ │ ├── CSharpFirely2-R5-Base.json │ │ │ ├── CSharpFirely2-R5-Conformance.json │ │ │ └── CSharpFirely2-R5-Satellite.json │ │ ├── R4 │ │ │ └── CapabilityStatement-candle-local.json │ │ ├── R4B │ │ │ └── ValueSet-nhin-purposeofuse.json │ │ └── R5 │ │ │ ├── StructureDefinition-integer64.json │ │ │ ├── ValueSet-units-of-time.json │ │ │ └── expansions │ │ │ └── ValueSet-units-of-time.json │ └── xunit.runner.json ├── Microsoft.Health.Fhir.CodeGen │ ├── AssemblyInfo.cs │ ├── CompareTool │ │ ├── ComparisonClasses.cs │ │ ├── CrossVersionMapCollection.cs │ │ ├── FhirTypeConversions.cs │ │ └── PackageComparer.cs │ ├── Configuration │ │ ├── ConfigCompare.cs │ │ ├── ConfigCrossVersionInteractive.cs │ │ ├── ConfigFluentUi.cs │ │ ├── ConfigGenerate.cs │ │ ├── ConfigGui.cs │ │ ├── ConfigInteractive.cs │ │ ├── ConfigRoot.cs │ │ ├── ConfigurationOption.cs │ │ └── ICodeGenConfig.cs │ ├── Extensions │ │ └── ConfigOptionAttribute.cs │ ├── FhirExtensions │ │ ├── BindingStrengthComparer.cs │ │ ├── ElementDefConstraintExtensions.cs │ │ ├── ElementDefTypeExtensions.cs │ │ ├── ElementDefinitionExtensions.cs │ │ ├── OpDefParameterExtensions.cs │ │ ├── OperationDefinitionExtensions.cs │ │ ├── SearchParameterExtensions.cs │ │ ├── StructureDefComponents.cs │ │ ├── StructureDefPrimitive.cs │ │ ├── StructureDefSlicing.cs │ │ ├── StructureDefinitionExtensions.cs │ │ └── ValueSetExtensions.cs │ ├── Language │ │ ├── ExportStreamWriter.cs │ │ ├── ExportStringBuilder.cs │ │ ├── Firely │ │ │ ├── CSharpFirely2.cs │ │ │ ├── CSharpFirelyCommon.cs │ │ │ ├── Cql │ │ │ │ ├── CqlModels.cs │ │ │ │ ├── Models │ │ │ │ │ └── fhir-modelinfo-4.0.1.xml │ │ │ │ ├── modelinfo.cs │ │ │ │ └── modelinfo.xsd │ │ │ ├── FirelyGenOptions.cs │ │ │ ├── FirelyNetIG.cs │ │ │ └── TypeReference.cs │ │ ├── IFileHashTestable.cs │ │ ├── ILanguage.cs │ │ ├── Info │ │ │ └── LangInfo.cs │ │ ├── LanguageManager.cs │ │ ├── OpenApi │ │ │ ├── LangOpenApi.cs │ │ │ ├── ModelBuilder.cs │ │ │ ├── OpenApiCommon.cs │ │ │ └── OpenApiOptions.cs │ │ ├── Ruby │ │ │ ├── LangRuby.cs │ │ │ ├── RubyCommon.cs │ │ │ └── RubyOptions.cs │ │ ├── Shorthand │ │ │ ├── ShorthandIG.cs │ │ │ └── ShorthandOptions.cs │ │ └── TypeScript.cs │ ├── Loader │ │ ├── LoaderOptions.cs │ │ └── PackageLoader.cs │ ├── Microsoft.Health.Fhir.CodeGen.csproj │ ├── Models │ │ ├── ComponentDefinition.cs │ │ ├── DefinitionCollection.cs │ │ ├── DefinitionCollectionSlicing.cs │ │ ├── DefinitionCollectionTx.cs │ │ ├── ElementDefinitionComparer.cs │ │ ├── FhirConcept.cs │ │ ├── FhirDotNestComparer.cs │ │ ├── FhirQueryParameter.cs │ │ ├── NaturalComparer.cs │ │ ├── SliceDiscriminator.cs │ │ ├── StructureElementCollection.cs │ │ └── ToolingTxIssueTypes.cs │ ├── Net │ │ └── ServerConnector.cs │ ├── Utils │ │ ├── FileSystemUtils.cs │ │ └── InterProcessSync.cs │ └── _ForPackages │ │ ├── AuthorJsonConverter.cs │ │ ├── DiskPackageCache.cs │ │ ├── FhirCiClient.cs │ │ ├── IniData.cs │ │ ├── JsonModels.cs │ │ ├── ManifestDateJsonConverter.cs │ │ └── VersionExtensions.cs ├── Microsoft.Health.Fhir.CodeGenCommon │ ├── Extensions │ │ ├── CommonDefinitions.cs │ │ ├── FhirEnumExtensions.cs │ │ ├── FhirLiteralAttribute.cs │ │ ├── FhirNameConventionExtensions.cs │ │ └── LinqExtensions.cs │ ├── Microsoft.Health.Fhir.CodeGenCommon.csproj │ ├── Models │ │ └── FhirArtifact.cs │ ├── Packaging │ │ ├── CachePackageManifest.cs │ │ ├── FhirPackageUtils.cs │ │ ├── FhirReleases.cs │ │ ├── PackageCacheRecord.cs │ │ └── PackageContents.cs │ ├── Polyfill │ │ └── CodeGenCommonPolyfill.cs │ ├── Smart │ │ └── SmartWellKnown.cs │ └── Utils │ │ ├── FhirSanitizationUtils.cs │ │ └── FhirTypeUtils.cs ├── Microsoft.Health.Fhir.CrossVersion │ ├── Convert_20_50 │ │ ├── Address_20_50.cs │ │ ├── Age_20_50.cs │ │ ├── Annotation_20_50.cs │ │ ├── Attachment_20_50.cs │ │ ├── BackboneElement_20_50.cs │ │ ├── CapabilityStatement_20_50.cs │ │ ├── CodeSystem_20_50.cs │ │ ├── CodeableConcept_20_50.cs │ │ ├── Coding_20_50.cs │ │ ├── CompartmentDefinition_20_50.cs │ │ ├── ConceptMap_20_50.cs │ │ ├── ContactDetail_20_50.cs │ │ ├── ContactPoint_20_50.cs │ │ ├── Contributor_20_50.cs │ │ ├── Count_20_50.cs │ │ ├── DataRequirement_20_50.cs │ │ ├── Distance_20_50.cs │ │ ├── DomainResource_20_50.cs │ │ ├── Dosage_20_50.cs │ │ ├── Duration_20_50.cs │ │ ├── ElementDefinition_20_50.cs │ │ ├── Element_20_50.cs │ │ ├── Extension_20_50.cs │ │ ├── HumanName_20_50.cs │ │ ├── Identifier_20_50.cs │ │ ├── ImplementationGuide_20_50.cs │ │ ├── Meta_20_50.cs │ │ ├── Money_20_50.cs │ │ ├── Narrative_20_50.cs │ │ ├── OperationDefinition_20_50.cs │ │ ├── ParameterDefinition_20_50.cs │ │ ├── Period_20_50.cs │ │ ├── Quantity_20_50.cs │ │ ├── Range_20_50.cs │ │ ├── Ratio_20_50.cs │ │ ├── Reference_20_50.cs │ │ ├── RelatedArtifact_20_50.cs │ │ ├── Resource_20_50.cs │ │ ├── SampledData_20_50.cs │ │ ├── SearchParameter_20_50.cs │ │ ├── Signature_20_50.cs │ │ ├── StructureDefinition_20_50.cs │ │ ├── Timing_20_50.cs │ │ ├── TriggerDefinition_20_50.cs │ │ ├── UsageContext_20_50.cs │ │ └── ValueSet_20_50.cs │ ├── Convert_30_50 │ │ ├── Address_30_50.cs │ │ ├── Age_30_50.cs │ │ ├── Annotation_30_50.cs │ │ ├── Attachment_30_50.cs │ │ ├── BackboneElement_30_50.cs │ │ ├── CapabilityStatement_30_50.cs │ │ ├── CodeSystem_30_50.cs │ │ ├── CodeableConcept_30_50.cs │ │ ├── Coding_30_50.cs │ │ ├── CompartmentDefinition_30_50.cs │ │ ├── ConceptMap_30_50.cs │ │ ├── ContactDetail_30_50.cs │ │ ├── ContactPoint_30_50.cs │ │ ├── Contributor_30_50.cs │ │ ├── Count_30_50.cs │ │ ├── DataRequirement_30_50.cs │ │ ├── Distance_30_50.cs │ │ ├── DomainResource_30_50.cs │ │ ├── Dosage_30_50.cs │ │ ├── Duration_30_50.cs │ │ ├── ElementDefinition_30_50.cs │ │ ├── Element_30_50.cs │ │ ├── Extension_30_50.cs │ │ ├── HumanName_30_50.cs │ │ ├── Identifier_30_50.cs │ │ ├── ImplementationGuide_30_50.cs │ │ ├── Meta_30_50.cs │ │ ├── Money_30_50.cs │ │ ├── Narrative_30_50.cs │ │ ├── OperationDefinition_30_50.cs │ │ ├── ParameterDefinition_30_50.cs │ │ ├── Period_30_50.cs │ │ ├── Quantity_30_50.cs │ │ ├── Range_30_50.cs │ │ ├── Ratio_30_50.cs │ │ ├── Reference_30_50.cs │ │ ├── RelatedArtifact_30_50.cs │ │ ├── Resource_30_50.cs │ │ ├── SampledData_30_50.cs │ │ ├── SearchParameter_30_50.cs │ │ ├── Signature_30_50.cs │ │ ├── StructureDefinition_30_50.cs │ │ ├── Timing_30_50.cs │ │ ├── TriggerDefinition_30_50.cs │ │ ├── UsageContext_30_50.cs │ │ └── ValueSet_30_50.cs │ ├── Convert_43_50 │ │ ├── Address_43_50.cs │ │ ├── Age_43_50.cs │ │ ├── Annotation_43_50.cs │ │ ├── Attachment_43_50.cs │ │ ├── BackboneElement_43_50.cs │ │ ├── CapabilityStatement_43_50.cs │ │ ├── CodeSystem_43_50.cs │ │ ├── CodeableConcept_43_50.cs │ │ ├── CodeableReference_43_50.cs │ │ ├── Coding_43_50.cs │ │ ├── CompartmentDefinition_43_50.cs │ │ ├── ConceptMap_43_50.cs │ │ ├── ContactDetail_43_50.cs │ │ ├── ContactPoint_43_50.cs │ │ ├── Contributor_43_50.cs │ │ ├── Count_43_50.cs │ │ ├── DataRequirement_43_50.cs │ │ ├── DataType_43_50.cs │ │ ├── Distance_43_50.cs │ │ ├── DomainResource_43_50.cs │ │ ├── Dosage_43_50.cs │ │ ├── Duration_43_50.cs │ │ ├── ElementDefinition_43_50.cs │ │ ├── Element_43_50.cs │ │ ├── Expression_43_50.cs │ │ ├── Extension_43_50.cs │ │ ├── HumanName_43_50.cs │ │ ├── Identifier_43_50.cs │ │ ├── ImplementationGuide_43_50.cs │ │ ├── MarketingStatus_43_50.cs │ │ ├── Meta_43_50.cs │ │ ├── Money_43_50.cs │ │ ├── Narrative_43_50.cs │ │ ├── OperationDefinition_43_50.cs │ │ ├── ParameterDefinition_43_50.cs │ │ ├── Period_43_50.cs │ │ ├── ProductShelfLife_43_50.cs │ │ ├── Quantity_43_50.cs │ │ ├── Range_43_50.cs │ │ ├── RatioRange_43_50.cs │ │ ├── Ratio_43_50.cs │ │ ├── Reference_43_50.cs │ │ ├── RelatedArtifact_43_50.cs │ │ ├── Resource_43_50.cs │ │ ├── SampledData_43_50.cs │ │ ├── SearchParameter_43_50.cs │ │ ├── Signature_43_50.cs │ │ ├── StructureDefinition_43_50.cs │ │ ├── Timing_43_50.cs │ │ ├── TriggerDefinition_43_50.cs │ │ ├── UsageContext_43_50.cs │ │ └── ValueSet_43_50.cs │ ├── Converter_20_50.cs │ ├── Converter_30_50.cs │ ├── Converter_40_50.cs │ ├── Converter_43_50.cs │ ├── ICrossVersionExtractor.cs │ ├── ICrossVersionProcessor.cs │ ├── Microsoft.Health.Fhir.CrossVersion.csproj │ ├── Normalization.cs │ └── PrimitiveExtractor.cs ├── Microsoft.Health.Fhir.MappingLanguage.Tests │ ├── Extensions │ │ ├── DirectoryContentsDataAttribute.cs │ │ └── FileDataAttribute.cs │ ├── FMLTests.cs │ ├── Microsoft.Health.Fhir.MappingLanguage.Tests.csproj │ └── data │ │ └── Encounter4Bto5.fml ├── Microsoft.Health.Fhir.MappingLanguage │ ├── AntlrUtils.cs │ ├── AssemblyInfo.cs │ ├── FhirMappingLanguage.cs │ ├── FhirStructureMap.cs │ ├── FmlParseVisitor.cs │ ├── FmlStructureDefinitionWalker.cs │ ├── FmlValidator.cs │ ├── MapUtilities.cs │ ├── Microsoft.Health.Fhir.MappingLanguage.csproj │ ├── Models │ │ ├── ExpressionNode.cs │ │ ├── NodeDefinitions │ │ │ ├── NodeDefinitionsFunction.cs │ │ │ └── NodeDefinitionsOperation.cs │ │ └── TypeDetails.cs │ ├── PropertyOrTypeDetails.cs │ ├── VisitorUtilities.cs │ └── antlr │ │ ├── FmlMapping.g4 │ │ ├── FmlMapping.interp │ │ ├── FmlMapping.tokens │ │ ├── FmlMappingBaseListener.cs │ │ ├── FmlMappingBaseVisitor.cs │ │ ├── FmlMappingLexer.cs │ │ ├── FmlMappingLexer.interp │ │ ├── FmlMappingLexer.tokens │ │ ├── FmlMappingListener.cs │ │ ├── FmlMappingParser.cs │ │ └── FmlMappingVisitor.cs ├── fhir-codegen │ ├── App.axaml │ ├── App.axaml.cs │ ├── CrossVersionInteractive.cs │ ├── Gui.cs │ ├── Icons.axaml │ ├── Models │ │ └── ComparisonUiModel.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── ViewLocator.cs │ ├── ViewModels │ │ ├── CompareDetailsValueSetsViewModel.cs │ │ ├── CoreComparisonViewModel.cs │ │ ├── INavigableViewModel.cs │ │ ├── MainWindowViewModel.cs │ │ ├── ViewModelBase.cs │ │ └── WelcomePageViewModel.cs │ ├── Views │ │ ├── CompareDetailsValueSetsView.axaml │ │ ├── CompareDetailsValueSetsView.axaml.cs │ │ ├── CoreComparisonView.axaml │ │ ├── CoreComparisonView.axaml.cs │ │ ├── MainWindow.axaml │ │ ├── MainWindow.axaml.cs │ │ ├── WelcomePageView.axaml │ │ └── WelcomePageView.axaml.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ └── fhir-codegen.csproj └── performance-test-cli │ ├── PackageLoading │ └── PackageLoadBenchmarks.cs │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ └── performance-test-cli.csproj ├── stylecop.json └── testenvironments.json /.github/workflows/ReleasePublish.yaml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | on: 3 | release: 4 | types: [published] 5 | 6 | env: 7 | DOTNET_VERSION: '8' # The .NET SDK version to use 8 | 9 | jobs: 10 | release: 11 | name: Release-${{matrix.os}} 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | matrix: 15 | os: [ubuntu-latest, windows-latest, macOS-latest] 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | # - name: Setup .NET 20 | # uses: actions/setup-dotnet@v3 21 | # with: 22 | # dotnet-version: ${{ env.DOTNET_VERSION }} 23 | 24 | - name: Build 25 | shell: bash 26 | run: | 27 | # Define some variables for things we need 28 | tag=$(git describe --tags --abbrev=0) 29 | release_name="fhir-codegen-$tag-${{ matrix.target }}" 30 | 31 | # Build everything 32 | dotnet publish src/fhir-codegen-cli/fhir-codegen-cli.csproj --framework netcoreapp3.1 --runtime "${{ matrix.target }}" -c Release -o "$release_name" 33 | 34 | # Pack files 35 | if [ "${{ matrix.target }}" == "win-x64" ]; then 36 | 7z a -tzip "${release_name}.zip" "./${release_name}/*" 37 | 7z a -tzip "generated-${tag}.zip" -r "./generated/*" 38 | else 39 | tar czvf "${release_name}.tar.gz" "$release_name" 40 | tar czvf "generated-${tag}.tar.gz" "generated" 41 | fi 42 | 43 | # Delete output directory 44 | rm -r "$release_name" 45 | 46 | - name: Publish 47 | uses: softprops/action-gh-release@v1 48 | with: 49 | fail_on_unmatched_files: false 50 | files: | 51 | "fhir-codegen-*" 52 | "generated-*.zip" 53 | "generated-*.tar.gz" 54 | env: 55 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 56 | -------------------------------------------------------------------------------- /.github/workflows/docs.yaml: -------------------------------------------------------------------------------- 1 | name: Docs 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - src/** 9 | - docfx/** 10 | - .github/workflows/docs.yml 11 | 12 | env: 13 | DOTNET_VERSION: '8' # The .NET SDK version to use 14 | 15 | jobs: 16 | generate-docs: 17 | runs-on: windows-latest 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Setup .NET Core 21 | uses: actions/setup-dotnet@v3 22 | with: 23 | dotnet-version: ${{ env.DOTNET_VERSION }} 24 | 25 | - name: Setup DocFX 26 | uses: crazy-max/ghaction-chocolatey@v1 27 | with: 28 | args: install docfx 29 | 30 | - name: DocFX Build 31 | run: docfx ./docfx/docfx.json 32 | continue-on-error: false 33 | 34 | - name: Upload Artifact 35 | uses: actions/upload-artifact@v1 36 | with: 37 | name: site 38 | path: docfx/_site 39 | 40 | deploy: 41 | concurrency: ci-${{ github.ref }} 42 | needs: [generate-docs] 43 | runs-on: ubuntu-latest 44 | steps: 45 | - name: Checkout 46 | uses: actions/checkout@v3 47 | 48 | - name: Download Artifact 49 | uses: actions/download-artifact@v1 50 | with: 51 | name: site 52 | 53 | - name: Deploy 54 | uses: JamesIves/github-pages-deploy-action@v4 55 | with: 56 | folder: 'site' 57 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ### 1.0.1 3 | 4 | * DSTU2 5 | * Fixed incorrect mapping of QuestionnaireResponseGroup to QuestionnaireGroup 6 | 7 | --- 8 | 9 | ### 1.0.0 10 | 11 | * Initial release 12 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /GeoPol.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | ]> 8 | 9 | 10 | 11 | &GitRepoName; 12 | 13 | 14 | 15 | . 16 | 17 | 18 | 19 | 20 | .gitignore 21 | GeoPol.xml 22 | fhirVersions 23 | generated 24 | src\Microsoft.Health.Fhir.SpecManager\fhir 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /THIRDPARTYNOTICES.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/fhir-codegen/173e7fd34f18b2a8863ac2f979a91a28158f5cf1/THIRDPARTYNOTICES.md -------------------------------------------------------------------------------- /docfx/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # DocFX # 3 | ############### 4 | /**/DROP/ 5 | /**/TEMP/ 6 | /**/packages/ 7 | /**/bin/ 8 | /**/obj/ 9 | _site 10 | -------------------------------------------------------------------------------- /docfx/api/.gitignore: -------------------------------------------------------------------------------- 1 | ############### 2 | # temp file # 3 | ############### 4 | *.yml 5 | .manifest 6 | -------------------------------------------------------------------------------- /docfx/api/index.md: -------------------------------------------------------------------------------- 1 | # API Documentation 2 | 3 | This section contains API documentation automatically generated from the source code comments. 4 | 5 | Information about specific projects can be found on the [Documentation Home Page](/fhir-codegen/index.md). -------------------------------------------------------------------------------- /docfx/articles/extending.md: -------------------------------------------------------------------------------- 1 | # Adding New Languages 2 | 3 | The system is designed to allow developers to add additional languages to be exported. 4 | 5 | Language files must be added to the `src/Microsoft.Health.Fhir.SpecManager/Language` directory, and implement the [ILanguage](/fhir-codegen/api/Microsoft.Health.Fhir.SpecManager.Language.ILanguage.html) interface present in the same directory. 6 | 7 | The library loads and parses all FHIR versions into a consistent local model. 8 | 9 | During export, the interface function [Export](/fhir-codegen/api/Microsoft.Health.Fhir.SpecManager.Language.ILanguage.html#methods) is called, with a [IPackageExportable](/fhir-codegen/api/Microsoft.Health.Fhir.SpecManager.Manager.IPackageExportable.html) already set to all user options (e.g., the requested version of FHIR has been loaded, filtering has been applied, etc.). 10 | 11 | The `Export` function may write as many files as desired in the `exportDirectory`. The exporter will move those files into the user-requested directory, and will bundle them together in an archive if necessary (relative paths are preserved). 12 | 13 | Existing language implementations can be used to serve as templates for export. Specifically: 14 | * [Info](/fhir-codegen/api/Microsoft.Health.Fhir.SpecManager.Language.Info.html) is a good 'single-file' export language that covers many types of artifacts. 15 | * [TypeScriptSdk](/fhir-codegen/api/Microsoft.Health.Fhir.SpecManager.Language.TypeScriptSdk.html) is a good example of an 'advanced' configuration that performs a conversion from the generic models into language-specific objects before exporting. 16 | 17 | More information about all of the implemented language modules can be found on the [Export Languages Page](languages.md). -------------------------------------------------------------------------------- /docfx/articles/intro.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | This project is intended to allow for easy use of FHIR specification packages. The FHIR specification (both core and implementation guides) are defined via FHIR models. FHIR definitional models are detailed computable structures for (e.g.): 4 | * defining and supporting the publication of the specifications, 5 | * consumption by applications to control behavior, 6 | * etc. 7 | 8 | Because of the targets of these structures, they are often are not too "friendly" for downstream projects or usage. 9 | 10 | Additionally, the FHIR specification has, and continues to, evolve over time. 11 | 12 | To that end, this project attempts to normalize the definitional aspects of FHIR into more developer-friendly models and abstract many of the internal changes that occur within the specifications. 13 | 14 | # Navigation 15 | 16 | Articles about the projects or major topics are in the navigation links (either side-bar or as 'Table of Contents'). 17 | 18 | API documentation is automatically generated from the source code and available [here](/fhir-codegen/api/index.html). 19 | 20 | 21 | # History / Development FAQs 22 | 23 | ## Why C#? 24 | 25 | The decision was somewhat arbitrary - when building tooling intended to be used in multiple language pipelines, one has to be chosen. I enjoy working in C# (both the language itself and associated tooling), it is performant, and it is cross-platform. 26 | 27 | ## Documentation Site 28 | 29 | [DocFX](https://dotnet.github.io/docfx/) is used to generate this documentation site. Articles are written in Markdown in this repo, while the API documentation is generated via the XMLDoc comments in the source code. 30 | 31 | [GitHub Pages](https://pages.github.com/) is used to host this documentation site. -------------------------------------------------------------------------------- /docfx/articles/test.md: -------------------------------------------------------------------------------- 1 | # Testing 2 | 3 | Running `dotnet run -p src/fhir-codegen-test-cli/fhir-codegen-test-cli.csproj` launches a full build and test. 4 | 5 | It will generate updated CSharpBasic and TypeScript files for FHIR Versions DSTU2, STU3, R4, and R5 (May 2020). It will then run each through a build process (requires `dotnet` and `tsc`) to validate there are no syntax errors in any of the generated files. 6 | 7 | Note that this test takes several minutes to run. 8 | 9 | ## Usage 10 | ``` 11 | fhir-codegen-test-cli: 12 | The FHIR CodeGen Test CLI. 13 | 14 | Usage: 15 | fhir-codegen-test-cli [options] 16 | 17 | Options: 18 | --repo-root-path The path to the repository root (if not CWD). 19 | --verbose True to display all output 20 | (default: false) 21 | --fixed-format-statistics True to output *only* test run statistics: 22 | #run[tab]#passed[tab]#failed[tab]#skipped 23 | (default: false) 24 | --errors-to-std-error True to write errors to stderr instead of stdout. 25 | (default: False) 26 | --version Show version information 27 | -?, -h, --help Show help and usage information 28 | ``` 29 | -------------------------------------------------------------------------------- /docfx/articles/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Introduction 2 | href: intro.md 3 | - name: Export Languages 4 | href: languages.md 5 | - name: Extending 6 | href: extending.md 7 | - name: Blazor UI 8 | href: blazorui.md 9 | - name: Command Line 10 | href: cli.md 11 | - name: Testing 12 | href: test.md 13 | -------------------------------------------------------------------------------- /docfx/docfx.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": [ 3 | { 4 | "src": [ 5 | { 6 | "files": ["**.csproj"], 7 | "src": "../src" 8 | } 9 | ], 10 | "dest": "api", 11 | "disableGitFeatures": false, 12 | "disableDefaultFilter": false 13 | } 14 | ], 15 | "build": { 16 | "content": [ 17 | { 18 | "files": [ 19 | "api/**.yml", 20 | "api/index.md" 21 | ] 22 | }, 23 | { 24 | "files": [ 25 | "articles/**.md", 26 | "articles/**/toc.yml", 27 | "toc.yml", 28 | "*.md" 29 | ] 30 | } 31 | ], 32 | "resource": [ 33 | { 34 | "files": [ 35 | "images/**" 36 | ] 37 | } 38 | ], 39 | "overwrite": [ 40 | { 41 | "files": [ 42 | "apidoc/**.md" 43 | ], 44 | "exclude": [ 45 | "obj/**", 46 | "_site/**" 47 | ] 48 | } 49 | ], 50 | "dest": "_site", 51 | "globalMetadataFiles": [], 52 | "fileMetadataFiles": [], 53 | "template": [ 54 | "default" 55 | ], 56 | "postProcessors": [], 57 | "markdownEngineName": "markdig", 58 | "noLangKeyword": false, 59 | "keepFileLink": false, 60 | "cleanupCacheHistory": false, 61 | "disableGitFeatures": false 62 | } 63 | } -------------------------------------------------------------------------------- /docfx/toc.yml: -------------------------------------------------------------------------------- 1 | - name: Articles 2 | href: articles/ 3 | - name: Api Documentation 4 | href: api/ 5 | homepage: api/index.md 6 | -------------------------------------------------------------------------------- /fhir-codegen.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12.0 6 | enable 7 | enable 8 | $([System.DateTime]::Now.ToString("'3.'yyyy.MMdd")) 9 | $(VersionPrefix) 10 | $(AssemblyName.Replace(' ', '_')) 11 | $([System.DateTime]::Now.ToString("'3.'yyyy.MMdd.HHmm")) 12 | $([System.DateTime]::Now.ToString("'3.'yyyy.MMdd.HHmm")) 13 | GinoCanessa 14 | Microsoft Corporation 15 | Copyright 2019-2024 16 | git 17 | https://github.com/Microsoft/fhir-codegen 18 | en 19 | 20 | 21 | 22 | 23 | LICENSE 24 | 25 | 26 | README.md 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /fhirVersions/.gitignore: -------------------------------------------------------------------------------- 1 | * -------------------------------------------------------------------------------- /languageInput/TypeScript2/additional-files/README.md: -------------------------------------------------------------------------------- 1 | 2 | # FHIR TypeScript Library 3 | 4 | TODO 5 | 6 | # Building 7 | 8 | 9 | `tsc --build` 10 | 11 | # Installing 12 | 13 | While this repo is the temp home: 14 | 15 | `npm install git+https://github.com/GinoCanessa/FhirTypeScriptOddsAndEnds.git` -------------------------------------------------------------------------------- /languageInput/TypeScript2/insertions/BundleEntry.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Access a bundle.entry[].resource as a typed resource 4 | */ 5 | resourceAs(): BundeContentType|unknown { 6 | return this.resource as unknown as BundeContentType; 7 | } 8 | -------------------------------------------------------------------------------- /languageInput/TypeScript2/insertions/HumanName.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Convert a HumanName into a displayable string 4 | */ 5 | toDisplay(familyFirst:boolean = true, includeAnnotations:boolean = false):string { 6 | if ((this.text) && (this.text.length > 0)) { 7 | return this.text; 8 | } 9 | 10 | var val:string = ''; 11 | 12 | if (familyFirst) { 13 | if (this.family) { 14 | val = this.family; 15 | } 16 | 17 | if (this.given) { 18 | val += (val.length > 0 ? ', ' : '') + this.given.join(' '); 19 | } 20 | 21 | if (includeAnnotations) { 22 | if (this.suffix) { 23 | val += (val.length > 0 ? ', ' : '') + this.suffix.join(', '); 24 | } 25 | 26 | if (this.prefix) { 27 | val += (val.length > 0 ? ', ' : '') + this.prefix.join(', '); 28 | } 29 | } 30 | 31 | return val; 32 | } 33 | 34 | if ((includeAnnotations) && (this.prefix)) { 35 | val += this.prefix.join(', '); 36 | } 37 | 38 | if (this.given) { 39 | val = (val.length > 0 ? ' ' : '') + this.given.join(' '); 40 | } 41 | if (this.family) { 42 | val += (val.length > 0 ? ' ' : '') + this.family; 43 | } 44 | 45 | if ((includeAnnotations) && (this.suffix)) { 46 | val += (val.length > 0 ? ', ' : '') + this.suffix.join(', '); 47 | } 48 | 49 | return val; 50 | } 51 | -------------------------------------------------------------------------------- /languageInput/TypeScript2/insertions/Reference.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Create a reference from an existing resource 4 | */ 5 | static fromResource(source:fhir.IResource, baseUrl:string=''):Reference { 6 | if (baseUrl.endsWith('/')) { 7 | return new Reference({ 8 | type: source.resourceType, 9 | reference: baseUrl + source.resourceType + '/' + source.id, 10 | }); 11 | } 12 | 13 | return new Reference({ 14 | type: source.resourceType, 15 | reference: ((baseUrl.length > 0) ? (baseUrl + '/') : '') + source.resourceType + '/' + source.id, 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /languageInput/TypeScriptSdk/additional-files/fhir/FhirPrimitiveSimple.ts: -------------------------------------------------------------------------------- 1 | // Minimum TypeScript Version: 3.7 2 | 3 | import * as fhir from '../fhir.js'; 4 | 5 | export interface FhirPrimitiveSimpleArgs { 6 | /** 7 | * Value of the primitive - constrained by decendant classes. 8 | */ 9 | value?:any|null|undefined; 10 | } 11 | 12 | export class FhirPrimitiveSimple extends fhir.FhirBase { 13 | public static readonly _fts_isPrimitive:boolean = true; 14 | /** 15 | * Mapping of this datatype to a FHIR equivalent 16 | */ 17 | public static override readonly _fts_dataType:string='PrimitiveType'; 18 | public static readonly _fts_jsonType:string='any'; 19 | 20 | /** 21 | * Value of the primitive - constrained by decendant classes. 22 | */ 23 | value?:boolean|number|bigint|string|null|undefined; 24 | 25 | /** 26 | * Constructor for FHIR primitive type elements that do not allow extended properties 27 | * @param source 28 | * @param options 29 | */ 30 | constructor(source:Partial = {}, options:fhir.FhirConstructorOptions = {}) { 31 | super({}, options); 32 | this.value = source?.value ?? undefined; 33 | } 34 | 35 | /** 36 | * Function to perform basic model validation (e.g., check if required elements are present). 37 | */ 38 | public override doModelValidation(exp:string = ''):fhir.FtsIssue[] { 39 | let iss:fhir.FtsIssue[] = super.doModelValidation(exp); 40 | if (this.value === undefined) { 41 | iss.push({ 42 | severity: 'error', 43 | code: 'required', 44 | details: { text: 'Simple Primitive values must have a value.' }, 45 | expression: [exp], 46 | }); 47 | } 48 | return iss; 49 | } 50 | } -------------------------------------------------------------------------------- /languageInput/TypeScriptSdk/insertions/BackboneElement.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/fhir-codegen/173e7fd34f18b2a8863ac2f979a91a28158f5cf1/languageInput/TypeScriptSdk/insertions/BackboneElement.ts -------------------------------------------------------------------------------- /languageInput/TypeScriptSdk/insertions/BundleEntry.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Access a bundle.entry[].resource as a typed resource 4 | */ 5 | resourceAs(): BundeContentType|unknown { 6 | return this.resource as unknown as BundeContentType; 7 | } 8 | -------------------------------------------------------------------------------- /languageInput/TypeScriptSdk/insertions/Extension.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/fhir-codegen/173e7fd34f18b2a8863ac2f979a91a28158f5cf1/languageInput/TypeScriptSdk/insertions/Extension.ts -------------------------------------------------------------------------------- /languageInput/TypeScriptSdk/insertions/HumanName.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Convert a HumanName into a displayable string 4 | */ 5 | toDisplay(familyFirst:boolean = true, includeAnnotations:boolean = false):string { 6 | if ((this.text) && (this.text.length > 0)) { 7 | return this.text.toString(); 8 | } 9 | 10 | var val:string = ''; 11 | 12 | if (familyFirst) { 13 | if (this.family) { 14 | val = this.family.toString(); 15 | } 16 | 17 | if (this.given) { 18 | val += (val.length > 0 ? ', ' : '') + this.given.join(' '); 19 | } 20 | 21 | if (includeAnnotations) { 22 | if (this.suffix) { 23 | val += (val.length > 0 ? ', ' : '') + this.suffix.join(', '); 24 | } 25 | 26 | if (this.prefix) { 27 | val += (val.length > 0 ? ', ' : '') + this.prefix.join(', '); 28 | } 29 | } 30 | 31 | return val; 32 | } 33 | 34 | if ((includeAnnotations) && (this.prefix)) { 35 | val += this.prefix.join(', '); 36 | } 37 | 38 | if (this.given) { 39 | val = (val.length > 0 ? ' ' : '') + this.given.join(' '); 40 | } 41 | if (this.family) { 42 | val += (val.length > 0 ? ' ' : '') + this.family; 43 | } 44 | 45 | if ((includeAnnotations) && (this.suffix)) { 46 | val += (val.length > 0 ? ', ' : '') + this.suffix.join(', '); 47 | } 48 | 49 | return val; 50 | } 51 | -------------------------------------------------------------------------------- /languageInput/TypeScriptSdk/insertions/Reference_DSTU2_R3.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Create a reference from an existing resource 4 | */ 5 | static fromResource(source:fhir.FhirResource, baseUrl:string=''):Reference { 6 | if (baseUrl.endsWith('/')) { 7 | return new Reference({ 8 | reference: baseUrl + source.resourceType + '/' + source.id, 9 | }); 10 | } 11 | 12 | return new Reference({ 13 | reference: ((baseUrl.length > 0) ? (baseUrl + '/') : '') + source.resourceType + '/' + source.id, 14 | }); 15 | } 16 | -------------------------------------------------------------------------------- /languageInput/TypeScriptSdk/insertions/Reference_R4.ts: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Create a reference from an existing resource 4 | */ 5 | static fromResource(source:fhir.FhirResource, baseUrl:string=''):Reference { 6 | if (baseUrl.endsWith('/')) { 7 | return new Reference({ 8 | type: source.resourceType ?? undefined, 9 | reference: baseUrl + source.resourceType + '/' + source.id, 10 | }); 11 | } 12 | 13 | return new Reference({ 14 | type: source.resourceType ?? undefined, 15 | reference: ((baseUrl.length > 0) ? (baseUrl + '/') : '') + source.resourceType + '/' + source.id, 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /languageInput/TypeScriptSdk/insertions/fhir.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/fhir-codegen/173e7fd34f18b2a8863ac2f979a91a28158f5cf1/languageInput/TypeScriptSdk/insertions/fhir.ts -------------------------------------------------------------------------------- /languageInput/TypeScriptSdk/replacement-files/fhir/FhirBoolean.ts: -------------------------------------------------------------------------------- 1 | // Minimum TypeScript Version: 3.7 2 | // FHIR Primitive: boolean 3 | 4 | import * as fhir from '../fhir.js'; 5 | 6 | /** 7 | * Value of "true" or "false" 8 | */ 9 | export interface FhirBooleanArgs extends fhir.FhirPrimitiveArgs { 10 | /** 11 | * Value of "true" or "false" 12 | */ 13 | value?:FhirBoolean|boolean|undefined|null; 14 | } 15 | 16 | /** 17 | * Value of "true" or "false" 18 | */ 19 | export class FhirBoolean extends fhir.FhirPrimitive { 20 | /** 21 | * Mapping of this datatype to a FHIR equivalent 22 | */ 23 | public static override readonly _fts_dataType:string = 'Boolean'; 24 | /** 25 | * Mapping of this datatype to a JSON equivalent 26 | */ 27 | public static override readonly _fts_jsonType:string = 'boolean'; 28 | // published regex: true|false 29 | public static override readonly _fts_regex:RegExp = /^true|false$/ 30 | /** 31 | * A boolean value, represented as a JS boolean 32 | */ 33 | declare value?:boolean|null|undefined; 34 | /** 35 | * Create a FhirBoolean 36 | * @param value Value of "true" or "false" 37 | * @param id Unique id for inter-element referencing (uncommon on primitives) 38 | * @param extension Additional content defined by implementations 39 | * @param options Options to pass to extension constructors 40 | */ 41 | constructor(source:Partial = {}, options:fhir.FhirConstructorOptions = { } ) { 42 | super(source, options); 43 | } 44 | /** 45 | * Function to perform basic model validation (e.g., check if required elements are present). 46 | */ 47 | public override doModelValidation(exp:string = ''):fhir.FtsIssue[] { 48 | let iss:fhir.FtsIssue[] = super.doModelValidation(exp); 49 | if ((this.value) && (this.value !== null) && ((typeof this.value !== 'boolean') || (!FhirBoolean._fts_regex.test(this.value.toString())))) { 50 | iss.push({ severity: 'error', code: 'invalid', details: { text: 'Invalid value in primitive type boolean' }, expression: [exp]}); 51 | } 52 | return iss; 53 | } 54 | /** 55 | * Returns the primitive value of the specified object. 56 | */ 57 | public override valueOf():boolean { return (this.value ?? false); } 58 | } 59 | -------------------------------------------------------------------------------- /languageInput/TypeScriptSdk/replacement-files/fhir/FhirTime.ts: -------------------------------------------------------------------------------- 1 | // Minimum TypeScript Version: 3.7 2 | // FHIR Primitive: time 3 | 4 | import * as fhir from '../fhir.js'; 5 | 6 | /** 7 | * A time during the day, with no date specified 8 | */ 9 | export interface FhirTimeArgs extends fhir.FhirPrimitiveArgs { 10 | /** 11 | * A time during the day, with no date specified 12 | */ 13 | value?:FhirTime|string|undefined|null; 14 | } 15 | 16 | /** 17 | * A time during the day, with no date specified 18 | */ 19 | export class FhirTime extends fhir.FhirPrimitive { 20 | /** 21 | * Mapping of this datatype to a FHIR equivalent 22 | */ 23 | public static override readonly _fts_dataType:string = 'Time'; 24 | /** 25 | * Mapping of this datatype to a JSON equivalent 26 | */ 27 | public static override readonly _fts_jsonType:string = 'string'; 28 | // published regex: ([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)? 29 | public static override readonly _fts_regex:RegExp = /^([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?$/ 30 | /** 31 | * A time value, represented as a JS string 32 | */ 33 | declare value?:string|null|undefined; 34 | /** 35 | * Create a FhirTime 36 | * @param value A time during the day, with no date specified 37 | * @param id Unique id for inter-element referencing (uncommon on primitives) 38 | * @param extension Additional content defined by implementations 39 | * @param options Options to pass to extension constructors 40 | */ 41 | constructor(source:Partial = {}, options:fhir.FhirConstructorOptions = { } ) { 42 | super(source, options); 43 | } 44 | /** 45 | * Function to perform basic model validation (e.g., check if required elements are present). 46 | */ 47 | public override doModelValidation(exp:string = ''):fhir.FtsIssue[] { 48 | let iss:fhir.FtsIssue[] = super.doModelValidation(exp); 49 | if ((this.value !== undefined) && (this.value !== null) && ((this.value === '') || (typeof this.value !== 'string') || (!FhirTime._fts_regex.test(this.value)))) { 50 | iss.push({ severity: 'error', code: 'invalid', details: { text: 'Invalid value in primitive type time' }, expression: [exp]}); 51 | } 52 | return iss; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen.Tests/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen.Tests/PackagesTests.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using FluentAssertions; 12 | using Microsoft.Health.Fhir.CodeGen.Tests.Extensions; 13 | 14 | namespace Microsoft.Health.Fhir.CodeGen.Tests; 15 | 16 | public class PackagesTests 17 | { 18 | // IniData has been removed temporarily - may be added back later 19 | //[Theory] 20 | //[FileName("TestData/Packages/packages-01-empty.ini")] 21 | //public void LoadPackageIni(string path) 22 | //{ 23 | // _ForPackages.IniData iniData = new(path); 24 | 25 | // iniData.Sections.Count.Should().Be(5); 26 | 27 | // ((_ForPackages.IniData.IniSection?)iniData.Sections[0])?.Name.Should().Be("cache"); 28 | // ((_ForPackages.IniData.IniSection?)iniData.Sections[1])?.Name.Should().Be("urls"); 29 | // ((_ForPackages.IniData.IniSection?)iniData.Sections[2])?.Name.Should().Be("local"); 30 | // ((_ForPackages.IniData.IniSection?)iniData.Sections[3])?.Name.Should().Be("packages"); 31 | // ((_ForPackages.IniData.IniSection?)iniData.Sections[4])?.Name.Should().Be("package-sizes"); 32 | 33 | // iniData.Sections[0].Should().Be(iniData["cache"]); 34 | // iniData.Sections[1].Should().Be(iniData["urls"]); 35 | // iniData.Sections[2].Should().Be(iniData["local"]); 36 | // iniData.Sections[3].Should().Be(iniData["packages"]); 37 | // iniData.Sections[4].Should().Be(iniData["package-sizes"]); 38 | 39 | // ((_ForPackages.IniData.IniSection?)iniData.Sections[0])?.Values.Count.Should().NotBe(0); 40 | // ((_ForPackages.IniData.IniSection?)iniData.Sections[0])?[0]!.Key.Should().Be("version"); 41 | // ((_ForPackages.IniData.IniSection?)iniData.Sections[0])?[0]!.Value.Should().Be("3"); 42 | //} 43 | } 44 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen.Tests/TestCommon.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.Health.Fhir.CodeGen.Tests; 8 | 9 | public static class TestCommon 10 | { 11 | /// The FHIR R5 package entries. 12 | public static readonly string[] EntriesR5 = 13 | [ 14 | "hl7.fhir.r5.core#5.0.0", 15 | //"hl7.fhir.r5.expansions#5.0.0", 16 | //"hl7.fhir.uv.extensions#1.0.0", 17 | ]; 18 | 19 | /// The FHIR R4B package entries. 20 | public static readonly string[] EntriesR4B = 21 | [ 22 | "hl7.fhir.r4b.core#4.3.0", 23 | //"hl7.fhir.r4b.expansions#4.3.0", 24 | //"hl7.fhir.uv.extensions#1.0.0", 25 | ]; 26 | 27 | /// The FHIR R4 package entries. 28 | public static readonly string[] EntriesR4 = 29 | [ 30 | "hl7.fhir.r4.core#4.0.1", 31 | //"hl7.fhir.r4.expansions#4.0.1", 32 | //"hl7.fhir.uv.extensions#1.0.0", 33 | ]; 34 | 35 | /// The FHIR STU3 package entries. 36 | public static readonly string[] EntriesR3 = 37 | [ 38 | "hl7.fhir.r3.core#3.0.2", 39 | //"hl7.fhir.r3.expansions#3.0.2", 40 | ]; 41 | 42 | /// The FHIR DSTU2 package entries. 43 | public static readonly string[] EntriesR2 = 44 | [ 45 | "hl7.fhir.r2.core#1.0.2", 46 | //"hl7.fhir.r2.expansions#1.0.2", 47 | ]; 48 | } 49 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen.Tests/TestData/Hashes/CSharpFirely2-R5-Conformance.json: -------------------------------------------------------------------------------- 1 | {"\\Generated\\Template-Bindings.cs":"1c319dfcca60c161c14c49be12d28c84cebf4f677c755b9099e8cba372380320","\\Generated\\ElementDefinition.cs":"351898c3cfaecdef99c1839bd059388d2749e92b0f3c494741c28c7212300a98","\\Generated\\RelatedArtifact.cs":"9ced9750ab070a2e8c81d69e37f4399f236f5bb15ade38647a6a600bc8624b2f","\\Generated\\CapabilityStatement.cs":"8b654eadd6e92ad6eac4c47230d9876da622a463fc282c95afc98d6774cca983","\\Generated\\CodeSystem.cs":"a8b7ece12ff7d14f17f1292439cb2d18f80ca52b18199d5242ad4532c3af671e","\\Generated\\StructureDefinition.cs":"d27a7e4e58484292b1be020655acd04b48dccce9c19e09e87c3b88589f1292ce","\\Generated\\ValueSet.cs":"0045bb1c8ef79127ddcbf36a410ae170f436c19b9e649b2f2f286d1aa6c60759","\\Generated\\_GeneratorLog.cs":"950291cb98b247a9d65880cecfbc7ce385fbccba340cb9376245f3fd370d5630"} -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen.Tests/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "maxParallelThreads": 5, 3 | "parallelAlgorithm": "conservative", 4 | "parallelizeAssembly": true, 5 | "parallelizeTestCollections": true 6 | } 7 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("Microsoft.Health.Fhir.CodeGen.Tests")] 4 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Configuration/ConfigGui.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | namespace Microsoft.Health.Fhir.CodeGen.Configuration; 7 | 8 | /// A configuration for launching the Avalonia UI. 9 | public class ConfigGui : ConfigRoot 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Configuration/ConfigInteractive.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | namespace Microsoft.Health.Fhir.CodeGen.Configuration; 7 | 8 | /// A configuration interactive. 9 | public class ConfigInteractive : ConfigRoot 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Configuration/ConfigurationOption.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | 7 | namespace Microsoft.Health.Fhir.CodeGen.Configuration; 8 | 9 | public record class ConfigurationOption 10 | { 11 | /// Gets or initializes the name. 12 | public required string Name { get; init; } 13 | 14 | /// Gets or sets the name of the environment variable name. 15 | public string EnvVarName { get; init; } = string.Empty; 16 | 17 | /// Gets or sets the default value. 18 | public required object DefaultValue { get; init; } 19 | 20 | /// Gets or initializes the CLI option. 21 | public required System.CommandLine.Option CliOption { get; init; } 22 | } 23 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Configuration/ICodeGenConfig.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | namespace Microsoft.Health.Fhir.CodeGen.Configuration; 7 | 8 | public interface ICodeGenConfig 9 | { 10 | /// Gets options for controlling the operation. 11 | ConfigurationOption[] GetOptions(); 12 | 13 | /// Parses the given parse result. 14 | /// The parse result. 15 | void Parse(System.CommandLine.Parsing.ParseResult parseResult); 16 | } 17 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Extensions/ConfigOptionAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using System.CommandLine; 7 | 8 | namespace Microsoft.Health.Fhir.CodeGen.Extensions; 9 | 10 | /// Attribute for configuration option. 11 | public class ConfigOptionAttribute : Attribute 12 | { 13 | /// Gets or sets the name of the environment variable name. 14 | public string EnvName { get; set; } = string.Empty; 15 | 16 | /// Gets or sets the name of the argument. 17 | public string ArgName { get; set; } = string.Empty; 18 | 19 | /// Gets or sets the argument aliases. 20 | public string[] ArgAliases { get; set; } = []; 21 | 22 | /// Gets or sets the description. 23 | public string Description { get; set; } = string.Empty; 24 | 25 | /// Gets or sets the arity, specified as a FHIR Cardinality string. 26 | public string ArgArity { get; set; } = "0..1"; 27 | } 28 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/FhirExtensions/ElementDefConstraintExtensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.Model; 7 | using Microsoft.Health.Fhir.CodeGenCommon.FhirExtensions; 8 | 9 | namespace Microsoft.Health.Fhir.CodeGen.FhirExtensions; 10 | 11 | public static class ElementDefConstraintExtensions 12 | { 13 | /// 14 | /// Gets whether this constraint is flagged as a best practice. 15 | /// 16 | /// A ConstraintComponent to process. 17 | /// True if it succeeds, false if it fails. 18 | public static bool cgIsBestPractice(this ElementDefinition.ConstraintComponent c) => 19 | c.GetExtensionValue(CommonDefinitions.ExtUrlBestPractice)?.Value 20 | ?? false; 21 | 22 | /// 23 | /// Gets the explanation of why this constraint is flagged as a best practice, or an empty string 24 | /// if not flagged. 25 | /// 26 | /// A ConstraintComponent to process. 27 | /// A string. 28 | public static string cgBestPracticeDescription(this ElementDefinition.ConstraintComponent c) => 29 | c.GetExtensionValue(CommonDefinitions.ExtUrlBestPracticeExplanation)?.ToString() 30 | ?? c.GetExtensionValue(CommonDefinitions.ExtUrlBestPracticeExplanation)?.ToString() 31 | ?? string.Empty; 32 | 33 | /// 34 | /// Test if this constraint is inherited or newly defined in the current StructureDefinition. 35 | /// 36 | /// A ConstraintComponent to process. 37 | /// The SD. 38 | /// True if it succeeds, false if it fails. 39 | public static bool cgIsInherited(this ElementDefinition.ConstraintComponent c, StructureDefinition sd) => 40 | !(c.Source?.Equals(sd.Url, StringComparison.Ordinal) ?? true); 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/FhirExtensions/OpDefParameterExtensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.Model; 7 | using Hl7.Fhir.Utility; 8 | using Microsoft.Health.Fhir.CodeGenCommon.FhirExtensions; 9 | 10 | namespace Microsoft.Health.Fhir.CodeGen.FhirExtensions; 11 | 12 | public static class OpDefParameterExtensions 13 | { 14 | public record class ParameterFieldOrder 15 | { 16 | public required int FieldOrder { get; init; } 17 | } 18 | 19 | public static void cgSetFieldOrder(this OperationDefinition.ParameterComponent pc, int fieldOrder) 20 | { 21 | ParameterFieldOrder pfo = new() 22 | { 23 | FieldOrder = fieldOrder, 24 | }; 25 | 26 | if (pc.HasAnnotation()) 27 | { 28 | pc.RemoveAnnotations(); 29 | } 30 | 31 | pc.AddAnnotation(pfo); 32 | } 33 | 34 | /// Gets the field order. 35 | public static int cgFieldOrder(this OperationDefinition.ParameterComponent pc) 36 | { 37 | if (pc.TryGetAnnotation(out ParameterFieldOrder? pfo)) 38 | { 39 | return pfo!.FieldOrder; 40 | } 41 | 42 | return -1; 43 | } 44 | 45 | public static string cgCardinality(this OperationDefinition.ParameterComponent pc) => $"{pc.Min ?? 0}..{pc.Max ?? "*"}"; 46 | 47 | /// Gets the cardinality minimum. 48 | public static int cgCardinalityMin(this OperationDefinition.ParameterComponent pc) => pc.Min ?? 0; 49 | 50 | /// Gets the cardinality maximum, -1 for *. 51 | public static int cgCardinalityMax(this OperationDefinition.ParameterComponent pc) => pc.Max == "*" ? -1 : int.Parse(pc.Max ?? "0"); 52 | } 53 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Language/Firely/Cql/CqlModels.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Serialization; 2 | using Hl7.Fhir.Model; 3 | 4 | namespace Ncqa.Cql.Model 5 | { 6 | internal static class CqlModels 7 | { 8 | private static readonly XmlSerializer xmlSerializer = new(typeof(ModelInfo)); 9 | 10 | public static IDictionary ClassesByName(ModelInfo model) 11 | { 12 | var result = model.typeInfo.OfType() 13 | .ToDictionary(classInfo => classInfo.name); 14 | return result; 15 | } 16 | 17 | public static ModelInfo LoadFromStream(System.IO.Stream stream) 18 | { 19 | return xmlSerializer.Deserialize(stream) as ModelInfo 20 | ?? throw new ArgumentException($"This resource is not a valid {nameof(ModelInfo)}"); 21 | } 22 | 23 | public static ModelInfo LoadEmbeddedResource(string resourceName) 24 | { 25 | var stream = typeof(CqlModels).Assembly.GetManifestResourceStream(resourceName) 26 | ?? throw new ArgumentException($"Manifest resource stream {resourceName} is not included in this assembly."); 27 | return LoadFromStream(stream); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Language/IFileHashTestable.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Text; 9 | 10 | namespace Microsoft.Health.Fhir.CodeGen.Language; 11 | 12 | internal interface IFileHashTestable 13 | { 14 | internal bool GenerateHashesInsteadOfOutput { get; set; } 15 | 16 | internal Dictionary FileHashes { get; } 17 | } 18 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Language/ILanguage.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | 7 | using Microsoft.Health.Fhir.CodeGen.Models; 8 | 9 | namespace Microsoft.Health.Fhir.CodeGen.Language; 10 | 11 | /// Interface for code generation languages. 12 | public interface ILanguage 13 | { 14 | /// Gets the language name. 15 | string Name { get; } 16 | 17 | /// Gets the FHIR primitive type map. 18 | Dictionary FhirPrimitiveTypeMap { get; } 19 | 20 | /// Gets a value indicating whether this language is idempotent. 21 | bool IsIdempotent { get; } 22 | 23 | /// Gets the type of the configuration. 24 | Type ConfigType { get; } 25 | 26 | /// Exports the given configuration. 27 | /// The configuration. 28 | /// The definitions to export. 29 | /// (Optional) Stream to write data to. 30 | void Export( 31 | object config, 32 | DefinitionCollection definitions); 33 | } 34 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Language/Ruby/RubyCommon.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace Microsoft.Health.Fhir.CodeGen.Language.Ruby; 13 | 14 | public static class RubyCommon 15 | { 16 | public static HashSet ReservedWords = 17 | [ 18 | "__ENCODING__", 19 | "__LINE__", 20 | "__FILE__", 21 | "BEGIN", 22 | "END", 23 | "alias", 24 | "and", 25 | "begin", 26 | "break", 27 | "case", 28 | "class", 29 | "def", 30 | "defined?", 31 | "do", 32 | "else", 33 | "elseif", 34 | "end", 35 | "ensure", 36 | "false", 37 | "for", 38 | "if", 39 | "in", 40 | "module", 41 | "next", 42 | "nil", 43 | "not", 44 | "or", 45 | "redo", 46 | "rescue", 47 | "retry", 48 | "return", 49 | "self", 50 | "super", 51 | "then", 52 | "true", 53 | "undef", 54 | "unless", 55 | "until", 56 | "when", 57 | "while", 58 | "yield", 59 | "method", // note this is not actually a reserved word, but treated as one in the output 60 | ]; 61 | 62 | public static void WriteRubyComment( 63 | this ExportStreamWriter writer, 64 | string value) 65 | { 66 | writer.WriteLineIndented("##"); 67 | foreach (string line in value.Split('\n')) 68 | { 69 | writer.WriteLineIndented($"# {line}"); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Language/Shorthand/ShorthandOptions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Text; 9 | using Microsoft.Health.Fhir.CodeGen.Configuration; 10 | 11 | namespace Microsoft.Health.Fhir.CodeGen.Language.Shorthand; 12 | 13 | public class ShorthandOptions : ConfigGenerate 14 | { 15 | 16 | private static readonly ConfigurationOption[] _options = 17 | [ 18 | ]; 19 | 20 | public override ConfigurationOption[] GetOptions() 21 | { 22 | return [.. base.GetOptions(), .. _options]; 23 | } 24 | 25 | public override void Parse(System.CommandLine.Parsing.ParseResult parseResult) 26 | { 27 | // parse base properties 28 | base.Parse(parseResult); 29 | 30 | //// iterate over options for ones we are interested in 31 | //foreach (ConfigurationOption opt in _options) 32 | //{ 33 | // switch (opt.Name) 34 | // { 35 | // } 36 | //} 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Models/ElementDefinitionComparer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.Model; 7 | using Microsoft.Health.Fhir.CodeGen.FhirExtensions; 8 | 9 | namespace Microsoft.Health.Fhir.CodeGen.Models; 10 | 11 | public class ElementDefinitionComparer : IComparer 12 | { 13 | public static readonly ElementDefinitionComparer Instance = new(); 14 | 15 | public int Compare(ElementDefinition? x, ElementDefinition? y) 16 | { 17 | if (x == null && y == null) 18 | { 19 | return 0; 20 | } 21 | 22 | if (x == null) 23 | { 24 | return -1; 25 | } 26 | 27 | if (y == null) 28 | { 29 | return 1; 30 | } 31 | 32 | if (x.Path == y.Path) 33 | { 34 | return 0; 35 | } 36 | 37 | if (x.Path == null) 38 | { 39 | return -1; 40 | } 41 | 42 | if (y.Path == null) 43 | { 44 | return 1; 45 | } 46 | 47 | // if the paths are different, first compare the root dot component 48 | string xRoot = x.Path.Split('.')[0]; 49 | string yRoot = y.Path.Split('.')[0]; 50 | 51 | int rootCompare = string.Compare(xRoot, yRoot); 52 | if (rootCompare != 0) 53 | { 54 | return rootCompare; 55 | } 56 | 57 | // if we are in the same root, we need to compare field orders 58 | int xOrder = x.cgFieldOrder(); 59 | int yOrder = y.cgFieldOrder(); 60 | 61 | return xOrder.CompareTo(yOrder); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Models/FhirQueryParameter.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.Model; 7 | 8 | namespace Microsoft.Health.Fhir.CodeGen.Models; 9 | 10 | public record class FhirQueryParameter 11 | { 12 | /// Gets or initializes the name. 13 | public required string Name { get; init; } 14 | 15 | /// Gets or initializes URL of the document. 16 | public required string Url { get; init; } 17 | 18 | /// Gets or initializes the description. 19 | public required string Description { get; init; } 20 | 21 | /// Gets or initializes the type of the parameter. 22 | public required SearchParamType ParamType { get; init; } 23 | 24 | /// Gets or initializes the allowed values. 25 | public IEnumerable AllowedValues { get; init; } = []; 26 | } 27 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Models/SliceDiscriminator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CodeGen.Models; 10 | 11 | /// A slice discriminator. 12 | public record class SliceDiscriminator 13 | { 14 | /// Gets or initializes the type. 15 | public required string Type { get; init; } 16 | 17 | /// Gets or initializes the type of the discriminator. 18 | public required Hl7.Fhir.Model.ElementDefinition.DiscriminatorType DiscriminatorType { get; init; } 19 | 20 | /// Gets or initializes the full pathname of the file. 21 | public required string Path { get; init; } 22 | 23 | /// Gets or initializes the full pathname of the post resolve file. 24 | public required string PostResolvePath { get; init; } 25 | 26 | /// Gets or initializes the identifier. 27 | public required string Id { get; init; } 28 | 29 | /// Gets or initializes the value. 30 | public required DataType Value { get; init; } 31 | 32 | /// Gets or initializes a value indicating whether this object is binding. 33 | public bool IsBinding { get; init; } = false; 34 | 35 | /// Gets or initializes the name of the binding. 36 | public string BindingName { get; init; } = string.Empty; 37 | } 38 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/Models/StructureElementCollection.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | 7 | namespace Microsoft.Health.Fhir.CodeGen.Models; 8 | 9 | /// A container for a structure and some subset of elements from it. 10 | public class StructureElementCollection 11 | { 12 | /// Gets or initializes the structure. 13 | public required Hl7.Fhir.Model.StructureDefinition Structure { get; init; } 14 | 15 | /// Gets or initializes the elements. 16 | public required List Elements { get; init; } 17 | } 18 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/_ForPackages/DiskPackageCache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics.CodeAnalysis; 4 | using System.Text; 5 | using Firely.Fhir.Packages; 6 | using Newtonsoft.Json; 7 | 8 | namespace Microsoft.Health.Fhir.CodeGen._ForPackages; 9 | 10 | public class DiskPackageCache : Firely.Fhir.Packages.DiskPackageCache 11 | { 12 | public DiskPackageCache(string? rootDirectory = null) 13 | : base(rootDirectory) 14 | { 15 | } 16 | 17 | private static readonly JsonSerializerSettings SETTINGS = new() 18 | { 19 | MissingMemberHandling = MissingMemberHandling.Ignore, 20 | //Converters = new List { new AuthorJsonConverter(), new ManifestDateJsonConverter() } 21 | }; 22 | 23 | public Task ReadManifestEx(Firely.Fhir.Packages.PackageReference reference) 24 | { 25 | string folder = PackageContentFolder(reference); 26 | 27 | if (!Directory.Exists(folder)) 28 | { 29 | return Task.FromResult(null); 30 | } 31 | 32 | string path = Path.Combine(folder, Firely.Fhir.Packages.PackageFileNames.MANIFEST); 33 | if (!File.Exists(path)) 34 | { 35 | return Task.FromResult(null); 36 | } 37 | 38 | string json = File.ReadAllText(path); 39 | PackageManifest? manifest = JsonConvert.DeserializeObject(json, SETTINGS); 40 | 41 | return Task.FromResult(manifest); 42 | } 43 | 44 | 45 | /// 46 | /// Deletes a package from the disk package cache. 47 | /// 48 | /// The package reference. 49 | #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously 50 | public async Task Delete(PackageReference reference) 51 | #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously 52 | { 53 | var target = PackageContentFolder(reference); 54 | if (!Directory.Exists(target)) 55 | { 56 | return; 57 | } 58 | 59 | // delete the directory recursively 60 | Directory.Delete(target, true); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/_ForPackages/ManifestDateJsonConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Text; 5 | using Newtonsoft.Json; 6 | 7 | namespace Microsoft.Health.Fhir.CodeGen._ForPackages 8 | { 9 | internal class ManifestDateJsonConverter : JsonConverter 10 | { 11 | public override bool CanConvert(Type objectType) 12 | { 13 | return (objectType == typeof(DateTimeOffset)) || 14 | (objectType == typeof(string)); 15 | } 16 | 17 | public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) 18 | { 19 | string? dateString = reader.Value?.ToString(); 20 | 21 | if (string.IsNullOrEmpty(dateString)) 22 | { 23 | return null; 24 | } 25 | 26 | if (DateTimeOffset.TryParseExact( 27 | dateString, 28 | "yyyyMMddHHmmss", 29 | CultureInfo.InvariantCulture.DateTimeFormat, 30 | DateTimeStyles.None, out DateTimeOffset dto)) 31 | { 32 | return dto; 33 | } 34 | 35 | return null; 36 | } 37 | 38 | public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) 39 | { 40 | if (value is DateTimeOffset dto) 41 | { 42 | serializer.Serialize(writer, dto.ToUniversalTime().ToString("yyyyMMddHHmmss")); 43 | } 44 | else if (value != null) 45 | { 46 | serializer.Serialize(writer, value); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGen/_ForPackages/VersionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Text.RegularExpressions; 5 | 6 | #if NETSTANDARD2_0 7 | using Microsoft.Health.Fhir.CodeGenCommon.Polyfill; 8 | #endif 9 | 10 | namespace Microsoft.Health.Fhir.CodeGen._ForPackages 11 | { 12 | internal static class VersionExtensions 13 | { 14 | /// 15 | /// Gets the regular expression for matching known core package names. 16 | /// 17 | /// A regular expression. 18 | private static readonly Regex _matchCorePackageOnly = new Regex("^hl7\\.fhir\\.(r\\d+[A-Za-z]?)\\.core$", RegexOptions.Compiled); 19 | 20 | /// 21 | /// Retrieves the FHIR versions from a dictionary of package ids and versions. 22 | /// 23 | /// The dictionary of package ids and versions. 24 | /// A list of FHIR version numbers if provided (e.g., 4.0.1), R-literals if not (e.g., R4). 25 | public static List FhirVersionsFromPackages(Dictionary? packages) 26 | { 27 | List fhirVersions = new(); 28 | 29 | if (packages == null) 30 | { 31 | return fhirVersions; 32 | } 33 | 34 | foreach ((string packageId, string? version) in packages) 35 | { 36 | Match match = _matchCorePackageOnly.Match(packageId); 37 | if (!match.Success) 38 | { 39 | continue; 40 | } 41 | 42 | if (string.IsNullOrEmpty(version)) 43 | { 44 | fhirVersions.Add(match.Groups[0].Value.ToUpperInvariant()); 45 | } 46 | else 47 | { 48 | fhirVersions.Add(version!); 49 | } 50 | } 51 | 52 | return fhirVersions; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGenCommon/Extensions/FhirLiteralAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | namespace Microsoft.Health.Fhir.CodeGenCommon.Extensions; 7 | 8 | /// Attribute for FHIR enum values to link strings and .Net equivalents. 9 | [AttributeUsage(AttributeTargets.Field)] 10 | public class FhirLiteralAttribute : Attribute 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | /// The FHIR literal. 16 | public FhirLiteralAttribute(string fhirLiteral) 17 | { 18 | FhirLiteral = fhirLiteral; 19 | } 20 | 21 | /// Gets or sets the FHIR literal. 22 | public string FhirLiteral { get; protected set; } 23 | } 24 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGenCommon/Microsoft.Health.Fhir.CodeGenCommon.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | netstandard2.0;net8.0 6 | 7 | 8 | 9 | 10 | all 11 | runtime; build; native; contentfiles; analyzers; buildtransitive 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CodeGenCommon/Packaging/PackageCacheRecord.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using static Microsoft.Health.Fhir.CodeGenCommon.Packaging.FhirReleases; 7 | 8 | namespace Microsoft.Health.Fhir.CodeGenCommon.Packaging; 9 | 10 | /// A package cache entry. 11 | /// The FHIR version this package is for. 12 | /// Pathname of the directory where the package can be found. 13 | /// The resolved directive in '[name]#[version or literal]' style. 14 | /// Name of the resolved package. 15 | /// The the resolved version (version string, not literal such as 'latest'). 16 | public record class PackageCacheEntry 17 | { 18 | public required FhirSequenceCodes FhirVersion { get; init; } 19 | public required string Directory { get; init; } 20 | public required string ResolvedDirective { get; init; } 21 | public required string Name { get; init; } 22 | public required string Version { get; init; } 23 | 24 | public PackageCacheEntry[] ResolvedDependencies = []; 25 | } 26 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Age_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Age_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Age_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Age Extract(ISourceNode node) 20 | { 21 | Age v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Age current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Annotation_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Annotation_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Annotation_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Annotation Extract(ISourceNode node) 20 | { 21 | Annotation v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Annotation current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "authorReference": 35 | current.Author = new ResourceReference(node.Text); 36 | break; 37 | 38 | case "authorString": 39 | current.Author = new FhirString(node.Text); 40 | break; 41 | 42 | case "_authorString": 43 | _converter._element.Process(node, current.Author); 44 | break; 45 | 46 | case "time": 47 | current.TimeElement = new FhirDateTime(node.Text); 48 | break; 49 | 50 | case "_time": 51 | _converter._element.Process(node, current.TimeElement); 52 | break; 53 | 54 | case "text": 55 | current.TextElement = new Markdown(node.Text); 56 | break; 57 | 58 | // process inherited elements 59 | default: 60 | _converter._element.Process(node, current); 61 | break; 62 | 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/BackboneElement_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class BackboneElement_20_50 : ICrossVersionProcessor 12 | { 13 | private Converter_20_50 _converter; 14 | internal BackboneElement_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public void Process(ISourceNode node, BackboneElement current) 20 | { 21 | switch (node.Name) 22 | { 23 | case "modifierExtension": 24 | current.ModifierExtension.Add(_converter._extension.Extract(node)); 25 | break; 26 | 27 | // process inherited elements 28 | default: 29 | _converter._element.Process(node, current); 30 | break; 31 | 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/CodeableConcept_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class CodeableConcept_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal CodeableConcept_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public CodeableConcept Extract(ISourceNode node) 20 | { 21 | CodeableConcept v = []; 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, CodeableConcept current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "coding": 35 | current.Coding.Add(_converter._coding.Extract(node)); 36 | break; 37 | 38 | case "text": 39 | current.TextElement = new FhirString(node.Text); 40 | break; 41 | 42 | case "_text": 43 | _converter._element.Process(node, current.TextElement); 44 | break; 45 | 46 | // process inherited elements 47 | default: 48 | _converter._element.Process(node, current); 49 | break; 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Coding_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Coding_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Coding_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Coding Extract(ISourceNode node) 20 | { 21 | Coding v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Coding current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "system": 35 | current.SystemElement = new FhirUri(node.Text); 36 | break; 37 | 38 | case "_system": 39 | _converter._element.Process(node, current.SystemElement); 40 | break; 41 | 42 | case "version": 43 | current.VersionElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_version": 47 | _converter._element.Process(node, current.VersionElement); 48 | break; 49 | 50 | case "code": 51 | current.CodeElement = new Code(node.Text); 52 | break; 53 | 54 | case "_code": 55 | _converter._element.Process(node, current.CodeElement); 56 | break; 57 | 58 | case "display": 59 | current.DisplayElement = new FhirString(node.Text); 60 | break; 61 | 62 | case "_display": 63 | _converter._element.Process(node, current.DisplayElement); 64 | break; 65 | 66 | case "userSelected": 67 | current.UserSelectedElement = new FhirBoolean(_converter._primitive.GetBoolOpt(node)); 68 | break; 69 | 70 | case "_userSelected": 71 | _converter._element.Process(node, current.UserSelectedElement); 72 | break; 73 | 74 | // process inherited elements 75 | default: 76 | _converter._element.Process(node, current); 77 | break; 78 | 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/ContactDetail_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class ContactDetail_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal ContactDetail_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public ContactDetail Extract(ISourceNode node) 20 | { 21 | ContactDetail v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, ContactDetail current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "name": 35 | current.NameElement = new FhirString(node.Text); 36 | break; 37 | 38 | case "_name": 39 | _converter._element.Process(node, current.NameElement); 40 | break; 41 | 42 | case "telecom": 43 | current.Telecom.Add(_converter._contactPoint.Extract(node)); 44 | break; 45 | 46 | // process inherited elements 47 | default: 48 | _converter._element.Process(node, current); 49 | break; 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/ContactPoint_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class ContactPoint_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal ContactPoint_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public ContactPoint Extract(ISourceNode node) 20 | { 21 | ContactPoint v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, ContactPoint current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "system": 35 | current.System = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_system": 39 | _converter._element.Process(node, current.SystemElement); 40 | break; 41 | 42 | case "value": 43 | current.ValueElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_value": 47 | _converter._element.Process(node, current.ValueElement); 48 | break; 49 | 50 | case "use": 51 | current.Use = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 52 | break; 53 | 54 | case "_use": 55 | _converter._element.Process(node, current.UseElement); 56 | break; 57 | 58 | case "rank": 59 | current.RankElement = new PositiveInt(_converter._primitive.GetIntOpt(node)); 60 | break; 61 | 62 | case "_rank": 63 | _converter._element.Process(node, current.RankElement); 64 | break; 65 | 66 | case "period": 67 | current.Period = _converter._period.Extract(node); 68 | break; 69 | 70 | // process inherited elements 71 | default: 72 | _converter._element.Process(node, current); 73 | break; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Contributor_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Contributor_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Contributor_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Contributor Extract(ISourceNode node) 20 | { 21 | Contributor v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Contributor current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "type": 35 | current.Type = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_type": 39 | _converter._element.Process(node, current.TypeElement); 40 | break; 41 | 42 | case "name": 43 | current.NameElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_name": 47 | _converter._element.Process(node, current.NameElement); 48 | break; 49 | 50 | case "contact": 51 | current.Contact.Add(_converter._contactDetail.Extract(node)); 52 | break; 53 | 54 | // process inherited elements 55 | default: 56 | _converter._element.Process(node, current); 57 | break; 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Count_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Count_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Count_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Count Extract(ISourceNode node) 20 | { 21 | Count v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Count current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Distance_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Distance_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Distance_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Distance Extract(ISourceNode node) 20 | { 21 | Distance v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Distance current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/DomainResource_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class DomainResource_20_50 : ICrossVersionProcessor 12 | { 13 | private Converter_20_50 _converter; 14 | internal DomainResource_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public void Process(ISourceNode node, DomainResource current) 20 | { 21 | switch (node.Name) 22 | { 23 | case "text": 24 | current.Text = _converter._narrative.Extract(node); 25 | break; 26 | 27 | case "contained": 28 | current.Contained.Add(_converter._resource.Extract(node)); 29 | break; 30 | 31 | case "extension": 32 | current.Extension.Add(_converter._extension.Extract(node)); 33 | break; 34 | 35 | case "modifierExtension": 36 | current.ModifierExtension.Add(_converter._extension.Extract(node)); 37 | break; 38 | 39 | // process inherited elements 40 | default: 41 | _converter._resource.Process(node, current); 42 | break; 43 | 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Duration_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Duration_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Duration_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Duration Extract(ISourceNode node) 20 | { 21 | Duration v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Duration current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Element_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Element_20_50 : ICrossVersionProcessor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Element_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public void Process(ISourceNode node, Element? current) 20 | { 21 | if (current == null) 22 | { 23 | return; 24 | } 25 | 26 | switch (node.Name) 27 | { 28 | case "id": 29 | current.ElementId = node.Text; 30 | break; 31 | 32 | case "extension": 33 | current.Extension.Add(_converter._extension.Extract(node)); 34 | break; 35 | 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/HumanName_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class HumanName_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal HumanName_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public HumanName Extract(ISourceNode node) 20 | { 21 | HumanName v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, HumanName current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "use": 35 | current.Use = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_use": 39 | _converter._element.Process(node, current.UseElement); 40 | break; 41 | 42 | case "text": 43 | current.TextElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_text": 47 | _converter._element.Process(node, current.TextElement); 48 | break; 49 | 50 | case "family": 51 | current.FamilyElement = new FhirString(node.Text); 52 | break; 53 | 54 | case "_family": 55 | _converter._element.Process(node, current.FamilyElement); 56 | break; 57 | 58 | case "given": 59 | current.GivenElement.Add(new FhirString(node.Text)); 60 | break; 61 | 62 | case "prefix": 63 | current.PrefixElement.Add(new FhirString(node.Text)); 64 | break; 65 | 66 | case "suffix": 67 | current.SuffixElement.Add(new FhirString(node.Text)); 68 | break; 69 | 70 | case "period": 71 | current.Period = _converter._period.Extract(node); 72 | break; 73 | 74 | // process inherited elements 75 | default: 76 | _converter._element.Process(node, current); 77 | break; 78 | 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Identifier_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Identifier_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Identifier_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Identifier Extract(ISourceNode node) 20 | { 21 | Identifier v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Identifier current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "use": 35 | current.Use = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_use": 39 | _converter._element.Process(node, current.UseElement); 40 | break; 41 | 42 | case "type": 43 | current.Type = _converter._codeableConcept.Extract(node); 44 | break; 45 | 46 | case "system": 47 | current.SystemElement = new FhirUri(node.Text); 48 | break; 49 | 50 | case "_system": 51 | _converter._element.Process(node, current.SystemElement); 52 | break; 53 | 54 | case "value": 55 | current.ValueElement = new FhirString(node.Text); 56 | break; 57 | 58 | case "_value": 59 | _converter._element.Process(node, current.ValueElement); 60 | break; 61 | 62 | case "period": 63 | current.Period = _converter._period.Extract(node); 64 | break; 65 | 66 | case "assigner": 67 | current.Assigner = new ResourceReference(node.Text); 68 | break; 69 | 70 | // process inherited elements 71 | default: 72 | _converter._element.Process(node, current); 73 | break; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Meta_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Meta_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Meta_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Meta Extract(ISourceNode node) 20 | { 21 | Meta v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Meta current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "versionId": 35 | current.VersionIdElement = new Id(node.Text); 36 | break; 37 | 38 | case "_versionId": 39 | _converter._element.Process(node, current.VersionIdElement); 40 | break; 41 | 42 | case "lastUpdated": 43 | current.LastUpdatedElement = new Instant(new FhirDateTime(node.Text).ToDateTimeOffset(TimeSpan.Zero)); 44 | break; 45 | 46 | case "_lastUpdated": 47 | _converter._element.Process(node, current.LastUpdatedElement); 48 | break; 49 | 50 | case "profile": 51 | current.ProfileElement.Add(new FhirUri(node.Text)); 52 | break; 53 | 54 | case "security": 55 | current.Security.Add(_converter._coding.Extract(node)); 56 | break; 57 | 58 | case "tag": 59 | current.Tag.Add(_converter._coding.Extract(node)); 60 | break; 61 | 62 | // process inherited elements 63 | default: 64 | _converter._element.Process(node, current); 65 | break; 66 | 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Money_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Money_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Money_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Money Extract(ISourceNode node) 20 | { 21 | Money v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Money current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._element.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Narrative_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Narrative_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Narrative_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Narrative Extract(ISourceNode node) 20 | { 21 | Narrative v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Narrative current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "status": 35 | current.Status = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_status": 39 | _converter._element.Process(node, current.StatusElement); 40 | break; 41 | 42 | case "div": 43 | current.Div = node.Text; 44 | break; 45 | 46 | // process inherited elements 47 | default: 48 | _converter._element.Process(node, current); 49 | break; 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Period_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Period_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Period_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Period Extract(ISourceNode node) 20 | { 21 | Period v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Period current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "start": 35 | current.StartElement = new FhirDateTime(node.Text); 36 | break; 37 | 38 | case "_start": 39 | _converter._element.Process(node, current.StartElement); 40 | break; 41 | 42 | case "end": 43 | current.EndElement = new FhirDateTime(node.Text); 44 | break; 45 | 46 | case "_end": 47 | _converter._element.Process(node, current.EndElement); 48 | break; 49 | 50 | // process inherited elements 51 | default: 52 | _converter._element.Process(node, current); 53 | break; 54 | 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Range_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Range_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Range_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Hl7.Fhir.Model.Range Extract(ISourceNode node) 20 | { 21 | Hl7.Fhir.Model.Range v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Hl7.Fhir.Model.Range current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "low": 35 | current.Low = _converter._quantity.Extract(node); 36 | break; 37 | 38 | case "high": 39 | current.High = _converter._quantity.Extract(node); 40 | break; 41 | 42 | // process inherited elements 43 | default: 44 | _converter._element.Process(node, current); 45 | break; 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Ratio_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Ratio_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Ratio_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Ratio Extract(ISourceNode node) 20 | { 21 | Ratio v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Ratio current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "numerator": 35 | current.Numerator = _converter._quantity.Extract(node); 36 | break; 37 | 38 | case "denominator": 39 | current.Denominator = _converter._quantity.Extract(node); 40 | break; 41 | 42 | // process inherited elements 43 | default: 44 | _converter._element.Process(node, current); 45 | break; 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Reference_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Reference_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Reference_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public ResourceReference Extract(ISourceNode node) 20 | { 21 | ResourceReference v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, ResourceReference current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "reference": 35 | current.ReferenceElement = new FhirString(node.Text); 36 | break; 37 | 38 | case "_reference": 39 | _converter._element.Process(node, current.ReferenceElement); 40 | break; 41 | 42 | case "identifier": 43 | current.Identifier = _converter._identifier.Extract(node); 44 | break; 45 | 46 | case "display": 47 | current.DisplayElement = new FhirString(node.Text); 48 | break; 49 | 50 | case "_display": 51 | _converter._element.Process(node, current.DisplayElement); 52 | break; 53 | 54 | // process inherited elements 55 | default: 56 | _converter._element.Process(node, current); 57 | break; 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/RelatedArtifact_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class RelatedArtifact_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal RelatedArtifact_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public RelatedArtifact Extract(ISourceNode node) 20 | { 21 | RelatedArtifact v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, RelatedArtifact current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "type": 35 | current.Type = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_type": 39 | _converter._element.Process(node, current.TypeElement); 40 | break; 41 | 42 | case "display": 43 | current.DisplayElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_display": 47 | _converter._element.Process(node, current.DisplayElement); 48 | break; 49 | 50 | case "citation": 51 | current.CitationElement = new Markdown(node.Text); 52 | break; 53 | 54 | case "url": 55 | // element RelatedArtifact.url has been removed in the target spec 56 | break; 57 | 58 | case "document": 59 | current.Document = _converter._attachment.Extract(node); 60 | break; 61 | 62 | case "resource": 63 | current.ResourceElement = new Canonical(node.Text); 64 | break; 65 | 66 | // process inherited elements 67 | default: 68 | _converter._element.Process(node, current); 69 | break; 70 | 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/Signature_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class Signature_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal Signature_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Signature Extract(ISourceNode node) 20 | { 21 | Signature v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Signature current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "type": 35 | current.Type.Add(_converter._coding.Extract(node)); 36 | break; 37 | 38 | case "when": 39 | current.WhenElement = new Instant(new FhirDateTime(node.Text).ToDateTimeOffset(TimeSpan.Zero)); 40 | break; 41 | 42 | case "_when": 43 | _converter._element.Process(node, current.WhenElement); 44 | break; 45 | 46 | case "whoUri": 47 | // element Signature.who[x] has been removed in the target spec 48 | break; 49 | 50 | case "whoReference": 51 | // element Signature.who[x] has been removed in the target spec 52 | break; 53 | 54 | case "onBehalfOfUri": 55 | // element Signature.onBehalfOf[x] has been removed in the target spec 56 | break; 57 | 58 | case "onBehalfOfReference": 59 | // element Signature.onBehalfOf[x] has been removed in the target spec 60 | break; 61 | 62 | case "contentType": 63 | // element Signature.contentType has been removed in the target spec 64 | break; 65 | 66 | case "blob": 67 | // element Signature.blob has been removed in the target spec 68 | break; 69 | 70 | // process inherited elements 71 | default: 72 | _converter._element.Process(node, current); 73 | break; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_20_50/UsageContext_20_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_20_50; 10 | 11 | public class UsageContext_20_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_20_50 _converter; 14 | internal UsageContext_20_50(Converter_20_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public UsageContext Extract(ISourceNode node) 20 | { 21 | UsageContext v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, UsageContext current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "code": 35 | current.Code = _converter._coding.Extract(node); 36 | break; 37 | 38 | case "valueCodeableConcept": 39 | current.Value = _converter._codeableConcept.Extract(node); 40 | break; 41 | 42 | case "valueQuantity": 43 | current.Value = _converter._quantity.Extract(node); 44 | break; 45 | 46 | case "valueRange": 47 | current.Value = _converter._range.Extract(node); 48 | break; 49 | 50 | // process inherited elements 51 | default: 52 | _converter._element.Process(node, current); 53 | break; 54 | 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Age_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Age_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Age_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Age Extract(ISourceNode node) 20 | { 21 | Age v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Age current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Annotation_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Annotation_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Annotation_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Annotation Extract(ISourceNode node) 20 | { 21 | Annotation v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Annotation current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "authorReference": 35 | current.Author = new ResourceReference(node.Text); 36 | break; 37 | 38 | case "authorString": 39 | current.Author = new FhirString(node.Text); 40 | break; 41 | 42 | case "_authorString": 43 | _converter._element.Process(node, current.Author); 44 | break; 45 | 46 | case "time": 47 | current.TimeElement = new FhirDateTime(node.Text); 48 | break; 49 | 50 | case "_time": 51 | _converter._element.Process(node, current.TimeElement); 52 | break; 53 | 54 | case "text": 55 | current.TextElement = new Markdown(node.Text); 56 | break; 57 | 58 | case "_text": 59 | _converter._element.Process(node, current.TextElement); 60 | break; 61 | 62 | // process inherited elements 63 | default: 64 | _converter._element.Process(node, current); 65 | break; 66 | 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/BackboneElement_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class BackboneElement_30_50 : ICrossVersionProcessor 12 | { 13 | private Converter_30_50 _converter; 14 | internal BackboneElement_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public void Process(ISourceNode node, BackboneElement current) 20 | { 21 | switch (node.Name) 22 | { 23 | case "modifierExtension": 24 | current.ModifierExtension.Add(_converter._extension.Extract(node)); 25 | break; 26 | 27 | // process inherited elements 28 | default: 29 | _converter._element.Process(node, current); 30 | break; 31 | 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/CodeableConcept_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class CodeableConcept_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal CodeableConcept_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public CodeableConcept Extract(ISourceNode node) 20 | { 21 | CodeableConcept v = []; 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, CodeableConcept current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "coding": 35 | current.Coding.Add(_converter._coding.Extract(node)); 36 | break; 37 | 38 | case "text": 39 | current.TextElement = new FhirString(node.Text); 40 | break; 41 | 42 | case "_text": 43 | _converter._element.Process(node, current.TextElement); 44 | break; 45 | 46 | // process inherited elements 47 | default: 48 | _converter._element.Process(node, current); 49 | break; 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Coding_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Coding_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Coding_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Coding Extract(ISourceNode node) 20 | { 21 | Coding v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Coding current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "system": 35 | current.SystemElement = new FhirUri(node.Text); 36 | break; 37 | 38 | case "_system": 39 | _converter._element.Process(node, current.SystemElement); 40 | break; 41 | 42 | case "version": 43 | current.VersionElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_version": 47 | _converter._element.Process(node, current.VersionElement); 48 | break; 49 | 50 | case "code": 51 | current.CodeElement = new Code(node.Text); 52 | break; 53 | 54 | case "_code": 55 | _converter._element.Process(node, current.CodeElement); 56 | break; 57 | 58 | case "display": 59 | current.DisplayElement = new FhirString(node.Text); 60 | break; 61 | 62 | case "_display": 63 | _converter._element.Process(node, current.DisplayElement); 64 | break; 65 | 66 | case "userSelected": 67 | current.UserSelectedElement = new FhirBoolean(_converter._primitive.GetBoolOpt(node)); 68 | break; 69 | 70 | case "_userSelected": 71 | _converter._element.Process(node, current.UserSelectedElement); 72 | break; 73 | 74 | // process inherited elements 75 | default: 76 | _converter._element.Process(node, current); 77 | break; 78 | 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/ContactDetail_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class ContactDetail_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal ContactDetail_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public ContactDetail Extract(ISourceNode node) 20 | { 21 | ContactDetail v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, ContactDetail current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "name": 35 | current.NameElement = new FhirString(node.Text); 36 | break; 37 | 38 | case "_name": 39 | _converter._element.Process(node, current.NameElement); 40 | break; 41 | 42 | case "telecom": 43 | current.Telecom.Add(_converter._contactPoint.Extract(node)); 44 | break; 45 | 46 | // process inherited elements 47 | default: 48 | _converter._element.Process(node, current); 49 | break; 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/ContactPoint_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class ContactPoint_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal ContactPoint_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public ContactPoint Extract(ISourceNode node) 20 | { 21 | ContactPoint v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, ContactPoint current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "system": 35 | current.System = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_system": 39 | _converter._element.Process(node, current.SystemElement); 40 | break; 41 | 42 | case "value": 43 | current.ValueElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_value": 47 | _converter._element.Process(node, current.ValueElement); 48 | break; 49 | 50 | case "use": 51 | current.Use = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 52 | break; 53 | 54 | case "_use": 55 | _converter._element.Process(node, current.UseElement); 56 | break; 57 | 58 | case "rank": 59 | current.RankElement = new PositiveInt(_converter._primitive.GetIntOpt(node)); 60 | break; 61 | 62 | case "_rank": 63 | _converter._element.Process(node, current.RankElement); 64 | break; 65 | 66 | case "period": 67 | current.Period = _converter._period.Extract(node); 68 | break; 69 | 70 | // process inherited elements 71 | default: 72 | _converter._element.Process(node, current); 73 | break; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Contributor_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Contributor_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Contributor_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Contributor Extract(ISourceNode node) 20 | { 21 | Contributor v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Contributor current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "type": 35 | current.Type = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_type": 39 | _converter._element.Process(node, current.TypeElement); 40 | break; 41 | 42 | case "name": 43 | current.NameElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_name": 47 | _converter._element.Process(node, current.NameElement); 48 | break; 49 | 50 | case "contact": 51 | current.Contact.Add(_converter._contactDetail.Extract(node)); 52 | break; 53 | 54 | // process inherited elements 55 | default: 56 | _converter._element.Process(node, current); 57 | break; 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Count_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Count_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Count_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Count Extract(ISourceNode node) 20 | { 21 | Count v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Count current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Distance_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Distance_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Distance_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Distance Extract(ISourceNode node) 20 | { 21 | Distance v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Distance current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/DomainResource_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class DomainResource_30_50 : ICrossVersionProcessor 12 | { 13 | private Converter_30_50 _converter; 14 | internal DomainResource_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public void Process(ISourceNode node, DomainResource current) 20 | { 21 | switch (node.Name) 22 | { 23 | case "text": 24 | current.Text = _converter._narrative.Extract(node); 25 | break; 26 | 27 | case "contained": 28 | current.Contained.Add(_converter._resource.Extract(node)); 29 | break; 30 | 31 | case "extension": 32 | current.Extension.Add(_converter._extension.Extract(node)); 33 | break; 34 | 35 | case "modifierExtension": 36 | current.ModifierExtension.Add(_converter._extension.Extract(node)); 37 | break; 38 | 39 | // process inherited elements 40 | default: 41 | _converter._resource.Process(node, current); 42 | break; 43 | 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Duration_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Duration_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Duration_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Duration Extract(ISourceNode node) 20 | { 21 | Duration v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Duration current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Element_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Element_30_50 : ICrossVersionProcessor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Element_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public void Process(ISourceNode node, Element? current) 20 | { 21 | if (current == null) 22 | { 23 | return; 24 | } 25 | 26 | switch (node.Name) 27 | { 28 | case "id": 29 | current.ElementId =node.Text; 30 | break; 31 | 32 | case "extension": 33 | current.Extension.Add(_converter._extension.Extract(node)); 34 | break; 35 | 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/HumanName_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class HumanName_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal HumanName_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public HumanName Extract(ISourceNode node) 20 | { 21 | HumanName v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, HumanName current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "use": 35 | current.Use = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_use": 39 | _converter._element.Process(node, current.UseElement); 40 | break; 41 | 42 | case "text": 43 | current.TextElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_text": 47 | _converter._element.Process(node, current.TextElement); 48 | break; 49 | 50 | case "family": 51 | current.FamilyElement = new FhirString(node.Text); 52 | break; 53 | 54 | case "_family": 55 | _converter._element.Process(node, current.FamilyElement); 56 | break; 57 | 58 | case "given": 59 | current.GivenElement.Add(new FhirString(node.Text)); 60 | break; 61 | 62 | case "prefix": 63 | current.PrefixElement.Add(new FhirString(node.Text)); 64 | break; 65 | 66 | case "suffix": 67 | current.SuffixElement.Add(new FhirString(node.Text)); 68 | break; 69 | 70 | case "period": 71 | current.Period = _converter._period.Extract(node); 72 | break; 73 | 74 | // process inherited elements 75 | default: 76 | _converter._element.Process(node, current); 77 | break; 78 | 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Identifier_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Identifier_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Identifier_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Identifier Extract(ISourceNode node) 20 | { 21 | Identifier v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Identifier current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "use": 35 | current.Use = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_use": 39 | _converter._element.Process(node, current.UseElement); 40 | break; 41 | 42 | case "type": 43 | current.Type = _converter._codeableConcept.Extract(node); 44 | break; 45 | 46 | case "system": 47 | current.SystemElement = new FhirUri(node.Text); 48 | break; 49 | 50 | case "_system": 51 | _converter._element.Process(node, current.SystemElement); 52 | break; 53 | 54 | case "value": 55 | current.ValueElement = new FhirString(node.Text); 56 | break; 57 | 58 | case "_value": 59 | _converter._element.Process(node, current.ValueElement); 60 | break; 61 | 62 | case "period": 63 | current.Period = _converter._period.Extract(node); 64 | break; 65 | 66 | case "assigner": 67 | current.Assigner = new ResourceReference(node.Text); 68 | break; 69 | 70 | // process inherited elements 71 | default: 72 | _converter._element.Process(node, current); 73 | break; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Meta_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Meta_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Meta_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Meta Extract(ISourceNode node) 20 | { 21 | Meta v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Meta current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "versionId": 35 | current.VersionIdElement = new Id(node.Text); 36 | break; 37 | 38 | case "_versionId": 39 | _converter._element.Process(node, current.VersionIdElement); 40 | break; 41 | 42 | case "lastUpdated": 43 | current.LastUpdatedElement = new Instant(new FhirDateTime(node.Text).ToDateTimeOffset(TimeSpan.Zero)); 44 | break; 45 | 46 | case "_lastUpdated": 47 | _converter._element.Process(node, current.LastUpdatedElement); 48 | break; 49 | 50 | case "profile": 51 | current.ProfileElement.Add(new FhirUri(node.Text)); 52 | break; 53 | 54 | case "security": 55 | current.Security.Add(_converter._coding.Extract(node)); 56 | break; 57 | 58 | case "tag": 59 | current.Tag.Add(_converter._coding.Extract(node)); 60 | break; 61 | 62 | // process inherited elements 63 | default: 64 | _converter._element.Process(node, current); 65 | break; 66 | 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Money_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Money_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Money_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Money Extract(ISourceNode node) 20 | { 21 | Money v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Money current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._element.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Narrative_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Narrative_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Narrative_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Narrative Extract(ISourceNode node) 20 | { 21 | Narrative v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Narrative current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "status": 35 | current.Status = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_status": 39 | _converter._element.Process(node, current.StatusElement); 40 | break; 41 | 42 | case "div": 43 | current.Div = node.Text; 44 | break; 45 | 46 | // process inherited elements 47 | default: 48 | _converter._element.Process(node, current); 49 | break; 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Period_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Period_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Period_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Period Extract(ISourceNode node) 20 | { 21 | Period v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Period current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "start": 35 | current.StartElement = new FhirDateTime(node.Text); 36 | break; 37 | 38 | case "_start": 39 | _converter._element.Process(node, current.StartElement); 40 | break; 41 | 42 | case "end": 43 | current.EndElement = new FhirDateTime(node.Text); 44 | break; 45 | 46 | case "_end": 47 | _converter._element.Process(node, current.EndElement); 48 | break; 49 | 50 | // process inherited elements 51 | default: 52 | _converter._element.Process(node, current); 53 | break; 54 | 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Range_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Range_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Range_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Hl7.Fhir.Model.Range Extract(ISourceNode node) 20 | { 21 | Hl7.Fhir.Model.Range v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Hl7.Fhir.Model.Range current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "low": 35 | current.Low = _converter._quantity.Extract(node); 36 | break; 37 | 38 | case "high": 39 | current.High = _converter._quantity.Extract(node); 40 | break; 41 | 42 | // process inherited elements 43 | default: 44 | _converter._element.Process(node, current); 45 | break; 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Ratio_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Ratio_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Ratio_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Ratio Extract(ISourceNode node) 20 | { 21 | Ratio v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Ratio current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "numerator": 35 | current.Numerator = _converter._quantity.Extract(node); 36 | break; 37 | 38 | case "denominator": 39 | current.Denominator = _converter._quantity.Extract(node); 40 | break; 41 | 42 | // process inherited elements 43 | default: 44 | _converter._element.Process(node, current); 45 | break; 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Reference_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Reference_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Reference_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public ResourceReference Extract(ISourceNode node) 20 | { 21 | ResourceReference v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, ResourceReference current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "reference": 35 | current.ReferenceElement = new FhirString(node.Text); 36 | break; 37 | 38 | case "_reference": 39 | _converter._element.Process(node, current.ReferenceElement); 40 | break; 41 | 42 | case "identifier": 43 | current.Identifier = _converter._identifier.Extract(node); 44 | break; 45 | 46 | case "display": 47 | current.DisplayElement = new FhirString(node.Text); 48 | break; 49 | 50 | case "_display": 51 | _converter._element.Process(node, current.DisplayElement); 52 | break; 53 | 54 | // process inherited elements 55 | default: 56 | _converter._element.Process(node, current); 57 | break; 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/RelatedArtifact_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class RelatedArtifact_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal RelatedArtifact_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public RelatedArtifact Extract(ISourceNode node) 20 | { 21 | RelatedArtifact v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, RelatedArtifact current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "type": 35 | current.Type = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_type": 39 | _converter._element.Process(node, current.TypeElement); 40 | break; 41 | 42 | case "display": 43 | current.DisplayElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_display": 47 | _converter._element.Process(node, current.DisplayElement); 48 | break; 49 | 50 | case "citation": 51 | current.CitationElement = new Markdown(node.Text); 52 | break; 53 | 54 | case "_citation": 55 | _converter._element.Process(node, current.CitationElement); 56 | break; 57 | 58 | case "url": 59 | // element RelatedArtifact.url has been removed in the target spec 60 | break; 61 | 62 | case "document": 63 | current.Document = _converter._attachment.Extract(node); 64 | break; 65 | 66 | case "resource": 67 | current.ResourceElement = new Canonical(node.Text); 68 | break; 69 | 70 | // process inherited elements 71 | default: 72 | _converter._element.Process(node, current); 73 | break; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/Signature_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class Signature_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal Signature_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Signature Extract(ISourceNode node) 20 | { 21 | Signature v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Signature current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "type": 35 | current.Type.Add(_converter._coding.Extract(node)); 36 | break; 37 | 38 | case "when": 39 | current.WhenElement = new Instant(new FhirDateTime(node.Text).ToDateTimeOffset(TimeSpan.Zero)); 40 | break; 41 | 42 | case "_when": 43 | _converter._element.Process(node, current.WhenElement); 44 | break; 45 | 46 | case "whoUri": 47 | // element Signature.who[x] has been removed in the target spec 48 | break; 49 | 50 | case "whoReference": 51 | // element Signature.who[x] has been removed in the target spec 52 | break; 53 | 54 | case "onBehalfOfUri": 55 | // element Signature.onBehalfOf[x] has been removed in the target spec 56 | break; 57 | 58 | case "onBehalfOfReference": 59 | // element Signature.onBehalfOf[x] has been removed in the target spec 60 | break; 61 | 62 | case "contentType": 63 | // element Signature.contentType has been removed in the target spec 64 | break; 65 | 66 | case "blob": 67 | // element Signature.blob has been removed in the target spec 68 | break; 69 | 70 | // process inherited elements 71 | default: 72 | _converter._element.Process(node, current); 73 | break; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_30_50/UsageContext_30_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_30_50; 10 | 11 | public class UsageContext_30_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_30_50 _converter; 14 | internal UsageContext_30_50(Converter_30_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public UsageContext Extract(ISourceNode node) 20 | { 21 | UsageContext v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, UsageContext current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "code": 35 | current.Code = _converter._coding.Extract(node); 36 | break; 37 | 38 | case "valueCodeableConcept": 39 | current.Value = _converter._codeableConcept.Extract(node); 40 | break; 41 | 42 | case "valueQuantity": 43 | current.Value = _converter._quantity.Extract(node); 44 | break; 45 | 46 | case "valueRange": 47 | current.Value = _converter._range.Extract(node); 48 | break; 49 | 50 | // process inherited elements 51 | default: 52 | _converter._element.Process(node, current); 53 | break; 54 | 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Age_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Age_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Age_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Age Extract(ISourceNode node) 20 | { 21 | Age v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Age current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Annotation_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Annotation_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Annotation_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Annotation Extract(ISourceNode node) 20 | { 21 | Annotation v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Annotation current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "authorReference": 35 | current.Author = new ResourceReference(node.Text); 36 | break; 37 | 38 | case "authorString": 39 | current.Author = new FhirString(node.Text); 40 | break; 41 | 42 | case "_authorString": 43 | _converter._element.Process(node, current.Author); 44 | break; 45 | 46 | case "time": 47 | current.TimeElement = new FhirDateTime(node.Text); 48 | break; 49 | 50 | case "_time": 51 | _converter._element.Process(node, current.TimeElement); 52 | break; 53 | 54 | case "text": 55 | current.TextElement = new Markdown(node.Text); 56 | break; 57 | 58 | case "_text": 59 | _converter._element.Process(node, current.TextElement); 60 | break; 61 | 62 | // process inherited elements 63 | default: 64 | _converter._element.Process(node, current); 65 | break; 66 | 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/BackboneElement_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class BackboneElement_43_50 : ICrossVersionProcessor 12 | { 13 | private Converter_43_50 _converter; 14 | internal BackboneElement_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public void Process(ISourceNode node, BackboneElement current) 20 | { 21 | switch (node.Name) 22 | { 23 | case "modifierExtension": 24 | current.ModifierExtension.Add(_converter._extension.Extract(node)); 25 | break; 26 | 27 | // process inherited elements 28 | default: 29 | _converter._element.Process(node, current); 30 | break; 31 | 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/CodeableConcept_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class CodeableConcept_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal CodeableConcept_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public CodeableConcept Extract(ISourceNode node) 20 | { 21 | CodeableConcept v = []; 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, CodeableConcept current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "coding": 35 | current.Coding.Add(_converter._coding.Extract(node)); 36 | break; 37 | 38 | case "text": 39 | current.TextElement = new FhirString(node.Text); 40 | break; 41 | 42 | case "_text": 43 | _converter._element.Process(node, current.TextElement); 44 | break; 45 | 46 | // process inherited elements 47 | default: 48 | _converter._element.Process(node, current); 49 | break; 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/CodeableReference_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class CodeableReference_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal CodeableReference_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public CodeableReference Extract(ISourceNode node) 20 | { 21 | CodeableReference v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, CodeableReference current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "concept": 35 | current.Concept = _converter._codeableConcept.Extract(node); 36 | break; 37 | 38 | case "reference": 39 | current.Reference = new ResourceReference(node.Text); 40 | break; 41 | 42 | // process inherited elements 43 | default: 44 | _converter._element.Process(node, current); 45 | break; 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Coding_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Coding_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Coding_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Coding Extract(ISourceNode node) 20 | { 21 | Coding v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Coding current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "system": 35 | current.SystemElement = new FhirUri(node.Text); 36 | break; 37 | 38 | case "_system": 39 | _converter._element.Process(node, current.SystemElement); 40 | break; 41 | 42 | case "version": 43 | current.VersionElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_version": 47 | _converter._element.Process(node, current.VersionElement); 48 | break; 49 | 50 | case "code": 51 | current.CodeElement = new Code(node.Text); 52 | break; 53 | 54 | case "_code": 55 | _converter._element.Process(node, current.CodeElement); 56 | break; 57 | 58 | case "display": 59 | current.DisplayElement = new FhirString(node.Text); 60 | break; 61 | 62 | case "_display": 63 | _converter._element.Process(node, current.DisplayElement); 64 | break; 65 | 66 | case "userSelected": 67 | current.UserSelectedElement = new FhirBoolean(_converter._primitive.GetBoolOpt(node)); 68 | break; 69 | 70 | case "_userSelected": 71 | _converter._element.Process(node, current.UserSelectedElement); 72 | break; 73 | 74 | // process inherited elements 75 | default: 76 | _converter._element.Process(node, current); 77 | break; 78 | 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/ContactDetail_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class ContactDetail_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal ContactDetail_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public ContactDetail Extract(ISourceNode node) 20 | { 21 | ContactDetail v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, ContactDetail current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "name": 35 | current.NameElement = new FhirString(node.Text); 36 | break; 37 | 38 | case "_name": 39 | _converter._element.Process(node, current.NameElement); 40 | break; 41 | 42 | case "telecom": 43 | current.Telecom.Add(_converter._contactPoint.Extract(node)); 44 | break; 45 | 46 | // process inherited elements 47 | default: 48 | _converter._element.Process(node, current); 49 | break; 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/ContactPoint_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class ContactPoint_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal ContactPoint_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public ContactPoint Extract(ISourceNode node) 20 | { 21 | ContactPoint v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, ContactPoint current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "system": 35 | current.System = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_system": 39 | _converter._element.Process(node, current.SystemElement); 40 | break; 41 | 42 | case "value": 43 | current.ValueElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_value": 47 | _converter._element.Process(node, current.ValueElement); 48 | break; 49 | 50 | case "use": 51 | current.Use = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 52 | break; 53 | 54 | case "_use": 55 | _converter._element.Process(node, current.UseElement); 56 | break; 57 | 58 | case "rank": 59 | current.RankElement = new PositiveInt(_converter._primitive.GetIntOpt(node)); 60 | break; 61 | 62 | case "_rank": 63 | _converter._element.Process(node, current.RankElement); 64 | break; 65 | 66 | case "period": 67 | current.Period = _converter._period.Extract(node); 68 | break; 69 | 70 | // process inherited elements 71 | default: 72 | _converter._element.Process(node, current); 73 | break; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Contributor_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Contributor_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Contributor_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Contributor Extract(ISourceNode node) 20 | { 21 | Contributor v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Contributor current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "type": 35 | current.Type = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_type": 39 | _converter._element.Process(node, current.TypeElement); 40 | break; 41 | 42 | case "name": 43 | current.NameElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_name": 47 | _converter._element.Process(node, current.NameElement); 48 | break; 49 | 50 | case "contact": 51 | current.Contact.Add(_converter._contactDetail.Extract(node)); 52 | break; 53 | 54 | // process inherited elements 55 | default: 56 | _converter._element.Process(node, current); 57 | break; 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Count_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Count_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Count_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Count Extract(ISourceNode node) 20 | { 21 | Count v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Count current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/DataType_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class DataType_43_50 : ICrossVersionProcessor 12 | { 13 | private Converter_43_50 _converter; 14 | internal DataType_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public void Process(ISourceNode node, DataType current) 20 | { 21 | switch (node.Name) 22 | { 23 | // process inherited elements 24 | default: 25 | _converter._element.Process(node, current); 26 | break; 27 | 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Distance_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Distance_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Distance_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Distance Extract(ISourceNode node) 20 | { 21 | Distance v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Distance current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/DomainResource_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class DomainResource_43_50 : ICrossVersionProcessor 12 | { 13 | private Converter_43_50 _converter; 14 | internal DomainResource_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public void Process(ISourceNode node, DomainResource current) 20 | { 21 | switch (node.Name) 22 | { 23 | case "text": 24 | current.Text = _converter._narrative.Extract(node); 25 | break; 26 | 27 | case "contained": 28 | current.Contained.Add(_converter._resource.Extract(node)); 29 | break; 30 | 31 | case "extension": 32 | current.Extension.Add(_converter._extension.Extract(node)); 33 | break; 34 | 35 | case "modifierExtension": 36 | current.ModifierExtension.Add(_converter._extension.Extract(node)); 37 | break; 38 | 39 | // process inherited elements 40 | default: 41 | _converter._resource.Process(node, current); 42 | break; 43 | 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Duration_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Duration_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Duration_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Duration Extract(ISourceNode node) 20 | { 21 | Duration v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Duration current) 31 | { 32 | switch (node.Name) 33 | { 34 | // process inherited elements 35 | default: 36 | _converter._quantity.Process(node, current); 37 | break; 38 | 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Element_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Element_43_50 : ICrossVersionProcessor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Element_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public void Process(ISourceNode node, Element? current) 20 | { 21 | if (current == null) 22 | { 23 | return; 24 | } 25 | 26 | switch (node.Name) 27 | { 28 | case "id": 29 | current.ElementId = node.Text; 30 | break; 31 | 32 | case "extension": 33 | current.Extension.Add(_converter._extension.Extract(node)); 34 | break; 35 | 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Expression_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Expression_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Expression_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Expression Extract(ISourceNode node) 20 | { 21 | Expression v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Expression current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "description": 35 | current.DescriptionElement = new FhirString(node.Text); 36 | break; 37 | 38 | case "_description": 39 | _converter._element.Process(node, current.DescriptionElement); 40 | break; 41 | 42 | case "name": 43 | current.NameElement = new Code(node.Text); 44 | break; 45 | 46 | case "_name": 47 | _converter._element.Process(node, current.NameElement); 48 | break; 49 | 50 | case "language": 51 | current.LanguageElement = new Code(node.Text); 52 | break; 53 | 54 | case "_language": 55 | _converter._element.Process(node, current.LanguageElement); 56 | break; 57 | 58 | case "expression": 59 | current.ExpressionElement = new FhirString(node.Text); 60 | break; 61 | 62 | case "_expression": 63 | _converter._element.Process(node, current.ExpressionElement); 64 | break; 65 | 66 | case "reference": 67 | current.ReferenceElement = new FhirUri(node.Text); 68 | break; 69 | 70 | case "_reference": 71 | _converter._element.Process(node, current.ReferenceElement); 72 | break; 73 | 74 | // process inherited elements 75 | default: 76 | _converter._element.Process(node, current); 77 | break; 78 | 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/HumanName_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class HumanName_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal HumanName_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public HumanName Extract(ISourceNode node) 20 | { 21 | HumanName v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, HumanName current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "use": 35 | current.Use = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_use": 39 | _converter._element.Process(node, current.UseElement); 40 | break; 41 | 42 | case "text": 43 | current.TextElement = new FhirString(node.Text); 44 | break; 45 | 46 | case "_text": 47 | _converter._element.Process(node, current.TextElement); 48 | break; 49 | 50 | case "family": 51 | current.FamilyElement = new FhirString(node.Text); 52 | break; 53 | 54 | case "_family": 55 | _converter._element.Process(node, current.FamilyElement); 56 | break; 57 | 58 | case "given": 59 | current.GivenElement.Add(new FhirString(node.Text)); 60 | break; 61 | 62 | case "prefix": 63 | current.PrefixElement.Add(new FhirString(node.Text)); 64 | break; 65 | 66 | case "suffix": 67 | current.SuffixElement.Add(new FhirString(node.Text)); 68 | break; 69 | 70 | case "period": 71 | current.Period = _converter._period.Extract(node); 72 | break; 73 | 74 | // process inherited elements 75 | default: 76 | _converter._element.Process(node, current); 77 | break; 78 | 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Identifier_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Identifier_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Identifier_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Identifier Extract(ISourceNode node) 20 | { 21 | Identifier v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Identifier current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "use": 35 | current.Use = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_use": 39 | _converter._element.Process(node, current.UseElement); 40 | break; 41 | 42 | case "type": 43 | current.Type = _converter._codeableConcept.Extract(node); 44 | break; 45 | 46 | case "system": 47 | current.SystemElement = new FhirUri(node.Text); 48 | break; 49 | 50 | case "_system": 51 | _converter._element.Process(node, current.SystemElement); 52 | break; 53 | 54 | case "value": 55 | current.ValueElement = new FhirString(node.Text); 56 | break; 57 | 58 | case "_value": 59 | _converter._element.Process(node, current.ValueElement); 60 | break; 61 | 62 | case "period": 63 | current.Period = _converter._period.Extract(node); 64 | break; 65 | 66 | case "assigner": 67 | current.Assigner = new ResourceReference(node.Text); 68 | break; 69 | 70 | // process inherited elements 71 | default: 72 | _converter._element.Process(node, current); 73 | break; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/MarketingStatus_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class MarketingStatus_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal MarketingStatus_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public MarketingStatus Extract(ISourceNode node) 20 | { 21 | MarketingStatus v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, MarketingStatus current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "country": 35 | current.Country = _converter._codeableConcept.Extract(node); 36 | break; 37 | 38 | case "jurisdiction": 39 | current.Jurisdiction = _converter._codeableConcept.Extract(node); 40 | break; 41 | 42 | case "status": 43 | current.Status = _converter._codeableConcept.Extract(node); 44 | break; 45 | 46 | case "dateRange": 47 | current.DateRange = _converter._period.Extract(node); 48 | break; 49 | 50 | case "restoreDate": 51 | current.RestoreDateElement = new FhirDateTime(node.Text); 52 | break; 53 | 54 | case "_restoreDate": 55 | _converter._element.Process(node, current.RestoreDateElement); 56 | break; 57 | 58 | // process inherited elements 59 | default: 60 | _converter._element.Process(node, current); 61 | break; 62 | 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Meta_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Meta_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Meta_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Meta Extract(ISourceNode node) 20 | { 21 | Meta v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Meta current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "versionId": 35 | current.VersionIdElement = new Id(node.Text); 36 | break; 37 | 38 | case "_versionId": 39 | _converter._element.Process(node, current.VersionIdElement); 40 | break; 41 | 42 | case "lastUpdated": 43 | current.LastUpdatedElement = new Instant(new FhirDateTime(node.Text).ToDateTimeOffset(TimeSpan.Zero)); 44 | break; 45 | 46 | case "_lastUpdated": 47 | _converter._element.Process(node, current.LastUpdatedElement); 48 | break; 49 | 50 | case "source": 51 | current.SourceElement = new FhirUri(node.Text); 52 | break; 53 | 54 | case "_source": 55 | _converter._element.Process(node, current.SourceElement); 56 | break; 57 | 58 | case "profile": 59 | current.ProfileElement.Add(new FhirUri(node.Text)); 60 | break; 61 | 62 | case "security": 63 | current.Security.Add(_converter._coding.Extract(node)); 64 | break; 65 | 66 | case "tag": 67 | current.Tag.Add(_converter._coding.Extract(node)); 68 | break; 69 | 70 | // process inherited elements 71 | default: 72 | _converter._element.Process(node, current); 73 | break; 74 | 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Money_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Money_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Money_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Money Extract(ISourceNode node) 20 | { 21 | Money v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Money current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "value": 35 | current.ValueElement = new FhirDecimal(_converter._primitive.GetDecimalOpt(node)); 36 | break; 37 | 38 | case "_value": 39 | _converter._element.Process(node, current.ValueElement); 40 | break; 41 | 42 | case "currency": 43 | current.Currency = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 44 | break; 45 | 46 | case "_currency": 47 | _converter._element.Process(node, current.CurrencyElement); 48 | break; 49 | 50 | // process inherited elements 51 | default: 52 | _converter._element.Process(node, current); 53 | break; 54 | 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Narrative_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Narrative_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Narrative_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Narrative Extract(ISourceNode node) 20 | { 21 | Narrative v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Narrative current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "status": 35 | current.Status = Hl7.Fhir.Utility.EnumUtility.ParseLiteral(node.Text); 36 | break; 37 | 38 | case "_status": 39 | _converter._element.Process(node, current.StatusElement); 40 | break; 41 | 42 | case "div": 43 | current.Div = node.Text; 44 | break; 45 | 46 | // process inherited elements 47 | default: 48 | _converter._element.Process(node, current); 49 | break; 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Period_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Period_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Period_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Period Extract(ISourceNode node) 20 | { 21 | Period v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Period current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "start": 35 | current.StartElement = new FhirDateTime(node.Text); 36 | break; 37 | 38 | case "_start": 39 | _converter._element.Process(node, current.StartElement); 40 | break; 41 | 42 | case "end": 43 | current.EndElement = new FhirDateTime(node.Text); 44 | break; 45 | 46 | case "_end": 47 | _converter._element.Process(node, current.EndElement); 48 | break; 49 | 50 | // process inherited elements 51 | default: 52 | _converter._element.Process(node, current); 53 | break; 54 | 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/ProductShelfLife_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class ProductShelfLife_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal ProductShelfLife_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public ProductShelfLife Extract(ISourceNode node) 20 | { 21 | ProductShelfLife v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, ProductShelfLife current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "identifier": 35 | // element ProductShelfLife.identifier has been removed in the target spec 36 | break; 37 | 38 | case "type": 39 | current.Type = _converter._codeableConcept.Extract(node); 40 | break; 41 | 42 | case "period": 43 | // element ProductShelfLife.period has been removed in the target spec 44 | break; 45 | 46 | case "specialPrecautionsForStorage": 47 | current.SpecialPrecautionsForStorage.Add(_converter._codeableConcept.Extract(node)); 48 | break; 49 | 50 | // process inherited elements 51 | default: 52 | _converter._element.Process(node, current); 53 | break; 54 | 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Range_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Range_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Range_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Hl7.Fhir.Model.Range Extract(ISourceNode node) 20 | { 21 | Hl7.Fhir.Model.Range v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Hl7.Fhir.Model.Range current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "low": 35 | current.Low = _converter._quantity.Extract(node); 36 | break; 37 | 38 | case "high": 39 | current.High = _converter._quantity.Extract(node); 40 | break; 41 | 42 | // process inherited elements 43 | default: 44 | _converter._element.Process(node, current); 45 | break; 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/RatioRange_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class RatioRange_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal RatioRange_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public RatioRange Extract(ISourceNode node) 20 | { 21 | RatioRange v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, RatioRange current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "lowNumerator": 35 | current.LowNumerator = _converter._quantity.Extract(node); 36 | break; 37 | 38 | case "highNumerator": 39 | current.HighNumerator = _converter._quantity.Extract(node); 40 | break; 41 | 42 | case "denominator": 43 | current.Denominator = _converter._quantity.Extract(node); 44 | break; 45 | 46 | // process inherited elements 47 | default: 48 | _converter._element.Process(node, current); 49 | break; 50 | 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Ratio_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Ratio_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Ratio_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public Ratio Extract(ISourceNode node) 20 | { 21 | Ratio v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, Ratio current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "numerator": 35 | current.Numerator = _converter._quantity.Extract(node); 36 | break; 37 | 38 | case "denominator": 39 | current.Denominator = _converter._quantity.Extract(node); 40 | break; 41 | 42 | // process inherited elements 43 | default: 44 | _converter._element.Process(node, current); 45 | break; 46 | 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/Reference_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class Reference_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal Reference_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public ResourceReference Extract(ISourceNode node) 20 | { 21 | ResourceReference v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, ResourceReference current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "reference": 35 | current.ReferenceElement = new FhirString(node.Text); 36 | break; 37 | 38 | case "_reference": 39 | _converter._element.Process(node, current.ReferenceElement); 40 | break; 41 | 42 | case "type": 43 | current.TypeElement = new FhirUri(node.Text); 44 | break; 45 | 46 | case "_type": 47 | _converter._element.Process(node, current.TypeElement); 48 | break; 49 | 50 | case "identifier": 51 | current.Identifier = _converter._identifier.Extract(node); 52 | break; 53 | 54 | case "display": 55 | current.DisplayElement = new FhirString(node.Text); 56 | break; 57 | 58 | case "_display": 59 | _converter._element.Process(node, current.DisplayElement); 60 | break; 61 | 62 | // process inherited elements 63 | default: 64 | _converter._element.Process(node, current); 65 | break; 66 | 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Convert_43_50/UsageContext_43_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion.Convert_43_50; 10 | 11 | public class UsageContext_43_50 : ICrossVersionProcessor, ICrossVersionExtractor 12 | { 13 | private Converter_43_50 _converter; 14 | internal UsageContext_43_50(Converter_43_50 converter) 15 | { 16 | _converter = converter; 17 | } 18 | 19 | public UsageContext Extract(ISourceNode node) 20 | { 21 | UsageContext v = new(); 22 | foreach (ISourceNode child in node.Children()) 23 | { 24 | Process(child, v); 25 | } 26 | 27 | return v; 28 | } 29 | 30 | public void Process(ISourceNode node, UsageContext current) 31 | { 32 | switch (node.Name) 33 | { 34 | case "code": 35 | current.Code = _converter._coding.Extract(node); 36 | break; 37 | 38 | case "valueCodeableConcept": 39 | current.Value = _converter._codeableConcept.Extract(node); 40 | break; 41 | 42 | case "valueQuantity": 43 | current.Value = _converter._quantity.Extract(node); 44 | break; 45 | 46 | case "valueRange": 47 | current.Value = _converter._range.Extract(node); 48 | break; 49 | 50 | case "valueReference": 51 | current.Value = new ResourceReference(node.Text); 52 | break; 53 | 54 | // process inherited elements 55 | default: 56 | _converter._element.Process(node, current); 57 | break; 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Converter_40_50.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | 7 | namespace Microsoft.Health.Fhir.CrossVersion; 8 | 9 | 10 | /// A R4 loader. 11 | public class Converter_40_50 : Converter_43_50 12 | { 13 | // note that for our use cases, 40 and 43 are the same 14 | } 15 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/ICrossVersionExtractor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | 7 | using Hl7.Fhir.ElementModel; 8 | using Hl7.Fhir.Model; 9 | 10 | namespace Microsoft.Health.Fhir.CrossVersion; 11 | 12 | public interface ICrossVersionExtractor where T : Hl7.Fhir.Model.Base, new() 13 | { 14 | #if NET8_0_OR_GREATER 15 | /// Gets the instance. 16 | #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. 17 | static ICrossVersionExtractor Instance { get; } 18 | #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. 19 | #endif 20 | 21 | /// Extracts the given source node into a resource. 22 | /// Source content. 23 | /// A T. 24 | T Extract(ISourceNode node); 25 | } 26 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/ICrossVersionProcessor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.ElementModel; 7 | using Hl7.Fhir.Model; 8 | 9 | namespace Microsoft.Health.Fhir.CrossVersion; 10 | 11 | public interface ICrossVersionProcessor where T : Hl7.Fhir.Model.Base 12 | { 13 | #if NET8_0_OR_GREATER 14 | /// Gets the instance. 15 | #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. 16 | static ICrossVersionProcessor Instance { get; } 17 | #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. 18 | #endif 19 | 20 | /// Process the source node values into the current object. 21 | /// Source for the. 22 | /// The current. 23 | void Process(ISourceNode node, T current); 24 | } 25 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.CrossVersion/Microsoft.Health.Fhir.CrossVersion.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | netstandard2.0;net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.MappingLanguage.Tests/Microsoft.Health.Fhir.MappingLanguage.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | net8.0 6 | false 7 | true 8 | 9 | 10 | 11 | 12 | runtime; build; native; contentfiles; analyzers; buildtransitive 13 | all 14 | 15 | 16 | 17 | 18 | 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | all 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | PreserveNewest 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.MappingLanguage/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | [assembly: InternalsVisibleTo("Microsoft.Health.Fhir.MappingLanguage.Tests")] 4 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.MappingLanguage/Microsoft.Health.Fhir.MappingLanguage.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | netstandard2.0;net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | all 17 | runtime; build; native; contentfiles; analyzers; buildtransitive 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.MappingLanguage/Models/TypeDetails.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.Model; 7 | using Microsoft.Health.Fhir.CodeGenCommon.FhirExtensions; 8 | 9 | namespace Microsoft.Health.Fhir.MappingLanguage.Models; 10 | 11 | public class TypeDetails 12 | { 13 | /// A profiled type. 14 | public class ProfiledType 15 | { 16 | private string _uri = null!; 17 | 18 | /// Gets or sets URI of the document. 19 | public required string Uri 20 | { 21 | get => _uri; 22 | set => _uri = MapUtilities.IsAbsoluteUrl(value) ? value : CommonDefinitions.FhirStructureUrlPrefix + value; 23 | } 24 | 25 | /// Gets or sets the profiles. 26 | public List Profiles { get; set; } = []; 27 | 28 | /// Gets or sets the element definitions. 29 | public List ElementDefinitions { get; set; } = []; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/Microsoft.Health.Fhir.MappingLanguage/PropertyOrTypeDetails.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Hl7.Fhir.Specification.Navigation; 7 | using Hl7.Fhir.Specification.Source; 8 | using Hl7.Fhir.Utility; 9 | using Hl7.FhirPath; 10 | 11 | namespace Microsoft.Health.Fhir.MappingLanguage; 12 | 13 | public class PropertyOrTypeDetails 14 | { 15 | public PropertyOrTypeDetails(string propertyPath, ElementDefinitionNavigator element, IAsyncResourceResolver resolver) 16 | { 17 | PropertyPath = propertyPath; 18 | Element = element; 19 | Resolver = resolver; 20 | } 21 | 22 | public string PropertyPath { get; private set; } 23 | public IAsyncResourceResolver Resolver { get; private set; } 24 | public ElementDefinitionNavigator Element { get; private set; } 25 | 26 | public override string ToString() 27 | { 28 | // return $"{Definition.Url}|{Definition.Version} # {Element.Path} ({String.Join(",", Element.Current.Type.Select(t => t.Code))})"; 29 | return $"{Element.Path}|{Element.StructureDefinition.Version} ({String.Join(",", Element.Current.Type.Select(t => t.Code))})"; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/fhir-codegen/App.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia; 2 | using Avalonia.Controls; 3 | using Avalonia.Controls.ApplicationLifetimes; 4 | using Avalonia.Controls.Templates; 5 | using Avalonia.Data.Core.Plugins; 6 | using Avalonia.Markup.Xaml; 7 | using CommunityToolkit.Mvvm.DependencyInjection; 8 | using fhir_codegen.ViewModels; 9 | using fhir_codegen.Views; 10 | using Splat; 11 | 12 | namespace fhir_codegen; 13 | 14 | public partial class App : Application 15 | { 16 | public override void Initialize() 17 | { 18 | AvaloniaXamlLoader.Load(this); 19 | } 20 | 21 | public override void OnFrameworkInitializationCompleted() 22 | { 23 | // Since we use CommunityToolkit, the line below is needed to remove Avalonia data validation - otherwise we get duplicate validation errors 24 | BindingPlugins.DataValidators.RemoveAt(0); 25 | 26 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) 27 | { 28 | desktop.MainWindow = new MainWindow() 29 | { 30 | DataContext = Ioc.Default.GetService() ?? new MainWindowViewModel(), 31 | }; 32 | } 33 | 34 | base.OnFrameworkInitializationCompleted(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/fhir-codegen/Models/ComparisonUiModel.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using CommunityToolkit.Mvvm.ComponentModel; 12 | using Microsoft.Health.Fhir.CodeGen.CompareTool; 13 | using Microsoft.Health.Fhir.CodeGen.Models; 14 | 15 | namespace fhir_codegen.Models; 16 | 17 | public partial class ComparisonUiModel : ObservableObject 18 | { 19 | [ObservableProperty] 20 | private DefinitionCollection? _source = null; 21 | 22 | [ObservableProperty] 23 | private DefinitionCollection? _target = null; 24 | 25 | [ObservableProperty] 26 | private PackageComparison? _results = null; 27 | } 28 | -------------------------------------------------------------------------------- /src/fhir-codegen/ViewLocator.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using System; 7 | using Avalonia.Controls; 8 | using Avalonia.Controls.Templates; 9 | using fhir_codegen.ViewModels; 10 | 11 | namespace fhir_codegen; 12 | 13 | public class ViewLocator : IDataTemplate 14 | { 15 | public Control? Build(object? data) 16 | { 17 | if (data is null) 18 | return null; 19 | 20 | var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal); 21 | var type = Type.GetType(name); 22 | 23 | if (type != null) 24 | { 25 | var control = (Control)Activator.CreateInstance(type)!; 26 | control.DataContext = data; 27 | return control; 28 | } 29 | 30 | return new TextBlock { Text = "Not Found: " + name }; 31 | } 32 | 33 | public bool Match(object? data) 34 | { 35 | return data is ViewModelBase; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/fhir-codegen/ViewModels/CompareDetailsValueSetsViewModel.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using Material.Icons; 12 | 13 | namespace fhir_codegen.ViewModels; 14 | 15 | public partial class CompareDetailsValueSetsViewModel : ViewModelBase, INavigableViewModel 16 | { 17 | public static string Label => "Value Set Comparison"; 18 | public static MaterialIconKind IconKind => MaterialIconKind.AlphaVBox; 19 | public static bool Indented => true; 20 | 21 | public CompareDetailsValueSetsViewModel(object? args = null) 22 | : base() 23 | { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/fhir-codegen/ViewModels/INavigableViewModel.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using Material.Icons; 7 | 8 | namespace fhir_codegen.ViewModels; 9 | 10 | // 11 | // Represents a view model that can be navigated to. 12 | // 13 | internal interface INavigableViewModel 14 | { 15 | /// 16 | /// Gets the label for the navigable view model. 17 | /// 18 | public static string Label { get; } = " - "; 19 | 20 | /// 21 | /// Gets if this model is indented in layout (only single level for now). 22 | /// 23 | public static bool Indented { get; } = false; 24 | 25 | /// 26 | /// Gets the icon kind for the navigable view model. 27 | /// 28 | public static MaterialIconKind IconKind { get; } 29 | } 30 | -------------------------------------------------------------------------------- /src/fhir-codegen/ViewModels/ViewModelBase.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using CommunityToolkit.Mvvm.ComponentModel; 12 | using ReactiveUI; 13 | 14 | namespace fhir_codegen.ViewModels; 15 | 16 | public class ViewModelBase : ObservableObject 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/fhir-codegen/Views/CompareDetailsValueSetsView.axaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | -------------------------------------------------------------------------------- /src/fhir-codegen/Views/CompareDetailsValueSetsView.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia; 2 | using Avalonia.Controls; 3 | using Avalonia.Markup.Xaml; 4 | 5 | namespace fhir_codegen.Views; 6 | 7 | public partial class CompareDetailsValueSetsView : UserControl 8 | { 9 | public CompareDetailsValueSetsView() 10 | { 11 | InitializeComponent(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/fhir-codegen/Views/CoreComparisonView.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia; 2 | using Avalonia.Controls; 3 | using Avalonia.Markup.Xaml; 4 | 5 | namespace fhir_codegen.Views; 6 | 7 | public partial class CoreComparisonView : UserControl 8 | { 9 | public CoreComparisonView() 10 | { 11 | InitializeComponent(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/fhir-codegen/Views/MainWindow.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia; 2 | using Avalonia.Controls; 3 | using Avalonia.Controls.Primitives; 4 | using Avalonia.Interactivity; 5 | using Avalonia.Markup.Xaml; 6 | using fhir_codegen; 7 | using fhir_codegen.ViewModels; 8 | 9 | namespace fhir_codegen.Views; 10 | 11 | public partial class MainWindow : Window 12 | { 13 | public MainWindow() 14 | { 15 | InitializeComponent(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/fhir-codegen/Views/WelcomePageView.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia; 2 | using Avalonia.Controls; 3 | using Avalonia.Markup.Xaml; 4 | using Avalonia.Markup.Xaml.MarkupExtensions; 5 | using Avalonia.Media; 6 | using fhir_codegen.ViewModels; 7 | 8 | namespace fhir_codegen.Views; 9 | 10 | public partial class WelcomePageView : UserControl 11 | { 12 | public WelcomePageView() 13 | { 14 | InitializeComponent(); 15 | 16 | if (DataContext == null) 17 | { 18 | DataContext = new WelcomePageViewModel(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/fhir-codegen/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/fhir-codegen/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Ui_Listen_Port": "", 3 | "Output_Path": "c:/git/fhir-codegen/v3/generated", 4 | "Logging": { 5 | "LogLevel": { 6 | "Default": "Information", 7 | "Microsoft.AspNetCore": "Warning" 8 | } 9 | }, 10 | "AllowedHosts": "*" 11 | } 12 | -------------------------------------------------------------------------------- /src/performance-test-cli/Program.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. 4 | // 5 | 6 | using BenchmarkDotNet.Running; 7 | 8 | namespace performance_test_cli; 9 | 10 | public static class Program 11 | { 12 | /// Main entry-point for this application. 13 | /// An array of command-line argument strings. 14 | static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/performance-test-cli/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "performance-test-cli": { 4 | "commandName": "Project", 5 | "commandLineArgs": "-f *" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /src/performance-test-cli/performance-test-cli.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Exe 6 | net8.0 7 | performance_test_cli 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /stylecop.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", 3 | "settings": { 4 | "documentationRules": { 5 | "companyName": "Microsoft Corporation", 6 | "copyrightText": " Copyright (c) {companyName}. All rights reserved.\n Licensed under the {licenseName} License ({licenseName}). See {licenseFile} in the repo root for license information.", 7 | "variables": { 8 | "licenseName": "MIT", 9 | "licenseFile": "LICENSE" 10 | }, 11 | "xmlHeader": true, 12 | "headerDecoration": "-------------------------------------------------------------------------------------------------" 13 | }, 14 | "orderingRules": { 15 | "systemUsingDirectivesFirst": true, 16 | "usingDirectivesPlacement": "outsideNamespace", 17 | "elementOrder": [ 18 | "kind" 19 | ] 20 | }, 21 | "indentation": { 22 | "useTabs": false, 23 | "indentationSize": 4, 24 | "tabSize": 4 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /testenvironments.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1", 3 | "environments": [ 4 | { 5 | "name": "WSL-Ubuntu", 6 | "type": "wsl", 7 | "wslDistribution": "Ubuntu" 8 | } 9 | ] 10 | } 11 | --------------------------------------------------------------------------------