/****************************************************************************
** Leistungsorientierte Krankenanstaltenfinanzierung (LKF)                 **
** Scoring-C-Sourcen V14.0 (Abrechnungsmodell 2010)                        **
** (C) 1997-2009 Bundesministerium für Gesundheit                          **
*****************************************************************************
** lkf5defs.h - Schnittstellendefinitionen                                 **
**                                                                         **
**		 Alex.Holzer@chello.at                                             **
**       Bernhard.Pesec@dothealth.at                                       **
***************************************************************************/

#ifndef LKF5DEFS_H
#define LKF5DEFS_H


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

#define _CRT_SECURE_NO_DEPRECATE 1

#define LKF_VERSION "13.0"     /* V13.0 */
#define LKF_YEAR_FIRST  2001   /* V9.2 */
#define LKF_YEAR_LATEST 2010   /* V14.0 */



/*****************************************************************************
** PLAUSIBILITÄTS-ERRORCODES                                                **
*****************************************************************************/

#define PATID_FEHLT			  1
#define GEBDAT_FEHLT		  2
#define AUFDAT_VOR_GEBDAT	  3
#define GEBDAT_FALSCH		  4
#define ENTDAT_FEHLT		  5
#define ENTDAT_FALSCH		  6
#define ENTDAT_NOERHEBUNG	  7
#define ENTDAT_NOPERIODE	  8
#define AUFDAT_FEHLT		  9
#define AUFDAT_FALSCH		 10
#define AUFDAT_NACH_ENTDAT	 11
#define AUF_FC_FEHLT		 12
#define ABTDAT_FALSCH		 13
#define ABT_FC_FEHLT		 14
#define NO_CHRONO_DAT		 15
#define GESCHL_FALSCH		 16
#define AUFART_FALSCH		 17
#define ENTART_FALSCH		 18
#define ABTFC_FALSCH		 19
#define ABTFC_DAT_FEHLT		 20
#define HD_UNGUELTIG		 21
#define HD_FALSCH			 22
#define HD_FEHLT			 23
#define HD_ENTART_FALSCH	 24
#define HD_ALTER_FALSCH		 25
#define HD_GESCHL_FALSCH	 26
#define ZD_FALSCH			 27
#define ZD_ENTART_FALSCH	 28
#define ZD_ALTER_FALSCH		 29
#define ZD_GESCHL_FALSCH	 30
#define MEL_MELANZ_FALSCH	 31
#define MEL_ALTER_FALSCH	 32
#define MEL_GESCHL_FALSCH	 33
#define MELANZ_FALSCH		 34
#define MELANZ_OHNE_MEL		 35
#define MEL_FALSCH			 36
#define MEL_PLAUSANZ_ERR	 37
#define HALBSTAT_ERR		 38
#define ABTFC_NO_ORDER       39
#define MEL_BDGR0_ERR		 40
#define MEL_ENTART_FALSCH	 41
#define ABT1_UNGLEICH_AUFDAT 43

#define HD_DREISTELLER		 45
#define ZD_DREISTELLER		 46
#define PSYCHTKL_AUFART_FALSCH 47
#define KA_FALSCH			 48
#define HD_MULTIBEL			 49

#define MEL_NICHT_ERBRINGBAR 50
#define VERLEGUNGEN_UNGUELTIG 51
#define AUFART_ABT_UNGUELTIG 52
#define ENTART_ABT_UNGUELTIG 53
#define PSYCH_SERIE_UNTERBROCHEN 54
#define PSYCH_ABSCHLIESSEN   55
#define PSYCH_HALBSTAT_MEL_FEHLT 56 /* V7.1 */
#define MIN_ERRORCODE_NUM	  1
#define MAX_ERRORCODE_NUM    60

/*****************************************************************************
** PLAUSIBILITÄTS-WARNINGCODES                                              **
*****************************************************************************/

