Skip to content
cccskills
FreePublished on GitHub

arbeidsgiver

Expert knowledge of Employer/Employment integration (EREG/AAREG) in melosys-api. Use when: (1) Working with organization data from EREG (Enhetsregisteret), (2) Working with employment data from AAREG (Arbeidsforhold), (3) Understanding employer/organization lookup, (4) Debugging employer or employment issues, (5) Understanding the mapping between register data and domain models. Triggers: orgnummer, arbeidsforhold, EREG, AAREG, Enhetsregisteret, registeropplysninger, ansettelsesperiode, saksopplysning.

The English summary is being prepared. Showing the original description.

See how to install

Files included (4)

  • SKILL.md10.9 KB
  • references/aareg-api.md9.6 KB
  • references/debugging.md7.9 KB
  • references/ereg-api.md8.0 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Arbeidsgiver (Employer/Employment) System

Melosys retrieves employer and employment data from two registers:

  • EREG (Enhetsregisteret): Organization data - names, addresses, sector codes
  • AAREG (Arbeidsgiver- og arbeidstakerregisteret): Employment relationships - work contracts, periods

This data is used for case processing, determining applicable legislation, and letter generation.

Quick Reference

Module Structure

integrasjon/ereg/
├── EregFasade.kt                 # Interface for EREG operations
├── EregRestService.kt            # Implementation
├── EregDtoTilSaksopplysningKonverter.kt  # DTO → domain mapper
└── organisasjon/
    ├── OrganisasjonRestClient.kt       # REST client
    ├── OrganisasjonRestClientConfig.kt # WebClient config
    └── OrganisasjonResponse.kt           # Response DTOs

integrasjon/aareg/arbeidsforhold/
├── ArbeidsforholdClient.kt     # REST client for AAREG
├── ArbeidsforholdClientConfig.kt
├── ArbeidsforholdQuery.kt        # Query parameters
└── ArbeidsforholdResponse.kt     # Response DTOs

service/aareg/
├── ArbeidsforholdService.kt      # Service layer for employment
└── ArbeidsforholdKonverter.kt    # Response → domain mapper

service/registeropplysninger/
├── RegisteropplysningerService.java  # Coordinates all register lookups
└── OrganisasjonOppslagService.java   # Organization lookup helper

domain/dokument/arbeidsforhold/
├── Arbeidsforhold.kt             # Employment relationship
├── ArbeidsforholdDokument.kt     # Collection of employments
├── Arbeidsavtale.kt              # Work contract
├── PermisjonOgPermittering.kt    # Leave/layoff
└── Utenlandsopphold.kt           # Foreign stays

domain/dokument/organisasjon/
├── OrganisasjonDokument.kt       # Organization entity
├── OrganisasjonsDetaljer.kt      # Details (addresses, contacts)
└── Organisasjonsnavn.kt          # Name history

Key Services

ServicePurpose
EregFasadeLookup organization by orgnummer
EregRestServiceEREG REST implementation
ArbeidsforholdServiceFetch employment history for person
ArbeidsforholdClientREST client to AAREG
OrganisasjonOppslagServiceOrganization lookup helper
RegisteropplysningerServiceCoordinates all register lookups

EREG (Organization Data)

Operations

// Lookup organization (throws if not found)
val saksopplysning = eregFasade.hentOrganisasjon(orgnummer)
val orgDokument = saksopplysning.dokument as OrganisasjonDokument

// Optional lookup
val optSaksopplysning = eregFasade.finnOrganisasjon(orgnummer)

// Get name only
val navn = eregFasade.hentOrganisasjonNavn(orgnummer)

// Lookup multiple via helper service
val orgnumre = setOf("123456789", "987654321")
val organisasjoner = organisasjonOppslagService.hentOrganisasjoner(orgnumre)

Organization Types

TypeDescription
JuridiskEnhetLegal entity (AS, ANS, etc.)
VirksomhetBusiness unit (underenhet)
OrganisasjonsleddOrganizational unit

Organization Response

class OrganisasjonResponse.Organisasjon(
    val organisasjonsnummer: String,      // 9-digit org number
    val navn: Navn?,                       // Current name
    val organisasjonDetaljer: OrganisasjonDetaljer?
)

data class OrganisasjonDetaljer(
    val registreringsdato: LocalDateTime?,
    val opphoersdato: LocalDate?,          // Closure date
    val forretningsadresser: List<Adresse>?,
    val postadresser: List<Adresse>?,
    val telefonnummer: List<Telefonnummer>?,
    val epostadresser: List<Epostadresse>?,
    val naeringer: List<Naering>?,         // Industry codes
    val enhetstyper: List<Enhetstype>?,
    val ansatte: List<Ansatte>?            // Employee count
)

Organization Domain Model

