rad server industry template - connected nurses station - setup document

23
RAD Server Industry Template - Connected Nurses Station The RAD Server Connected Nurses Station Sample Project can be downloaded via the GetIt Package Manager (Tools > GetIt Package Manager) in RAD Studio 10.2 Tokyo. Key Setup Steps 1. Setup InterBase database (EMS database) Put your NURSESDB.IB InterBase database here: C:\NurseStation\Database\NURSESDB.IB The NursesDB only has one table called Patient that looks like this, with no data pre-loaded. /* Table: PATIENT, Owner: SYSDBA */ CREATE TABLE "PATIENT" ( "ID" VARCHAR(50) NOT NULL, "HEART_RATE" VARCHAR(20), "WEIGHT" VARCHAR(20), CONSTRAINT "PK" PRIMARY KEY ("ID")); 2. Start your InterBase XE7 database server. Note: My InterBase instance is called gds_db Using IBConsole (C:\Program Files (x86)\Embarcadero\Studio\17.0\InterBaseXE7\bin\IBConsole.exe), add the NURSESDB.IB database. Username=SYSDBA, Password=masterkey. Copyright © 2017 Embarcadero Technologies, Inc.

Upload: embarcadero-technologies

Post on 23-Jan-2018

303 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Rad Server Industry Template - Connected Nurses Station - Setup Document

RAD Server Industry Template - Connected Nurses Station  The RAD Server Connected Nurses Station Sample Project can be downloaded via the GetIt Package Manager (Tools > GetIt Package Manager) in RAD Studio 10.2 Tokyo.  

Key Setup Steps  1. Setup InterBase database (EMS database) Put your NURSESDB.IB InterBase database here:  C:\NurseStation\Database\NURSESDB.IB The NursesDB only has one table called Patient that looks like this, with no data pre-loaded. /* Table: PATIENT, Owner: SYSDBA */ CREATE TABLE "PATIENT" (   "ID"  VARCHAR(50) NOT NULL,   "HEART_RATE"  VARCHAR(20),   "WEIGHT"  VARCHAR(20), CONSTRAINT "PK" PRIMARY KEY ("ID")); 2. Start your InterBase XE7 database server.  Note:  My InterBase instance is called gds_db 

  Using IBConsole (C:\Program Files (x86)\Embarcadero\Studio\17.0\InterBaseXE7\bin\IBConsole.exe), add the NURSESDB.IB database.  Username=SYSDBA, Password=masterkey.  

 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 2: Rad Server Industry Template - Connected Nurses Station - Setup Document

 The Nursesdb has one table called PATIENT, with three columns; ID, HEART_RATE, and WEIGHT: 

   2. Create and Configure the RAD Server EMS Server  Note: If you have not run EMSDevserver.exe to create the InterBase EMSSERVER.IB database and emsserver.ini, located at C:\Users\Public\Documents\Embarcadero\EMS, then first run EMSDevserver.exe (from C:\Program Files (x86)\Embarcadero\Studio\19.0\bin).  

 Click YES.  

Copyright © 2017 Embarcadero Technologies, Inc.

