形式上 IRIS 有两种属性:
属性,保存值。该值可以是以下任意值:
属性一词通常仅指作为properties的attributes,而不是指具有关联的属性。
关系,保持对象之间的关联。
可以在包含 ObjectScript 方法、Python 方法或两者组合的类中定义属性。但是,无法从 Python 方法访问关系。本节展示了一个示例类,其中包含显示以下一些变体的属性定义:
Class MyApp.Main.Patient Extends %Persistent
{
Property PatientID As %String [Required];
Property Gender As %String(DISPLAYLIST = ",Female,Male", VALUELIST = ",F,M");
Property BirthDate As %Date;
Property Age As %Numeric [Transient];
Property MyTempArray [MultiDimensional];
Property PrimaryCarePhysician As Doctor;
Property Allergies As list Of PatientAllergy;
Relationship Diagnoses As PatientDiagnosis [ Cardinality = children, Inverse = Patient ];
}
请注意以下事项:
As 后面的项目是属性的类型。每种类型都是一个类。语法 As List Of 是特定集合类的简写。%String、%Date 和 %Numeric 是数据类型类。
%String是默认类型。
Diagnoses是一种关系属性;其余的是属性属性。PatientID、Gender、BirthDate 和 Age 只能包含简单的文字值。PatientID 是必需的,因为它使用必需关键字。这意味着如果没有为此属性指定值,则无法保存此类的对象。Age不会保存到磁盘。这是因为它使用了 Transient 关键字。MyTempArray 是一个多维属性,因为它使用 MultiDimensional 关键字。默认情况下,此属性不保存到磁盘。PrimaryCarePhysician 和 Allergies 是对象值属性。Gender 属性定义包括属性参数的值。这些是该属性使用的数据类型类中的参数。此属性仅限于值 M 和 F。当查看显示值(如在管理门户中)时,会看到 Male 和 Female。每个数据类型类都提供 LogicalToDisplay() 等方法。