/*
 * Copyright (c) 1995, 1996 Gunther Schadow.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

:- module(composites,[ctyp_imp/2]).

:- style_check(+string).

/* Implementation of HL7 v2.1 composite data types
 *
 * ctyp_imp(Type,C_Decl).
 *
 * where C_Decl is a list of type records.
 * A type record is a list of the folowing structure:
 *  [Type,Name]. 
 */

ctyp_imp(ad,[[st,'street address'],
	[st,'other destination'],
	[st,city],
	[st,'state or province'],
	[st,zip],
	[st,country]]).
ctyp_imp(pn,[[st,'family name'],
	[st,'given name'],
	[st,'middle initial or name'],
	[st,suffix],
	[st,prefix],
	[st,degree]]).
ctyp_imp(cm,[[st,'component 1'],
	[st,'component 2'],
	[st,'component 3'],
	[st,'component 4'],
	[st,'component 5'],
	[st,'component 6'],
	[st,'component 7'],
	[st,'component 8']]).
ctyp_imp(ce,[[id,'identifier'],
	[st,'text'],
	[id,'coding system'],
	[id,'alternate identifier'],
	[st,'alternate text'],
	[id,'alternate coding system']]).
ctyp_imp(ck,[[id,'id number'],
	[nm,'check digit'],
	[code(61),'check digit scheme']]).
ctyp_imp(cn,[[id,'id number'],
	[st,'family name'],
	[st,'given name'],
	[st,'middle initial or name'],
	[st,suffix],
	[st,prefix],
	[st,degree]]).
ctyp_imp(cq,[[nm,'quantity'],
	[id,'units']]).
ctyp_imp(zm,[[code(76),'message id'],
	[code(3),'event type']]).
ctyp_imp(zl,[[id,'nurse unit'], [id,'room'], [id,'bed']]).
ctyp_imp(ze,[[st,'segment id'],
	[nm,'sequence'],
	[nm,'field position'],
	[ce,'code identifying error'],
	[st,'full path']]).

/*
 * Installation Clause
 */

:- forall(composites:ctyp_imp(A,_),
	(
	    uppercase(A,UA),
	    concat(UA,'typ.h',F),
	    asserta(desc_files:file(cmp_type,A,F))
	)).

