/****************************************************************************
** Leistungsorientierte Krankenanstaltenfinanzierung (LKF)                 **
** Scoring-C-Sourcen V2026.1                                               **
** (C) 2026 BMASGPK                                                        **
*****************************************************************************
** lkf5defs.h - Schnittstellendefinitionen                                 **
**                                                                         **
**		 Alex.Holzer@chello.at                                             **
**       Bernhard.Pesec@dothealth.at                                       **
***************************************************************************/

#ifndef LKF5DEFS_H
#define LKF5DEFS_H

#if defined (__APPLE__)
#pragma clang diagnostic ignored "-Winvalid-source-encoding"
#endif


#ifndef _SCORING_EXPORT
#ifdef _USRDLL
#define _SCORING_EXPORT _declspec(dllexport)
#else
#define _SCORING_EXPORT
#endif
#endif

#define _CRT_SECURE_NO_DEPRECATE 1

// Unterstuetzung Modelle 2009 - 2016
//#define SUPPORT_PRE2017 1

#define LKF_VERSION "30.1"     /* V2026.1 */
#ifdef SUPPORT_PRE2017
#define LKF_YEAR_FIRST  2009
#else
#define LKF_YEAR_FIRST  2017   
#endif
#define LKF_YEAR_LATEST 2026   /* V2026.0 */

#define LKF_INCLUDE_DEPRECATED_FUNCTIONALITY

#define NPPLAUS_WARNING       32
#define NPPLAUS_NUR_NEON      33
#define NPPLAUS_NUR_UEB       34
#define NPPLAUS_7299		  35
#define NPPLAUS_MELOHNEDAT	  40

#define PSYCH_IGNOREMEL	  36 /* V7.2 */

#define SPEZ_ABTFC_UNGUELTIG 38 /* V8.0 */
#define ABTFC_19_WARNING 39
/*
#define MIN_WARNINGCODE_NUM   1 
#define MAX_WARNINGCODE_NUM  50
*/

/*************************************************************************
** Konstante fuer Kriterien                                              **
*************************************************************************/

#define PAT_KRIT_DIFF				0			
#define PAT_KRIT_EQUAL				1
#define PAT_KRIT_GREATER			2
#define PAT_KRIT_GREATER_EQUAL      3
#define PAT_KRIT_LESS				4
#define PAT_KRIT_LESS_EQUAL			5
#define PAT_KRIT_WILDCARD_DIFF		8
#define PAT_KRIT_WILDCARD_EQUAL		9
#define PAT_KRIT_SUBAUSDRUCK	   -2
#define PAT_KRIT_NEGATE			   -3
#define PAT_KRIT_WILDCARD_ONE_CHARACTER   '%'
#define PAT_KRIT_WILDCARD_SOME_CHARACTERS '*'

/* Konstanten für die Position repetierender Felder */
#define PAT_KRIT_ABTEILUNG		   -100
#define PAT_KRIT_ZD				   -200
#define PAT_KRIT_HD_or_ZD		   -300
#define PAT_KRIT_MEL			   -400


#define PERIODE_TAG			'T'
#define PERIODE_MONAT		'M'
#define PERIODE_QUARTAL		'Q'
#define PERIODE_HALBJAHR	'H'
#define PERIODE_JAHR		'J'

/* Macros */

#define IS_SCHALTJAHR(j)  (!((j)&3) && (((j)%100) || !((j)%400))) 


/* V8.1: Konstanten fuer Error-Output */
#define CHECKFIELD_KANR           2
#define CHECKFIELD_AUFNR		  3
#define CHECKFIELD_AUFDAT		 40
#define CHECKFIELD_GEBDAT		  4
#define CHECKFIELD_GESCHL		  6
#define CHECKFIELD_ENTDAT		 16
#define CHECKFIELD_SATZART		101
#define CHECKFIELD_CODE			102
#define CHECKFIELD_IDENT		103
#define CHECKFIELD_MASSNAHME	104
#define CHECKFIELD_TEXT			105 /* Laenge dynamisch - als letzte Spalte geeignet */
#define CHECKFIELD_ACCEPTABLE   119 /* V2020.1: Error/Warning akzeptierbar */
#define CHECKFIELD_TEXT150CHAR  110 /* V21.1 - 150 Zeichen (und moeglicherweise etwas mehr Byte in UTF8) */
#define CHECKFIELD_TEXT150BYTE  111 /* V21.1 - 150 Byte lang */
#define CHECKFIELD_FELD			106
#define	CHECKFIELD_FELDID		107
#define CHECKFIELD_FELDNAME		108
#define CHECKFIELD_FELD_LANG	109
#define CHECKFIELD_BERICHTSTYP	120 /* V14.2 */
#define CHECKFIELD_ENTABT		 38
#define CHECKFIELD_ABTFC         71 /* V10.1 */
#define CHECKFIELD_ABTFCENT      72 /* V10.1 */
#define CHECKFIELD_ABTFCINDEX	 73	/* V10.1 */
#define CHECKFIELD_ABTFCENTINDEX 74 /* V10.1 */
#define CHECKFIELD_AUFABT        77 /* V2025.1 */
#define CHECKFIELD_ENTABTINDEX   75 /* V10.1 */
#define CHECKFIELD_KST           81 /* V11.0 */
#define CHECKFIELD_ENTKST        82 /* V11.0 */
#define CHECKFIELD_KST_ENTKST    83 /* V11.0 */
#define CHECKFIELD_AUFID64       13 /* V19.0 */
#define CHECKFIELD_ALTER         14 /* V19.0 */
#define CHECKFIELD_ALTER2        12 /* V19.0 */
#define CHECKFIELD_FUCOAUFNR     15 /* V21.1 */
#define CHECKFIELD_CHILD_IDENT   18 /* V22.1 */
#define CHECKFIELD_AUFENTHALTINDEX 99 /* V2023.0 */

/* Konstanten fuer den Custom-Output */
#define SCORFIELD_FLAG           1
#define SCORFIELD_KANR			 2
#define SCORFIELD_AUFNR			 3
#define SCORFIELD_GEBDAT		 4
#define SCORFIELD_ALTER			 5
#define SCORFIELD_GESCHL		 6
#define SCORFIELD_STAATB		 7
#define SCORFIELD_STAATW		 8
#define SCORFIELD_PLZW			 9
#define SCORFIELD_AUFART		10
#define SCORFIELD_NEUGEB        11
#define SCORFIELD_ALTERSGRUPPE  12
#define SCORFIELD_AUFID         13
#define SCORFIELD_GESVD			14
#define SCORFIELD_ENTART		15
#define SCORFIELD_ENTDAT		16
#define SCORFIELD_HD			17
#define SCORFIELD_KOST			20
#define SCORFIELD_GRP			21
#define SCORFIELD_KNO			22
#define SCORFIELD_VDU			23
#define SCORFIELD_VDO			24
#define SCORFIELD_VDMW			25
#define SCORFIELD_LDFPTK		26
#define SCORFIELD_LDFPLK		27
#define SCORFIELD_SCUTK			28
#define SCORFIELD_SCULK			29
#define SCORFIELD_VDZU			30
#define SCORFIELD_INTZU			31
#define SCORFIELD_MELZU			32
#define SCORFIELD_SCSPEZ		33
#define SCORFIELD_SCGES			34
#define SCORFIELD_LDFPK			35
#define SCORFIELD_SCUK			36
#define SCORFIELD_MELANZ		37 /* für Filter-Routinen */
#define SCORFIELD_ENTABT		38 /* Entlassende Abteilung */
#define SCORFIELD_AUFABT		39 /* Aufnehmende Abteilung */
#define SCORFIELD_AUFDAT        40
#define SCORFIELD_SCGES_INLKF   41 /* V5.1: Gesamtpunkte innerhalb LKF */
#define SCORFIELD_SCGES_EXLKF   42 /* V5.1: Gesamtpunkte außerhalb LKF */
#define SCORFIELD_SCUTK_TKL     43 /* V5.1T */
#define SCORFIELD_SCGES_TKL     44 /* V5.1T */
#define SCORFIELD_SCGES_INLKF_TKL   45 /* V5.1T: Gesamtpunkte innerhalb LKF */
#define SCORFIELD_SCGES_EXLKF_TKL   46 /* V5.1T: Gesamtpunkte außerhalb LKF */
#define SCORFIELD_LKA           47
#define SCORFIELD_SCUTK_NOTKL	48
#define SCORFIELD_SCGES_STAT    50 /* V21.1 */
#define SCORFIELD_SCGES_AMB     51 /* V21.1 */
#define SCORFIELD_GESVD_MINUS   52 /* V2026.0 */
#define SCORFIELD_GESVD_SPEZ    53 /* V2026.0 */


#define SCORFIELD_BEHANDLUNGSART 61 /* V21.6 */

#define SCORFIELD_MAX_SUBINDEX  95 /* V13.1 */
#define SCORFIELD_MAXMELINDEX   96 /* V13.1 */
#define SCORFIELD_TKLMEL        97 /* V13.1 */
#define SCORFIELD_NR			98
#define SCORFIELD_MARK			99
#define SCORFIELD_ERRORCOUNT   110
#define SCORFIELD_MAXMELMELINDEX 111

#define SCORFIELD_AUFKEY       103

/* Konstanten Für Scoring_GetValue */
#define SCORVAL_LDFPAUSCHALE			0
#define SCORVAL_VERWEILDAUER_UNTEN		1
#define SCORVAL_VERWEILDAUER_OBEN		2
#define SCORVAL_ZUSATZ_INTENSIV			3
#define SCORVAL_ZUSATZ_MEHRFACH			4
#define SCORVAL_PKT_SPEZIFISCH			5
#define SCORVAL_PKT_TOTAL				6
#define SCORVAL_LDF_TAGESANTEIL			7
#define SCORVAL_LDF_LEISTUNGSANTEIL		8
#define SCORVAL_VD_UNTEN_TAGESANTEIL    9
#define SCORVAL_VD_UNTEN_LEISTUNGSANTEIL 10

/* Constanten für private Stammdaten im LKF-Context */
#define LKFCONTEXT_USE_ALL_PRIVATE        (LKFCONTEXT_USE_PRIVATE_SPEZLIST+LKFCONTEXT_USE_PRIVATE_KOSTLIST+LKFCONTEXT_USE_PRIVATE_MELKALIST)

/* Sonstige FLAGS-Konstanten */
#define LKFCONTEXT_MODUS_BMG              (1<<0)    /* V19: 1 - Modus BMG ab Modell 2015 */
#define LKFCONTEXT_STANDORT               (1<<3)    /* V19: Schaltet Standort-Info aus (2015) bzw. ein (2014) */
#define LKFCONTEXT_FILL_BMG               (1<<4)    /* V19: BMG-Felder ausfüllen */
#define LKFCONTEXT_UTF8                   (1<<5)    /* V21: Schaltet UTF-8-Output ein/aus */
#define LKFCONTEXT_ALLOWQUICKSCORE        (1<<6)   /* V6.0 */
#define LKFCONTEXT_OPTIMIZER              (1<<7)   /* V6.0 */
#define LKFCONTEXT_AKWARNREPLACEVALUE     (1<<8)   /* V2022.1 - abt 000: wird durch tats. Abteilung ersetzt */
#define LKFCONTEXT_NPPLAUS                (1<<11)   /* V7.2 */
#define LKFCONTEXT_NICHTFONDSKA			  (1<<12)
#define LKFCONTEXT_NUR_MBDS               (1<<13)    /* V9.4: fuehrt nur den MBDS-Plaus-Check durch (keine Ueberpruefung bezueglich Kostenstellenplan, Intensiv */
#define LKFCONTEXT_INTENSIV               (1<<14)   /* V14.0: fuehrt den Intensiv-Modus auch durch, wenn NUR_MBDS gesetzt ist */
#define LKFCONTEXT_AUFPLAUS_IERRORS		  (1<<16)   /* V10.1 */
#define LKFCONTEXT_EXTENDED_ERROR_INFO    (1<<17)   /* V11.1: 131072 */
#define LKFCONTEXT_OSG					  (1<<18)   /* V11.1: 262144 schaltet die Plaus-Zusatzueberpruefung fuer OSG ein */
#define LKFCONTEXT_DISABLE_SOME_CHECKS	  (1<<19)	/* V12.0: 524288 schaltet manche Errors/Warnings aus  */
	/* derzeit: EK71 */
#define LKFCONTEXT_IMPLICIT_YEAR          (1<<20)   /* V12.1: 1048576: Abrechnungsjahr wird aus der Datei ermittelt - fuer Testzwecke */

