Can I Run Healthcare Business Logic Without a Server?

Vinothkumar S

2 min read

Yes, now you are able to run an application without your own server! I work for Spritle Software where we develop awesome web and mobile applications. Recently we developed a HealthCare application that has a single business logic that needs a server to execute a Python script. But wait we haven’t picked up a server for that we had some other idea!

Google Cloud function:

We successfully made the backend for the iOS application go Server-less, the application has to record certain things using the iPhone sensors and send the patient information to the backend. Here I’ll be helping you to run your own application without a server with the use of Google Cloud Functions.

First, let us try to understand what google cloud functions are and its execution environment.

Google Cloud Functions — It’s Execution Environment:

Google Cloud Function is a serverless execution environment for building and connecting cloud services. With Cloud Functions, you write simple, single-purpose functions, which can be directly triggered by HTTP function trigger or event-based trigger.

Cloud Functions supports multiple runtime environments. They are:

  • .NET Core 3.1  BETA
  • GO 1.11
  • GO 1.13
  • JAVA 11
  • Node.js 8
  • Node.js 10
  • Node.js 12
  • Python 3.7
  • Python 3.8

Trigger a PHI Google Cloud Function

HTTP Function:- are functions that can be triggered or run by calling the HTTP url assigned or created for the function.

Background Function:-Background function basically a kind of function which triggers events external or other cloud services.

Just follow the below 7 simple steps, then you will have your own server-less application

Step 1: Login to the google console and there you can find an option for Cloud Functions.

Step 2: Click on Create Function, and mention your function name, region and trigger type.

Step 3: I have selected the http trigger which will give you an end-point which will work like an API, by hitting that particular end-point it will return you the data.

Step 4: Click save and Next it will be redirected to IDE where you can write your business logic.

Step 5: Select your Execution Environment and Entry Point(Entry point will be the function which will be triggered first when you hit the end-point).

Step 6: You will find two files, main.py where you have to write your business logic and requirement.txt here you have to specify your function dependencies like the packages the you are going to use inside your main.py file.

Step 7: Once you are done with the business logic function just click deploy and the function will be deployed.

Done! Now when you try to trigger the URL it will return the output of your function.

Code Snippet:

main.py

#Import packages

import pandas as pd

def print_patient_symptomns(request):
    
   print(pd.__version__)
   pd_version = pd.__version__
   return {
    "pandas_version": pd_version,
    "message":"The patient has anorexia (R63.0) weight loss (R63.4) symptoms"
   }

requirements.txt

# Function dependencies
pandas==1.1.1

Trigger URL

https://us-central1-serverless-api-b059c.cloudfunctions.net/patient_symptoms

Output:

{
	"message":"The patient has anorexia (R63.0) weight loss (R63.4) symptoms",
	"pandas_version":"1.1.1"
}

Conclusion:

Google Cloud functions are great when you want to deploy some single functionality code in the cloud without having to mess with your server. It has lots of additional features like your own server, you can able to check the logs, triggers, metrics, and more. You can learn more about it here.

Hopefully, this tutorial showed you a way to get your functions in the cloud and start to use this great feature!

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *