0

I Have function register a patient that will Return Medical record Number , Need store this as Global Variable to so that use the same for Different Functions Eg: Create Vital Sign , Create Lab Order etc.

aqTestCase.Begin(" User able to Register a Unknown patient")
   Log.AppendFolder("Unknown Registeration Logs")
   ERPage=Aliases.MedBrowser.pageER
   ReusableFunctions.ClickonObject(ERPage.RegisterUnknownPatientIcon)
   ReusableFunctions.ClickonObject(ERPage.UnknownRegMaleLabel)
   ReusableFunctions.setTextValue(ERPage.txtAge, "20")
   ReusableFunctions.ClickonObject(ERPage.UnknownRegregistrBtn)
   ReusableFunctions.ClickonButton(ERPage.AssignBuutonclose)
   AppReusableFunctions.getToastMsgs(ERPage)
   labelER = Aliases.VidaPlusBrowser.pageER.FindElement("//span[.='ER']")
   ReusableFunctions.ClickonObject(labelER)
   mrn = ERPage.FindElement("//div[10]/div[5]/app-er-patient-grid-mrn/span").contentText
   aqUtils.Delay(2000)
   ReusableFunctions.ClickonObject(ERPage.ERArrvialTime)
   Log.Message(" Unknown Patient Registred MRN is : "  +mrn)
   return mrn
1
  • ERPage=Aliases.MedBrowser.pageER return mrn Commented Oct 17, 2022 at 20:31

2 Answers 2

0

You can set the variable as a global variable and return it.

def foo():
    global X
    X = 1
    return X

In your case, creating a class may work better.

class Foo:
    def __init__(self, x):
        self.x = x
    def bar(self):
        return self.x

f = Foo(1)
f.bar()
Sign up to request clarification or add additional context in comments.

Comments

0
x = "awesome"

def myfunc():
  global x
  x = "fantastic"


myfunc()

print("Python is " + x)

1 Comment

Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, can you edit your answer to include an explanation of what you're doing and why you believe it is the best approach?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.