| name | behandlingsresultat |
| description | 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.
|
Behandlingsresultat Domain
Behandlingsresultat captures the outcome of a Behandling, including which law applies, membership status,
periods, decision metadata, and eligibility criteria results.
Quick Reference
Entity Structure
Behandling (1)
↓ OneToOne
Behandlingsresultat
├─ VedtakMetadata (decision date, appeal deadline)
├─ Lovvalgsperiode* (law choice periods)
│ └─ Trygdeavgiftsperiode*
├─ Medlemskapsperiode* (membership periods)
│ └─ Trygdeavgiftsperiode*
├─ Anmodningsperiode* (Article 16 request periods)
│ └─ AnmodningsperiodeSvar
├─ Utpekingsperiode* (designation periods)
├─ Vilkaarsresultat* (eligibility criteria)
├─ Kontrollresultat* (verification results)
├─ Avklartefakta* (clarified facts)
└─ HelseutgiftDekkesPeriode (EEA pensioner health coverage)
Key Attributes
| Attribute | Type | Description |
|---|
type | Behandlingsresultattyper | IKKE_FASTSATT, FASTSATT_LOVVALGSLAND, MEDLEM_I_FOLKETRYGDEN, etc. |
behandlingsmåte | Behandlingsmaate | AUTOMATISERT, MANUELT, DELVIS_AUTOMATISERT |
fastsattAvLand | Land_iso2 | Country that determined the result |
vedtakMetadata | VedtakMetadata | Decision date and appeal deadline |
begrunnelseFritekst | String? | Free-text justification |
Result Types (Behandlingsresultattyper)
| Type | Description | Use Case |
|---|
IKKE_FASTSATT | Not determined | Initial state |
FASTSATT_LOVVALGSLAND | Law choice country set | EU/EEA lovvalg |
MEDLEM_I_FOLKETRYGDEN | Member of Norwegian NI | FTRL membership |
UNNTATT_MEDLEMSKAP | Exempt from membership | Non-member |
AVSLAG_SØKNAD | Application denied | Rejection |
OPPHØRT | Membership terminated | Termination |
ANMODNING_OM_UNNTAK | Article 16 exception request | Sent to foreign authority |
REGISTRERT_UNNTAK | Registered exception | Exception approved |
HENLEGGELSE | Case dismissed | Dropped case |
FERDIGBEHANDLET | Completed | Generic completion |
MEDHOLD | Appeal upheld | Klage result |
OMGJORT | Decision reversed | Klage result |
Period Types
Lovvalgsperiode (Law Choice Period)
Determines which country's social security law applies.
lovvalgsperiode.lovvalgsland
lovvalgsperiode.bestemmelse
lovvalgsperiode.innvilgelsesresultat
lovvalgsperiode.medlemskapstype
lovvalgsperiode.dekning
Medlemskapsperiode (Membership Period)
Membership in Norwegian National Insurance (folketrygden).
medlemskapsperiode.innvilgelsesresultat
medlemskapsperiode.medlemskapstype
medlemskapsperiode.trygdedekning
medlemskapsperiode.bestemmelse
Anmodningsperiode (Article 16 Request Period)
Request for exception under EU Regulation Article 16.
anmodningsperiode.sendtUtland
anmodningsperiode.anmodetAv
anmodningsperiode.anmodningsperiodeSvar
Utpekingsperiode (Designation Period)
Provisional designation of applicable law (EU/EFTA).
Common Operations
Fetching Behandlingsresultat
val resultat = behandlingsresultatService.hentBehandlingsresultat(behandlingId)
val resultat = behandlingsresultatService.hentBehandlingsresultatMedAnmodningsperioder(behandlingId)
val resultat = behandlingsresultatService.hentResultatMedMedlemskapOgLovvalg(behandlingId)
Status Checks
resultat.erInnvilgelse()
resultat.erAvslag()
resultat.erOpphørt()
resultat.erAnmodningOmUnntak()
resultat.erUtpeking()
resultat.erAutomatisert()
resultat.erRegistrertUnntak()
Period Access
val lovvalg = resultat.hentLovvalgsperiode()
val anmodning = resultat.hentAnmodningsperiode()
val lovvalg: Optional<Lovvalgsperiode> = resultat.finnLovvalgsperiode()
val periode: PeriodeOmLovvalg? = resultat.finnValidertPeriodeOmLovvalg()
val medlemsperioder = resultat.medlemskapsperioder
Trygdeavgift (Social Insurance Charges)
val avgiftsPerioder = resultat.finnAvgiftspliktigPerioder()
resultat.harInnvilgetAvgiftspliktigPeriodeSomOverlapperMedÅr(2024)
val trygdeavgift = resultat.trygdeavgiftsperioder
VedtakMetadata (Decision)
resultat.harVedtak()
resultat.settVedtakMetadata(
vedtaksdato = Instant.now(),
vedtakKlagefrist = LocalDate.now().plusWeeks(6)
)
Clearing for Reprocessing
behandlingsresultatService.tømBehandlingsresultat(resultat)
behandlingsresultatService.tømMedlemskapsperioder(resultat)
Important Interfaces
PeriodeOmLovvalg
Implemented by: Lovvalgsperiode, Anmodningsperiode, Utpekingsperiode
interface PeriodeOmLovvalg {
val lovvalgsland: Land_iso2
val bestemmelse: LovvalgBestemmelse?
}
AvgiftspliktigPeriode
Implemented by: Lovvalgsperiode, Medlemskapsperiode
interface AvgiftspliktigPeriode {
val trygdeavgiftsperioder: Set<Trygdeavgiftsperiode>
}
Key Services
BehandlingsresultatService
hentBehandlingsresultat() - Fetch by ID
lagreNyttBehandlingsresultat() - Create (initial: IKKE_FASTSATT, MANUELT)
oppdaterBehandlingsresultattype() - Update type
tømBehandlingsresultat() - Clear for reprocessing
AngiBehandlingsresultatService
oppdaterBehandlingsresultattypeOgAvsluttFagsakOgBehandling() - Set type with validation and close case
- Validates result type against case type, theme, and treatment type
ReplikerBehandlingsresultatService
replikerBehandlingsresultat() - Clone result for replicated treatment
- Deep clones all relationships, resets to IKKE_FASTSATT/MANUELT
Important Gotchas
1. Single Period Assumption
Some methods assume only one period of a type exists:
resultat.hentLovvalgsperiode()
resultat.finnLovvalgsperiode()
2. Type-Driven Logic
Business logic depends heavily on type and fagsak.erLovvalg():
val perioder = if (fagsak.erLovvalg()) {
resultat.lovvalgsperioder
} else {
resultat.medlemskapsperioder
}
3. Cascade Deletion
All child entities use CascadeType.ALL with orphanRemoval = true.
Removing a period from the collection deletes it from the database.
4. Conditional Eager Loading
Use specific service methods to optimize loading:
hentBehandlingsresultatMedAnmodningsperioder()
hentResultatMedMedlemskapOgLovvalg()
Debugging
Find Behandlingsresultat
SELECT br.* FROM behandlingsresultat br
WHERE br.id = :behandlingId;
Find All Periods for a Result
SELECT * FROM lovvalgsperiode WHERE behandlingsresultat_id = :id;
SELECT * FROM medlemskapsperiode WHERE behandlingsresultat_id = :id;
SELECT * FROM anmodningsperiode WHERE behandlingsresultat_id = :id;
Find Results Without Decision
SELECT br.id, b.status
FROM behandlingsresultat br
JOIN behandling b ON b.id = br.id
LEFT JOIN vedtak_metadata vm ON vm.behandlingsresultat_id = br.id
WHERE vm.id IS NULL
AND br.type != 'IKKE_FASTSATT';
Find Results with Multiple Periods (potential issue)
SELECT br.id, COUNT(*) as period_count
FROM behandlingsresultat br
JOIN lovvalgsperiode lp ON lp.behandlingsresultat_id = br.id
GROUP BY br.id
HAVING COUNT(*) > 1;
Detailed Documentation