You are on page 1of 23

RADServerIndustryTemplate-ConnectedNursesStation

TheRADServerConnectedNursesStationSampleProjectcanbedownloadedviatheGetItPackage
Manager(Tools>GetItPackageManager)inRADStudio10.2Tokyo.

KeySetupSteps

1.SetupInterBasedatabase(EMSdatabase)
PutyourNURSESDB.IBInterBasedatabasehere:C:\NurseStation\Database\NURSESDB.IB
TheNursesDBonlyhasonetablecalledPatientthatlookslikethis,withnodatapre-loaded.
/*Table:PATIENT,Owner:SYSDBA*/
CREATETABLE"PATIENT"
(
"ID" VARCHAR(50)NOTNULL,
"HEART_RATE" VARCHAR(20),
"WEIGHT" VARCHAR(20),
CONSTRAINT"PK"PRIMARYKEY("ID"));
2.StartyourInterBaseXE7databaseserver.Note:MyInterBaseinstanceiscalledgds_db

UsingIBConsole(C:\ProgramFiles(x86)\Embarcadero\Studio\17.0\InterBaseXE7\bin\IBConsole.exe),
addtheNURSESDB.IBdatabase.Username=SYSDBA,Password=masterkey.

Copyright 2017 Embarcadero Technologies, Inc.



TheNursesdbhasonetablecalledPATIENT,withthreecolumns;ID,HEART_RATE,andWEIGHT:

2.CreateandConfiguretheRADServerEMSServer
Note:IfyouhavenotrunEMSDevserver.exetocreatetheInterBaseEMSSERVER.IBdatabaseand
emsserver.ini,locatedatC:\Users\Public\Documents\Embarcadero\EMS,thenfirstrun
EMSDevserver.exe(fromC:\ProgramFiles(x86)\Embarcadero\Studio\19.0\bin).


ClickYES.

Copyright 2017 Embarcadero Technologies, Inc.


TotheEMSSetupWizard,NewDatabasepage,AddyourInterBaseServerInstance.Mineisgds_db

TocheckthatyourInterBaseinstanceisrunning(use"<Interbase>\bin\IBMgr.exe"gds_db)

ClickNext.

