Skip to content
cccskills
FreePublished on GitHub

medlemskap

Expert knowledge of membership (medlemskap) domain in melosys-api. Use when: (1) Understanding pliktig vs frivillig membership determination, (2) Debugging medlemskapsperiode creation and updates, (3) Understanding trygdedekning combinations and rules, (4) Investigating MEDL synchronization issues, (5) Understanding membership status transitions and innvilgelsesresultat, (6) Working with UtledMedlemskapsperioder for proposal generation, (7) Understanding the relationship between bestemmelse, medlemskapstype, and trygdedekning. Triggers: medlemskapsperiode, pliktig, frivillig, trygdedekning, MEDL, innvilgelsesresultat, medlPeriodeID, bestemmelse.

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

See how to install

Files included (5)

  • SKILL.md11.2 KB
  • references/debugging.md7.3 KB
  • references/medl-sync.md6.8 KB
  • references/periods.md6.7 KB
  • references/types.md6.8 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Medlemskap Domain

Medlemskap (membership) determines whether a person is covered by the Norwegian National Insurance Scheme (folketrygden). The domain handles membership period creation, type determination (pliktig/frivillig), coverage levels (trygdedekning), and synchronization with the central MEDL registry.

Quick Reference

Domain Model Hierarchy

Behandlingsresultat
└── medlemskapsperioder: Set<Medlemskapsperiode>

    Medlemskapsperiode
    ├── id: Long
    ├── fom: LocalDate               # Period start date
    ├── tom: LocalDate?              # Period end date (nullable for open-ended)
    ├── innvilgelsesresultat: InnvilgelsesResultat  # INNVILGET, DELVIS_INNVILGET, AVSLAATT, OPPHØRT
    ├── medlemskapstype: Medlemskapstyper           # PLIKTIG, FRIVILLIG, UNNTATT, ...
    ├── trygdedekning: Trygdedekninger              # FULL_DEKNING_FTRL, FTRL_2_9_*, etc.
    ├── bestemmelse: Bestemmelse                    # FTRL paragraph
    ├── medlPeriodeID: Long?         # Reference to MEDL registry
    └── trygdeavgiftsperioder: Set<Trygdeavgiftsperiode>

Key Enums

EnumValuesDescription
InnvilgelsesResultatINNVILGET, DELVIS_INNVILGET, AVSLAATT, OPPHØRTPeriod outcome
MedlemskapstyperPLIKTIG, FRIVILLIG, UNNTATT, DELVIS_UNNTATT, IKKE_MEDLEMMembership type (mandatory/voluntary/exempt)
TrygdedekningerFULL_DEKNING, FULL_DEKNING_FTRL, FULL_DEKNING_EOSFO, UTEN_DEKNING, the FTRL_2_9_* family, FTRL_2_7_/FTRL_2_7A_, treaty values (TILLEGGSAVTALE_NATO_HELSEDEL, UNNTATT_USA_5_2_G, UNNTATT_CAN_7_5_B)Coverage type (stored in column trygde_dekning). See kodeverk enum Trygdedekninger for the full set.

Trygdedekninger vs Avgiftsdekning — the HELSEDEL_MED_SYKEPENGER / HELSEDEL_UTEN_SYKEPENGER / PENSJONSDEL_MED_YRKESSKADETRYGD / PENSJONSDEL_UTEN_YRKESSKADETRYGD constants are NOT Trygdedekninger; they are the Avgiftsdekning enum, derived from a Trygdedekninger value via AvgiftsdekningerFraTrygdedekning for trygdeavgift. Don't confuse the two.

Medlemskapstype Determination

Determined by bestemmelse via UtledMedlemskapstype:

PLIKTIG (Mandatory) - Based on FTRL §2-1, §2-2, §2-5:

// From PliktigeMedlemskapsbestemmelser
- FTRL_KAP2_2_1        // Bosatt i Norge
- FTRL_KAP2_2_2        // Arbeidstaker i Norge
- FTRL_KAP2_2_3_ANDRE_LEDD
- FTRL_KAP2_2_5_FØRSTE_LEDD_A through H  // Various §2-5 provisions
- FTRL_KAP2_2_5_ANDRE_LEDD
- Vertslandsavtale_bestemmelser (NATO, etc.)

FRIVILLIG (Voluntary) - FTRL §2-8 and special cases:

