티스토리 뷰

How to establish a server to provide patient information where I live

 

Google Play Distributed : since 2015-06 , Banned : 2020-03-16 , 

refer (FORBES) : https://www.forbes.com/sites/thomasbrewster/2020/03/24/google-bans-coronavirus-apps-but-after-400000-downloads/#3d83354534c0

 

NOW Distributed ONLY --> KOREA [ ONESTORE ] : https://www.onestore.co.kr/userpoc/apps/view?pid=0000746566

 

 


 

  


CASE Windows 10.

download nodejs window version ( 64bit )

https://nodejs.org/en/download/

depending on your pc environment
After you receive it, click to install it.

Ctrl + R => CMD

mkdir c:\nodejs_server

cd c:\nodejs_server

c:\nodejs_server>npm init
c:\nodejs_server>npm install express

make file c:\nodejs_server\block_corona_server.js

The following is the source content:

 

 

You just need to modify the RED source code part.

___________block_corona_server.js  source code _____________________

 

 

var express = require('express')
var app = express()
var fs = require('fs');
var path = require('path');
var qs = require('querystring');


//___________________________________________________
//patient info array
//___________________________________________________



var staticdata = {
    "mersfirelist": [


        {
            "id": 101, 
            "command":"merge",
            "visible":"show",
            "getinfo": "GPS",
            "latitude": 37.444792,
            "longitude": 126.453688,
            "get_in_time": "2018-09-07 16:51:00",  /* need to same day (yyyy-mm-dd need to same day)*/
            "get_out_time": "2018-09-07 17:51:00", /* need to same day (yyyy-mm-dd need to same day) */
            "check_radius": 50,  /*  1~50 , 50 meter is max*/
            "title": "title0000",
            "content": "content 000",
             "title_eng": "english title",
            "content_eng": "english content",
            "sicker_type": "pass",
            "address": "address 00xx00",
            "refer_url": "refered a newspaper url "
        }

 

        ,



        {
            "id": 101,
            "command":"delete",   //delete before id 101
             "visible":"",
            "getinfo": "",
            "latitude": 0.0,
            "longitude":0.0,
            "get_in_time": "",
            "get_out_time": "",
            "check_radius": 0,
            "title": "",
            "content": "",
             "title_eng": "",
            "content_eng": "",
            "sicker_type": "",
            "address": "",
             "refer_url": ""

        },

 

{
            "id": 102,
            "command":"merge",
            "visible":"show",
            "getinfo": "GPS",
            "latitude": 37.444792,
            "longitude": 126.453688,
            "get_in_time": "2018-09-07 16:51:00",
            "get_out_time": "2018-09-07 17:51:00",
            "check_radius": 80,
            "title": "title000222",
            "content": "content000222",
             "title_eng": "english title 000",
            "content_eng": "english content 000",
            "sicker_type": "pass",
            "address": "address 0000",
             "refer_url": "refered a newspaper url "
        }

         ,

     {
        "id": 103,     --> PRIMARY KEY , 101,102,103,104... Need to write increasing
        "command":"merge",  ---> merge OR delete
        "visible":"show",          --> show FIX
        "getinfo": "GPS",   ----> GPS FIX
        "latitude": 35.1792708,  --> LATITUDE
        "longitude": 126.8198425,  ---> LONGITUDE
        "get_in_time": "2015-06-14 12:23:39",  ----> Time entered for that position
        "get_out_time": "2015-06-14 12:25:51", ----> Time outed for that position
        "check_radius": 10, ---> check radius ( unit is a meter , 50 meter is max)
        "title": "0000 title",  --> title
        "content": "0000 content",  --> content
        "title_eng": "at 00 fire", --> english title
        "content_eng": "abcdefg",  --> english content
        "sicker_type": "pass",     ----> patient type : pass, Isolation ,etc...
        "address": "000000 house load 3034", ---> address
        "refer_url": "http://aaere.aa.com"  --->refered a newspaper ur
        }

         ,

        {

...

        }

        //Repeat above
    ]
};


