Skip to content
cccskills
FreePublished on GitHub

behandling

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.

See how to install

Files included (3)

  • SKILL.md7.7 KB
  • references/debugging.md9.7 KB
  • references/kodeverk.md6.6 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Behandling Domain

Behandling (case treatment) is the core domain entity in melosys-api representing an individual processing instance within a Fagsak (case). Each behandling tracks the lifecycle of one decision-making process from creation through to closure.

Quick Reference

Domain Model Hierarchy

Fagsak (Case)
├── saksnummer: String (PK — no numeric id)
├── type: Sakstyper (EU_EOS, FTRL, TRYGDEAVTALE)
├── tema: Sakstemaer
├── status: Saksstatuser
└── behandlinger: List<Behandling>  (linked via saksnummer FK)

    Behandling (Treatment)
    ├── id: Long
    ├── status: Behandlingsstatus
    ├── type: Behandlingstyper
    ├── tema: Behandlingstema
    ├── behandlingsfrist: LocalDate
    ├── registrertDato / endretDato: Instant
    └── behandlingsresultat: Behandlingsresultat

        Behandlingsresultat  (PK is behandling_id — no separate id)
        ├── type: Behandlingsresultattyper
        ├── medlemskapsperioder: List<Medlemskapsperiode>
        ├── lovvalgsperioder: List<Lovvalgsperiode>
        └── vedtakMetadata: VedtakMetadata

Key Enums

EnumValuesDescription
BehandlingsstatusOPPRETTET, UNDER_BEHANDLING, AVSLUTTET, IVERKSETTER_VEDTAK, MIDLERTIDIG_LOVVALGSBESLUTNING, AVVENT_DOK_UTL, AVVENT_DOK_PARTCurrent processing state
BehandlingstyperFØRSTEGANG, NY_VURDERING, HENVENDELSE, KLAGE, ENDRET_PERIODE, MANGLENDE_INNBETALING_TRYGDEAVGIFT, ÅRSAVREGNING, SATSENDRINGType of processing
BehandlingstemaYRKESAKTIV, IKKE_YRKESAKTIV, PENSJONIST, UTSENDT_ARBEIDSTAKER, ARBEID_FLERE_LAND, etc.Subject matter

Behandling Lifecycle

OPPRETTET → UNDER_BEHANDLING → IVERKSETTER_VEDTAK → AVSLUTTET
                   │                                    ↑
                   ├── AVVENT_DOK_UTL ─────────────────┤
                   ├── AVVENT_DOK_PART ────────────────┤
                   └── MIDLERTIDIG_LOVVALGSBESLUTNING

MIDLERTIDIG_LOVVALGSBESLUTNING counts as INACTIVE (erInaktiv()) and is
not editable; it does not flow straight to AVSLUTTET like the AVVENT_* states.

Behandling Creation Paths

1. Journalføring (Document Registration)

// JFR_NY_SAK_BRUKER saga
prosessinstansService.opprettProsessinstansJournalføringNySakBruker(journalpostId, ...)
// Creates: Fagsak + Behandling + Oppgave

2. SED Reception (EESSI)

// REGISTRERING_UNNTAK_NY_SAK, ARBEID_FLERE_LAND_NY_SAK, etc.
sedMottakOpprettFagsakOgBehandling.utfør(prosessinstans)
// Creates behandling from incoming SED

3. Ny Vurdering (Re-evaluation)

// From journalføring/digital søknad to an existing sak.
// opprettNyVurdering is a private helper inside the saksflyt step
// HåndterEksisterendeSakDigitalSøknad; it ultimately calls
// BehandlingService.nyBehandling(fagsak, status, type, tema, ...).

4. Automatic Creation

// OPPRETT_NY_BEHANDLING_MANGLENDE_INNBETALING
// OPPRETT_NY_BEHANDLING_AARSAVREGNING
prosessinstansService.opprettProsessinstansNyBehandlingManglendeInnbetaling(...)

Status Transitions

Legal Transitions

