CREATE TABLE [Patient]
(
	[PatID] [nvarchar](64) PRIMARY KEY,
	[PatName] [nvarchar](16),
	[PatSex] [nchar] NOT NULL,
	[PatAge] [tinyint] DEFAULT(18),
	[InTime] [datetime] NOT NULL,
	[InCode] [nvarchar](64),
	[Insurance] [nvarchar](16),
	[Remarks] [nvarchar](1024),
	[EtnCode] [smallint] DEFAULT(-1),
	[NurseLevel] [tinyint] NOT NULL,
	[Balance] [Money],
	[DoctorName] [nvarchar](16),
	[NurseName] [nvarchar](16),
	[Medicine] [nvarchar](128),
	[DrAdvice] [nvarchar](128),
	[DrInfo] [nvarchar](128),
	[Diagnosis] [nvarchar](32),
	[DrugAllergy] [nvarchar](32),
	[DietType] [nvarchar](32)
)

CREATE TABLE [EtnBed]
(
	[EtnCode] [smallint] PRIMARY KEY,
	[BedExist] [Bit] DEFAULT(0),
	[BedBcstExist] [Bit] DEFAULT(0),
	[BedNo] [nvarchar](16) NOT NULL,
	[RoomName] [nvarchar](16) NOT NULL,
	[RoomEtn] [smallint] NOT NULL DEFAULT(-1),
	[DoctorTitle] [nvarchar](16),
	[NurseTitle] [nvarchar](16),
	[ShowBed] [Bit] DEFAULT(1)
)

CREATE TABLE [DoseWarn]
(
	[PatID] [nvarchar](64),
	[WarnTime1] [nvarchar](8),
	[WarnTime2] [nvarchar](8),
	[WarnTime3] [nvarchar](8),
	[WarnTime4] [nvarchar](8),
	[WarnTime5] [nvarchar](8)
)

CREATE TABLE [EtnRoom]
(
	[EtnCode] [smallint] PRIMARY KEY,
	[ToiletExist] [Bit] DEFAULT(0),
	[DoorLampExist] [Bit] DEFAULT(0),
	[RoomName] [nvarchar](16) NOT NULL
)

CREATE TABLE [TalkLog]
(
	[EtnCode] [smallint],
	[CallFlag] [nvarchar](16),
	[EtnType] [tinyint],
	[BedNo] [nvarchar](16),
	[RoomName] [nvarchar](16),
	[StartTime] [datetime] NOT NULL,
	[PickupTime] [datetime],
	[StopTime] [datetime],
	[ClearTime] [datetime]
)

CREATE TABLE [LedPara]
(
	[Addr] [tinyint] NOT NULL UNIQUE DEFAULT(1),
	[Width] [tinyint] NOT NULL,
	[Height] [tinyint] NOT NULL
)

CREATE TABLE [LedAdvt]
(
	[AutoID] [int] IDENTITY (1, 1) PRIMARY KEY,
	[ID] [smallint] NOT NULL DEFAULT(1),
	[AdvtMsg] [nvarchar](40)
)