//_______________________________________________

 

 

 


//________________________________________________
// Your server notice
//________________________________________________


var staticnotice = {
    "noticelist": [
  
  {"tit_content":"title1 | notice content | english title | english content "},
  {"tit_content":"title2 | notice content2 | english title2 | english content2 "}

   //Repeat above
  
     ]
};

//________________________________________________
 

 

 

 


//_______________________________________________
//No modification is required
//_______________________________________________


//__________________________________________________
// 2020-03-12 append
//__________________________________________________
function isEmpty(str){
 
if(typeof str == "undefined" || str == null || str == "")
return true;
else
return false ;
}

HashMap = function(){
this.map = new Array();
};

HashMap.prototype = {
put : function(key,value){
this.map[key] = value;
} ,
get:function(key){
return this.map[key];
} ,
clear: function(){
this.map = new Array();
}
};

var staticmap = null;

function map_init(){
if( staticmap == null){
staticmap = new HashMap();
for(i = 0 ;i < staticdata.mersfirelist.length ;i++){
if( isEmpty(staticmap.get( staticdata.mersfirelist[i].id ) ) ) {
staticmap.put( staticdata.mersfirelist[i].id  , i );
}
}
}
}
//__________________________________________________
//2020-03-12 append end.
//__________________________________________________

app.get('/upload/notice.json', function(request, response){
    try{
        request.accepts('application/json');

        response.json(staticnotice);
      
  
    }catch(e){
        console.log(JSON.stringify(e));
    }
});



app.get('/upload/serverside.json', function(request, response){
    try{
        request.accepts('application/json');

  

        map_init();//2020-03-12 append

  
        response.json(staticdata);
      
  
    }catch(e){
        console.log(JSON.stringify(e));
    }
});




app.get('/upload/serverside.json/:maxcurid', function(request, response){
    try{
    request.accepts('application/json');

 

    map_init();//2020-03-12 append

    var filteredId = path.parse(request.params.maxcurid).base;
  
    var numparamid = Number(filteredId);

    var retstr = "";
    var isfirst = true;
    var new_item_find = false;

 

     //----------------------------------------------------------
     //2020-03-12 append
     //----------------------------------------------------------
     var startidx = 0;
     if(staticmap!=null){
          if( !isEmpty(staticmap.get(filteredId)) ){
              startidx = staticmap.get(filteredId);
          }
     }
     //----------------------------------------------------------


    for(i = startidx /* 2020-03-12 modified */ ;i < staticdata.mersfirelist.length ; i++) {
        var numid = Number(staticdata.mersfirelist[i].id );
        if(numid >= numparamid){
           new_item_find = true;
         }

        if( new_item_find ){

      
            if(isfirst){
                isfirst = false;
            }else{
                retstr += ",";
            }
            retstr += "{";
            retstr += "\"id\": "+numid +",";
            retstr += "\"command\":\""+staticdata.mersfirelist[i].command +"\",";
            retstr += "\"visible\":\""+staticdata.mersfirelist[i].visible +"\",";
            retstr += "    \"getinfo\": \""+staticdata.mersfirelist[i].getinfo +"\",";
            retstr += "    \"latitude\":"+staticdata.mersfirelist[i].latitude +",";
            retstr += "    \"longitude\": "+staticdata.mersfirelist[i].longitude +",";
            retstr += "    \"get_in_time\": \""+staticdata.mersfirelist[i].get_in_time +"\",";
            retstr += "    \"get_out_time\": \""+staticdata.mersfirelist[i].get_out_time +"\",";
            retstr += "    \"check_radius\":" +staticdata.mersfirelist[i].check_radius +",";
            retstr += "    \"title\": \""+staticdata.mersfirelist[i].title +"\", ";
            retstr += "    \"content\": \""+staticdata.mersfirelist[i].content +"\",";
            retstr += "    \"title_eng\": \""+staticdata.mersfirelist[i].title_eng +"\",";
            retstr += "    \"content_eng\": \""+staticdata.mersfirelist[i].content_eng +"\",";
            retstr += "    \"sicker_type\": \""+staticdata.mersfirelist[i].sicker_type +"\",";
            retstr += "    \"address\": \""+staticdata.mersfirelist[i].address +"\",";
            retstr += "    \"refer_url\": \""+staticdata.mersfirelist[i].refer_url +"\"";
            retstr += "    }";
        }
    }
  
    var allret = "";
    allret += "{";
    allret += "\"mersfirelist\": [";
    allret += retstr;
    allret += "]";
    allret += "};";


    response.send(allret);
    //response.json(staticdata);
  
  
    }catch(e){
        console.log(JSON.stringify(e));
    }
});

 
 
 
 
 
app.listen(1234, function() {
  console.log('BlockCorona Server listening on port 1234!')
});

