VarianAPIs / Varian-Code-Samples

Code samples for ESAPI and other Varian APIs and web services.
MIT License
116 stars 108 forks source link

How to identify development enviroment within code #67

Open larpra opened 4 years ago

larpra commented 4 years ago

Is there a way API code can identify whether the code is executed in a clinical system or in a development environment?

Kiragroh commented 4 years ago

It depends on your reason for this check.

If you only want to identify your research system you can simply use standard c# code to look for the pc-name because research systems are most often limited (we have only one): if (Environment.MachineName.ToString().ToLower() == vmstbox) ... else ...

All code that add, modify or delete things in a patient need script approval in clinical systems. Therefore you get errors if you do not approve them. Therefore you can use a try-catch-command to identify this cases. try {modify patient in some way. For instance AddStructure} catch{MessageBox.Show("ScriptApproval is missing")}

Kiragroh commented 4 years ago

You can try some things that are only possible in research mode.

I found out that RemovePlanSetup is only possible in ResearchMOde. Therefore you could create a plan and then try to delete it. If it is not possible your are in clinical mode.

Other possible loops should be possible.

larpra commented 4 years ago

I wonder whether there is a more direct way? ESAPI must know whether it runs on a clinical system because several methods are only possible in Research mode.