With the gradual ageing of China's population and the single-child family system becoming the backbone of society, the traditional pension way of relying on children at home not only does not guarantee the quality of life of the elderly, but also brings great pressure to the work and life of young people. The way of relying on pension institutions to provide for the aged is becoming gradually accepted by society. In elderly care institutions, safety supervision systems provide an important link to protect the safety of the elderly, thereby ensuring accurate analysis and supervision of the elderly persons’ activity routes and activity rules, and thus allowing an early warning to be given in a dangerous situation. The system realises the real-time positioning and monitoring of the elderly activity track, and can give early warning and timely rescue to the elderly who enter into any dangerous area. The system includes a server monitoring program and mobile APP; ASP.NET Technology to develop the monitoring program; SQL Server 2012 for data storage; and model view controller (MVC) architecture for the APP to improve the efficiency of program development. The supervision program comprises the functions of personnel information management, fence management, positioning service, activity track record, danger warning and rapid rescue. The APP deploys the location-based service (LBS) technology of Android, uses Baidu map API to obtain location information and draw activity track, and stores the information in the mobile phone SQLite database. The APP is installed on mobile phones, bracelets and other devices carried by the elderly and staff, which can record the current position of the person in real-time and simultaneously transmit it to the computer. When the elderly enter into a dangerous area, the system can quickly select the nearest staff and inform them for rescue, so as to ensure the safety of the elderly. After simulation test, the system has now reached the preset function.
- nursing home
- Baidu map
At present, China has become the country with the largest elderly population in the world, and the single-child family system has become the backbone of society. Children not only need to take care of many elderly people, but also bear great work pressure, and therefore have to ensure that they have enough energy to work. Pension homes and community care are gradually being accepted by people, and the personal safety of inmates of pension institutions has become a focus of social concern. Therefore, there is an urgent need for a system that can monitor the activity route of the elderly, analyse their activity rules, locate their whereabouts in real-time and carry out risk warning.
The concept of location-based service (LBS)  appeared in the United States as early as 1996. At that time, it mainly provided rescue teams with the location information of the helpers, so as to facilitate quick rescue. For example, Spring PCS in the United States released the GPSONE technology in October 2001, which is a deep optimisation of GPS technology and can provide accurate location information about people. In April 2001, SECOM of Japan also released a device that could track the location information in real-time; it can accurately locate the location information of people or vehicles in any situation. Nowadays, LBS has achieved good development in various industries in various countries, and has won immense praise. More and more service providers and scholars have joined the team of research on LBS.
Compared with other countries, China's Internet and LBS started slowly. Beijing Mobile was the first company to provide LBS in China. In 2001, the company launched the LBS based on mobile dreamnet, which mainly focuses on SMSs. After 2 years, China Unicom launched the service of positioning star, and then carried out LBS business in succession all over the country. With the rapid development of LBS application services, the number of domestic enterprises and businesses studying LBSs is growing rapidly. The developed LBS-based software is widely used in all walks of life, such as social software based on LBS, ordering food takeaways, car navigation and so on. China is also ushering in a period of rapid growth in the field of LBSs.
China's traditional way of providing for the aged is home-based care and care by children. However, most of the people entering the ageing population are single children. A single couple has to support 4–6 old people. When an elderly couple relies on their children's care, this will seriously affect the children's work and life. At the same time, due to the untimely care, it will also cause security risks. In order to provide timely care for the elderly and improve their quality of life, pension institutions have been successively established. However, due to the late development of China's pension institutions and the relatively low degree of information technology, the activity management of the elderly mainly depends on manual work. On the one hand, manual management consumes a lot of manpower, material resources and financial resources of the nursing home. On the other hand, managers cannot get the location information of the elderly in real-time. When the elderly get lost, they cannot be located quickly, so there are great security risks. Therefore, it is necessary to use LBS technology to develop a software system that can monitor the activity routes of the elderly, analyse their activity rules, locate them in real-time and carry out risk warning.
The intelligent real-time safety supervision system of pension institutions includes the mobile APP and computer supervision program. The mobile APP realises real-time positioning, stores the activity track into the mobile phone and sends the obtained information to the computer program; the computer program is responsible for personnel information management, path management, fence setting, real-time display of the location of the elderly and danger alarm; HTTP protocol is used between the mobile APP and the computer program to realise the network communication between the APP and the computer program, and representational state transfer (REST) is used for data transmission format for data encapsulation, to ensure the rapid and safe transmission of information. The overall functional structure of the system is shown in Figure 1.
Intelligent real-time security management should be carried out in elderly care institutions, and a good data storage model is the basis to ensure the accuracy of data. From the analysis of software functions, the software database entities are ‘user information’, ‘employee information’, ‘location information’, ‘fence type’ and ‘fence parameters’; the ER diagram is shown in Figure 2.
The ‘user information’ is used to store the detailed information of the elderly, the ‘employee information’ is used to store the staff information, the ‘location’ entity is used to store the personnel activity track and the ‘fence type’ and ‘fence parameter’ entities are used to store the security fence type and coordinate position.
The system software includes the monitoring software on the computer side and APP, and ASP.NET Technology is used to develop the monitoring software;  the APP is based on Android system.  The monitoring software realises the functions of personnel management, positioning service, fence management and track management. The staff can view the position and activity-tracking information of the elderly in real-time on the computer, and deal with any dangerous situation in time. The APP uses Android LBS technology  and the Baidu map API to obtain location information and draw activity tracks. The information can be stored in the mobile phone SQLite database and transmitted to the computer at the same time. The APP is installed on mobile phones, bracelets and other devices carried by the elderly and staff. When the elderly move beyond the set boundary, the system will automatically generate a prompt, and immediately contact the phone of the nearest staff, thereby facilitating constant safety supervision.
Through analysis of the functional requirements of the system, the monitoring system for the elderly in a nursing home should have the functions of employee information management, user information management, real-time positioning, security fence setting, track query, security warning and rescue. The monitoring software is a B/S architecture, and the program is deployed on the server. The staff can use the browser to view the current position and activity track of the elderly at any time on the computer or mobile phone, and give safety tips. Through the decomposition and refinement of system functions, the structure of the monitoring program is as shown below (Figure 3):
Employee information management: It is used to manage the related information of the staff. After the staff login, it is automatically set to online status. User information management: It is used to edit and display the relevant information of the elderly. Real-time positioning: It obtains the current location information of users, which is used to accurately locate personnel. Security fence setting: It is the fence that is set according to the actual area of the pension institution. Track query: It mainly includes two functions – obtaining user track information and displaying user track.
Employee information management: It is used to manage the related information of the staff. After the staff login, it is automatically set to online status.
User information management: It is used to edit and display the relevant information of the elderly.
Real-time positioning: It obtains the current location information of users, which is used to accurately locate personnel.
Security fence setting: It is the fence that is set according to the actual area of the pension institution.
Track query: It mainly includes two functions – obtaining user track information and displaying user track.
A security fence is set on Baidu map according to the scope of activities of pension institutions, including circular fence and polygonal fence. When creating this setting, the steps outlined below are to be followed:
Step 1: Select the fence type; Step 2: Enter the name of the newly added fence; Step 3: Select the administrative region of the fence area; after this, a circular or square covering is automatically generated at the corresponding position of the map; Step 4: Click ‘Edit security fence’ (and the covering on the map can be edited); Step 5: Adjust the size of the covering to the required range, and then click the ‘End of editing fence’ button to build the system cover information, which is used as security fence information. Step 6: Click the ‘Update fence button’, and the system will store the security fence information into the database.
Step 1: Select the fence type;
Step 2: Enter the name of the newly added fence;
Step 3: Select the administrative region of the fence area; after this, a circular or square covering is automatically generated at the corresponding position of the map;
Step 4: Click ‘Edit security fence’ (and the covering on the map can be edited);
Step 5: Adjust the size of the covering to the required range, and then click the ‘End of editing fence’ button to build the system cover information, which is used as security fence information.
Step 6: Click the ‘Update fence button’, and the system will store the security fence information into the database.
The security fence is used to limit the scope of activities of the elderly, give a timely alarm and supervise the cross-border personnel, so as to ensure that the elderly can move within the safe area without facing the constant risk of transgressing into dangerous regions. The flow chart of adding a security fence is shown in Figure 4.
The real-time location monitoring server can automatically extract the security fence information and display the fence, receive the current position of the active personnel regularly sent by the mobile APP in real-time, mark the current position of the elderly and the staff with different colours on Baidu map  and judge whether the position of each elderly person exceeds the security fence. If it exceeds, the server will automatically give a danger alarm and find the nearest distance close to the staff, and inform the staff to manage in time to avoid safety accidents. The flow of real-time position display is shown in Figure 5.
In order to analyse the activity of the elderly, the software provides query of user activity track according to the conditions. The software first obtains the query conditions, thereafter reads the location information from the database and then displays the information on the Baidu map.
The server side of the elderly location monitoring system in the nursing home uses the design pattern of front-end and back-end separation, so an interface must be developed to realise the communication between the front-end and the back-end. The server side follows the restful design style. REST defines a set of architectural principles. All REST resources use a unified interface to facilitate the back-end and front-end systems to transmit information before, and all request methods use the standard HTTP methods such as put, push, get and delete.
The mobile APP uses model view controller (MVC) model based on Android operating system,  which provides users with input controller (model) and display image view (view). Data and code are saved in the model (controller). Interface design and background control program are separated to enhance the flexibility of the program. 
The mobile real-time positioning APP uses Android's LBS function to obtain the activity track of the elderly and the staff in real-time, stores the activity location information in the Android SQLite database  and sends it to the computer server at the same time. The mobile terminal has the functions of setting fence information, storing track, giving alarm when entering dangerous area, obtaining position information in real-time, displaying activity track in real-time on Baidu map and drawing a historical track.  The structure of the APP software is shown in Figure 6.
Security fence is the security area of personnel activities determined on the server side. After the software is run, an HTTP connection is established between the APP and server to request to obtain the currently valid fence information, and then the result of the server response is parsed. If the parsed data is empty, the APP will remind the user that the current fence acquisition has failed, and then it will start again after 3 min. The current valid fence information will be re-requested.  If the fence information cannot be obtained, a prompt is given. After the fence information is obtained, it is rendered on the map according to the dangerous fence information of the fence type. Users with fences enter the regulatory scope of pension institutions. The APP will get the current location information of each user in real-time and judge the physical relationship between the user's current location information and the dangerous fence. If the user's current location is in the fence, the APP will remind the user that the current location is in the safe range by voice, otherwise the software app will send an alarm report audio to remind the user that the current position is situated outside the fence.  The security fence setting process is shown in Figure 7.
When the user enters the main interface of the system, the core function is the real-time track display function. In order to ensure the accuracy of location information,  the APP continuously obtains 10 times of the user's current location information, and calculates the average value of these 10 times of location information to obtain a relatively accurate location information. In order to reduce the amount of information storage and data transmission, the distance between two points can be set (assuming 1 m). When the distance between two points is near, it can be considered that the user is in a static state, and there is no need to save and send location information. Only when the distance between two points is greater than the set value, does the APP save the location information in SQLite database, and packages and uploads the location information through the HTTP protocol ‘Go’ to the server and refreshes the current location on the map.  The program flow of real-time trajectory display is shown in Figure 8.
When users log in, they can query the historical activity trajectory according to the actual needs. When the user selects a legal date range, APP will query the location information that meets the conditions from SQLite database,  convert it into the longitude and latitude information set of Baidu map, dot and display it on the map to form a historical activity track map and mark the starting and ending location information, so that the user can clearly view his activity track in this time period. The procedure flow of historical track query is shown in Figure 9.
The data transmission between Mobile APP and service is completed through HTTP protocol. Data interaction is involved in login, registration, location upload and fence acquisition. In order to enable better development, the data transmission interface must agree between the mobile terminal and the server. In this system, the following components are available: login interface, user registration interface, new user location information interface and query system information interface between mobile terminal and server. In the verification login and user registration interface, the APP packages the user's account name and password and sends them to the server. The new user location information needs to package and send the user's current real-time location information obtained by APP to the server. The query system requests the current dangerous fence information of the user APP from the server.
The system took the Xi’an Petroleum University campus and the surrounding villages as simulation test points, divided the security fence and tested the mobile phones carried by several individuals. After testing, all the test cases designed by the module passed normally, and showed the expected results. System joint debugging test and mobile location information can be sent to the computer server in time; the computer can correctly store personnel information and activity track, simultaneously display the current location of multiple people and query personnel activity track according to the prevalent conditions. The system has been put to the primary-use stage. The system is developed and designed in the background of old institutions, but only a few modifications to the system can also be used in the supervision of kindergartens and schools, and further functions are being developed.