#define HOHES_ALTER			  1
#define STAATW_FALSCH		  2
#define STAATW_FEHLT		  3
#define STAATB_FALSCH		  4	
#define STAATB_FEHLT		  5
#define PLZ_FEHLT			  6
#define PLZ_FALSCH			  7
#define KOST_FALSCH			  8
#define KOST_FEHLT			  9
#define HD_UNWAHRSCHEINLICH	 10
#define HD_KEIN_UCODE		 11
#define ZD_UNWAHRSCHEINLICH	 12
#define MEL_PLAUSANZ_WARN	 13
#define MEL_DIAG_ERR		 14
#define MEL_KA_UNPLAUSIBEL   15
#define MEL_ENTFERNT		 16
#define MEL_KJNP_OHNEFC		 17
#define IST_KURZLIEGER		 18
#define VD_LANG				 19
#define MEL_AMBULANT		 20
#define HD_BDGR0			 21
#define HD_AMBULANT			 22
#define MEL_BDGR0_WARN		 23
#define STERN_OHNE_KREUZ_ZD  24
#define STERN_OHNE_KREUZ_HD  25
#define MEL_MEL_KOMBINATION  26

#define MEL_MELDAT_FALSCH	  27
#define MEL_MELDAT_FEHLT	  28
#define MEL_MELDAT_AUSSERHALB 29
#define PSYCHMEL_KEINEPUNKTE  30
#define PSYCHMEL_OHNE_HALBSTAT 31 /* V7.1 */

#define NPPLAUS_WARNING       32 /* V7.2 */
#define NPPLAUS_NUR_NEON      33 /* V7.2 */
#define NPPLAUS_NUR_UEB       34 /* V7.2 */
#define NPPLAUS_7299		  35 /* V7.2 */
#define NPPLAUS_MELOHNEDAT	  40 /* V10.0 */


#define PSYCH_IGNOREMEL	  36 /* V7.2 */

#define MEL_MEL_KOMBINATION_TAG 37 /* V8.0 */
#define SPEZ_ABTFC_UNGUELTIG 38 /* V8.0 */
#define ABTFC_19_WARNING 39

#define MIN_WARNINGCODE_NUM   1 
#define MAX_WARNINGCODE_NUM  50


/*************************************************************************
** Konstante für 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 für 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
#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_ENTABTINDEX   75 /* V10.1 */
#define CHECKFIELD_KST           81 /* V11.0 */
#define CHECKFIELD_ENTKST        82 /* V11.0 */
#define CHECKFIELD_KST_ENTKST    83 /* V11.0 */


/* Konstanten für 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_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_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

/* nicht mehr unterstützt (-> lkf_auf_get_??? verwenden)
#define SCORFIELD_ABTFC			11
#define SCORFIELD_ABTDAT		12
#define SCORFIELD_ABTVD			13
#define SCORFIELD_ZD			18
#define SCORFIELD_MEL			19
**********/


/* 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_PRIVATE_SPEZLIST	  (1<<8)
#define LKFCONTEXT_USE_PRIVATE_KOSTLIST   (1<<9)
#define LKFCONTEXT_USE_PRIVATE_MELKALIST  (1<<10)
#define LKFCONTEXT_USE_ALL_PRIVATE        (LKFCONTEXT_USE_PRIVATE_SPEZLIST+LKFCONTEXT_USE_PRIVATE_KOSTLIST+LKFCONTEXT_USE_PRIVATE_MELKALIST)

/* Sonstige FLAGS-Konstanten */
#define LKFCONTEXT_TAGESKLINIKMODELL      (1<<5)   /* V5.1T */
#define LKFCONTEXT_ALLOWQUICKSCORE        (1<<6)   /* V6.0 */
#define LKFCONTEXT_OPTIMIZER              (1<<7)   /* V6.0 */
#define LKFCONTEXT_NICHTFONDSKA			  (1<<12)
#define LKFCONTEXT_EXPORT_ABCD			  (1<<15)
#define LKFCONTEXT_NPPLAUS				  (1<<11)   /* V7.2 */
#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_IGNORE2007ERRORS       (1<<17)   /* V11.0: ignoriert fuer Testzwecke alle Plaus-Errors, die 2007 dazugekommen sind; ab 12.1: auch 2008 */
#define LKFCONTEXT_OSG					  (1<<18)   /* V11.1: 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_SIM1					  (1<<21)   /* V13.0: 2097152: Simulation 1 */ 
#define LKFCONTEXT_SIM2                   (1<<22)   /* V13.0: 4194304: Simulation 2 */

