{"id":21365148,"url":"https://github.com/altinn/codelists-lib-dotnet","last_synced_at":"2025-03-16T07:40:36.749Z","repository":{"id":73736481,"uuid":"507013911","full_name":"Altinn/codelists-lib-dotnet","owner":"Altinn","description":"Library containing common code lists","archived":false,"fork":false,"pushed_at":"2024-02-24T01:49:16.000Z","size":514,"stargazers_count":0,"open_issues_count":6,"forks_count":3,"subscribers_count":17,"default_branch":"main","last_synced_at":"2024-02-24T02:34:42.831Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Altinn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-06-24T13:06:57.000Z","updated_at":"2024-04-15T03:27:58.095Z","dependencies_parsed_at":"2023-07-08T02:30:50.452Z","dependency_job_id":"bb8e16ed-a489-44e2-88b1-fb4af4936744","html_url":"https://github.com/Altinn/codelists-lib-dotnet","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altinn%2Fcodelists-lib-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altinn%2Fcodelists-lib-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altinn%2Fcodelists-lib-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altinn%2Fcodelists-lib-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Altinn","download_url":"https://codeload.github.com/Altinn/codelists-lib-dotnet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841204,"owners_count":20356441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T07:09:54.014Z","updated_at":"2025-03-16T07:40:36.729Z","avatar_url":"https://github.com/Altinn.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Altinn Common Codelists\n![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/altinn/codelists-lib-dotnet)\n![GitHub last commit](https://img.shields.io/github/last-commit/altinn/codelists-lib-dotnet)\n![GitHub](https://img.shields.io/github/license/altinn/codelists-lib-dotnet)\n\nThis library contains common code lists for use in Altinn 3 based applications. \n\nThe [Getting started](#getting-started) section describes the basic steps required in order to use this package within an Altinn 3 application. For a more comprehensive description of code lists in Altinn 3 please see https://docs.altinn.studio/app/development/data/options/.\n\u003chr\u003e\n\u003cbr/\u003e  \n\n## Getting started using the package\n\nThis guide assumes you have an existing Altinn 3 application. If not please see https://docs.altinn.studio/app/getting-started/create-app/ to get started.\n\n### 1. Add reference to [Altinn.Codelists nuget package](https://www.nuget.org/packages/Altinn.Codelists)  \n   Open command line to the repo of your application and navigate to the App folder where the App.csproj file is located and run the following command:\n\n   ```shell\n   dotnet add package Altinn.Codelists\n   ```\n   This will add the latest stable version of the package to your solution.\n\n   As an alternative you can edit your applications App.csproj file directly by adding the reference below to the `\u003citemgroup\u003e` where you have package references. \n   ```xml\n     \u003cPackageReference Include=\"Altinn.Codelists\" Version=\"0.5.0\" /\u003e     \n   ```\n   Note that you then need to explicitly specify the version you would like. See the link on step one for available versions.\n\n### 2. Register the codelists in your app DI container  \n   Add the following to your Program.cs file:\n   ```csharp\n   services.AddAltinnCodelists();\n   ```\n   By calling this you will register all codelists accross all sources listed below in available codelists. You can also register codelists one by one if you for example would like to provide your own codelist id, or if you would like to control the mappings to description and help texts.\n\n### 3. Connect your application to the codelist you would like to use  \n   See the section below for available codelist id's.\n\n   You can either do this using [Altinn Studio](https://altinn.studio) and configure the *Kodeliste-ID* of your component in the UI.\n\n   Or you can configure the component by editing the optionsId property in FormLayout.json according to the [documentation](https://docs.altinn.studio/app/development/data/options/#connect-the-component-to-options-code-list) \n\n## Custom configuration\nWhile the above mentioned configuration where you call `services.AddAltinnCodelists();` will add all available codelists with default values, there are cases where you might want to customize the configuration. The examples will vary a bit depending on the source of the codelist.\n\n### Add a codelist with custom codelist id\nIf you don't want to use the default codelist id, or only want to register codelists relevant for you app you can register each codelist individually.\n\nExample using codelist from SSB overriding the option id:\n```csharp\n   services.AddSSBClassificationCodelistProvider(\"næring\", Classification.IndustryGrouping);\n```\n\n### Add a codelist with default parameters\nSome of the codelists accepts parameters controlling what's returned.\n\nExample using the codelist from SSB specifiying a level filter to only get values from the first level (this particular codelist is hierarchical).\n\n```csharp\n   services.AddSSBClassificationCodelistProvider(\"næring\", Classification.IndustryGrouping, new Dictionary\u003cstring, string\u003e() { { \"level\", \"1\" } });\n```\nThe default parameters is a name/value pair collection allowing for any parameter to be passed in and picked up by the implementation of the codelist provider.\n\n### Add a codelist that has support for description and/or help text values\nWhile a regular codelist is only key/value pairs, you can extend this with adding description and help text allowing for a more descriptive UI.\n\nThe following example enables the notes field from SSB classification to populate the description text.\n\n```csharp\n    services.AddSSBClassificationCodelistProvider(\"næring\", Classification.IndustryGrouping,\n        new ClassificationOptions() { MapNotesToDescription = true },\n        new Dictionary\u003cstring, string\u003e() { { \"level\", \"1\" } });\n```\nThe above example enables a predefined way of adding a description text. If you would like to customize the description text even further you can pass inn a function.\nThe follwing examples passes in a function that that will be evaluated when populating the code list and will return a combination of the classification code and the notes fields separated by colon.\n\n```csharp\nservices.AddSSBClassificationCodelistProvider(\n        \"næring\",\n        Classification.IndustryGrouping,\n        new ClassificationOptions() \n        { \n            MapDescriptionFunc = (classificationCode) =\u003e $\"{classificationCode.Code}: {classificationCode.Notes}\" \n        },\n        new Dictionary\u003cstring, string\u003e() { { \"level\", \"1\" } });\n```\n\n### Add a codelist from SSB not available in the `Classification` enum.\nCurrently only a small subset of the available codelist from SSB is included in the `Classification` enum. The enum is really only provided as a more readable version of the underlying id provided by SSB. But in our case also serves as a way of telling what codelists we have tested explicitly against. If you find a codelist you would like to use, you can specify it's id instead of the enum.\n\n```csharp\n   services.AddSSBClassificationCodelistProvider(\"næring\", 6);\n```\n\n\n## Available codelists\nThe list below shows currently implemented code lists with their default id.\n\n| Default Codelist Id      | Source       | Description                                               |\n|------------------------- | ------------ | --------------------------------------------------------- |\n| fylker                   | SSB          | The counties of Norway                                    |\n| fylker-kv                | Kartverket   | The counties of Norway                                    |\n| grunnbeløpfolketrygden   | SSB          | National insurance base amount                            |\n| kjønn                    | SSB          | Sex                                                       |\n| kommuner                 | SSB          | The communes of Norway (all)                              |\n| kommuner-kv              | Kartverket   | The communes of Norway with ability to filter on county   |\n| land                     | SSB          | The countries of the world                                |\n| næringsgruppering        | SSB          | Industrical grouping                                      |\n| poststed                 | Posten       | Norwegian postal codes                                              |\n| sivilstand               | SSB          | Marital status                                            |\n| yrker                    | SSB          | Occupations                                               |\n\n\n\n## Sources\nBelow are the sources used for the various codelists above. The underlying api's provide different functionality with regards to query parameters. Espessialy the SSB api's provide a rich set of parameters allowing the query for valid values on a given date or date range.\n\n### [Statistisk Sentralbyrå/SSB](https://www.ssb.no/)\nDoc: https://data.ssb.no/api/klass/v1/api-guide.html\n\nLicence: https://data.ssb.no/api/klass/v1/api-guide.html#_license\n\n### [Kartverket/KV](https://www.kartverket.no/)\nDoc: https://kartkatalog.geonorge.no/metadata/administrative-enheter-kommuner/041f1e6e-bdbc-4091-b48f-8a5990f3cc5b\n\nApi: https://ws.geonorge.no/kommuneinfo/v1/\n\nLicence: https://www.kartverket.no/api-og-data/vilkar-for-bruk\n\n### [Posten](https://www.bring.no)\nDoc: https://www.bring.no/tjenester/adressetjenester/postnummer/postnummertabeller-veiledning\n\n## Contributing\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n## Authors\nAltinn Apps development team - If you want to get in touch, just create a new issue.\nSee also the list of [contributors](https://github.com/Altinn/codelists-lib-dotnet/graphs/contributors) who participated in this project.\n## License\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltinn%2Fcodelists-lib-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltinn%2Fcodelists-lib-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltinn%2Fcodelists-lib-dotnet/lists"}