//___________block_corona_server.js content end ___________

 

 

We are informing you again of the format corresponding to one patient information.

______________________________________________

command : beforedelete or beforehidden

..

content : '202' --> whatever you want to delete or hide before all

If you enter the ID value as '202' in the content, all of the previous ID rows will be deleted or hidden from each app user's phone.

______________________________________________

 

______________________________________________

command : deleteone or hiddenone

..

content : '211' --> whatever id that you want to delete or hide

If you enter the ID value as '211' in the content, the id's one row will be delete or hidden from each app user's phone.

______________________________________________

 

______________________________________________

command : bfdatedelete or bfdatehidden

..

content : '2020-05-01 15:03:33' --> whatever date that you want to delete or hide before date all

If you enter the date value as '2020-05-01 15:03:33' in the content, all of the previous date rows will be delete or hidden from each app user's phone.

______________________________________________

 

--------------   ONE PATIENT'S FORMAT START  ---------------

        {
        "id": 101,   -->id
        "command":"merge",  ---> merge or delete or beforedelete or beforehidden
        "visible":"show",          --> show or hidden
        "getinfo": "GPS",   ----> GPS FIX
        "latitude": 35.1792708, 
        "longitude": 126.8198425, 
        "get_in_time": "2015-06-14 12:23:39",  ----> Time entered in the location
        "get_out_time": "2015-06-14 12:25:51", ----> Time out of the location
        "check_radius": 10, ---> unit meters
        "title": "00에서 00발생", --> title
        "content": "내용",    --> content
         "title_eng": "at 00 fire", --> global title
        "content_eng": "abcdefg",  --> global content
        "sicker_type": "경유",     ----> patient type whatever you want  ( limit 10 characters )
        "address": "서울시 xxx", ---> address
        "refer_url": "http://aaere.aa.com
    }


----------------------------- ONE PATIENT'S FORMAT END -----------------



 

 
Server RUN :
CD C:\nodejs_server
c:\nodejs_server> node  --max-old-space-size=4096   block_corona_server.js


TO shutdown server :

CTRL + C


OPEN YOUR FIREWALL ON 1234 PORT

 
External IP's port : 80 port forward to your server PC's IP's 1234


RUN APP

SECOND TAP

WRITE YOUR [YOUR DOMAIN OR IP:1234]  or [YOUR DOMAIN OR IP:80] --> APPEND -> SELECT YOUR IP ON SELECT BOX -> APPLY
AND YOU CAN RECEIVE YOUR SERVER's PATIENT INFORMATION TO YOUR PHONE APP 

 

다운로드 | Node.js

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

nodejs.org

 


 

 

 

 

The above is that 49 seconds of contact history was found.


The actual app will be translated into the languages of each country and printed out.

 

AND NOW , It is possible to examine whether my movements and time CONTACT patients.

 

AND NOW , You can let other people know your EXTERNAL IP so that they can check for contact with a patient contact.

 

Leave your questions in the comments and I'll answer them.