#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 LKFDIFF_PLAUS   1
#define LKFDIFF_SCGES   (1<<1)


typedef struct LKF_CONTEXT LKF_CONTEXT;
typedef struct LKF_AUFENTHALT LKF_AUFENTHALT;
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_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;

typedef void * (*ALLOC_SEMAPHORE_CALLBACK)(void); /* V6.0 */
typedef void (*SEMAPHORE_CALLBACK)(void *);       /* V6.0 */

#define LKF_FILE_ERROR			0 /* V7.0 */
#define LKF_FILE_WARNING		1 /* V7.0 */
#define LKF_FILE_ABT			2 /* V7.0 */
#define LKF_FILE_MELDEDIAG      3 /* V7.0 */


/* V8.1: Error Facility */

#define LKF_FAC_ALL		 0	/* Error (Warning) für 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ßgeräte-Bereich */
#define LKF_FAC_BERICHT  5  /* V14.2: Error (Warning) im Berichts-Bereich */
#define LKF_FAC_ALLOC	 6

#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_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<<LKF_FAC_BERICHT)	/* =  8192 */
#define LKF_ERRORFILTER_ALLWARNINGS		(255<<8)								/* = 65280 */
#define LKF_ERRORFILTER_ALL				65535
#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_EINSTUFUNG  21
#define LKF_INTSCORFIELD_KORRFAKTOR  22
#define LKF_INTSCORFIELD_TISSMW      23

/* Routinen zur Bearbeitung der Aufenthalts-Struktur (auf5.c) *********************/
_SCORING_EXPORT LKF_AUFENTHALT *lkf_alloc_aufenthalt (void);
_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 (const LKF_AUFENTHALT *pAufenthalt); /* V6.0 */