FromToTrigger
OPPRETTETUNDER_BEHANDLINGSaksbehandler opens case
UNDER_BEHANDLINGIVERKSETTER_VEDTAKfattVedtak() called
UNDER_BEHANDLINGAVVENT_DOK_UTLWaiting for foreign authority
UNDER_BEHANDLINGAVVENT_DOK_PARTWaiting for user documents
UNDER_BEHANDLINGMIDLERTIDIG_LOVVALGSBESLUTNINGArt. 13 provisional decision
IVERKSETTER_VEDTAKAVSLUTTETVedtak saga completes
AVVENT_*UNDER_BEHANDLINGDocuments received
Any activeAVSLUTTETManual close via behandlingsmeny

Status Helper Methods

behandling.erInaktiv()      // AVSLUTTET or MIDLERTIDIG_LOVVALGSBESLUTNING
behandling.erAktiv()        // !erInaktiv() (everything except those two)
behandling.erAvsluttet()    // AVSLUTTET
behandling.erRedigerbar()   // erAktiv() && status != IVERKSETTER_VEDTAK
                            //   && !(ANMODNING_UNNTAK_SENDT && tema != IKKE_YRKESAKTIV)
behandling.erVenterForDokumentasjon()  // AVVENT_DOK_PART, AVVENT_DOK_UTL, ANMODNING_UNNTAK_SENDT

Service Layer

BehandlingService

Location: service/src/main/java/no/nav/melosys/service/behandling/BehandlingService.java

Key operations:

  • hentBehandling(behandlingId) - Get by ID
  • nyBehandling(fagsak, status, type, tema, ...) - Create a new behandling
  • endreStatus(behandling, status) / endreStatus(behandlingID, status) - Change status
  • endreBehandling(behandlingID, nyType, nyTema, nyStatus, nyMottaksdato) - Edit type/tema/status/frist
  • avsluttBehandling(behandlingId) / avsluttBehandling(behandlingId, behandlingsresultattype: Behandlingsresultattyper) - Close treatment

BehandlingsresultatService

Location: service/src/main/kotlin/no/nav/melosys/service/behandling/BehandlingsresultatService.kt

Key operations:

  • hentBehandlingsresultat(behandlingsid) - Get result
  • lagre(resultat) - Save result
  • lagreNyttBehandlingsresultat(behandling) - Create a fresh (IKKE_FASTSATT) result for a behandling
  • oppdaterBehandlingsresultattype(id, type) - Set the result type

Debugging Queries

Find Behandling by ID

SELECT b.*, f.saksnummer
FROM behandling b
JOIN fagsak f ON b.saksnummer = f.saksnummer
WHERE b.id = :behandlingId;

Find Active Behandlinger for Person

-- behandling links to fagsak via saksnummer; the actor (aktoer_id) lives in aktoer
SELECT b.*, f.saksnummer
FROM behandling b
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
AND b.status NOT IN ('AVSLUTTET');

Find Stuck Behandlinger

SELECT b.id, b.status, b.endret_dato, f.saksnummer
FROM behandling b
JOIN fagsak f ON b.saksnummer = f.saksnummer
WHERE b.status = 'IVERKSETTER_VEDTAK'
AND b.endret_dato < SYSDATE - INTERVAL '2' HOUR;

Check Behandling with Prosessinstans

-- saga progress is tracked via prosessinstans.status + sist_fullfort_steg
SELECT b.id, b.status, p.prosess_type, p.status as prosess_status, p.sist_fullfort_steg
FROM behandling b
LEFT JOIN prosessinstans p ON p.behandling_id = b.id
WHERE b.id = :behandlingId
ORDER BY p.registrert_dato DESC;

Common Issues

IssueSymptomsInvestigation
Stuck in IVERKSETTER_VEDTAKCan't edit behandlingCheck prosessinstans status / sist_fullfort_steg
Wrong behandlingstypeValidation errorsCheck journalføring logic
Missing behandlingsresultatNullPointerCheck saga completed successfully
Can't create ny vurderingFunksjonellExceptionCheck fagsak.status and existing active behandling
Status not updatingStale data in UICheck audit trail, version conflicts

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 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