#define LKFCONTEXT_CHECKINTE0			  (1<<21)   /* V2024.1: 2097152: Plaus-Check fuer E0 */
#define LKFCONTEXT_SIM1                    LKFCONTEXT_CHECKINTE0 /* compatibility */
#define LKFCONTEXT_SIM2                   (1<<22)   /* V13.0: 4194304: Simulation 2 */
#define LKFCONTEXT_OSG_WARN                  (1<<23)   /* V14.2: 8388608: schaltet die Plaus-Zusatzueberpruefung fuer OSG ein - aber erzeugt nur Warnings */
#define LKFCONTEXT_ACCEPT_ALL_ERRORS      (1<<24)   /* V14.2: 16777216: alle akzeptierbaren Errors werden automatisch akzeptiert */
#define LKFCONTEXT_ACCEPT_ALL_WARNINGS    (1<<25)   /* V14.2: 33554432: alle akzeptierbaren Warnings werden automatisch akzeptiert */
#define LKFCONTEXT_SIM3                   (1<<26)   /* V19.1: 67108864: Simulation 3 */
#define LKFCONTEXT_SIM4                   (1<<27)   /* V2020.1: 134217728*/
#define LKFCONTEXT_EXPORTX04RESULTS       (1<<28)   /* V2020.1: 268435456 */
#define LKFCONTEXT_EXPORT_MELPOS          (1<<29)   /* V2023.1: 536870912 */

#ifdef SUPPORT_PRE2017
#define LKFCONTEXT_SATZART_INPUT_M        (1<<2)    /* V21: Erlaubt im Modell 2017 (ul) die Verwendung von Satzart M */
#endif

#define SA1EXLEN	  330		/* incl. 2 byte recordterminator*/
#define POS_PKTETOTAL 319
#define SA1LEN		  263		/* incl. 2 byte recordterminator*/

#define NOLKF_KA_ERR	19
#define DIFF_KAS_ERR	13

#define MASSNAHME_KORR  1
#define MASSNAHME_PRUEF 2

#define LKFCONTEXT_IGNORE_2017ERRORS LKFCONTEXT_SIM2

#define LKFDIFF_PLAUS   1
#define LKFDIFF_SCGES   (1<<1)


/* V22.0: Konstanten fuer lAmbCounter */

#define LKF_AMBCOUNT_CHEMO          0
#define LKF_AMBCOUNT_PSYCHTAG       1
#define LKF_AMBCOUNT_ZAE            2
#define LKF_AMBCOUNT_TKL            3 /* V2019.0 */
#define LKF_AMBCOUNT_ABTFC         10 /* V2020.1 */

/* V24.0: Errorcodes */
#define LKFCERROR_OK                0
#define LKFCERROR_GENERAL          -1
#define LKFCERROR_OUTOFBOUNDS      -2
#define LKFCERROR_NULLREF          -3
#define LKFCERROR_UNSUPPORTED      -4
#define LKFCERROR_INVALIDID        -5
#define LKFCERROR_INVALIDFORMAT    -6
#define LKFCERROR_NOCASE           -8
#define LKFCERROR_NOCONTEXT        -9

typedef struct LKF_METADATA LKF_METADATA;
typedef struct LKF_CONTEXT LKF_CONTEXT;
typedef struct LKF_ANONYMISATION_CONTEXT LKF_ANONYMISATION_CONTEXT;
typedef struct LKF_CONTEXT_ERRORFORMAT LKF_CONTEXT_ERRORFORMAT;
typedef struct LKF_AUFENTHALT LKF_AUFENTHALT;
typedef struct LKF_KNOTEN LKF_KNOTEN;
typedef struct LKF_ERROR_LIST LKF_ERROR_LIST;
typedef struct LKF_FILTER LKF_FILTER;
typedef struct LKF_BATCH_PROCESSING LKF_BATCH_PROCESSING;
typedef struct LKF_SATZART_DEFS LKF_SATZART_DEFS;
typedef struct LKF_SATZART_ERROR LKF_SATZART_ERROR;
typedef struct LKF_MEL_CUSTOM_CHECK LKF_MEL_CUSTOM_CHECK;

typedef struct LKF_SATZART_ERRORINFO_USAGE LKF_SATZART_ERRORINFO_USAGE;
typedef struct LKF_SATZART_ERRORINFO_LIST LKF_SATZART_ERRORINFO_LIST;
typedef struct LKF_SATZART_ERRORINFO LKF_SATZART_ERRORINFO;

#define LKF_FILE_ERROR			0
#define LKF_FILE_WARNING		1
#define LKF_FILE_ABT			2
#define LKF_FILE_MELDEDIAG      3


#define LKF_OUTOFMEMORY_UINTERROR 99999999
#define LKF_OUTOFMEMORY_ERROR     -99999999

#ifdef _WIN32
typedef const char *(__stdcall *STAMM_ADD_LINE_FUNC) (LKF_CONTEXT *, const char *);
typedef const char *(__stdcall *STAMM_FILE_PATH_FUNC) (LKF_CONTEXT *, const char *);
typedef int (__stdcall *DATAPROVIDER_MODEL_FILE_FUNC) (int modelYear, const char *fileName, int buflen, char *buf); /* V2020.5 */
typedef void * (__stdcall *ALLOC_SEMAPHORE_CALLBACK)(void);
typedef void (__stdcall *SEMAPHORE_CALLBACK)(void *);
typedef long (__stdcall *ALLOC_SEMAPHORE_CALLBACK2)(void);
typedef void (__stdcall *SEMAPHORE_CALLBACK2)(long);
typedef int (__stdcall *LKFEXECUTION_DELEGATE) (LKF_CONTEXT *pContext, const char *step, unsigned int sum);
typedef void (__stdcall *LKFTRACE_DELEGATE) (LKF_CONTEXT *, const char *);
typedef void (__stdcall *LKFMEMORY_DELEGATE) (LKF_CONTEXT *, const char *, const char *, long long ptr, long elem, long siz);
#else
typedef const char* (* STAMM_ADD_LINE_FUNC) (LKF_CONTEXT*, const char*);
typedef const char* (* STAMM_FILE_PATH_FUNC) (LKF_CONTEXT*, const char*);
typedef int (* DATAPROVIDER_MODEL_FILE_FUNC) (int modelYear, const char* fileName, int buflen, char* buf); /* V2020.5 */
typedef void * (*ALLOC_SEMAPHORE_CALLBACK)(void);
typedef void (*SEMAPHORE_CALLBACK)(void *);
typedef long (*ALLOC_SEMAPHORE_CALLBACK2)(void);
typedef void (*SEMAPHORE_CALLBACK2)(long);
typedef int (*LKFEXECUTION_DELEGATE) (LKF_CONTEXT *pContext, const char *step, unsigned int sum);
typedef void (*LKFTRACE_DELEGATE) (LKF_CONTEXT *, const char *);

typedef void (*LKFMEMORY_DELEGATE) (LKF_CONTEXT *, const char *, const char *, long long ptr, long elem, long siz);

#endif


/* Error Severity */

#define LKF_SEV_FATAL    8
#define LKF_SEV_ERROR    4
#define LKF_SEV_WARNING  2
#define LKF_SEV_INFO     1
#define LKF_SEV_WARNING_PRUEF  2
#define LKF_SEV_WARNING_KORR 258
#define LKF_SEV_ACCEPTABLE 512

/* Error Facility */

#define LKF_FAC_ALL		 0	/* Error (Warning) fuer alle Bereiche */
#define LKF_FAC_MBDS     1	/* Error (Warning) im MBDS-Bereich */
#define LKF_FAC_INTSCOR  2	/* Error (Warning) im Intensiv-Scoring-Bereich */
#define LKF_FAC_KAS_KORE 3	/* Error (Warning) im KAS-KORE-Bereich */
#define LKF_FAC_GG       4	/* Error (Warning) im Großgeraete-Bereich */
#define LKF_FAC_BERICHT  5  /* V14.2: Error (Warning) im Berichts-Bereich */
#define LKF_FAC_A        6  /* V14.2: Error (Warning) im Berichts-Bereich */
#define LKF_FAC_ALLOC	 7

#define LKF_ERRORFILTER_GENERALERROR	1
#define LKF_ERRORFILTER_MBDSERROR		(1<<LKF_FAC_MBDS)						/* =     2 */
#define LKF_ERRORFILTER_INTSCORERROR	(1<<LKF_FAC_INTSCOR)					/* =     4 */
#define LKF_ERRORFILTER_KASKOREERROR	(1<<LKF_FAC_KAS_KORE)					/* =     8 */
#define LKF_ERRORFILTER_GGERROR			(1<<LKF_FAC_GG)							/* =    16 */
#define LKF_ERRORFILTER_BERICHTERROR	(1<<LKF_FAC_BERICHT)					/* =    32 */
#define LKF_ERRORFILTER_AERROR          (1<<LKF_FAC_A)                          /* =    64 */
#define LKF_ERRORFILTER_ALLERRORS		255
#define LKF_ERRORFILTER_GENERALWARNING  (LKF_ERRORFILTER_GENERALERROR<<8)		/* =   256 */
#define LKF_ERRORFILTER_MBDSWARNING		(LKF_ERRORFILTER_MBDSERROR<<8)			/* =   512 */
#define LKF_ERRORFILTER_INTSCORWARNING	(LKF_ERRORFILTER_INTSCORERROR<<8)		/* =  1024 */
#define LKF_ERRORFILTER_KASKOREWARNING	(LKF_ERRORFILTER_KASKOREERROR<<8)		/* =  2048 */
#define LKF_ERRORFILTER_GGWARNING		(LKF_ERRORFILTER_GGERROR<<8)			/* =  4096 */
#define LKF_ERRORFILTER_BERICHTWARNING	(LKF_ERRORFILTER_BERICHTERROR<<8)	/* =  8192 ; V2019.1: fix shift*/
#define LKF_ERRORFILTER_AWARNING        (LKF_ERRORFILTER_AERROR<<8)             /* =    16384 */

#define LKF_ERRORFILTER_ALLWARNINGS		(255<<8)								/* = 65280 */
#define LKF_ERRORFILTER_ALL				0xFFFFFFFF
#define LKF_ERRORFILTER_SHOWDETAILS		(1<<16)									/* =65536 */
#define LKF_ERRORFILTER_GENERALINFO     (1<<20)
#define LKF_ERRORFILTER_MBDSINFO		(LKF_ERRORFILTER_MBDSERROR<<20)
#define LKF_ERRORFILTER_INTSCORINFO		(LKF_ERRORFILTER_INTSCORERROR<<20)		/* =  1024 */
#define LKF_ERRORFILTER_KASKOREINFO		(LKF_ERRORFILTER_KASKOREERROR<<20)		/* =  2048 */
#define LKF_ERRORFILTER_GGINFO			(LKF_ERRORFILTER_GGERROR<<20)			/* =  4096 */
#define LKF_ERRORFILTER_ALLINFOS        (LKF_ERRORFILTER_MBDSINFO|LKF_ERRORFILTER_INTSCORINFO|LKF_ERRORFILTER_KASKOREINFO|LKF_ERRORFILTER_GGINFO)

#define LKF_INTSCORFIELD_PATID		0
#define LKF_INTSCORFIELD_ABTPOS		1
#define LKF_INTSCORFIELD_ABTFC		2
#define LKF_INTSCORFIELD_ERHEBDAT	3
#define LKF_INTSCORFIELD_SCORE		4
#define LKF_INTSCORFIELD_ADDINFO1	5
#define LKF_INTSCORFIELD_LINEID		6
#define LKF_INTSCORFIELD_LINE		7
#define LKF_INTSCORFIELD_AUFID64   13
#define LKF_INTSCORFIELD_AUFDAT    40

#define LKF_INTSCORFIELD_EINSTUFUNG  21
#define LKF_INTSCORFIELD_KORRFAKTOR  22
#define LKF_INTSCORFIELD_TISSMW      23

#define LKF_MELFIELD_MELZU			0
#define LKF_MELFIELD_LDFPLK          1
#define LKF_MELFIELD_LEIST           2
#define LKF_MELFIELD_RELEVANT        3
#define LKF_MELFIELD_GRUPPE          4
#define LKF_MELFIELD_KNOTEN          5
#define LKF_MELFIELD_HAUPTINDEX      6
#define LKF_MELFIELD_SEITE           7
#define LKF_MELFIELD_COUNT           8
#define LKF_MELFIELD_MELPOS         11
#define LKF_MELFIELD_MEL            12
#define LKF_MELFIELD_DATE           13
#define LKF_MELFIELD_KALEIST        14
#define LKF_MELFIELD_FCLEIST        15
#define LKF_MELFIELD_UHRZEIT        16
#define LKF_MELFIELD_TEXT           20
#define LKF_MELFIELD_STATGRP        21
#define LKF_MELFIELD_AMBGRP         22