IMPORTANT:UN-checktheSampleusersandSampleusergroups(ReasonforthisisdefaultEMS
installcreatesaFieldNamecalleddescription.TheNursesStationDemoneedstheFieldNameisbe
DescriptionwithanuppercaseD.

ClickNexttocreatetheConsoleUserNameandPassword.(consoleuser,consolepass).

Copyright 2017 Embarcadero Technologies, Inc.


ClickFinish.

Ifyougetthiserror:

VerifyyourInterBaselicenseisinstalledand/oryourInterBaseServerinstanceisrunning.

Note:IfyougetWarningMessage,thatyouareusingInterBasewithoutanEMSLicense,thenits
OK.TheNursesStationapplicationwillrunOKwithoutneedinganEMSlicense.Youcanrunthe
applicationsusinganEMSDevelopmentServer.

ClickOK.

EMSDevserver.exewillcreatethesefiles:EMSSERVER.IBandemsserver.ini

Copyright 2017 Embarcadero Technologies, Inc.


Theemsserver.inifileislocatedhere:C:\Users\Public\Documents\Embarcadero\EMS

RunningEMSDevserver.exeagain,shouldnowstartyourEMSDevelopmentServer,likethis:

3.Partofthesetupistoaddanewusercallednurseuser.Foraninitialsetup,createafewnewUsers
andanewGroupforourRAD(EMS)Server.TheNursesApp(NurseApp_PatientVitals)expectsaUser
nurseuser.Withoutthisuser,youwillgetanerror.

TheNurseappexpectsthisLogin(nurseuser,nursepass):

procedureTForm23.FormShow(Sender:TObject);
begin
//EMSProcess
NurseStationClientModule.Login('nurseuser','nursepass');
PushRegister();
end;

Withoutthisnurseuseruser,youwillgetthiserror:

Copyright 2017 Embarcadero Technologies, Inc.


Toaddusers,useEMSManagementConsole.exeincludedwithRADStudio10.2TokyotoaddUser=
nurseuser,withPassword=nursepass

Fromtheemsserver.ini,wearerunninginSingleTenantmode,soweun-commentthe
DefaultTenantId=00000000-0000-0000-0000-000000000001
[Server.Tenants]
;#ThissectiondefinessettingsforSingleorMulti-Tenantmodes.
;#
;#TheMultiTenantModeoptionisusedtoturnontheMulti-Tenantmode.
;#IftheMulti-Tenantmodeisturnedon,thenTenantIdandTenantSecretisrequiredtoaccessEMS
Server.
;MultiTenantMode=1
;#
;#DefaultTenantisusedonlyintheSingleTenantmode.
DefaultTenantId=00000000-0000-0000-0000-000000000001;
#DefinecustomcookienametostoreTenantIdinEMSConsole.
;TenantIDCookieName=TenantID

First,usetheTenanttab,andenteryourDefaultTenantIDandTenantSecretpassword:secret


Next,usetheConnectiontabandEnteryourlocalHostIPaddressofyourrunningEMSServer.Port=
8080

ClickTestConnection,toverifyyoucanconnecttoEMS.

Copyright 2017 Embarcadero Technologies, Inc.



ClickOK.

ClicktheUserstab,andclickAdd+



Enter:Username=nurseuser,Password=nursepass,FieldName=Description,FieldValue=Nancy
Nurse.



NOTE:ItisveryimportantthattheFieldNameDescriptionisspelledwithanuppercaseD.
ThePatientApp(PatientCheckIn2)looksforafieldvalueDescriptionwithanuppercaseD.

ClickOK,andyournewUsergetscreated:

ClickOK.

AndanotherUserthatyoucanuseasthePatient(test1,test1),withyournameAlMannarinoasthe
FieldValue.Note:DescriptionmustbeanuppercaseD.

Copyright 2017 Embarcadero Technologies, Inc.



NotethattheFieldNameDescriptionisuppercaseasit'sneeded.

Younowhavetwo(2)Userscreated:


Note:YoudoNOTneedtocreateanyGroups,InstallationsorPush.
Note:FortheInstallationstab,youdoNOTneedtoaddanything.Therunningappsthatconnectto
theEMSServerwillcreatetheInstallationsforyou.

CheckifyoucanAuthenticatewithUsersnurseuserandtest1.

SelectAuthenticatetab.EnterUsername=nurseuserandPassword=nursepass.

ClickLogin.VerifyyoucanLogin.ClickOK.ClickLogout.



DothesameforUsername(Test1,test1).
YoucannowCLOSEtheEMSManagementConsole.

4.InstallSSLlibraries.
WithRADStudio10.2Tokyo,EMS,BaaSandRESTclientsoniOS,Android,WindowsandMacnolonger
needtousetheOpenSSLlibraries.In10.2Tokyo,theywillusethenativelibraryoneachOS.

ButtheRAD(EMS)ServerrequirestheOpenSSLlibrariestosupportHTTPSrequestsandsendingpush
notificationstoiOSdevices.ThiswillrequiretheWindowsOpenSSLlibraries.

Copyright 2017 Embarcadero Technologies, Inc.


ForWindows,IinstalledtheWindowsOpenSSLfromhere:
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/EMS_Push_Notifications
WhichtellsyoutodownloadthelatestOpenSSLbinariesfrom:https://www.openssl.org/
ForWin32,Iusedhttps://www.openssl.org/related/binaries.html
AndselectedChooseOpenSSLforWindows.
http://slproweb.com/products/Win32OpenSSL.html

UsingthelatestWin32OpenSSLv1.0.2kLightandlettingtheinstalleraddthelibstomyWindowspath
workedOKforme.

Note:TosendEMSPushnotificationmessagestotheregistereddevicesinyourEMSServer,youneed
toinstalltheOpenSLLlibrariesinthesystemwheretheEMSServerruns.

Note:Youneedtoinstallthe32-bitor64-bitOpenSSLbinary,dependingonthetargetplatformofthe
EMSServer.

IfyoudonotinstalltheOpenSSLlibrariesandusetheEMSServertosendpushnotificationmessages
toyourregistereddevice,theEMSServershowsthefollowingerrorexceptionintheEMSServer
Windowlog:

{"Error":{"Type":"Other","Exception":"EIdOSSLCouldNotLoadSSLLibrary","Message":"Could
notloadSSLlibrary.","Thread":5576}}

3.SetupPushNotificationMessagingServiceforAndroidandiOSforEMSBackendService
TheRemoteNotificationsforEMSweareusingwiththeseapplicationsrequires:
ToallowyourapplicationstoreceiveRemoteNotifications,youneed:
ForAndroidapps,anewprojectonGoogleDeveloperConsole.
ForiOSapps,anewApp-IDonAppleDeveloperProgram.

ThecompletestepsareheretosetupthemessagingserviceforbothAndroidandiOSapps:
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Setting_Up_the_Messaging_Service

ForANDROID,
Followthesesteps:
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Setting_Up_the_Messaging_Service
CreateanewAndroidprojectandServerKeyintheGoogleDeveloperConsoleaccordingtothe
instructionsathttp://developer.android.com/google/gcm/gs.html

Note:FirebaseCloudMessaging(FCM)isthenewversionofGoogleCloudMessaging(GCM).Itinherits
thereliableandscalableGCMinfrastructure,plusnewfeatures!

Copyright 2017 Embarcadero Technologies, Inc.



NOTE:TheGCMorFCMProjectNumberistheGCMAppIDtoaddtoyourTEMSProvidercomponents
AndroidPushGCMAppIDproperty,intheNurseStationClientModuleU.

ForAppleiOS:
Followthesesteps:
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Setting_Up_the_Messaging_Service

3.Add[Server.Push.GCM]and[Server.Push.APN]filestoemsserver.ini
EditC:\Users\Public\Documents\Embarcadero\EMS\emsserver.ini.

ForAndroid,addyourGCMAPIKeyfromtheServerKeyyoucreatedaboveforyourGoogleCloud
Messaging(GCM)/FCMimplementationin[Server.Push.GCM]
[Server.Push.GCM]
;#ThissectionisforGoogleCloudMessaging(GCM)settings.
;#ThesesettingsareneededtosendpushnotificationstoanAndroiddevice
ApiKey=BxyxxaSyABuQw4Pn0XABClZDiBxydqa

ForiOSyouwilladdyour.p12CertificateFileNametotheemsserver.inifileinsection
[Server.Push.APNS]:

4.SetupBeacons
Youneedtohavetwo(2)beacons.OnebeaconwillbetheNursesRoom,andtheotherbeaconwillbe
theHospitalorClinicHall.

ThePatientCheckIn2(PatientApp)definestwoBeaconUUIDsintheBeacon.MonitorizedRegions[]
property:

Forexample(adjusttheUIDandMinorvaluesforyourspecificbeacons):
HOSPITAL_HALL=30720;//Minor

Copyright 2017 Embarcadero Technologies, Inc.


NURSE_ROOM=30887; //Minor

TheOnBeaconProximityEventdefines:
HOSPITAL_HALL=30720;//Minor
NURSE_ROOM=30887; //Minor

IfABeacon.Minor=HOSPITAL_HALLthen'WelcometotheHospital';
ifABeacon.Minor=NURSE_ROOMthenNurseRoom

Note:EachBeaconhastheirownwebsiteandinstructionsonhowtochangetheUUID,Majorand
Minor.

Forexample,ImusingtwoBeaconsfromEMMicroelectronic
thathaveUUID=699EBC80-E1F3-11E3-9A0F-0CF3EE3BC012
AndMinor=30720(Hospital_Hall)andMinor=30887(NURSE_ROOM)

Fortestingthatyoucanconnecttothebeacons,youcanuseusetheRADStudiosample
BeaconsProximityDEMOapp,andaddyourUUID:
CheckManager;
ifFBeaconManager.RegisterBeacon(TGUID.Create('{699EBC80-E1F3-11E3-9A0F-0CF3EE3BC012}'))
then

Copyright 2017 Embarcadero Technologies, Inc.


ListBox1.Items.Add('{699EBC80-E1F3-11E3-9A0F-0CF3EE3BC012};-1;-1');

RunningtheBeaconsProximityDemoappwillverifythatyoucandetectyourtwobeacons:

NurseProjectGroupSetup(usingRADStudio/Delphi10.2Tokyo)
OpentheNurseProjectGroupinDelphi10.2Tokyo:


1. ConfiguretheDatabasepropertyoftheTFDConnectionintheNurseStationStorageU(from
NurseStationResourcePackage)toC:\NurseStation\Database\NURSESDB.IB(thelocationon
diskforyourNURSESDB.IB).

2.Also,forWindows,addthedatabasepathincodetotheNurseStationStorageU.pas:

Copyright 2017 Embarcadero Technologies, Inc.


3.AddGCM/FCMProjectNumber(GCMAppID)toTEMSProvider
InthePatientCheckIn2project,theGCMProjectNumberistheGCMAppIDtoaddtoyour
TEMSProvidercomponentsAndroidPushGCMAppIDproperty,intheNurseStationClientModuleU,
shownonthisscreenshot:

4.AddURLHostandURLPortofEMSServerGCMtoTEMSProvider
OnthesameTEMSProvidercomponent,youwillneedtoaddyourIPaddressofyourrunningEMS
ServertotheTEMSProvidercomponentURLHostontheNurseStationClientModuleUandalso
verifyyouhaveyourGCMAppID(thatyouenteredabove).ThedefaultURLPortis8080,and
URLProtocolishttp.


WiththeNurseStationResourcePackage.bplrunning(EMSServerrunning),ontheObjectInspector,
clicktheTestConnectiontoverifyyoucanconnecttotherunningEMSServer.Ifyoucanconnect,the
versionendpointinformationgetsreturnedlikethis:

Copyright 2017 Embarcadero Technologies, Inc.



5.AddiOSPushNotificationProvisionProfiletoyourNurseApp_PatientVitalsProject
TotheNurseApp_PatientVitalsproject,foriOS,youneedtoaddaniOSProvisioningProfilethathas
PushNotificationsenabled,(useProject|Options|Provisioning).

6.SettheVersioninfoforyourNurseApp_PatientVitalsproject.
UseProject|Options|VersionInfo|CFBundleIdentifier(forTarget:DebugconfigurationiOS
Device32bitplatform):
Formyapplication,IneedtosettheCFBundleIdentifiertocom.embarcadero.alpush1formy
NurseApp_PatientVitalsproject(youwillusetheIDthatgotassignedtoyou):

NursesStationDemoAppWalkthrough
1. OpentheNurseProjectGroupinDelphi10.2Tokyo:

Copyright 2017 Embarcadero Technologies, Inc.


2. ThePatientCheckIn2projectisthePatientapplication.Theprojecthastwofiles;the
PatientCheckinUnit2.pasandNurseStationClientModuleU.pas.

PatientCheckinUnit2hasthreetabscreens:

Welcome Login PatientBeaconCheckIn

---> --->

NurseStationClientModuleUhastheEMSandPushcomponents.TheNurseStationClientModuleU
issharedbybothPatientAppandNursesApp:

3.NurseApp_PatientVitalsprojectistheNursesapplication.Ithastwofiles;the
NurseAppMainForm.pasandtheSensorMonitorsU.pas

TheNurseAppMainFormhastwotabsscreens:

GetData StoredData

Copyright 2017 Embarcadero Technologies, Inc.


TheSensorMonitorsUisusedbytheNurseAppMainFormtoconnecttoaHeartRateService,and
displaytheCurrentPatientsHeartRate.

TheGetDatatabshowscurrentPatientName,andletsyoucollectPatientHeartRateandWeight
data.

TheStoredDatatabdisplaysPatientsHeartRateandWeightdata.

4.TheEMSServeristherunningNurseStationResourcePackage.bpl

TheNurseStationStorageUhastheFDConnectionandQuerySelect,InsertandUpdateforthe
Patienttable:

Copyright 2017 Embarcadero Technologies, Inc.


RunningtheNursesStationApplications
1.StarttheEMSServer.
OpenNurseProjectGroup(fromC:\NurseStation)

HighlightNurseStationResourcePackage.bpl|right-click|RunwithoutDebugging
TheEMSServerStarts:


Note:Asacheck,verifybothyourAndroidandiOSappcanconnecttotheWindowsEMSServerIP
andport.IuseaPingprogramfromAppStoreandGooglePlayStore,oropenabrowseronAndroid
oriOSandenterhttp://192.168.1.20:8080/versionandverifytheEMSversionJSONgetsreturned,like
this:

2.FromtheNursesRoom(beacon),onaniOSDevice(iPad)runtheNurseapplication
(NurseApp_PatientVitals):

WhentheNurseAppconnectstoEMS,thenyouwillseetheRecordPatientVitalsscreen.
EMSdisplays:
{"Request":{"Resource":"Users","Endpoint":"LoginUser","Method":"POST","User":"(blank)","Time":"
4/10/20156:29:46PM","Thread":6024}}
{"Request":{"Resource":"Installations","Endpoint":"AddInstallation","Method":"POST","User":"8B9
8E8C3-B8BF-4A93-95A0-53A064CAD6B2","Time":"4/10/20156:29:46PM","Thread":2996}}

Note:IftheNurseappcannotconnecttoEMS,itwillshutdownandexit.

Copyright 2017 Embarcadero Technologies, Inc.


TheBEACONattheNURSESROOMrepresentstheNURSESROOM.TurnONtheNurse'sRoom
BEACON,ifnotalreadyON.

3.Next,onANDROID(asthePatientapplication),adistanceawayfromtheHospitalHallbeacon,run
thePatientApplication(PatientCheckIn2).ThebeaconattheHospitalHallrepresentstheHospital
Hall.

ThePatientApp(Androidapp-PatientCheckIn2)startsandyougetthisscreen:


TheappsaysYouneedtobeinthewaitingroomtocheck-in.

4.WiththePatientApp,walkNEARtheHospitalHallbeacon.WhenyouareNEARtheHospitalHall,
thescreenwilldisplayWelcometoHospital

Copyright 2017 Embarcadero Technologies, Inc.


5.ClicktheNextbuttontocheck-in.

6.LoginwithUsernameandPasswordthatyoucreatedintheEMSServer(Test1,test1).

7.ClickLogin.

ThissendsanEMSPushNotificationtotheNursesApplication,andonyourPatientappyouseethis
screenwithyourPatientName:

TheAndroid(PatientApp)getsInstalled(shownfromEMSMANAGEMENTCONSOLE.exe):

EMSdisplaysthesemessages:
{"Request":{"Resource":"Users","Endpoint":"GetUsers","Method":"GET","User":"611F0317-23D2-48C
7-9D54-F4ED71665A52","Time":"4/10/20157:00:43PM","Thread":4380}}

Copyright 2017 Embarcadero Technologies, Inc.



{"Request":{"Resource":"NurseStation","Endpoint":"PostSendMessageNurse","Method":"POST","Use
r":"611F0317-23D2-48C7-9D54-F4ED71665A52","Time":"4/10/20157:00:43PM","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/20157:00:47PM","Thread":5488}}

8.Next,leavingyourPatientappbytheHospitalHall,walkbacktotheNursesApplication.TheNurses
ApplicationshowsthatyouhavearrivedtotheHospital(withthePushNotification).
ImportantNote:ClickintheComboBoxabovetheCurrentPatientHeartrateboxtoactivatethe
PushNotificationpop-uplist,likethis:

SelectyourPatientName,clickDone.
YouPatientName(lDescription)getsaddedtotheComboBox,likethis:

9.WalkbacktotheHospitalHallandgetyourPatientApp.ThePatientAppnowsays:Youarenow
checkedin.Thenurseisreadytoseeyou.

Copyright 2017 Embarcadero Technologies, Inc.



10.WithyourPatientAppfromtheHospitalHall,walkbacktotheNurse'sRoom.

11.WhenyourPatientAppgetsNEARtotheNurse'sRoombeacon,theNursesAppwillgetthe
messageAlMannarinohasenteredtheroom.

12.IfyoudoNOThaveaBTLEWeightScale,youwillclickoneditboxCurrentPatientWeight,and
manuallyenterthePatientsweight.IfyouhavetheWeightScale,thenyoucanclicktheConnectto
DeviceforthePateintWeight.

ThenclickSaveDatafortheweight.ClickOK.

13.Next,usingyourBTLEHeartRateSensor,(IusedaZephyr,butmostBTLEHRMSensorsshould
work).Fordemopurposes,itsOKtousetwofingersovertheHRMcontactssotheHRMsendsBeats
PerMinute(BPM)Data.Forexample:

Copyright 2017 Embarcadero Technologies, Inc.


UsinganAppleiOSiPad,checkthatyouhaveBluetoothTurnedOn,andyourHRMisconnected:

ThisfirsttimeoniPad,youmaygetthismessageusingBluetooth:

ClickOK.

14.ClickonPatientHeartRateConnecttoDevice:

WaitafewsecondsfortheHRMtobedetected,andthenyouwillseeyourHRBPMgetdisplayedon
theNursesApp.ClickSaveData.ClickOK.

Copyright 2017 Embarcadero Technologies, Inc.


15.OntheEMSSERVER,youcanseealltheRESTAPIcalls.

{"Request":{"Resource":"Users","Endpoint":"GetUser","Method":"GET","User":"8B98E8C3-B8BF-4A93
-95A0-53A064CAD6B2","Time":"4/10/20158:24:11PM","Thread":7716}}

{"Request":{"Resource":"NurseStation","Endpoint":"PostAddPatientData","Method":"POST","User":"
8B98E8C3-B8BF-4A93-95A0-53A064CAD6B2","Time":"4/10/20158:34:39PM","Thread":6316}}

16.Lastly,usingtheInterBasedatabaseIBConsole,lookingintotheInterBasedatabase
NURSESDB.IB,youwillseeyourPatientID,Heart_RateandyourWeight,allsavedsecurelytodiskin
theInterBasedatabase!

ThisendstheNursesStationSetupandDemonstration!Congratulations!

Copyright 2017 Embarcadero Technologies, Inc.