This repository has been archived on 2024-04-22. You can view files and clone it, but cannot push or open issues or pull requests.
ocl-examples/health_system/health_system.ocl

59 lines
2.5 KiB
Plaintext

-- Copyright (c) 2003-2007 ETH Zurich, Switzerland
-- 2016 The University of Sheffield, UK
--
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- SPDX-License-Identifier: BSD-2-Clause
--
package health_system
-- You can only add a prescription if you have previously created the corresponding MedicalInfo
context HealthRecord::createMedicalInfo(p:MedicalInfo,prescription:Prescription):HealthRecord
pre perm1: p.creator = environment.caller
-- To create a MedicalInfo about a patient you need to be one of its doctors
context HealthRecord::createMedicalInfo(description:String):HealthRecord
post perm2: self.owner.treatedBy.oclAsType(OclAny) ->includes (environment.caller.oclAsType(OclAny))
-- Similar: To create a MedicalInfo, you need to be a doctor (not necessarily the one of the patient)
context HealthRecord::createMedicalInfo(description:String):HealthRecord
pre perm3: environment.caller.role = 'Doctor'
-- The amount of a prescription must not be too large
context Prescription
inv AmountNotTooLarge: self.amount < 1000
-- Closed medical infos can only be read by the doctor which created it
context HealthRecord::readMedicalInfo():MedicalInfo
post perm4: resultresult.creator.oclAsType(OclAny) = environment.caller.oclAsType(OclAny)
endpackage