/*
 * 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,install_files/0]).

:- style_check(+string).

/* Implementation of HL7 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'],
	[pn,name]]).
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']]).

file(cmp_type,pn,'PNtyp.h').
file(cmp_type,ad,'ADtyp.h').
file(cmp_type,cm,'CMtyp.h').
file(cmp_type,ce,'CEtyp.h').
file(cmp_type,ck,'CKtyp.h').
file(cmp_type,cn,'CNtyp.h').
file(cmp_type,cq,'CQtyp.h').
file(cmp_type,zm,'ZMtyp.h').
file(cmp_type,zl,'ZLtyp.h').

install_files(forall(composites::file(A,B,C),
	(
	    retractall(desc-files::file(_,B,_)),
	    asserta(desc-files::file(A,B,C))
	)).