#define LKF_MELFIELD_ORIGMEL        23
#define LKF_MELFIELD_ORIGMELANZ     24

#define LKF_MELFIELD_SUBGRUPPENINDEX          80
#define LKF_MELFIELD_SUBGRUPPE_HAUPTX04       81
#define LKF_MELFIELD_ABTINDEX      85
#define LKF_MELFIELD_ABTPOS      86

#define LKF_MELFIELD_MELMELINFO    89
#define LKF_MELFIELD_MELMELPOOL    90

/* Routinen zur Bearbeitung der Aufenthalts-Struktur (auf5.c) *********************/
_SCORING_EXPORT LKF_AUFENTHALT *lkf_alloc_aufenthalt (void);
_SCORING_EXPORT LKF_AUFENTHALT *lkf_alloc_aufenthalt2 (LKF_CONTEXT *pContext);
_SCORING_EXPORT LKF_AUFENTHALT *lkf_alloc_aufenthalt_context (LKF_CONTEXT *pContext);
_SCORING_EXPORT void lkf_free_aufenthalt (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT void lkf_reset_aufenthalt (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT LKF_AUFENTHALT *lkf_copy_aufenthalt (LKF_AUFENTHALT *pAufenthalt); /* V6.0 */
_SCORING_EXPORT LKF_AUFENTHALT *lkf_copy_aufenthalt2 (LKF_AUFENTHALT *pAufenthalt, LKF_CONTEXT *pContext, int copyIntensiv); /* V2024.1 */
_SCORING_EXPORT unsigned int lkf_auf_getlineanz (LKF_AUFENTHALT *pAufenthalt); /* V6.0 */
_SCORING_EXPORT int lkf_auf_getline (LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *line);
_SCORING_EXPORT int lkf_auf_getLineAndIdent (LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *line, char *ident); /* V2024.0 */
_SCORING_EXPORT int lkf_auf_deleteLine (LKF_AUFENTHALT *pAufenthalt, const char *ident); /* V2024.0 */
_SCORING_EXPORT int lkf_auf_getLineWithIdent (LKF_AUFENTHALT *pAufenthalt, const char *ident, char *l); /* V2024.0 */

_SCORING_EXPORT unsigned int lkf_add_abt  (LKF_AUFENTHALT *pAufenthalt, const char *abtfc, const char *abtdat, const char *abtpos);
_SCORING_EXPORT unsigned int lkf_add_abt2 (LKF_AUFENTHALT *pAufenthalt, const char *abtfc, const char *abtdat, const char *abtpos, const char *intdata); 
_SCORING_EXPORT unsigned int lkf_add_abt3 (LKF_AUFENTHALT *pAufenthalt, const char *abtfc, const char *abtdat, const char *abtpos, const char *intdata, const char *addinfo); /* V11.1 */
_SCORING_EXPORT unsigned int lkf_add_diag (LKF_AUFENTHALT *pAufenthalt, const char *diag, const char *type);
_SCORING_EXPORT unsigned int lkf_add_diag2 (LKF_AUFENTHALT *pAufenthalt, const char *diag, const char *type, const char *pos); /* V6.0 */
_SCORING_EXPORT unsigned int lkf_add_diag3 (LKF_AUFENTHALT *pAufenthalt, const char *diag, const char *type, const char *pos, const char *addinfo); /* V11.1 */
_SCORING_EXPORT unsigned int lkf_add_diag4 (LKF_AUFENTHALT *pAufenthalt, const char *diag, const char *type, const char *pos, const char *addfields, const char *addinfo); /* V21.0 */
_SCORING_EXPORT unsigned int lkf_add_mel2  (LKF_AUFENTHALT *pAufenthalt, const char *mel, const char *melanz, const char *meldat);
_SCORING_EXPORT unsigned int lkf_add_mel3  (LKF_AUFENTHALT *pAufenthalt, const char *mel, const char *melanz, const char *meldat, const char *melpos);
_SCORING_EXPORT unsigned int lkf_add_mel4  (LKF_AUFENTHALT *pAufenthalt, const char *mel, const char *melanz, const char *meldat, const char *melpos, const char *addinfo); /* V11.0 */
_SCORING_EXPORT unsigned int lkf_add_mel5  (LKF_AUFENTHALT *pAufenthalt, const char *mel, const char *melanz, const char *meldat, const char *melpos, const char *melzeit, const char *addinfo); /* V21.0 */
_SCORING_EXPORT unsigned int lkf_add_mel6  (LKF_AUFENTHALT *pAufenthalt, const char *mel, const char *melanz, const char *meldat, const char *melpos, const char *melzeit, const char *seite, const char *fcleist, const char *kaleist, const char *addinfo); /* V2020.2 */
_SCORING_EXPORT unsigned int lkf_add_akwarn (LKF_AUFENTHALT *pAufenthalt, const char *tcode, const char *value, const char *komm);
_SCORING_EXPORT unsigned int lkf_add_kost (LKF_AUFENTHALT *pAufenthalt, const char *kost);
_SCORING_EXPORT unsigned int lkf_add_komm (LKF_AUFENTHALT *pAufenthalt, const char *komm);
_SCORING_EXPORT int lkf_add_line_auf (LKF_AUFENTHALT *pAufenthalt, const char *line);

_SCORING_EXPORT unsigned int lkf_auf_get_abtanz (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_melanz (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_diaganz (LKF_AUFENTHALT *pAufenthalt); /* Anzahl Diagnosen (Haupt + Zusatz) */
_SCORING_EXPORT unsigned int lkf_auf_get_hdiaganz(LKF_AUFENTHALT *pAufenthalt); /* V21.1 - Anzahl Hauptdiagnosen */
_SCORING_EXPORT unsigned int lkf_auf_get_akwarnanz (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_kommentaranz (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_kommentaranz2 (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_kostanz (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_scoringanz (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_customanz (LKF_AUFENTHALT *pAufenthalt);

_SCORING_EXPORT unsigned int lkf_auf_get_abt  (LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *abtfc, char *abtdat, char *abtpos);
_SCORING_EXPORT unsigned int lkf_auf_get_mel  (LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *mel, char *melanz); /* V6.0 */
_SCORING_EXPORT unsigned int lkf_auf_get_mel2  (LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *mel, char *melanz, char *meldat); /* V6.0 */
_SCORING_EXPORT unsigned int lkf_auf_get_mel3  (LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *mel, char *melanz, char *meldat, char *melpos); /* V6.0 */
_SCORING_EXPORT unsigned int lkf_auf_get_diag (LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *diag, char *diagtype); /* V6.0 */
_SCORING_EXPORT unsigned int lkf_auf_get_diag2 (LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *diag, char *diagtype, char *diagpos); /* V6.0 */

_SCORING_EXPORT long long lkf_debugmemory_bytes(void);
_SCORING_EXPORT long long lkf_debugmemory_blocks(void);


#define LKF_DIAGFIELD_DIAG   0
#define LKF_DIAGFIELD_TYPE   1
#define LKF_DIAGFIELD_POS    2
#define LKF_DIAGFIELD_TEXT   3
#define LKF_DIAGFIELD_GRUPPE 4
_SCORING_EXPORT unsigned int lkf_auf_get_diagfield (LKF_AUFENTHALT *pAufenthalt, unsigned int index, unsigned int fieldIndex, char *buffer);

_SCORING_EXPORT unsigned int lkf_auf_get_abtbd (LKF_AUFENTHALT *pAufenthalt, unsigned int index, long *abtbd); /* V6.0 */



#define LKF_ABTFIELD_POS                5
#define LKF_ABTFIELD_ABTFC              6
#define LKF_ABTFIELD_ABTDAT             7
#define LKF_ABTFIELD_AUFZEIT            8
#define LKF_ABTFIELD_PHYS               9
#define LKF_ABTFIELD_NEUGEB             SCORFIELD_NEUGEB
#define LKF_ABTFIELD_ALTERSGRUPPE       SCORFIELD_ALTERSGRUPPE
#define LKF_ABTFIELD_ENTDAT             60
#define LKF_ABTFIELD_ENTZEIT            61
#define LKF_ABTFIELD_ENTART             12
#define LKF_ABTFIELD_FUNKTEXT           90
#define LKF_ABTFIELD_K01TEXT            91
#define LKF_ABTFIELD_K01ORFUNK          92

_SCORING_EXPORT unsigned int lkf_auf_get_abtfield (LKF_AUFENTHALT *pAufenthalt, unsigned int index, unsigned int field, char *buf, unsigned int buflen); /* V19.0 */

_SCORING_EXPORT int lkf_auf_get_field (LKF_AUFENTHALT *pAufenthalt, unsigned int fieldnum, const char **field, unsigned int *len); /* NOT THREAD-SAFE - use lkf_auf_get_fieldvalue instead */
_SCORING_EXPORT unsigned int lkf_auf_get_fieldvalue (LKF_AUFENTHALT *pAufenthalt, unsigned int fieldnum, char *buf, unsigned int buflen);

_SCORING_EXPORT const char *lkf_auf_get_ident (LKF_AUFENTHALT *pAufenthalt, char *buf);
_SCORING_EXPORT int lkf_auf_getdiff (LKF_AUFENTHALT *pAufenthalt);

_SCORING_EXPORT int lkf_auf_line_root (LKF_AUFENTHALT *pAufenthalt, char *line);
_SCORING_EXPORT int lkf_auf_line_abt (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *line);
_SCORING_EXPORT int lkf_auf_line_diag (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *line);
_SCORING_EXPORT int lkf_auf_line_mel (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *line);
_SCORING_EXPORT int lkf_auf_line_kost (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *line);
_SCORING_EXPORT int lkf_auf_line_scoring (LKF_AUFENTHALT *pAufenthalt, char *line);
_SCORING_EXPORT int lkf_auf_line_akwarn (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *line);
_SCORING_EXPORT int lkf_auf_line_akwarn2 (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *line, unsigned int *pHitCount); /* V12.1 */

_SCORING_EXPORT int lkf_auf_line_kommentar (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *line);
_SCORING_EXPORT int lkf_auf_line_svnr (LKF_AUFENTHALT *pAufenthalt, char *line);
_SCORING_EXPORT int lkf_auf_line_custom (LKF_AUFENTHALT *pAufenthalt, char *line);
_SCORING_EXPORT void lkf_auf_reset_diag (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT void lkf_auf_reset_mel (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT void lkf_auf_reset_abt (LKF_AUFENTHALT *pAufenthalt);

_SCORING_EXPORT int lkf_auf_is_optimizable (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT int lkf_auf_get_opt_subgruppe (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT int lkf_auf_get_min_subgruppe (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT double lkf_auf_get_opt_percentage (LKF_AUFENTHALT *pAufenthalt);

_SCORING_EXPORT long long lkf_get_melLongKey (LKF_CONTEXT *pContext, const char *mel);
_SCORING_EXPORT long long lkf_get_diagLongKey (LKF_CONTEXT *pContext, const char *diag);

_SCORING_EXPORT int lkf_auf_findFirstDiagIndex (LKF_AUFENTHALT *pAufenthalt, long long diagLongKey); /* V2022.1 */
_SCORING_EXPORT int lkf_auf_findFirstMelIndex (LKF_AUFENTHALT *pAufenthalt, long long melLongKey);  /* V2022.1 */
_SCORING_EXPORT int lkf_auf_findFirstDiagString (LKF_AUFENTHALT *pAufenthalt, const char *diag, unsigned int diaglen); /* V2025.2 */
_SCORING_EXPORT int lkf_auf_findFirstAbtString (LKF_AUFENTHALT *pAufenthalt, const char *abtfc, unsigned int abtlen); /* V2025.2 */
_SCORING_EXPORT int lkf_auf_findFirstMelString (LKF_AUFENTHALT *pAufenthalt, const char *mel, unsigned int mellen);  /* V2025.2 */
_SCORING_EXPORT int lkf_auf_matchGroupString (LKF_AUFENTHALT *pAufenthalt, const char *groupString, unsigned int grouplen); /* V2025.2 */

_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_firsterror (LKF_AUFENTHALT *);
_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_nexterror (const LKF_ERROR_LIST *);
_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_firstwarning (LKF_AUFENTHALT *);
_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_nextwarning (const LKF_ERROR_LIST *);
_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_firstinfo (LKF_AUFENTHALT *); /* V13.1 */
_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_nextinfo (const LKF_ERROR_LIST *); /* V13.1 */
_SCORING_EXPORT void lkf_auf_getErrorLine (LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *pList, char *sBuf, unsigned int nBufLen); /* V10.1 */
_SCORING_EXPORT void lkf_auf_getWarningLine (LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *pList, char *sBuf, unsigned int nBufLen); /* V10.1 */
_SCORING_EXPORT void lkf_auf_getInfoLine (LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *pList, char *sBuf, unsigned int nBufLen); /* V13.1 */
_SCORING_EXPORT int lkf_auf_geterrorcode (const LKF_ERROR_LIST *, int *index);
_SCORING_EXPORT int lkf_auf_getwarningcode (const LKF_ERROR_LIST *, int *index);
_SCORING_EXPORT const char *lkf_auf_getvalue (LKF_AUFENTHALT *pAufenthalt, unsigned int i, unsigned int j, char *buf);
_SCORING_EXPORT void lkf_sort_aufenthalt (LKF_AUFENTHALT *);
_SCORING_EXPORT unsigned int lkf_auf_get_maxsubgruppe (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_subgruppenanz (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT long lkf_auf_get_scorvalue (LKF_AUFENTHALT *pAufenthalt, unsigned int field);
_SCORING_EXPORT const char *lkf_auf_get_gruppe (LKF_AUFENTHALT *pAufenthalt, char *gruppe, char *knoten);
_SCORING_EXPORT const char *lkf_auf_get_gruppe_mel (LKF_AUFENTHALT *pAufenthalt, char *mel);
_SCORING_EXPORT const char *lkf_auf_get_subgruppe_gruppe (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *gruppe, char *knoten);
_SCORING_EXPORT const char *lkf_auf_get_subgruppe_mel (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *mel);
_SCORING_EXPORT const char *lkf_auf_get_subgruppe_diag (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *diag); /* V6.0 */
_SCORING_EXPORT long lkf_auf_get_subgruppe_scorvalue (LKF_AUFENTHALT *pAufenthalt, unsigned int i, unsigned int field);
_SCORING_EXPORT int lkf_auf_is_marked (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT int lkf_auf_mark (LKF_AUFENTHALT *pAufenthalt, int m);
_SCORING_EXPORT char lkf_auf_getmeldediag (const LKF_ERROR_LIST *pMeldeDiag, long *index); /* V7.0 */
_SCORING_EXPORT unsigned int lkf_auf_getintlineanz (LKF_AUFENTHALT *pAufenthalt); 
_SCORING_EXPORT int lkf_auf_getintline (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *l);
_SCORING_EXPORT int lkf_auf_getintLineAndIdent (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *l, char *ident); /* V2024.0 */
_SCORING_EXPORT int lkf_auf_replaceIntLine (LKF_AUFENTHALT *pAufenthalt, const char *line, const char *ident); /* V2024.0 */
_SCORING_EXPORT int lkf_auf_deleteIntLine (LKF_AUFENTHALT *pAufenthalt, const char *ident); /* V2024.0 */
_SCORING_EXPORT int lkf_auf_getIntLineWithIdent (LKF_AUFENTHALT *pAufenthalt, const char *ident, char *l); /* V2024.0 */


_SCORING_EXPORT double lkf_auf_get_abtscor (LKF_AUFENTHALT *pAufenthalt, unsigned int abtIndex, char *abtpos, double *tp, double *lp); /* V21.4 */
_SCORING_EXPORT long lkf_auf_get_abtscor100 (LKF_AUFENTHALT *pAufenthalt, unsigned int abtIndex, char *abtpos, long *tp100, long *lp100); /* V21.4 */
_SCORING_EXPORT long lkf_auf_get_mel_field (LKF_AUFENTHALT *pAufenthalt, unsigned int melId, unsigned int melFieldIndex); /* V22.1 */
_SCORING_EXPORT int lkf_auf_get_melIndexForPos (LKF_AUFENTHALT *pAufenthalt, char *melpos); /* V22.1 */
_SCORING_EXPORT const char *lkf_auf_get_mel_value (LKF_AUFENTHALT *pAufenthalt, unsigned int melId, unsigned int melFieldIndex, unsigned int buflen, char *buf); /* V22.3 */
_SCORING_EXPORT const LKF_SATZART_ERROR *lkf_auf_getSatzartError (LKF_AUFENTHALT *pAufenthalt); /* V2019.0 */

_SCORING_EXPORT unsigned int lkf_getSatzartErrorFromFormat (const LKF_CONTEXT *pContext, const LKF_SATZART_ERROR *pError, const LKF_CONTEXT_ERRORFORMAT *pErrorFormat, unsigned int nBufLen, char *sBuf); /* V2022.1 */
_SCORING_EXPORT unsigned int lkf_getSatzartErrorFromFields (const LKF_CONTEXT *pContext, const LKF_SATZART_ERROR *pError, unsigned int fieldCount, const unsigned int *fields, unsigned int nBufLen, char *sBuf); /* V2025.2 */
_SCORING_EXPORT LKF_CONTEXT_ERRORFORMAT *lkf_createErrorFormat (unsigned int fieldcount, const unsigned int *fields); /* V2022.1 */
_SCORING_EXPORT void lkf_freeErrorFormat (LKF_CONTEXT_ERRORFORMAT *errorFormat); /* V2022.1 */
_SCORING_EXPORT const LKF_SATZART_ERROR *lkf_auf_getNextSatzartError (const LKF_SATZART_ERROR *pError); /* V2019.0 */
_SCORING_EXPORT int lkf_auf_isAmb (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT int lkf_scoringdetails_getHead (LKF_AUFENTHALT *pAufenthalt, char *buf, unsigned int buflen);
_SCORING_EXPORT unsigned int lkf_scoringdetails_getMELCommentCount (LKF_AUFENTHALT *pAufenthalt, unsigned int group);
_SCORING_EXPORT unsigned int lkf_scoringdetails_getDIAGCommentCount (LKF_AUFENTHALT *pAufenthalt, unsigned int group);

_SCORING_EXPORT int lkf_scoringdetails_getMELComment (LKF_AUFENTHALT *pAufenthalt, unsigned int mainGroup, unsigned int index, char *buf, unsigned int buflen);
_SCORING_EXPORT int lkf_scoringdetails_getDIAGComment (LKF_AUFENTHALT *pAufenthalt, unsigned int mainGroup, unsigned int index, char *buf, unsigned int buflen);
_SCORING_EXPORT int lkf_scoringdetails_getAbt (LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *buf, unsigned int buflen);
_SCORING_EXPORT int lkf_scoringdetails_getMELInfo(LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *buf, unsigned int buflen);
_SCORING_EXPORT int lkf_scoringdetails_getDIAGInfo (LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *buf, unsigned int buflen);
_SCORING_EXPORT int lkf_scoringdetails_getSubgruppe (LKF_AUFENTHALT *pAufenthalt, int index, char *buf, unsigned int buflen);
_SCORING_EXPORT int lkf_scoringdetails_getSubgruppeMEL (LKF_AUFENTHALT *pAufenthalt, int subgruppeIndex, unsigned int melIndex, char *buf, unsigned int buflen);


_SCORING_EXPORT unsigned int lkf_auf_getCategoryCount (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT int lkf_auf_getCategory (LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *pBuf, unsigned int buflen);

/* Basis-Funktionen (utils5.c) ************************************************/
_SCORING_EXPORT int lkf_GetInt (const char *text, int len, int *resultat);
_SCORING_EXPORT long lkf_DatToLong (const char *dat); /* V6.0 */
_SCORING_EXPORT char *lkf_LongToDat (long lDat, char *sDatBuf); /* V11.0 */
_SCORING_EXPORT char *lkf_LongToDat8 (long lDat, char *sDatBuf); /* V2024.1 */

/* Scoring-Context-spezifische Routinen (context5.c) **************************/

_SCORING_EXPORT void lkf_set_dataprovider(DATAPROVIDER_MODEL_FILE_FUNC fileFunc); /* V2020.5 */
_SCORING_EXPORT void lkf_semaphore_callbacks (ALLOC_SEMAPHORE_CALLBACK sem_new, SEMAPHORE_CALLBACK sem_enter, SEMAPHORE_CALLBACK sem_leave,
                                              SEMAPHORE_CALLBACK sem_delete);
_SCORING_EXPORT void lkf_semaphore_callbacks2 (ALLOC_SEMAPHORE_CALLBACK2 sem_new, SEMAPHORE_CALLBACK2 sem_enter, SEMAPHORE_CALLBACK2 sem_leave,
                                               SEMAPHORE_CALLBACK2 sem_delete); /* V2021.2 */




_SCORING_EXPORT LKF_CONTEXT * lkf_alloc_context (unsigned int modelljahr, const char *input_path, char *error);
_SCORING_EXPORT LKF_CONTEXT * lkf_alloc_context2 (unsigned int modelljahr, const char *input_path, STAMM_ADD_LINE_FUNC func, char *error);
_SCORING_EXPORT LKF_CONTEXT * lkf_alloc_context3 (unsigned int modelljahr, const char *input_path, STAMM_FILE_PATH_FUNC pathFunc, STAMM_ADD_LINE_FUNC addLineFunc, char *error);
_SCORING_EXPORT LKF_CONTEXT * lkf_alloc_context_stamm (LKF_METADATA *pStamm, STAMM_FILE_PATH_FUNC pathFunc, STAMM_ADD_LINE_FUNC addLineFunc, char *error);
_SCORING_EXPORT void  lkf_free_context (LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_set_modelljahr (LKF_CONTEXT *pContext, unsigned int modelljahr, const char *input_path, char *error);
_SCORING_EXPORT void lkf_set_modelljahr_stamm (LKF_CONTEXT *pContext, LKF_METADATA *pStamm); /* V2025.0 */
_SCORING_EXPORT int  lkf_insert_aufenthalt (LKF_CONTEXT *pContext, LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT LKF_AUFENTHALT *  lkf_find_aufenthalt (LKF_CONTEXT *pContext, const char *kanr, const char *aufnahmezahl);
_SCORING_EXPORT int  lkf_add_line (LKF_CONTEXT *pContext, const char *line);
_SCORING_EXPORT int  lkf_add_lines (LKF_CONTEXT *pContext, const char *buffer);
_SCORING_EXPORT int  lkf_add_lines2 (LKF_CONTEXT *pContext, const char *buffer, int *charCount, int *errorCount);

_SCORING_EXPORT unsigned int  lkf_plaus_GetErrorCodeCount (LKF_CONTEXT *pContext, unsigned int kanr, unsigned int nr);
_SCORING_EXPORT unsigned int  lkf_plaus_GetWarningCodeCount (LKF_CONTEXT *pContext, unsigned int kanr, unsigned int nr);
_SCORING_EXPORT void  lkf_compose_filename (LKF_CONTEXT *pContext, const char *ka, char type, char *filename);
_SCORING_EXPORT int  lkf_read_inputfile (const char *input_file, LKF_CONTEXT *pContext, char *error);
_SCORING_EXPORT void  lkf_sort_input_order (LKF_CONTEXT *pContext);
_SCORING_EXPORT void  lkf_sort_patid_order (LKF_CONTEXT *pContext);
_SCORING_EXPORT int lkf_define_custom_line (LKF_CONTEXT *pContext, unsigned int fa, unsigned int *f, int fl, char c);
_SCORING_EXPORT void lkf_set_contextflags (LKF_CONTEXT *pContext, int flags); 
_SCORING_EXPORT int lkf_get_contextflags (LKF_CONTEXT *pContext); /* V2025.0 */
_SCORING_EXPORT void lkf_set_abrechnungsjahr (LKF_CONTEXT *pContext, int abrechnungsjahr);
_SCORING_EXPORT void  lkf_set_contextparameters (LKF_CONTEXT *pContext, int cmb_jahr, int period_val, int lfdnr, char period_type, int flags);
_SCORING_EXPORT int  lkf_set_contextparametersFromString (LKF_CONTEXT *pContext, const char *, int flags);
_SCORING_EXPORT int  lkf_write_file (const char *filename, LKF_CONTEXT *pContext, unsigned int kanr, int flags, char *error);
_SCORING_EXPORT int  lkf_write_errsumfile (const char *filename, LKF_CONTEXT *pContext, int flags, char *error);
_SCORING_EXPORT int  lkf_write_abtfile (const char *filename, LKF_CONTEXT *pContext, unsigned int kanr, int flags, char *error);
_SCORING_EXPORT int  lkf_write_svnrfile (const char *filename, LKF_CONTEXT *pContext, unsigned int kanr, int flags, char *error);
_SCORING_EXPORT int lkf_write_meldediagfile (const char *filename, LKF_CONTEXT *pContext, unsigned int kanr, char *error); /* V7.0 */

_SCORING_EXPORT unsigned int  lkf_get_aufenthalt_anz (const LKF_CONTEXT *pContext);
_SCORING_EXPORT LKF_AUFENTHALT  *lkf_get_aufenthalt (const LKF_CONTEXT *pContext, unsigned int i);
_SCORING_EXPORT int  lkf_insert_aufenthalt (LKF_CONTEXT *pContext, LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT void  lkf_reset_aufenthalte (LKF_CONTEXT *pContext);
_SCORING_EXPORT void  lkf_reset_aufenthalt_package (LKF_CONTEXT *pContext);
_SCORING_EXPORT const char *lkf_get_context_error (const LKF_CONTEXT *pContext); /* V9.2 */
_SCORING_EXPORT unsigned int lkf_context_errorcode_count (const LKF_CONTEXT *pContext, unsigned int ka, unsigned int code);
_SCORING_EXPORT unsigned int lkf_context_warningcode_count (const LKF_CONTEXT *pContext, unsigned int ka, unsigned int code); 

_SCORING_EXPORT unsigned int  lkf_get_context_ka_anz (const LKF_CONTEXT *);
_SCORING_EXPORT const char  * lkf_get_context_ka (const LKF_CONTEXT *pContext, unsigned int i, unsigned int *anz, unsigned int *filter_anz);
_SCORING_EXPORT void          lkf_reset_ka (LKF_CONTEXT *pContext); /* V6.0 */
_SCORING_EXPORT unsigned int  lkf_add_ka_stats (LKF_CONTEXT *pContext, LKF_AUFENTHALT *pAufenthalt, 
												int modus); /* V6.0 */
_SCORING_EXPORT unsigned int  lkf_get_context_ka_abtanz (const LKF_CONTEXT *, unsigned int i); /* V6.0 */
_SCORING_EXPORT const char *  lkf_get_context_ka_abtstat (const LKF_CONTEXT *, unsigned int ka, unsigned int abt, unsigned int *anz, unsigned int *bd, unsigned int *err); /* V6.0 */
_SCORING_EXPORT double lkf_get_context_ka_optimized (const LKF_CONTEXT *pContext, unsigned int i, unsigned int *anz, unsigned int *opt, double *maxpkt, double *actpkt);

_SCORING_EXPORT double  lkf_get_context_scorvalue (const LKF_CONTEXT *pContext, unsigned int kanr, unsigned int field);
_SCORING_EXPORT unsigned int  lkf_context_GetErrorAnz (const LKF_CONTEXT *pContext, unsigned int kanr, int *accepted);
_SCORING_EXPORT unsigned int  lkf_context_GetWarningAnz (const LKF_CONTEXT *pContext, unsigned int kanr, int *accepted);
_SCORING_EXPORT unsigned int  lkf_context_GetHinweisAnz (const LKF_CONTEXT *pContext, unsigned int kanr, int *accepted); /* V13.0 */
_SCORING_EXPORT unsigned int  lkf_context_GetMeldeDiagAnz (const LKF_CONTEXT *pContext, unsigned int kanr); /* V7.0 */

_SCORING_EXPORT unsigned int lkf_context_get_plaused_anz (const LKF_CONTEXT *pContext, unsigned int *worked);
_SCORING_EXPORT unsigned int lkf_context_get_scored_anz (const LKF_CONTEXT *pContext, unsigned int *worked);
_SCORING_EXPORT int lkf_context_getValue (const LKF_CONTEXT *pContext, unsigned int field); /* V2025.1 */
_SCORING_EXPORT const char *lkf_context_get_errortext (const LKF_CONTEXT *pContext);
_SCORING_EXPORT const char *lkf_context_get_outOfMemoryText (const LKF_CONTEXT *pContext);

_SCORING_EXPORT int lkf_context_add_spez (LKF_CONTEXT *pContext, const char *line);
_SCORING_EXPORT int lkf_context_add_kost (LKF_CONTEXT *pContext, const char *line);
_SCORING_EXPORT int lkf_context_add_melka (LKF_CONTEXT *pContext, const char *line);
_SCORING_EXPORT int lkf_context_add_melka_tkl (LKF_CONTEXT *pContext, const char *line); 
_SCORING_EXPORT int lkf_context_add_systeminfo (LKF_CONTEXT *pContext, const char *line);
_SCORING_EXPORT int lkf_context_sort_private_stamm (LKF_CONTEXT *pContext);
_SCORING_EXPORT const char *lkf_get_systeminfo (const LKF_CONTEXT *pContext);

_SCORING_EXPORT const char  *lkf_GetVersion(void);
_SCORING_EXPORT void lkf_GetVersion2(char *versionString, unsigned int buflen);
_SCORING_EXPORT unsigned int lkf_GetYearFirst (void);
_SCORING_EXPORT unsigned int lkf_GetYearLatest (void);

_SCORING_EXPORT unsigned int lkf_getaddlineanz (LKF_CONTEXT *pContext); 
_SCORING_EXPORT int lkf_getaddline (LKF_CONTEXT *pContext, unsigned int i, char *l);

_SCORING_EXPORT int lkf_getaddlineWithIdent (LKF_CONTEXT *pContext, const char *ident, char *l); /* V2024.0 */
_SCORING_EXPORT int lkf_getaddlineAndIdent (LKF_CONTEXT *pContext, unsigned int i, char *l, char *ident); /* V2024.0 */

_SCORING_EXPORT unsigned int lkf_context_getSummensatz (LKF_CONTEXT *pContext, char *sBuf, unsigned int nBufLen); 

_SCORING_EXPORT int lkf_context_getModellJahr (const LKF_CONTEXT *pContext); /* V18.0 */

int lkf_SpezMelOhneGenehmigung (LKF_AUFENTHALT *pAufenthalt, unsigned int melindex, unsigned int *spezmelindex); /* V16.0 */
_SCORING_EXPORT int lkf_context_getutf8mode (const LKF_CONTEXT *pContext);

/* Routinen zur Unterstützung des alten LKF-Formats (oldlkf5.c) */
_SCORING_EXPORT void  lkf_old_patient (const char *act_record, LKF_AUFENTHALT *pNew);
_SCORING_EXPORT int  lkf_add_flat_line (LKF_CONTEXT *pContext, const char *line);
_SCORING_EXPORT int  lkf_read_flat_inputfile (const char *input_file, LKF_CONTEXT *pContext, char *error);

_SCORING_EXPORT int  lkf_get_amb_counter (LKF_CONTEXT *pContext, unsigned ambIndex); /* V22.0 */
_SCORING_EXPORT unsigned int lkf_get_amb_kostenstelle_count(LKF_CONTEXT *pContext); /* V2020.1 */
_SCORING_EXPORT int lkf_get_amb_kostenstelle_value (LKF_CONTEXT *pContext, unsigned int index, unsigned int ambIndex); /* V2020.1 */
_SCORING_EXPORT void lkf_get_amb_kostenstelle_stringvalue (LKF_CONTEXT *pContext, unsigned int index, unsigned int ambIndex, char *buffer, unsigned int buflen); /* V2020.1 */
_SCORING_EXPORT int lkf_get_amb_kostenstelle_counter (LKF_CONTEXT *pContext, const char *kostenstelle, unsigned int ambIndex); /* V2020.1 */
_SCORING_EXPORT int lkf_get_amb_kostenstelle_index (LKF_CONTEXT *pContext, const char *kostenstelle); /* V2020.1 */
_SCORING_EXPORT int lkf_get_PeriodYear (LKF_CONTEXT *pContext); /* V2024.0 */
_SCORING_EXPORT unsigned int lkf_set_statjahr (LKF_CONTEXT *pContext, unsigned int abrechjahr, const char *input_path, char *error);

_SCORING_EXPORT int lkf_getLineIdent(LKF_CONTEXT *pContext, const char *satzart, unsigned int index, char *buf, unsigned int buflen); /* V2025.1 */


#define LKF_CONTEXT_MODELPARAMETER_TKLFACTOR 0

_SCORING_EXPORT int lkf_context_set_modelparameter (LKF_CONTEXT *pContext, int parameterId, const char *value);

#define LKF_COMPATIBILITY_SCORINGOUTPUT				4
#define LKF_COMPATIBILITY_IGNOREERRORSFORINTSCOR   16

_SCORING_EXPORT void lkf_set_compatibilitymode (LKF_CONTEXT *pContext, unsigned int compatibility);
_SCORING_EXPORT int lkf_write_datafile (LKF_CONTEXT *pContext, const char *filename, unsigned int filetype, unsigned int flags);

#define LKF_CONTEXTINFO_KTR							1

_SCORING_EXPORT int lkf_context_GetGlobalInfo (const LKF_CONTEXT *pContext, unsigned int nType);

_SCORING_EXPORT unsigned int lkf_context_read_dat (LKF_CONTEXT *pContext, const char *fileName); /* V21.2 */
_SCORING_EXPORT const char *lkf_context_dat_line (LKF_CONTEXT *pContext, unsigned int lineIndex); /* V21.2 */
_SCORING_EXPORT void lkf_context_free_dat (LKF_CONTEXT *pContext); /* V21.2 */

_SCORING_EXPORT unsigned int lkf_context_getSatzartErrorAnz (const LKF_CONTEXT *pContext, unsigned int flags); /* V21.2 */
/* Routinen des Plausibilitäts-Checks (plaus5.c) */
_SCORING_EXPORT int lkf_plaus (LKF_CONTEXT *pContext, LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT int lkf_context_plaus (LKF_CONTEXT *pContext, unsigned int anzahl);
_SCORING_EXPORT int lkf_context_plaus_package (LKF_CONTEXT *pContext, int firstPackage); /* V21.0 */
_SCORING_EXPORT int  lkf_plaus_GetErrorAnz (LKF_AUFENTHALT *pAufenthalt, int *accepted);
_SCORING_EXPORT int  lkf_plaus_GetWarningAnz (LKF_AUFENTHALT *pAufenthalt, int *accepted);
_SCORING_EXPORT int  lkf_plaus_GetInfoAnz (LKF_AUFENTHALT *pAufenthalt, int *accepted); /* V13.1 */
_SCORING_EXPORT const char *  lkf_plaus_WarningCode2Text (LKF_CONTEXT *, int nr);
_SCORING_EXPORT int  lkf_plaus_WarningCode2Massnahme (const LKF_CONTEXT *, int nr);
_SCORING_EXPORT const char *  lkf_plaus_ErrorCode2Text (LKF_CONTEXT *pContext, int nr);
_SCORING_EXPORT int  lkf_plaus_GetErrorText4 (LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *pError, char *errortext, char *errorfield);
_SCORING_EXPORT int  lkf_plaus_GetErrorText (LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *, char *text, int len);
_SCORING_EXPORT int  lkf_plaus_GetWarningText4 (LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *pError, char *warningtext, char *warningfield);
_SCORING_EXPORT int  lkf_plaus_GetWarningText (LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *, char *text, int len);

_SCORING_EXPORT int  lkf_plaus_GetMeldeDiagText (LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *, char *text, int len); /* V7.0 */

_SCORING_EXPORT void  lkf_plaus_WriteAbtHeader (LKF_CONTEXT *pContext, FILE *abt, unsigned int kanr);
_SCORING_EXPORT void  lkf_plaus_WriteAbtFooter (LKF_CONTEXT *pContext, FILE *f_abt, unsigned int kanr);

_SCORING_EXPORT const char *lkf_plaus_meldediag_typ (const LKF_CONTEXT *pContext, char nr);
_SCORING_EXPORT const char *lkf_plaus_meldediag_text(const LKF_CONTEXT *pContext, char nr);
_SCORING_EXPORT LKF_ERROR_LIST *lkf_auf_firstmeldediag (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT LKF_ERROR_LIST *lkf_auf_nextmeldediag (const LKF_ERROR_LIST *pMeldeDiag);
_SCORING_EXPORT int  lkf_plaus_GetMeldeDiagAnz (LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT const char *lkf_plaus_meldediag_text_fmt(const LKF_CONTEXT *pContext, char nr, char *buf); /* V21.1 */
_SCORING_EXPORT const char *lkf_plaus_meldediag_typ_fmt(const LKF_CONTEXT *pContext, char nr, char *buf); /* V21.1 */

_SCORING_EXPORT void lkf_getErrorCodeMinMax (const LKF_CONTEXT *pContext, unsigned int *emin, unsigned int *emax); 
_SCORING_EXPORT void lkf_getWarningCodeMinMax (const LKF_CONTEXT *pContext, unsigned int *emin, unsigned int *emax); 
_SCORING_EXPORT const char *lkf_getErrorMBDSField (LKF_AUFENTHALT *pAufenthalt, const LKF_SATZART_ERROR *pError, char *text, unsigned int len);

/* Routinen zur Punkteberechnung (scoring5.c) */
_SCORING_EXPORT int  lkf_scoring (LKF_CONTEXT *pContext, LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT int lkf_context_scoring (LKF_CONTEXT *pContext, unsigned int anzahl);
_SCORING_EXPORT int lkf_context_scoring2 (LKF_CONTEXT *pContext, unsigned int anzahl, int reset);
_SCORING_EXPORT int lkf_scoring_abortable (LKF_CONTEXT *pContext, LKFEXECUTION_DELEGATE cb, unsigned int anzahl);


/* Routinen zur Stammdatenabfrage (stamm5.c) */
_SCORING_EXPORT int  lkf_KA_to_TA (const LKF_CONTEXT *pContext, const char *ka, char *ta);
_SCORING_EXPORT int  lkf_KA_to_Name (const LKF_CONTEXT *pContext, const char *ka, char *name);
_SCORING_EXPORT void  lkf_set_global_inputpath (const char *ip);
_SCORING_EXPORT unsigned int lkf_get_spez_anz (const LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_get_kost_anz (const LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_get_melka_anz (const LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_get_meltkl_anz (const LKF_CONTEXT *pContext); /* V2022.1 */
_SCORING_EXPORT int lkf_stamm_line_spez  (const LKF_CONTEXT *pContext, unsigned int i, char *line); /* V2022.1: unsupported */
_SCORING_EXPORT int lkf_stamm_line_kost  (const LKF_CONTEXT *pContext, const char *kanr, unsigned int i, char *line); /* V2022.1: unsupported */
_SCORING_EXPORT int lkf_stamm_line_melka (const LKF_CONTEXT *pContext, unsigned int i, char *line); /* V2022.1: unsupported */
_SCORING_EXPORT long lkf_unloadStamm (void);
_SCORING_EXPORT unsigned int lkf_get_stamm_path (const LKF_CONTEXT *pContext, const char *filename, char *buf, unsigned int buflen); 
_SCORING_EXPORT int lkf_ABTFC_to_Name (const LKF_CONTEXT *pContext, const char *sAbtFC, char *buf); 

_SCORING_EXPORT int lkf_stamm_getDiagCount (const LKF_CONTEXT *pContext); /* V2024.1 */
_SCORING_EXPORT int lkf_stamm_getMelCount (const LKF_CONTEXT *pContext); /* V2024.1 */
_SCORING_EXPORT int lkf_stamm_getMelIndex (const LKF_CONTEXT *pContext, const char *mel);
_SCORING_EXPORT int lkf_stamm_getDiagIndex (const LKF_CONTEXT *pContext, const char *diag);

_SCORING_EXPORT const LKF_MEL_CUSTOM_CHECK *lkf_context_getMelCustomCheck (const LKF_CONTEXT *pContext, unsigned int melIndex);
_SCORING_EXPORT void lkf_context_getMelCustomCheckData (const LKF_CONTEXT *pContext, const LKF_MEL_CUSTOM_CHECK *pCustomCheck, char *pError, const char **pDescription, const LKF_MEL_CUSTOM_CHECK **pNextTrue, const LKF_MEL_CUSTOM_CHECK **pNextFalse);
_SCORING_EXPORT void lkf_stamm_getMelCustomCheckData (const LKF_METADATA *pMetaData, const LKF_MEL_CUSTOM_CHECK *pCustomCheck, char *pError, const char **ppDescription, const LKF_MEL_CUSTOM_CHECK **ppNextTrue, const LKF_MEL_CUSTOM_CHECK **ppNextFalse);

_SCORING_EXPORT const LKF_KNOTEN *lkf_stamm_getGroup (LKF_CONTEXT *pContext, const char *group);
_SCORING_EXPORT unsigned int lkf_stamm_getGroupLine (LKF_CONTEXT *pContext, const LKF_KNOTEN *pKnoten, unsigned int index, char *buf, unsigned int buflen);

_SCORING_EXPORT LKF_KNOTEN *lkf_stamm_getGroupFromBuffer (LKF_CONTEXT *pContext, unsigned int modelljahr, const char *buffer, char *errorBuffer); /* V2025.0 */
_SCORING_EXPORT int lkf_stamm_getGroupInfo (LKF_KNOTEN *pKnoten, int fieldNo, char *buf, unsigned int buflen); /* V2025.0 */
_SCORING_EXPORT void lkf_stamm_freeGroupFromBuffer (LKF_CONTEXT *pContext, LKF_KNOTEN *pKnoten);/* V2025.0 */

_SCORING_EXPORT void lkf_unloadSatzart (void);

_SCORING_EXPORT LKF_METADATA *lkf_alloc_stamm (unsigned int year, const char *path, unsigned int errorLength, char *error);
_SCORING_EXPORT LKF_METADATA *lkf_alloc_stamm2 (LKF_CONTEXT *pContext, unsigned int year, const char *path, unsigned int errorLength, char *error);

_SCORING_EXPORT void lkf_free_stamm (LKF_METADATA *pMetaData);

#define LKFSTAMM_MELFIELD_MEL          12
#define LKFSTAMM_MELFIELD_STATGRUPPE    4
#define LKFSTAMM_MELFIELD_AMBGRUPPE     5
#define LKFSTAMM_MELFIELD_SEITE         7
#define LKFSTAMM_MELFIELD_TEXT         20
#define LKFSTAMM_MELFIELD_GESCHL        8
#define LKFSTAMM_MELFIELD_MEL_WARN     41
#define LKFSTAMM_MELFIELD_MEL_ERR      42
#define LKFSTAMM_MELFIELD_MEL_TAGWARN  43
#define LKFSTAMM_MELFIELD_MEL_TAGERR   44
#define LKFSTAMM_MELFIELD_MEL_AMBWARN  45
#define LKFSTAMM_MELFIELD_MEL_AMBERR    46
#define LKFSTAMM_MELFIELD_LGR          31
#define LKFSTAMM_MELFIELD_AMBLGR       32


_SCORING_EXPORT void lkf_stamm_getMelField (const LKF_CONTEXT *pContext, unsigned int melIndex, unsigned int melField, char *buf, unsigned int buflen);


#define LKFSTAMM_DIAGFIELD_DIAG         1
#define LKFSTAMM_DIAGFIELD_GRP          4
#define LKFSTAMM_DIAGFIELD_DGR          7
#define LKFSTAMM_DIAGFIELD_TEXT        20

_SCORING_EXPORT void lkf_stamm_getDiagField (const LKF_CONTEXT *pContext, unsigned int diagIndex, unsigned int diagField, char *buf, unsigned int buflen);


_SCORING_EXPORT unsigned int lkf_stamm_getMelDiags (const LKF_CONTEXT *pContext, unsigned int melIndex, char *buf, unsigned int buflen);

_SCORING_EXPORT unsigned int lkf_stamm_getMelMel (LKF_CONTEXT *pContext, unsigned int melIndex, char *buf, unsigned int buflen);


/* Filter-Routinen (filter5.c) */
_SCORING_EXPORT LKF_FILTER *lkf_filter_create (const char **str);
_SCORING_EXPORT LKF_FILTER *lkf_filter_create2 (LKF_CONTEXT *pContext, const char **str);
_SCORING_EXPORT void lkf_filter_drop (LKF_FILTER *krit);
_SCORING_EXPORT int lkf_auf_filter (LKF_AUFENTHALT *pAufenthalt, const LKF_FILTER *pFilter);
_SCORING_EXPORT unsigned int lkf_context_filter (LKF_CONTEXT *pContext, const LKF_FILTER *pFilter, int flags);
_SCORING_EXPORT unsigned int lkf_context_get_marked_anz (const LKF_CONTEXT *pContext);
_SCORING_EXPORT void lkf_context_mark_all (LKF_CONTEXT *pContext, int m);
_SCORING_EXPORT unsigned int lkf_filter_gettext (const LKF_FILTER *pFilter, char *pBuf, unsigned int buflen);

/* NPPlaus-Routinen (npplaus5.c) - V7.2 */
_SCORING_EXPORT unsigned int lkf_npplaus_getProtokollHeadline (LKF_CONTEXT *pContext, char *buf, unsigned int maxlen);
_SCORING_EXPORT unsigned int lkf_npplaus_getWarningLineCount (LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_npplaus_getProtokollLineCount (LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_npplaus_getWarningLine (LKF_CONTEXT *pContext, unsigned int i, char *buf, unsigned int maxlen);
_SCORING_EXPORT unsigned int lkf_npplaus_getWarningInfo (LKF_CONTEXT *pContext, unsigned int i, char *buf, unsigned int maxlen); /* V9.4 */
_SCORING_EXPORT unsigned int lkf_npplaus_getProtokollLine (LKF_CONTEXT *pContext, unsigned int i, char *buf, unsigned int maxlen);
_SCORING_EXPORT const char *lkf_npplaus_sum_headline (LKF_CONTEXT *pContext, char *sBuf, unsigned int lBufLen); /* V10.0 */
_SCORING_EXPORT unsigned int lkf_npplaus_sum_abtcount (LKF_CONTEXT *pContext); /* V10.0 */
_SCORING_EXPORT const char *lkf_npplaus_sum_abtline (LKF_CONTEXT *pContext, unsigned int lLineIndex, char *sBuf, unsigned int lBufLen); /* V10.0 */
_SCORING_EXPORT unsigned int lkf_npplaus_getReasonCount (LKF_CONTEXT *pContext, unsigned int i); /* V10.1 */
_SCORING_EXPORT unsigned int lkf_npplaus_getReasonLine (LKF_CONTEXT *pContext, unsigned int i, unsigned int j, char *buf, unsigned int maxlen); /* V10.1 */
_SCORING_EXPORT unsigned int lkf_npplaus_getInfoLine (LKF_CONTEXT *pContext, unsigned int i, char *buf, unsigned int maxlen); /* V10.1 */

_SCORING_EXPORT unsigned int lkf_npplaus_tfsum_headline (LKF_CONTEXT *pContext, char *sBuf, unsigned int lBufLen);			/* V10.1 */
_SCORING_EXPORT unsigned int lkf_npplaus_critsum_headline (LKF_CONTEXT *pContext, char *sBuf, unsigned int lBufLen);		/* V10.1 */
_SCORING_EXPORT unsigned int lkf_npplaus_tfsum (LKF_CONTEXT *pContext, unsigned int i, char *sBuf, unsigned int lBufLen);   /* V10.1 */
_SCORING_EXPORT unsigned int lkf_npplaus_critsum (LKF_CONTEXT *pContext, unsigned int i, char *sBuf, unsigned int lBufLen); /* V10.1 */


_SCORING_EXPORT void lkf_set_npplaus_tracefilename (LKF_CONTEXT *pContext, const char *outputpath);
_SCORING_EXPORT unsigned int lkf_test_get_neonatologie_limit (const char *diag, unsigned int modelljahr);

/* Intensiv-Scoring-Routinen (intscor5.c) - V8.1 */
_SCORING_EXPORT int lkf_int_scoring (LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_int_getAbtAnz (LKF_CONTEXT *pContext);
_SCORING_EXPORT void lkf_int_getAbtHeadline (LKF_CONTEXT *pContext, char *buf, unsigned int buflen);
_SCORING_EXPORT void lkf_int_getAbtData (LKF_CONTEXT *pContext, unsigned int i, char *buf, unsigned int buflen);
_SCORING_EXPORT unsigned int lkf_int_getAbtEinstufungField (LKF_CONTEXT *pContext, unsigned int lIntAbt, unsigned int lFieldNr, char *sBuf, unsigned int lBufLen);
_SCORING_EXPORT int lkf_getIntAbtCounter (LKF_CONTEXT *pContext, unsigned int lIndex, char *sAbtFC, unsigned int *plAufCount, unsigned int *plTISSCountSum, unsigned int *plTISSCountOK, unsigned int *plTISSCountDouble);
_SCORING_EXPORT int lkf_setIntAbtDataIndex (LKF_CONTEXT *pContext, unsigned int lIndex, unsigned int lTatsBetten);
_SCORING_EXPORT int lkf_setIntAbtData (LKF_CONTEXT *pContext, const char *sAbtFC, unsigned int lTatsBetten);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltCount (const LKF_CONTEXT *pContext);
_SCORING_EXPORT LKF_AUFENTHALT *lkf_int_getAufenthalt (const LKF_CONTEXT *pContext, unsigned int lIntAuf); /* V13.0 */
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltTISSCount (const LKF_CONTEXT *pContext, unsigned int lIntAuf);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltSAPSCount (const LKF_CONTEXT *pContext, unsigned int lIntAuf);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltTRISSCount (const LKF_CONTEXT *pContext, unsigned int lIntAuf);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltDetailsHeadline (const LKF_CONTEXT *pContext, char *sBuf, unsigned int lBufLen);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltTISSDetails (const LKF_CONTEXT *pContext, unsigned int lIntAuf, unsigned int lTISSNr, char *sBuf, unsigned int lBufLen);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltTRISSDetails (const LKF_CONTEXT *pContext, unsigned int lIntAufenthalt, unsigned int lTRISSNr, char *sBuf, unsigned int lBufLen);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltSAPSDetails (const LKF_CONTEXT *pContext, unsigned int lIntAufenthalt, unsigned int lSAPS, char *sBuf, unsigned int lBufLen);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltDetails (const LKF_CONTEXT *pContext, unsigned int lIntAuf, char *sBuf, unsigned int lBufLen);
_SCORING_EXPORT const char *lkf_int_getAnalyseHeadline (const LKF_CONTEXT *pContext, char *buf, unsigned int buflen);
_SCORING_EXPORT const char *lkf_int_getAnalyseData (const LKF_CONTEXT *pContext, unsigned int lIntAbt, unsigned int lMonat, char *buf, unsigned int buflen);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltField (const LKF_CONTEXT *pContext, unsigned int lIntAuf, unsigned int lFieldNr, char *sBuf, unsigned int lBufLen);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltTISSField (const LKF_CONTEXT *pContext, unsigned int lIntAuf, unsigned int lTISS, unsigned int lFieldNr, char *sBuf, unsigned int lBufLen);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltTRISSField (const LKF_CONTEXT *pContext, unsigned int lIntAuf, unsigned int lTRISS, unsigned int lFIeldNr, char *sBuf, unsigned int lBufLen);
_SCORING_EXPORT unsigned int lkf_int_getIntAufenthaltSAPSField (const LKF_CONTEXT *pContext, unsigned int lIntAuf, unsigned int lSAPS, unsigned int lFieldNr, char *sBuf, unsigned int lBufLen);
_SCORING_EXPORT unsigned int lkf_int_setintcontextparameters (LKF_CONTEXT *pContext, const char *sVonDatum, const char *sBisDatum, unsigned int flags, unsigned int mindeststd);
_SCORING_EXPORT const char *ConvertI12toI02 (const LKF_CONTEXT *pContext, char *dest, const char *source); /* V15.1 */

_SCORING_EXPORT unsigned int lkf_int_getAufIsIntAbt (LKF_AUFENTHALT *pAufenthalt, unsigned int lIntAuf); /* V23.1 */
_SCORING_EXPORT unsigned int lkf_int_getAufIntAbtSAPSCount (LKF_AUFENTHALT *pAufenthalt, unsigned int lIntAuf); /* V23.1 */
_SCORING_EXPORT unsigned int lkf_int_getAufIntAbtDetails (LKF_AUFENTHALT *pAufenthalt, unsigned int lIntAuf, unsigned int lSAPS, char *sBuf, unsigned int lBufLen); /* V2019.1 */

_SCORING_EXPORT unsigned int lkf_get_contextvalue(LKF_CONTEXT *pContext, int nr);

/* V2019.1 - SAPS-Score */
#define LKF_INT11_SCORE                     0
#define LKF_INT11_SCORE_ALTER               1
#define LKF_INT11_COEXIST                   2
#define LKF_INT11_PREBELAG                  3
#define LKF_INT11_ZUTRANS                   4
#define LKF_INT11_THERAP_MASSNAHME          5
#define LKF_INT11_AUFNAHMETYP               6
#define LKF_INT11_NEURO                     7
#define LKF_INT11_KARDIOVASKULAER           8
#define LKF_INT11_GASTROINTESTINAL          9
#define LKF_INT11_LEBER                    10
#define LKF_INT11_CHIRURG_STATUS           11
#define LKF_INT11_CHIRURG_EINGRIFF         12
#define LKF_INT11_AKUT_AUFNAHME            13
#define LKF_INT11_GCS_SCORE                14
#define LKF_INT11_BILIRUBIN                15
#define LKF_INT11_KOERPERTEMP              16
#define LKF_INT11_SERUM_KREATININ          17
#define LKF_INT11_HERZFREQUENZ             18
#define LKF_INT11_BLUTBILD_LEUKOZYTEN      19
#define LKF_INT11_BLUTBILD_PH              20
#define LKF_INT11_BLUTBILD_THROMBO         21
#define LKF_INT11_SYSTOL_ARTER_BLUTDRUCK   22
#define LKF_INT11_SAUERSTOFF               23
#define LKF_INT11_AUFNAHMEGRUND            24
#define LKF_INT11_GCS_POINTS               25
#define LKF_INT11_MAX_SCORE_FIELDNR        25

_SCORING_EXPORT int lkf_int_getAufSAPSScore (LKF_AUFENTHALT *pAufenthalt, unsigned int lIntAuf, unsigned int lSAPS, unsigned int lFieldNr); /* V2019.1 */
_SCORING_EXPORT int lkf_int_getIntAufenthaltSAPSScore (const LKF_CONTEXT *pContext, unsigned int lIntAuf, unsigned int lSAPS, unsigned int lFieldNr); /* V2019.1 */

/* Routinen fuer zusaetzliche Satzarten (lkfstru5.c) - V8.1 */
_SCORING_EXPORT unsigned int lkf_setErrorFilter (LKF_CONTEXT *pContext, unsigned int Filter);
_SCORING_EXPORT unsigned int lkf_setErrorCountsFilter (LKF_CONTEXT *pContext, unsigned int Filter); /* V21.5 */
_SCORING_EXPORT unsigned int lkf_getSatzartErrorCount (const LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_getSatzartError (const LKF_CONTEXT *pContext, unsigned int nErrorIndex, unsigned int nBufLen, char *sBuf);
_SCORING_EXPORT unsigned int lkf_getSatzartErrorFields (const LKF_CONTEXT *pContext, unsigned int nErrorIndex, unsigned int fieldCount, const unsigned int *fields, unsigned int nBufLen, char *sBuf);  /* V2025.2 */
_SCORING_EXPORT unsigned int lkf_getSatzartErrorHeadline (const LKF_CONTEXT *pContext, unsigned int nFacility, unsigned int nBufLen, char *sBuf);
_SCORING_EXPORT unsigned int lkf_getSatzartErrorFieldHeadline (const LKF_CONTEXT *pContext, unsigned int nFieldNumber, char *sBuf, unsigned int nBufLen);
_SCORING_EXPORT unsigned int lkf_getSatzartErrorField (const LKF_CONTEXT *pContext, unsigned int nErrorIndex, unsigned int nFieldNumber, char *sBuf, unsigned int nBufLen);
_SCORING_EXPORT const LKF_SATZART_DEFS *lkf_Satzart_getDefinition (unsigned int modell_jahr);
_SCORING_EXPORT unsigned int lkf_Satzart_getCount (const LKF_SATZART_DEFS *pSatzartDefs);
_SCORING_EXPORT unsigned int lkf_Satzart_getSatzartFieldCount (const LKF_SATZART_DEFS *pSatzartDefs, unsigned int satzart_nr);
_SCORING_EXPORT unsigned int lkf_Satzart_getSatzartDef (const LKF_SATZART_DEFS *pSatzartDefs, unsigned int satzart_nr, char *buf, unsigned int buflen);
_SCORING_EXPORT unsigned int lkf_Satzart_getSatzartKeyInfo (const LKF_SATZART_DEFS *pSatzartDefs, unsigned int satzart_nr, char *buf, unsigned int buflen);
_SCORING_EXPORT unsigned int lkf_Satzart_getSatzartFieldInfo (const LKF_SATZART_DEFS *pSatzartDefs, unsigned int satzart_nr, unsigned int field_nr, char *buf, unsigned int buflen);
_SCORING_EXPORT int lkf_setErrorFormat (LKF_CONTEXT *pContext, unsigned int facility, unsigned int count, const unsigned int *fields);
_SCORING_EXPORT unsigned int lkf_Satzart_getSatzartFieldTextId (const LKF_SATZART_DEFS *pSatzartDefs, unsigned int satzart_nr, unsigned int field_nr, char *buf, unsigned int buflen);
_SCORING_EXPORT const void *lkf_Satzart_getSatzartFieldCheck (const LKF_CONTEXT *pContext, const LKF_SATZART_DEFS *pSatzartDefs, unsigned int satzart_nr, unsigned int field_nr); /* V10.2 - Inkompatible Aenderung der Signatur der Funktion */
_SCORING_EXPORT const void *lkf_Satzart_getNextCheck (const LKF_CONTEXT *pContext, const void *pErrorCheck, int onsuccess); /* V10.2 - Inkompatible Änderung der Signatur der Funktion */
_SCORING_EXPORT unsigned int lkf_Satzart_getCheckInfo (const LKF_CONTEXT *pContext, const void *pErrorCheck, const char *sFieldId, const char *sErrorPrefix, char *buf, unsigned int buflen);
_SCORING_EXPORT unsigned int lkf_getErrorIntFromCode (const char *errorcode);
_SCORING_EXPORT const char *lkf_getErrorCodeFromInt (unsigned int code, char *errorbuffer);
_SCORING_EXPORT unsigned int lkf_Satzart_getCheckDetails (const LKF_CONTEXT *pContext, const void *pErrorCheck, char *buf, unsigned int buflen); /* V9.0a */

_SCORING_EXPORT int lkf_write_errsumfile_fromFilter (const char *filename, LKF_CONTEXT *pContext, char *error); /* V21.5 */

#define LKF_ERRORCODE_ID		0
#define LKF_ERRORCODE_TEXT		1
#define LKF_ERRORCODE_COUNT		2
#define LKF_ERRORCODE_SEVERITY  3
#define LKF_ERRORCODE_FACILITY  4
#define LKF_ERRORCODE_OLDCODE	5
#define LKF_ERRORCODE_FOND_REL	6 /* V10.1 */
#define LKF_ERRROCODE_NFOND_REL 7 /* V10.1 */
#define LKF_ERRORCODE_VALUE     11 /* V2019.0 */

_SCORING_EXPORT unsigned int lkf_getSatzartErrorSum_Count (const LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_getSatzartErrorSum_Field (const LKF_CONTEXT *pContext, unsigned int nCodeNr, unsigned int nFieldNr, char *sBuf, unsigned int nBufLen);
_SCORING_EXPORT int lkf_getSatzartErrorSum_CodeToId (const LKF_CONTEXT *pContext, const char *sErrorCode);

_SCORING_EXPORT unsigned int lkf_context_getAllErrorCount (const LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_context_getAllErrorInfo (const LKF_CONTEXT *pContext, unsigned int nCodeNr, unsigned int nFieldNr, char *sBuf, unsigned int nBufLen);
_SCORING_EXPORT int lkf_context_getAllErrorInfo_CodeToId (const LKF_CONTEXT *pContext, const char *sErrorCode);

/* Check-Routinen fuer zusaetzliche Satzarten (satzchk5.c) */

/* #define LKF_CHECK_PLAUS			1
#define LKF_CHECK_INTSCOR		2 */
#define LKF_CHECK_GEN			4
#define LKF_CHECK_ALL			7

_SCORING_EXPORT unsigned int lkf_check (LKF_CONTEXT *pContext, unsigned int modus);
_SCORING_EXPORT unsigned int lkf_check_abortable (LKF_CONTEXT *pContext, unsigned int modus, LKFEXECUTION_DELEGATE cb, unsigned int stepSize);
_SCORING_EXPORT unsigned int lkf_check_nombds (LKF_CONTEXT *pContext, unsigned int modus);

_SCORING_EXPORT unsigned int lkf_recompute_aufenthalt (LKF_AUFENTHALT *pAufenthalt);

_SCORING_EXPORT LKF_SATZART_ERRORINFO_LIST *lkf_create_errorinfo (LKF_CONTEXT *pContext, unsigned int nListOptions);
_SCORING_EXPORT void lkf_free_errorinfo (LKF_SATZART_ERRORINFO_LIST *pList);
_SCORING_EXPORT unsigned int lkf_errorinfo_getCount (const LKF_SATZART_ERRORINFO_LIST *pList);
_SCORING_EXPORT const LKF_SATZART_ERRORINFO *lkf_errorinfo_getError (const LKF_SATZART_ERRORINFO_LIST *pList, unsigned int i);
_SCORING_EXPORT unsigned int lkf_errorinfo_getErrorUsageCount (const LKF_SATZART_ERRORINFO *pErrorInfo);
_SCORING_EXPORT LKF_SATZART_ERRORINFO_USAGE *lkf_errorinfo_getErrorUsage (const LKF_SATZART_ERRORINFO *pErrorInfo, unsigned int i);
_SCORING_EXPORT unsigned int lkf_errorinfo_getHeadline (const LKF_SATZART_ERRORINFO_LIST *pList, char *buf, unsigned int len);
_SCORING_EXPORT unsigned int lkf_errorinfo_getErrorLine (const LKF_SATZART_ERRORINFO *pErrorInfo, char *buf, unsigned int buflen);
_SCORING_EXPORT unsigned int lkf_errorinfo_getErrorUsageLine (const LKF_SATZART_ERRORINFO_USAGE *pErrorUsage, char *buf, unsigned int buflen);

_SCORING_EXPORT const char *lkf_satzart_getValue (const LKF_CONTEXT *pContext, const LKF_SATZART_ERROR *pError, unsigned int nField, char *buf, unsigned int buflen); /* V2019.0 */

/* V2024.1 */
_SCORING_EXPORT LKF_ANONYMISATION_CONTEXT *lkf_create_anonymisation_context (LKF_CONTEXT *pTargetContext, const char *parameters);
_SCORING_EXPORT void lkf_free_anonymisation_context (LKF_ANONYMISATION_CONTEXT *pAContext);
_SCORING_EXPORT LKF_AUFENTHALT *lkf_anonymisation_add_aufenthalt (LKF_ANONYMISATION_CONTEXT *pAContext, LKF_AUFENTHALT *pAufenthalt);

#define LKF_COPYADDLINE_K01      1
#define LKF_COPYADDLINE_K        2
#define LKF_COPYADDLINE_L        4
#define LKF_COPYADDLINE_B        8
#define LKF_COPYADDLINE_ADDL01  16
#define LKF_COPYADDLINE_ADDL02  32
#define LKF_COPYADDLINE_ADDL03  64
#define LKF_COPYADDLINE_ADDL04 128

_SCORING_EXPORT void lkf_copy_addlines (LKF_CONTEXT *pTargetContext, LKF_CONTEXT *pContext, int flags);

/* Batch-Routinen fuer Client-Server-Betrieb (batch5.c) */
_SCORING_EXPORT LKF_BATCH_PROCESSING *lkf_batch_alloc (LKF_CONTEXT *pContext);
_SCORING_EXPORT void lkf_batch_free (LKF_BATCH_PROCESSING *pBatch);
_SCORING_EXPORT unsigned int lkf_batch_execute (LKF_BATCH_PROCESSING *pBatch, const char *line);

/* Statistik-Routinen (lkfstat5.c) - V8.1 */

#define LKF_STAT_BELAGSTAGE   0
#define LKF_STAT_AUFNAHMEN    1
#define LKF_STAT_VERBLIEBEN   2
#define LKF_STAT_ENTLASSUNG   3
#define LKF_STAT_VERSTORBEN   4
#define LKF_STAT_VERBLEIBEND  5
#define LKF_STAT_GANZJAHR     6
#define LKF_STAT_EINTAG		  7
#define LKF_STAT_MAENNLICH    8
#define LKF_STAT_WEIBLICH	  9
#define LKF_STAT_AUFCOUNT	 10
#define LKF_STAT_PFLEGETAGE	 11
#define LKF_STAT_AMB         12
#define LKF_STAT_DIVERS      13 /* V2020.0 */

#define LKF_STAT_MAXSTATFIELD 12

#define LKF_STAT_AGGREGATE_VALUE -1

#define LKF_STATTYPE_KA				0
#define LKF_STATTYPE_ABT			1
#define LKF_STATTYPE_ALTER			2
#define LKF_STATTYPE_HAUPTWOHNSITZ	3

#define CASESTAT_CATEGORY_MAX 34
#define CASESTAT_IDENT_MAX 18
#define CASESTAT_KEY_MAX (CASESTAT_CATEGORY_MAX+CASESTAT_IDENT_MAX)
typedef struct {
    char category[CASESTAT_CATEGORY_MAX];
    char ident[CASESTAT_IDENT_MAX];
    char key[CASESTAT_KEY_MAX];
    unsigned int stat;
    unsigned int amb;
    unsigned int ambstat;
} LKF_CASESTAT_CATEGORY;

_SCORING_EXPORT unsigned int lkf_stat (LKF_CONTEXT *pContext);
_SCORING_EXPORT unsigned int lkf_stat_package (LKF_CONTEXT *pContext); /* V21.0 */
_SCORING_EXPORT unsigned int lkf_stat_getLineCount (LKF_CONTEXT *pContext, unsigned int nType);
_SCORING_EXPORT unsigned int lkf_stat_getHeadline (LKF_CONTEXT *pContext, unsigned int nType, char *sBuf, unsigned int nBufLen);
_SCORING_EXPORT unsigned int lkf_stat_getLine (LKF_CONTEXT *pContext, unsigned int nType, unsigned int nLine, char *sBuf, unsigned int nBufLen);
_SCORING_EXPORT unsigned int lkf_stat_getFieldByPosition (LKF_CONTEXT *pContext, unsigned int nType, unsigned int nLine, int nNr, char *sBuf, unsigned int nBufLen);
_SCORING_EXPORT unsigned int lkf_stat_getField (LKF_CONTEXT *pContext, unsigned int nType, unsigned int nLine, int nField, char *sBuf, unsigned int nBufLen);
_SCORING_EXPORT unsigned int lkf_stat_getFieldCount (LKF_CONTEXT *pContext, unsigned int nType);
_SCORING_EXPORT unsigned int lkf_stat_getFieldAtIndex (LKF_CONTEXT *pContext, unsigned int nType, unsigned int index);
_SCORING_EXPORT int lkf_stat_getFieldPosition (LKF_CONTEXT *pContext, unsigned int nType, int nField);
_SCORING_EXPORT unsigned int lkf_stat_getFieldHeadlineByPosition (LKF_CONTEXT *pContext, unsigned int nType, int nPos, char *sBuf, unsigned int nBufLen);
_SCORING_EXPORT unsigned int lkf_stat_getFieldHeadline (LKF_CONTEXT *pContext, unsigned int nType, int nFieldNr, char *sBuf, unsigned int nBufLen);
_SCORING_EXPORT int lkf_stat_getLineByLineInfo (LKF_CONTEXT *pContext, unsigned int nType, const char *sInfo);
_SCORING_EXPORT unsigned int lkf_casestat_get_category_count (LKF_CONTEXT *pContext);
_SCORING_EXPORT LKF_CASESTAT_CATEGORY *lkf_casestat_get_category(LKF_CONTEXT *pContext, unsigned int index);
/* Trace-Routinen (trace5.c) - V10.2 ******************************************************************/

//#define ENABLE_CASESTAT 1

#define LKFTRACE_INIT(context)	     /* lkf_set_debug_trace(context) */
#define LKFTRACE_DEBUG_FILENAME     "c:\\lkftrace.txt"
#define LKFTRACE_DEBUG_SAFE_FILE	0
#define LKFTRACE_DEBUG_MBDS			(LKF_TRACE_DETAIL | LKF_TRACE_INPUT)
#define LKFTRACE_DEBUG_INTSCOR		LKF_TRACE_DETAIL
#define LKFTRACE_DEBUG_KASKORE		LKF_TRACE_DETAIL
#define LKFTRACE_DEBUG_SAVEPROTOCOL 0
#define LKFTRACE_DEBUG_PATID		""

#define LKF_TRACE_OFF       0
#define LKF_TRACE_INFO      1
#define LKF_TRACE_DETAIL    2
#define LKF_TRACE_INPUT     256

_SCORING_EXPORT unsigned int lkf_trace_getLineCount (const LKF_CONTEXT *pContext);
_SCORING_EXPORT const char *lkf_trace_getLine (const LKF_CONTEXT *pContext, unsigned int nLineNr);
_SCORING_EXPORT void lkf_trace_setAufenthalt (LKF_CONTEXT *pContext, const char *sAufNr);
_SCORING_EXPORT void lkf_trace_setLevel (LKF_CONTEXT *pContext, int nFacility, int nLevel);
_SCORING_EXPORT const char *lkf_trace_getAufenthalt (const LKF_CONTEXT *pContext);
_SCORING_EXPORT int lkf_trace_getLevel (const LKF_CONTEXT *pContext, unsigned int nFacility);
_SCORING_EXPORT void lkf_set_debug_trace (LKF_CONTEXT *pContext);
_SCORING_EXPORT void lkf_set_debug_tracefile (LKF_CONTEXT *pContext, const char *sFile, int bSafeFile, int bFileOnly);
_SCORING_EXPORT void lkf_set_debug_tracecb (LKF_CONTEXT *pContext, LKFTRACE_DELEGATE traceDelegate, int bFileOnly); /* V2021.2 */

#define LKF_MEMORYSETTINGS_DELEGATE_ALL 1
_SCORING_EXPORT void lkf_setMemoryTraceDelegate (LKFMEMORY_DELEGATE memoryDelegate, int delegateFlags);

_SCORING_EXPORT void lkf_set_memoryDebugLimit (long long available, long long used, const char *breaking, int breakingCount);
_SCORING_EXPORT int lkf_enableMemoryTrace (void);

_SCORING_EXPORT void lkf_clear_debug_memory_limit (void);
_SCORING_EXPORT unsigned int lkf_get_debugmemoryStatus (char *bufptr, unsigned int len);

_SCORING_EXPORT void lkf_finish_debug_tracecb (LKF_CONTEXT *pContext); /* V2021.2 */
_SCORING_EXPORT void lkf_trace_finished (LKF_CONTEXT *pContext);

#ifdef LKF_INCLUDE_DEPRECATED_FUNCTIONALITY
_SCORING_EXPORT int  lkf_write_errorfile (const char *filename, LKF_CONTEXT *pContext, unsigned int kanr, int flags, const char *inputfile, const char *outputfile, char *error);
_SCORING_EXPORT void  lkf_plaus_WriteWEHeader (LKF_CONTEXT *pContext, FILE *err, FILE *warn, unsigned int kanr, const char *input_file);
_SCORING_EXPORT void  lkf_plaus_WriteWEFooter (LKF_CONTEXT *pContext, FILE *err, FILE *warn, unsigned int kanr, const char *ausgabedatei);
_SCORING_EXPORT void lkf_plaus_WriteFileHeader (LKF_CONTEXT *pContext, FILE *fp, unsigned int filenr, unsigned int kanr, const char *ausgabedatei, void *additional); /* V7.0 */
_SCORING_EXPORT void lkf_plaus_WriteFileFooter (LKF_CONTEXT *pContext, FILE *fp, unsigned int filenr, unsigned int kanr, const char *ausgabedatei, void *additional); /* V7.0 */
_SCORING_EXPORT unsigned int lkf_convertMBDSErrorCode (const LKF_CONTEXT *pContext, unsigned int olderrorcode);
_SCORING_EXPORT unsigned int lkf_convertMBDSWarningCode (const LKF_CONTEXT *pContext, unsigned int oldwarningcode);
_SCORING_EXPORT void lkf_get_errorcode_minmax (unsigned int *, unsigned int *);
_SCORING_EXPORT void lkf_get_warningcode_minmax (unsigned int *, unsigned int *);
_SCORING_EXPORT unsigned int lkf_add_mel  (LKF_AUFENTHALT *pAufenthalt, const char *mel, const char *melanz);

#endif

/* xrecords.c */
_SCORING_EXPORT int lkf_add_xline (LKF_CONTEXT *pContext, const char *line);
_SCORING_EXPORT int lkf_add_xlineIdent (LKF_CONTEXT *pContext, const char *line, char *ident); /* V2024.0 */
_SCORING_EXPORT int lkf_replace_xline (LKF_CONTEXT *pContext, const char *line, const char *ident); /* V2024.0 */
_SCORING_EXPORT int lkf_delete_xline (LKF_CONTEXT *pContext, const char *ident); /* V2024.0 */
_SCORING_EXPORT LKF_AUFENTHALT *lkf_getAufenthaltFromLine (LKF_CONTEXT *pContext, const char *line); /* V2024.0 */
_SCORING_EXPORT int lkf_auf_replaceLine (LKF_AUFENTHALT *pAufenthalt, const char *line, const char *ident); /* V2024.0 */
_SCORING_EXPORT unsigned int lkf_get_context_l (LKF_CONTEXT *pContext, unsigned int satzart, unsigned int index, char *buf, unsigned int buflen); /* V2024.1 */
_SCORING_EXPORT unsigned int lkf_get_context_l_count (LKF_CONTEXT *pContext, unsigned int satzart, int copyFlag); /* V2024.1 */
_SCORING_EXPORT LKF_AUFENTHALT *lkf_auf_addCopy (LKF_AUFENTHALT *pAufenthalt, const char *x01); /* V2025.0 */
_SCORING_EXPORT int lkf_delete_aufenthalt (LKF_AUFENTHALT *pAufenthalt); /* V2025.0 */
_SCORING_EXPORT int lkf_replace_aufenthalt (LKF_AUFENTHALT *pAufenthalt, const char *x01); /* V2025.0 */
#endif  /* LKF5DEFS_H */