- FTRL_KAP2_2_15_ANDRE_LEDD  // Special rule: always FRIVILLIG
- All other bestemmelser not in PLIKTIG list

Trygdedekning Options

Valid trygdedekninger per behandlingstema are defined in GyldigeTrygdedekningerService (then intersected with the bestemmelse via LovligeKombinasjonerTrygdedekningBestemmelse):

BehandlingstemaAvailable Trygdedekninger
YRKESAKTIVFULL_DEKNING_FTRL, the full FTRL_2_9_* family, FTRL_2_7_TREDJE_LEDD_B_, FTRL_2_7A_ANDRE_LEDD_B_, TILLEGGSAVTALE_NATO_HELSEDEL
IKKE_YRKESAKTIVFULL_DEKNING_FTRL, the FTRL_2_9_* family, FTRL_2_7_TREDJE_LEDD_B_*, TILLEGGSAVTALE_NATO_HELSEDEL
PENSJONISTFULL_DEKNING_FTRL, FTRL_2_9_* (helse/pensjon variants), FTRL_2_7_TREDJE_LEDD_B_*

Service Layer

MedlemskapsperiodeService

Location: service/src/main/kotlin/.../ftrl/medlemskapsperiode/MedlemskapsperiodeService.kt

Key operations:

  • hentMedlemskapsperioder(behandlingsresultatID) - Get all periods for treatment
  • opprettMedlemskapsperiode(...) - Create new period with validation
  • oppdaterMedlemskapsperiode(...) - Update existing period
  • slettMedlemskapsperiode(behandlingsresultatID, periodeID) - Delete period
  • erstattMedlemskapsperioder(...) - Replace periods on re-assessment
  • opprettEllerOppdaterMedlPeriode(...) - Sync to MEDL registry

OpprettForslagMedlemskapsperiodeService

Location: service/src/main/kotlin/.../ftrl/medlemskapsperiode/OpprettForslagMedlemskapsperiodeService.kt

Key operations:

  • opprettForslagPåMedlemskapsperioder(behandlingID, bestemmelse) - Generate period proposals

Validation checks:

  1. Sakstype must be FTRL (validerSakstype)
  2. Bestemmelse-trygdedekning combination must be valid (validerBestemmelse)
  3. Required vilkår must be fulfilled (validerVilkår)

UtledMedlemskapsperioder

Location: service/src/main/kotlin/.../ftrl/medlemskapsperiode/UtledMedlemskapsperioder.kt

Key operations:

  • lagMedlemskapsperioder(grunnlag) - Create periods for first-time treatment
  • lagMedlemskapsperioderForAndregangsbehandling(...) - Create periods for re-assessment

Logic overview:

  • For YRKESAKTIV/IKKE_YRKESAKTIV: Creates periods based on søknadsperiode and mottaksdato
  • For PENSJONIST: Creates helsedel periods only
  • Handles avslag (rejection) periods before mottaksdato

Period Lifecycle

Creation Flow

Søknad received → Journalføring → Behandling created
                                        │
                                        ▼
                              OpprettForslagMedlemskapsperiodeService
                              (generates period proposals)
                                        │
                                        ▼
                              Saksbehandler review/adjust
                                        │
                                        ▼
                              fattVedtak() → IVERKSETT_VEDTAK_FTRL
                                        │
                                        ▼
                              LAGRE_MEDLEMSKAPSPERIODE_MEDL (saksflyt steg)
                              (writes to MEDL registry)

InnvilgelsesResultat Transitions

FromToTrigger
(new)INNVILGETPositive vedtak
(new)AVSLAATTRejection vedtak
INNVILGETOPPHØRTTermination (opphør)

Re-assessment (Ny vurdering)

When creating new behandling for existing fagsak:

  1. Original periods are copied/referenced via opprinneligBehandling
  2. New periods can modify or extend original periods
  3. erstattMedlemskapsperioder() handles:
    • Opphør (terminate) original INNVILGET periods not carried forward
    • Feilregistrer (void) original OPPHØRT periods not carried forward
    • Create/update new periods

Validation Rules

Period Field Validation

// Required fields (always)
- fom: LocalDate         // Must be set
- innvilgelsesResultat   // Must be set
- bestemmelse            // Must be set
- trygdedekning          // Must be set

// tom: LocalDate - Required EXCEPT when:
- Land is only Norway (NOR) AND
- Bestemmelse is FTRL_KAP2_2_1 (bosatt i Norge)

// Period logic
- tom cannot be before fom (PeriodeRegler.feilIPeriode)

Bestemmelse-Trygdedekning Validation

// Via LovligeKombinasjonerTrygdedekningBestemmelse
erBestemmelseGyldigForTrygdedekning(bestemmelse, trygdedekning)

Vilkår Validation

Before creating period proposals, required vilkår must be fulfilled:

// Check via Behandlingsresultat
behandlingsresultat.oppfyllerVilkår(vilkårForBestemmelse)

MEDL Integration

Synchronization Points

Saga StepWhen
LAGRE_MEDLEMSKAPSPERIODE_MEDLAfter vedtak, writes INNVILGET periods to MEDL
Re-assessmentUpdates/terminates existing MEDL periods
OpphørChanges period status to AVST (terminated)

medlPeriodeID

  • Created when period is first synced to MEDL
  • Used for subsequent updates
  • NULL means period not yet in MEDL (or MEDL write failed)

See Also

Refer to medl skill for detailed MEDL integration patterns.

Debugging Queries

Find Medlemskapsperioder for Behandling

SELECT mp.*, br.behandling_id
FROM medlemskapsperiode mp
JOIN behandlingsresultat br ON mp.behandlingsresultat_id = br.behandling_id
WHERE br.behandling_id = :behandlingId
ORDER BY mp.fom_dato;

Find Periods by Person

-- The person/aktør is not a column on fagsak; it lives in the aktoer table
-- (rolle BRUKER) joined on saksnummer.
SELECT mp.*, b.id as behandling_id, f.saksnummer
FROM medlemskapsperiode mp
JOIN behandlingsresultat br ON mp.behandlingsresultat_id = br.behandling_id
JOIN behandling b ON br.behandling_id = b.id
JOIN fagsak f ON b.saksnummer = f.saksnummer
JOIN aktoer a ON a.saksnummer = f.saksnummer AND a.rolle = 'BRUKER'
WHERE a.aktoer_id = :aktorId
ORDER BY mp.fom_dato DESC;

Check MEDL Sync Status

SELECT mp.id, mp.fom_dato, mp.tom_dato, mp.innvilgelse_resultat,
       mp.medlemskapstype, mp.medlperiode_id
FROM medlemskapsperiode mp
JOIN behandlingsresultat br ON mp.behandlingsresultat_id = br.behandling_id
WHERE br.behandling_id = :behandlingId
AND mp.medlperiode_id IS NULL;  -- Not synced to MEDL

Find Periods with Trygdeavgift

SELECT mp.*, tp.id as avgift_id, tp.trygdeavgift_beloep_mnd_verdi, tp.trygdeavgift_beloep_mnd_valuta
FROM medlemskapsperiode mp
JOIN trygdeavgiftsperiode tp ON tp.medlemskapsperiode_id = mp.id
WHERE mp.behandlingsresultat_id = :behandlingsresultatId;

Check Period Validation Issues

SELECT mp.*, b.beh_tema, f.fagsak_type as sakstype
FROM medlemskapsperiode mp
JOIN behandlingsresultat br ON mp.behandlingsresultat_id = br.behandling_id
JOIN behandling b ON br.behandling_id = b.id
JOIN fagsak f ON b.saksnummer = f.saksnummer
WHERE mp.tom_dato IS NULL
AND mp.bestemmelse != 'FTRL_KAP2_2_1';  -- Open-ended but not bosatt

Common Issues

IssueSymptomsInvestigation
Wrong medlemskapstypePLIKTIG shown as FRIVILLIGCheck bestemmelse vs PliktigeMedlemskapsbestemmelser
Missing period proposalsNo periods generatedCheck vilkår fulfillment, bestemmelse-dekning combo
Invalid trygdedekningFunksjonellExceptionCheck LovligeKombinasjonerTrygdedekningBestemmelse
tom-dato required errorCan't save open-ended periodOnly allowed for FTRL_KAP2_2_1 with land=NO
MEDL sync failedmedlPeriodeID is NULLCheck prosessinstans status, MEDL API logs
Period overlapKontroll warningCheck existing periods in MEDL via MedlemskapDokument

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

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.

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

See all skills by navikt

Report a problem with this skill