_SCORING_EXPORT unsigned int lkf_auf_getlineanz (const LKF_AUFENTHALT *pAufenthalt); /* V6.0 */
_SCORING_EXPORT int lkf_auf_getline (const LKF_AUFENTHALT *pAufenthalt, unsigned int index, char *line); /* V6.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); /* V8.1 */
_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_mel  (LKF_AUFENTHALT *pAufenthalt, const char *mel, const char *melanz);
_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_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 (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_melanz (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_diaganz (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_akwarnanz (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_kommentaranz (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_kostanz (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_scoringanz (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_customanz (const LKF_AUFENTHALT *pAufenthalt);

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

_SCORING_EXPORT int lkf_auf_get_field (const LKF_AUFENTHALT *pAufenthalt, unsigned int fieldnum, const char **field, unsigned int *len); /* V6.0 - NOT THREAD-SAFE! */
_SCORING_EXPORT unsigned int lkf_auf_get_fieldvalue (const LKF_AUFENTHALT *pAufenthalt, unsigned int fieldnum, char *buf, unsigned int buflen); /* V8.1 */

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

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

_SCORING_EXPORT int lkf_auf_line_kommentar (const LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *line);
_SCORING_EXPORT int lkf_auf_line_svnr (const LKF_AUFENTHALT *pAufenthalt, char *line);
_SCORING_EXPORT int lkf_auf_line_custom (const 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 (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT int lkf_auf_get_opt_subgruppe (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT int lkf_auf_get_min_subgruppe (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT double lkf_auf_get_opt_percentage (const LKF_AUFENTHALT *pAufenthalt);

_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_firsterror (const LKF_AUFENTHALT *);
_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_nexterror (const LKF_ERROR_LIST *);
_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_firstwarning (const LKF_AUFENTHALT *);
_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_nextwarning (const LKF_ERROR_LIST *);
_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_firstinfo (const LKF_AUFENTHALT *); /* V13.1 */
_SCORING_EXPORT LKF_ERROR_LIST * lkf_auf_nextinfo (const LKF_ERROR_LIST *); /* V13.1 */
_SCORING_EXPORT void lkf_auf_getErrorLine (const LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *pList, char *sBuf, unsigned int nBufLen); /* V10.1 */
_SCORING_EXPORT void lkf_auf_getWarningLine (const LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *pList, char *sBuf, unsigned int nBufLen); /* V10.1 */
_SCORING_EXPORT void lkf_auf_getInfoLine (const 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 (const 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 (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT unsigned int lkf_auf_get_subgruppenanz (const LKF_AUFENTHALT *pAufenthalt);
_SCORING_EXPORT long lkf_auf_get_scorvalue (const LKF_AUFENTHALT *pAufenthalt, unsigned int field);
_SCORING_EXPORT const char *lkf_auf_get_gruppe (const LKF_AUFENTHALT *pAufenthalt, char *gruppe, char *knoten);
_SCORING_EXPORT const char *lkf_auf_get_gruppe_mel (const LKF_AUFENTHALT *pAufenthalt, char *mel);
_SCORING_EXPORT const char *lkf_auf_get_subgruppe_gruppe (const LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *gruppe, char *knoten);
_SCORING_EXPORT const char *lkf_auf_get_subgruppe_mel (const LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *mel);
_SCORING_EXPORT const char *lkf_auf_get_subgruppe_diag (const LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *diag); /* V6.0 */
_SCORING_EXPORT long lkf_auf_get_subgruppe_scorvalue (const LKF_AUFENTHALT *pAufenthalt, unsigned int i, unsigned int field);
_SCORING_EXPORT int lkf_auf_is_marked (const 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 (const LKF_AUFENTHALT *pAufenthalt); /* V8.1 */
_SCORING_EXPORT int lkf_auf_getintline (const LKF_AUFENTHALT *pAufenthalt, unsigned int i, char *l); /* V8.1 */

/* Basis-Funktionen (utils5.c) ************************************************/
_SCORING_EXPORT int lkf_GetInt (const char *text, int len, int *resultat);

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

_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 LKF_CONTEXT *  lkf_alloc_context (unsigned int modelljahr, const char *input_path, 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); /* V6.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 unsigned int  lkf_plaus_GetErrorCodeCount (LKF_CONTEXT *pContext, unsigned int kanr, int nr);
_SCORING_EXPORT unsigned int  lkf_plaus_GetWarningCodeCount (LKF_CONTEXT *pContext, unsigned int kanr, 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 void 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); /* V8.1 */
_SCORING_EXPORT void lkf_set_abrechnungsjahr (LKF_CONTEXT *pContext, int abrechnungsjahr); /* V8.1 */
_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_write_file (const char *filename, LKF_CONTEXT *pContext, unsigned int kanr, int flags, char *error);
_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 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 const char *lkf_get_context_error (const LKF_CONTEXT *pContext); /* V9.2 */
_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_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, const 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 const char *lkf_context_get_errortext (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); /* V8.1 */
_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();
_SCORING_EXPORT unsigned int lkf_GetYearFirst ();
_SCORING_EXPORT unsigned int lkf_GetYearLatest ();

_SCORING_EXPORT unsigned int lkf_getaddlineanz (const LKF_CONTEXT *pContext); /* V8.1 */
_SCORING_EXPORT int lkf_getaddline (const LKF_CONTEXT *pContext, unsigned int i, char *l); /* V8.1 */

_SCORING_EXPORT unsigned int lkf_context_getSummensatz (const LKF_CONTEXT *pContext, char *sBuf, unsigned int nBufLen); /* V8.1 */

/* 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);

#define LKF_COMPATIBILITY_NEW						0
#define LKF_COMPATIBILITY_OLD						1
#define LKF_COMPATIBILITY_OLD_WITH_ERRORS			3
#define LKF_COMPATIBILITY_SCORINGOUTPUT				4
#define LKF_COMPATIBILITY_ONLYINTSCORING			8
#define LKF_COMPATIBILITY_IGNOREERRORSFORINTSCOR   16

_SCORING_EXPORT void lkf_set_compatibilitymode (LKF_CONTEXT *pContext, unsigned int compatibility);
_SCORING_EXPORT int lkf_write_datafile (const 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);

/* 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_plaus_GetErrorAnz (const LKF_AUFENTHALT *pAufenthalt, int *accepted);
_SCORING_EXPORT int  lkf_plaus_GetWarningAnz (const LKF_AUFENTHALT *pAufenthalt, int *accepted);
_SCORING_EXPORT int  lkf_plaus_GetInfoAnz (const LKF_AUFENTHALT *pAufenthalt, int *accepted); /* V13.1 */
_SCORING_EXPORT const char *  lkf_plaus_WarningCode2Text (const LKF_CONTEXT *, int nr);
_SCORING_EXPORT int  lkf_plaus_WarningCode2Massnahme (const LKF_CONTEXT *, int nr);
_SCORING_EXPORT const char *  lkf_plaus_ErrorCode2Text (const LKF_CONTEXT *pContext, int nr);
_SCORING_EXPORT int  lkf_plaus_GetErrorText4 (const LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *pError, char *errortext, char *errorfield);
_SCORING_EXPORT int  lkf_plaus_GetErrorText (const LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *, char *text, int len);
_SCORING_EXPORT int  lkf_plaus_GetWarningText4 (const LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *pError, char *warningtext, char *warningfield);
_SCORING_EXPORT int  lkf_plaus_GetWarningText (const LKF_AUFENTHALT *pAufenthalt, const LKF_ERROR_LIST *, char *text, int len);

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

_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_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 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 const char *lkf_plaus_meldediag_typ (const LKF_CONTEXT *pContext, char nr); /* V7.0 */
_SCORING_EXPORT const char *lkf_plaus_meldediag_text (const LKF_CONTEXT *pContext, char nr); /* V7.0 */
_SCORING_EXPORT LKF_ERROR_LIST *lkf_auf_firstmeldediag (const LKF_AUFENTHALT *pAufenthalt); /* V7.0 */
_SCORING_EXPORT LKF_ERROR_LIST *lkf_auf_nextmeldediag (const LKF_ERROR_LIST *pMeldeDiag); /* V7.0 */
_SCORING_EXPORT int  lkf_plaus_GetMeldeDiagAnz (const LKF_AUFENTHALT *pAufenthalt);

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

_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);


/* 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);


/* 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 int lkf_stamm_line_spez  (const LKF_CONTEXT *pContext, unsigned int i, char *line);
_SCORING_EXPORT int lkf_stamm_line_kost  (const LKF_CONTEXT *pContext, const char *kanr, unsigned int i, char *line);
_SCORING_EXPORT int lkf_stamm_line_melka (const LKF_CONTEXT *pContext, unsigned int i, char *line);
_SCORING_EXPORT int lkf_init_stamm (unsigned int modelljahr, char *error);
_SCORING_EXPORT long lkf_unloadStamm (void); /* LKF2002 */
_SCORING_EXPORT unsigned int lkf_get_stamm_path (const LKF_CONTEXT *pContext, const char *filename, char *buf, unsigned int buflen); /* V8.1 */
_SCORING_EXPORT int lkf_ABTFC_to_Name (const LKF_CONTEXT *pContext, const char *sAbtFC, char *buf); /* V8.1 */

/* Filter-Routinen (filter5.c) */
_SCORING_EXPORT LKF_FILTER *lkf_filter_create (const char **str);
_SCORING_EXPORT void lkf_filter_drop (LKF_FILTER *krit);
_SCORING_EXPORT int lkf_auf_filter (const 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);


/* 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 const 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);

/* 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_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_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 void 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 Änderung 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 */

#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 */

_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 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);


/* 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_MAXSTATFIELD 11

#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

_SCORING_EXPORT unsigned int lkf_stat (LKF_CONTEXT *pContext);
_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_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);

/* Trace-Routinen (trace5.c) - V10.2 ******************************************************************/

#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 unsigned 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_trace_finished (LKF_CONTEXT *pContext);



#endif  /* LKF5DEFS_H */