Page 3: Rad Server Industry Template - Connected Nurses Station - Setup Document

       To the EMS Setup Wizard, New Database page, Add your InterBase Server Instance.  Mine is gds_db  To check that your InterBase instance is running (use "<Interbase>\bin\IBMgr.exe" gds_db)  Click Next.  

      IMPORTANT: UN-check the “Sample users” and “Sample user groups”  (Reason for this is default EMS install creates a Field Name called “description”.  The NursesStationDemo needs the Field Name is be “Description” with an uppercase “D”.  Click Next to create the Console User Name and Password. (consoleuser, consolepass).  

Copyright © 2017 Embarcadero Technologies, Inc.

Page 4: Rad Server Industry Template - Connected Nurses Station - Setup Document

  Click Finish.  If you get this error:  

  Verify your InterBase license is installed and/or your InterBase Server instance is running.  Note:  If you get Warning Message, that you are using InterBase without an EMS License, then it’s OK.  The Nurses Station application will run OK without needing an EMS license.  You can run the applications using an EMS Development Server.  Click OK.  EMSDevserver.exe will create these files:  EMSSERVER.IB   and emsserver.ini    

Copyright © 2017 Embarcadero Technologies, Inc.

Page 5: Rad Server Industry Template - Connected Nurses Station - Setup Document

     The emsserver.ini file is located here:  C:\Users\Public\Documents\Embarcadero\EMS  Running EMSDevserver.exe again, should now start your EMS Development Server, like this:  

   3. Part of the setup is to add a new user called nurseuser. For an initial setup, create a few new Users and a new Group for our RAD (EMS) Server. The Nurses App (NurseApp_PatientVitals) expects a User “nurseuser”. Without this user, you will get an error.   The Nurse app expects this Login(nurseuser, nursepass):    procedure TForm23.FormShow(Sender: TObject);   

begin   // EMS Process   NurseStationClientModule.Login('nurseuser', 'nursepass');   PushRegister();   

end;    Without this nurseuser user, you will get this error:  

Copyright © 2017 Embarcadero Technologies, Inc.

Page 6: Rad Server Industry Template - Connected Nurses Station - Setup Document

  To add users, use EMSManagementConsole.exe included with RAD Studio 10.2 Tokyo to add User = nurseuser, with Password = nursepass  From the emsserver.ini, we are running in Single Tenant mode, so we un-comment the DefaultTenantId=00000000-0000-0000-0000-000000000001 [Server.Tenants] ;# This section defines settings for Single or Multi-Tenant modes. ;# ;# The MultiTenantMode option is used to turn on the Multi-Tenant mode. ;# If the Multi-Tenant mode is turned on, then TenantId and TenantSecret is required to access EMS Server. ;MultiTenantMode=1 ;# ;# Default Tenant is used only in the Single Tenant mode. DefaultTenantId=00000000-0000-0000-0000-000000000001; # Define custom cookie name to store TenantId in EMS Console. ;TenantIDCookieName=TenantID   

   First, use the Tenant tab, and enter your Default Tenant ID and Tenant Secret password: secret  

 Next, use the Connection tab and Enter your local Host IP address of your running EMS Server. Port = 8080   

 Click Test Connection, to verify you can connect to EMS.  

Copyright © 2017 Embarcadero Technologies, Inc.

Page 7: Rad Server Industry Template - Connected Nurses Station - Setup Document

 Click OK.   

 Click the Users tab, and click Add +   

  

Enter: User name = nurseuser, Password = nursepass, Field Name = Description, Field Value = Nancy Nurse.    

  

NOTE: It is very important that the Field Name “Description” is spelled with an uppercase “D”.   The Patient App (PatientCheckIn2) looks for a field value “Description” with an uppercase D.    Click OK, and your new User gets created: 

  Click OK.    And another User that you can use as the Patient (test1, test1), with your name “Al Mannarino” as the Field Value. Note: “Description” must be an uppercase “D”.  

Copyright © 2017 Embarcadero Technologies, Inc.

Page 8: Rad Server Industry Template - Connected Nurses Station - Setup Document

       Note that the Field Name Description is uppercase as it's needed.   

 You now have two (2) Users created: 

 Note: You do NOT need to create any Groups, Installations or Push.   Note: For the Installations tab, you do NOT need to add anything. The running apps that connect to the EMS Server will create the Installations for you.   

 Check if you can Authenticate with Users “nurseuser” and “test1”.    Select Authenticate tab. Enter User name = nurseuser and Password = nursepass.    Click Login. Verify you can Login. Click OK. Click Log out.  

    

Do the same for Username (Test1, test1).   You can now CLOSE the EMSManagementConsole.     4. Install SSL libraries. With RAD Studio 10.2 Tokyo, EMS, BaaS and REST clients on iOS, Android, Windows and Mac no longer need to use the OpenSSL libraries. In 10.2 Tokyo, they will use the native library on each OS.   But the RAD (EMS) Server requires the OpenSSL libraries to support HTTPS requests and sending push notifications to iOS devices.  This will require the Windows OpenSSL libraries.  

Copyright © 2017 Embarcadero Technologies, Inc.

Page 9: Rad Server Industry Template - Connected Nurses Station - Setup Document

For Windows, I installed the Windows OpenSSL from here:  http://docwiki.embarcadero.com/RADStudio/Tokyo/en/EMS_Push_Notifications Which tells you to download the latest OpenSSL binaries from: https://www.openssl.org/ For Win32, I used https://www.openssl.org/related/binaries.html And selected “Choose OpenSSL for Windows.”   http://slproweb.com/products/Win32OpenSSL.html  Using the latest Win32 OpenSSL v1.0.2k Light and letting the installer add the libs to my Windows path worked OK for me. 

  Note:  To send EMS Push notification messages to the registered devices in your EMS Server, you need to install the OpenSLL libraries in the system where the EMS Server runs.  Note: You need to install the 32-bit or 64-bit OpenSSL binary, depending on the target platform of the EMS Server.  If you do not install the OpenSSL libraries and use the EMS Server to send push notification messages to your registered device, the EMS Server shows the following error exception in the EMS Server Window log:  {"Error":{"Type":"Other","Exception":"EIdOSSLCouldNotLoadSSLLibrary","Message":"Could not load SSL library.","Thread":5576}}  3. Setup Push Notification Messaging Service for Android and iOS for EMS Backend Service The Remote Notifications for EMS we are using with these applications requires: To allow your applications to receive Remote Notifications, you need: 

● For Android apps, a new project on Google Developer Console. ● For iOS apps, a new App-ID on Apple Developer Program. 

  The complete steps are here to set up the messaging service for both Android and iOS apps: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Setting_Up_the_Messaging_Service   For ANDROID, Follow these steps:  http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Setting_Up_the_Messaging_Service Create a new Android project and Server Key in the Google Developer Console according to the instructions at http://developer.android.com/google/gcm/gs.html  Note:  Firebase Cloud Messaging (FCM) is the new version of Google Cloud Messaging (GCM). It inherits the reliable and scalable GCM infrastructure, plus new features!  

Copyright © 2017 Embarcadero Technologies, Inc.

Page 10: Rad Server Industry Template - Connected Nurses Station - Setup Document

 NOTE:  The GCM or FCM Project Number is the GCMAppID to add to your TEMSProvider component’s AndroidPush GCMAppID property, in the NurseStationClientModuleU.   For Apple iOS: Follow these steps:  http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Setting_Up_the_Messaging_Service  3. Add [Server.Push.GCM]  and [Server.Push.APN] files to emsserver.ini 

Edit C:\Users\Public\Documents\Embarcadero\EMS\emsserver.ini.   For Android, add your GCM API Key from the Server Key you created above for your Google Cloud Messaging (GCM) / FCM implementation in [Server.Push.GCM] [Server.Push.GCM] ;# This section is for Google Cloud Messaging (GCM) settings. ;# These settings are needed to send push notifications to an Android device ApiKey= BxyxxaSyABuQw4Pn0XABClZDiBxydqa  For iOS you will add your .p12 CertificateFileName to the emsserver.ini file in section [Server.Push.APNS]:  

    4. Setup Beacons You need to have two (2) beacons.  One beacon will be the Nurses Room, and the other beacon will be the Hospital or Clinic Hall.   The PatientCheckIn2 (Patient App) defines two Beacon UUID’s in the Beacon.MonitorizedRegions[] property:  For example (adjust the UID and Minor values for your specific beacons): HOSPITAL_HALL = 30720;   //Minor 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 11: Rad Server Industry Template - Connected Nurses Station - Setup Document

  NURSE_ROOM = 30887;  //Minor 

  The OnBeaconProximity Event defines: HOSPITAL_HALL = 30720;   //Minor NURSE_ROOM = 30887;  //Minor   If ABeacon.Minor = HOSPITAL_HALL then 'Welcome to the Hospital'; if ABeacon.Minor = NURSE_ROOM    then “NurseRoom”   Note:  Each Beacon has their own website and instructions on how to change the UUID, Major and Minor.  For example, I’m using two Beacons from EM Microelectronic that have UUID = 699EBC80-E1F3-11E3-9A0F-0CF3EE3BC012 And Minor = 30720 (Hospital_Hall) and Minor = 30887 (NURSE_ROOM)   For testing that you can connect to the beacons, you can use use the RAD Studio sample “BeaconsProximityDEMO” app, and add your UUID: CheckManager;   if FBeaconManager.RegisterBeacon(TGUID.Create('{699EBC80-E1F3-11E3-9A0F-0CF3EE3BC012}')) then 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 12: Rad Server Industry Template - Connected Nurses Station - Setup Document

  ListBox1.Items.Add('{699EBC80-E1F3-11E3-9A0F-0CF3EE3BC012};-1;-1');  Running the “BeaconsProximityDemo” app will verify that you can detect your two beacons:  

  

NurseProjectGroup  Setup (using RAD Studio/Delphi 10.2 Tokyo)  Open the NurseProjectGroup in Delphi 10.2 Tokyo: 

 1. Configure the Database property of the TFDConnection in the NurseStationStorageU (from 

NurseStationResourcePackage) to C:\NurseStation\Database\NURSESDB.IB  (the location on disk for your NURSESDB.IB). 

  2. Also, for Windows, add the database path in code to the NurseStationStorageU.pas: 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 13: Rad Server Industry Template - Connected Nurses Station - Setup Document

  3. Add GCM / FCM Project Number (GCMAppID) to TEMSProvider In the PatientCheckIn2 project, the GCM Project Number is the GCMAppID to add to your TEMSProvider component’s AndroidPush GCMAppID property, in the NurseStationClientModuleU, shown on this screenshot:  

  4. Add URLHost and URLPort of EMS Server GCM to TEMSProvider On the same TEMSProvider component, you will need to add your IP address of your running EMS Server to the TEMSProvider component URLHost on the NurseStationClientModuleU and also verify you have your GCMAppID (that you entered above).  The default URLPort is 8080, and URLProtocol is http.  

 With the NurseStationResourcePackage.bpl running (EMS Server running), on the Object Inspector, click the Test Connection to verify you can connect to the running EMS Server.  If you can connect, the version endpoint information gets returned like this:  

 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 14: Rad Server Industry Template - Connected Nurses Station - Setup Document

 5. Add iOS Push Notification Provision Profile to your NurseApp_PatientVitals Project To the NurseApp_PatientVitals project, for iOS, you need to add an iOS Provisioning Profile that has Push Notifications enabled, (use Project | Options | Provisioning).   6. Set the Version info for your NurseApp_PatientVitals project. Use Project | Options | Version Info  |  CFBundleIdentifier  (for Target:  Debug configuration – iOS Device – 32 bit platform): For my application, I need to set the CFBundleIdentifier to  com.embarcadero.alpush1 for my NurseApp_PatientVitals project (you will use the ID that got assigned to you):  

 

 

NursesStationDemo App Walkthrough 1. Open the NurseProjectGroup in Delphi 10.2 Tokyo: 

 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 15: Rad Server Industry Template - Connected Nurses Station - Setup Document

2. The PatientCheckIn2 project is the Patient application.  The project has two files; the PatientCheckinUnit2.pas and NurseStationClientModuleU.pas. 

 PatientCheckinUnit2 has three tab screens:  Welcome  Login   PatientBeaconCheckIn 

   --->                 --->            NurseStationClientModuleU has the EMS and Push components.  The NurseStationClientModuleU is shared by both Patient App and Nurses App:  

      3. NurseApp_PatientVitals project is the Nurses application.  It has two files; the NurseAppMainForm.pas and the SensorMonitorsU.pas  The NurseAppMainForm has two tabs screens:  GetData    StoredData 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 16: Rad Server Industry Template - Connected Nurses Station - Setup Document

      The SensorMonitorsU is used by the NurseAppMainForm to connect to a Heart Rate Service, and display the Current Patient’s Heart Rate.  The GetData tab shows current Patient Name, and lets you collect Patient Heart Rate and Weight data.  The StoredData tab displays Patient’s Heart Rate and Weight data.   4. The EMS Server is the running NurseStationResourcePackage.bpl 

  The NurseStationStorageU has the FDConnection and Query Select, Insert and Update for the Patient table:  

 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 17: Rad Server Industry Template - Connected Nurses Station - Setup Document

Running the Nurses Station Applications 1. Start the EMS Server. Open  NurseProjectGroup (from C:\NurseStation)  

  Highlight NurseStationResourcePackage.bpl | right-click | Run without Debugging The EMS Server Starts:  

     Note:  As a check, verify both your Android and iOS app can connect to the Windows EMS Server IP and port.  I use a “Ping” program from AppStore and Google Play Store, or open a browser on Android or iOS and enter http://192.168.1.20:8080/version  and verify the EMS version JSON gets returned, like this: 

 

  2. From the Nurses Room (beacon), on an iOS Device (iPad) run the Nurse application (NurseApp_PatientVitals):  When the Nurse App connects to EMS, then you will see the Record Patient Vitals screen. EMS displays: {"Request":{"Resource":"Users","Endpoint":"LoginUser","Method":"POST","User":"(blank)","Time":"4/10/2015 6:29:46 PM","Thread":6024}} {"Request":{"Resource":"Installations","Endpoint":"AddInstallation","Method":"POST","User":"8B98E8C3-B8BF-4A93-95A0-53A064CAD6B2","Time":"4/10/2015 6:29:46 PM","Thread":2996}}  Note:  If the Nurse app cannot connect to EMS, it will shut down and exit. 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 18: Rad Server Industry Template - Connected Nurses Station - Setup Document

 

  The BEACON at the NURSES ROOM represents the NURSES ROOM.  Turn ON the Nurse's Room BEACON, if not already ON.   3. Next, on ANDROID (as the Patient application), a distance away from the Hospital Hall beacon, run the Patient Application (PatientCheckIn2).  The beacon at the Hospital Hall represents the Hospital Hall.  The Patient App (Android app - PatientCheckIn2) starts and you get this screen: 

 The app says “You need to be in the waiting room to check-in”.   4. With the Patient App, walk NEAR the Hospital Hall beacon.  When you are NEAR the Hospital Hall, the screen will display “Welcome to Hospital”   

 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 19: Rad Server Industry Template - Connected Nurses Station - Setup Document

5. Click the Next button to check-in.  

  6. Login with Username and Password that you created in the EMS Server (Test1 , test1).  7. Click Login.   This sends an EMS Push Notification to the Nurses Application, and on your Patient app you see this screen with your Patient Name:  

  The Android (Patient App) gets Installed (shown from EMSMANAGEMENTCONSOLE.exe):  

  EMS displays these messages: {"Request":{"Resource":"Users","Endpoint":"GetUsers","Method":"GET","User":"611F0317-23D2-48C7-9D54-F4ED71665A52","Time":"4/10/2015 7:00:43 PM","Thread":4380}} 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 20: Rad Server Industry Template - Connected Nurses Station - Setup Document

 {"Request":{"Resource":"NurseStation","Endpoint":"PostSendMessageNurse","Method":"POST","User":"611F0317-23D2-48C7-9D54-F4ED71665A52","Time":"4/10/2015 7:00:43 PM","Thread":4724}}  {"Push":{"action":"Queued","type":"TApnsNotification","Thread":5592}}  {"Push":{"action":"Sent","type":"TApnsNotification","Thread":5360}}  {"Request":{"Resource":"Users","Endpoint":"GetUser","Method":"GET","User":"8B98E8C3-B8BF-4A93-95A0-53A064CAD6B2","Time":"4/10/2015 7:00:47 PM","Thread":5488}}  8. Next, leaving your Patient app by the Hospital Hall, walk back to the Nurses Application.  The Nurses Application shows that you have arrived to the Hospital (with the Push Notification). Important Note:  Click in the ComboBox above the “Current Patient Heartrate” box to activate the Push Notification pop-up list, like this: 

  Select your Patient Name, click Done. You Patient Name (lDescription) gets added to the ComboBox, like this:  

  9. Walk back to the Hospital Hall and get your Patient App.  The Patient App now says: “You are now checked in.  The nurse is ready to see you.” 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 21: Rad Server Industry Template - Connected Nurses Station - Setup Document

 

 10.  With your Patient App from the Hospital Hall, walk back to the Nurse's Room.    11. When your Patient App gets NEAR to the Nurse's Room beacon, the Nurses App will get the message “Al Mannarino has entered the room”.  

  12. If you do NOT have a BT LE Weight Scale, you will click on editbox “Current Patient Weight”, and manually enter the Patient’s weight.  If you have the Weight Scale, then you can click the “Connect to Device” for the Pateint Weight.  Then click “SaveData” for the weight.   Click OK.  

       13. Next, using your BT LE HeartRate Sensor, (I used a Zephyr, but most BT LE HRM Sensors should work).  For demo purposes, it’s OK to use two fingers over the HRM contacts so the HRM sends Beats Per Minute (BPM) Data. For example: 

Copyright © 2017 Embarcadero Technologies, Inc.

Page 22: Rad Server Industry Template - Connected Nurses Station - Setup Document

          Using an Apple iOS iPad, check that you have Bluetooth Turned On, and your HRM is connected: 

  This first time on iPad, you may get this message using Bluetooth:  

  Click OK.  14. Click on Patient Heart Rate “Connect to Device”:  

  Wait a few seconds for the HRM to be detected, and then you will see your HR BPM get displayed on the Nurses App.  Click SaveData.   Click OK.  

Copyright © 2017 Embarcadero Technologies, Inc.

Page 23: Rad Server Industry Template - Connected Nurses Station - Setup Document

        15. On the EMS SERVER, you can see all the REST API calls.  {"Request":{"Resource":"Users","Endpoint":"GetUser","Method":"GET","User":"8B98E8C3-B8BF-4A93-95A0-53A064CAD6B2","Time":"4/10/2015 8:24:11 PM","Thread":7716}}  {"Request":{"Resource":"NurseStation","Endpoint":"PostAddPatientData","Method":"POST","User":"8B98E8C3-B8BF-4A93-95A0-53A064CAD6B2","Time":"4/10/2015 8:34:39 PM","Thread":6316}}  

  16. Lastly, using the InterBase database IBConsole, looking into the InterBase database NURSESDB.IB, you will see your Patient ID, Heart_Rate and your Weight, all saved securely to disk in the InterBase database!  

  This ends the Nurses Station Setup and Demonstration!   Congratulations!  

Copyright © 2017 Embarcadero Technologies, Inc.