class OrganisasjonDokument(
    val orgnummer: String,
    val navn: String,
    val enhetstype: String?,       // AS, ENK, etc.
    val sektorkode: String,        // Sector code
    val organisasjonDetaljer: OrganisasjonsDetaljer
) {
    fun harRegistrertPostadresse(): Boolean
    fun harRegistrertForretningsadresse(): Boolean
    fun hentTilgjengeligAdresse(): StrukturertAdresse?
}

AAREG (Employment Data)

Operations

// Fetch employment history for a person
val saksopplysning = arbeidsforholdService.finnArbeidsforholdPrArbeidstaker(
    ident = fnr,
    fom = LocalDate.of(2020, 1, 1),
    tom = LocalDate.of(2024, 12, 31)
)
val arbeidsforholdDokument = saksopplysning.dokument as ArbeidsforholdDokument

Query Parameters

data class ArbeidsforholdQuery(
    val regelverk: Regelverk = Regelverk.ALLE,
    val arbeidsforholdType: ArbeidsforholdType = ArbeidsforholdType.ALLE,
    val ansettelsesperiodeFom: LocalDate? = null,
    val ansettelsesperiodeTom: LocalDate? = null
)

enum class Regelverk {
    ALLE,
    A_ORDNINGEN,       // Current reporting system
    FOER_A_ORDNINGEN   // Pre-2015 data
}

enum class ArbeidsforholdType {
    ORDINAERT_ARBEIDSFORHOLD,
    MARITIMT_ARBEIDSFORHOLD,
    FRILANSER_OPPDRAGSTAKER_HONORARPE_RSONER_MM,
    FORENKLET_OPPGJOERSORDNING,
    ALLE
}

Employment Response

data class Arbeidsforhold(
    val arbeidsforholdId: String?,         // Employer's ID
    val navArbeidsforholdId: Int,          // NAV's ID
    val ansettelsesperiode: Ansettelsesperiode,
    val type: String?,                      // Employment type
    val arbeidstaker: Arbeidstaker,
    val arbeidsavtaler: List<Arbeidsavtale>?,
    val permisjonPermitteringer: List<PermisjonPermittering>?,
    val utenlandsopphold: List<Utenlandsopphold>?,
    val arbeidsgiver: Arbeidsgiver,         // Employer info
    val opplysningspliktig: Opplysningspliktig,
    val innrapportertEtterAOrdningen: Boolean?
)

data class Arbeidsavtale(
    val type: String?,              // Ordinaer, Frilanser, etc.
    val yrke: String?,              // Occupation code
    val stillingsprosent: BigDecimal?,
    val gyldighetsperiode: Periode,
    val beregnetAntallTimerPrUke: BigDecimal?
)

Employment Domain Model

class Arbeidsforhold {
    var arbeidsforholdID: String?
    var arbeidsforholdIDnav: Long
    var ansettelsesPeriode: Periode?
    var arbeidsforholdstype: String?
    var arbeidsavtaler: List<Arbeidsavtale>
    var permisjonOgPermittering: List<PermisjonOgPermittering>
    var utenlandsopphold: List<Utenlandsopphold>
    var arbeidsgivertype: Aktoertype?  // ORGANISASJON or PERSON
    var arbeidsgiverID: String?         // Orgnummer
    var opplysningspliktigtype: Aktoertype?
    var opplysningspliktigID: String?

    fun hentOrgnumre(): List<String>    // Get all org numbers
}

enum class Aktoertype {
    ORGANISASJON,
    PERSON
}

Register Data Flow

Fetching Register Data

RegisteropplysningerService.hentOgLagreOpplysninger()
    │
    ├── ARBFORH → ArbeidsforholdService → ArbeidsforholdClient
    │                                          ↓
    │                                     ArbeidsforholdResponse
    │                                          ↓
    │                                     ArbeidsforholdKonverter
    │                                          ↓
    │                                     ArbeidsforholdDokument
    │
    └── ORG → EregFasade → OrganisasjonRestClient
                               ↓
                          OrganisasjonResponse
                               ↓
                          EregDtoTilSaksopplysningKonverter
                               ↓
                          OrganisasjonDokument

Usage in Case Processing

  1. RegisteropplysningerService fetches employment data (ARBFORH)
  2. Extracts organization numbers from employment records
  3. Fetches organization details (ORG) for each employer
  4. All data stored as Saksopplysning on Behandling

Saksopplysning Types

TypeSourceDescription
ARBFORHAAREGEmployment history
ORGEREGOrganization details
INNTKInntektIncome data
MEDLMEDLMembership periods

Common Issues

Issue: Organization Not Found

Symptom: IkkeFunnetException when looking up orgnummer

Causes:

  • Invalid organization number (must be 9 digits)
  • Organization doesn't exist or is deleted
  • Using fnr instead of orgnr (11 digits rejected)

Check:

// Validate orgnr length
if (orgnr.length == 11) {
    log.warn("Looks like fnr, not orgnr: $orgnr")
}

Issue: Empty Employment History

Symptom: No arbeidsforhold returned

Causes:

  • Person has no registered employment
  • Date range doesn't overlap any employment
  • Using wrong Regelverk (A_ORDNINGEN vs FOER_A_ORDNINGEN)

Check:

val query = ArbeidsforholdQuery(
    regelverk = Regelverk.ALLE,  // Try all data sources
    arbeidsforholdType = ArbeidsforholdType.ALLE,
    ansettelsesperiodeFom = fom.minusYears(5),  // Expand range
    ansettelsesperiodeTom = tom
)

Issue: Missing Organization Address

Symptom: harRegistrertAdresse() returns false

Cause: Organization has no registered address in EREG

Check:

val org = organisasjonOppslagService.hentOrganisasjon(orgnr)
log.info("Postadresse: ${org.harRegistrertPostadresse()}")
log.info("Forretningsadresse: ${org.harRegistrertForretningsadresse()}")

Key Code Locations

ComponentLocation
EREG Facadeintegrasjon/.../ereg/EregFasade.kt
EREG Serviceintegrasjon/.../ereg/EregRestService.kt
EREG Clientintegrasjon/.../ereg/organisasjon/OrganisasjonRestClient.kt
EREG DTOsintegrasjon/.../ereg/organisasjon/OrganisasjonResponse.kt
AAREG Serviceservice/.../aareg/ArbeidsforholdService.kt
AAREG Clientintegrasjon/.../aareg/arbeidsforhold/ArbeidsforholdClient.kt
AAREG DTOsintegrasjon/.../aareg/arbeidsforhold/ArbeidsforholdResponse.kt
Domain Modelsdomain/.../dokument/arbeidsforhold/
Org Domaindomain/.../dokument/organisasjon/
Register Serviceservice/.../registeropplysninger/RegisteropplysningerService.java

Detailed Documentation

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Expert knowledge of Altinn A1 application processing for posted workers in melosys-api. Use when: (1) Understanding Altinn søknad/skjema processing, (2) Debugging MedlemskapArbeidEOS form mapping, (3) Understanding SoeknadMapper transformations, (4) Investigating posted worker application issues, (5) Understanding the MOTTAK_SOKNAD_ALTINN saga flow.

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

Modular monolith architecture overview for melosys-api. Use when needing to understand module structure, dependencies between modules, where to place new code, or when changes in one module might affect others. Triggers: "architecture", "module dependencies", "where should I put", "which modules", "dependency graph".

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

Expert knowledge of Behandling (case treatment) domain in melosys-api. Use when: (1) Understanding the behandling lifecycle and status transitions, (2) Debugging issues with behandling creation, status changes, or closure, (3) Understanding relationships between Fagsak, Behandling, and Behandlingsresultat, (4) Investigating why a behandling is stuck or has wrong status, (5) Understanding Behandlingstyper, Behandlingstema, Behandlingsstatus enums, (6) Debugging journalføring or SED-triggered behandling creation, (7) Understanding behandling creation via saksflyt sagas.

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

Expert knowledge of Behandlingsresultat (treatment result) domain in melosys-api. Use when: (1) Understanding result types and their meaning (FASTSATT_LOVVALGSLAND, MEDLEM_I_FOLKETRYGDEN, etc.), (2) Working with periods - Lovvalgsperiode, Medlemskapsperiode, Anmodningsperiode, Utpekingsperiode, (3) Debugging vedtak/decision metadata, criteria evaluation, or social insurance charges, (4) Understanding EU/EEA coordination logic and Article 16 exception handling, (5) Working with trygdeavgift (social insurance charge) calculations.

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

brev

Free

Expert knowledge of Brev (letter generation) in melosys-api. Use when: (1) Producing letters and decision documents (vedtaksbrev), (2) Understanding Dokgen templates and mapping, (3) Configuring letter recipients and distribution, (4) Debugging letter generation issues, (5) Adding new letter types or templates.

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

Expert knowledge of the melosys-api Oracle database schema. Use when: (1) Writing SQL queries against the melosys database, (2) Understanding table relationships and foreign keys, (3) Debugging data issues by querying the database, (4) Understanding what data is stored where, (5) Creating or modifying Flyway migrations, (6) Mapping domain entities to database tables. Triggers: SQL against melosys DB, table/column lookup, FK relationships, "where is X stored", "what column stores X", "why is data missing", beh_resultat_id, behandlingsresultat_id, saksnummer, schema.

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

See all skills by navikt

Report a problem with this skill