pokpack / EMR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EMR

Start

git clone --recurse-submodules https://github.com/pokpack/EMR.git
cd ERD
npm install

Ubuntu & MacOS


HTTP_PORT=3001 P2P_PORT=6001 PEERS=ws://localhost:6002,ws://localhost:6003,ws://localhost:6004 SECRET_KEY=x]vf4yp0yf npm start
HTTP_PORT=3002 P2P_PORT=6002 PEERS=ws://localhost:6001,ws://localhost:6003,ws://localhost:6004 SECRET_KEY=x]vf4yp0yf npm start
HTTP_PORT=3003 P2P_PORT=6003 PEERS=ws://localhost:6001,ws://localhost:6002,ws://localhost:6004 SECRET_KEY=x]vf4yp0yf npm start
HTTP_PORT=3004 P2P_PORT=6004 PEERS=ws://localhost:6001,ws://localhost:6002,ws://localhost:6003 SECRET_KEY=x]vf4yp0yf npm start

curl -H "Content-type:application/json" -H "Authorization: Bearer x]vf4yp0yf" --data '{"data" : {"first_name": "firstname", "last_name" : "last_name"}}' http://localhost:3001/mineEMR

curl -H "Authorization: Bearer x]vf4yp0yf" http://localhost:3001/EMRs
curl -H "Authorization: Bearer x]vf4yp0yf" http://localhost:3001/EMRs/1

curl -H "Content-type:application/json" -H "Authorization: Bearer x]vf4yp0yf" --data '{"token" : "xxx"}' http://localhost:3001/newToken


Window


set HTTP_PORT=3001 && set P2P_PORT=6001 && set PEERS=ws://localhost:6002,ws://localhost:6003,ws://localhost:6004 && set SECRET_KEY=x]vf4yp0yf && npm start
set HTTP_PORT=3002 && set P2P_PORT=6002 && set PEERS=ws://localhost:6001,ws://localhost:6003,ws://localhost:6004 && set SECRET_KEY=x]vf4yp0yf && npm start
set HTTP_PORT=3003 && set P2P_PORT=6003 && set PEERS=ws://localhost:6001,ws://localhost:6002,ws://localhost:6004 && set SECRET_KEY=x]vf4yp0yf && npm start
set HTTP_PORT=3004 && set P2P_PORT=6004 && set PEERS=ws://localhost:6001,ws://localhost:6003,ws://localhost:6002 && set SECRET_KEY=x]vf4yp0yf && npm start


curl -H "Content-Type: application/json" -H "Authorization: Bearer x]vf4yp0yf" -X POST  http://localhost:3001/mineEMR -d "{\"data\":{\"user_id\": \"1\", \"fist_name\": \"fistname\", \"last_name\": \"lastname\"}}"

curl -H "Authorization: Bearer x]vf4yp0yf" GET http://localhost:3001/EMRs
curl -H "Authorization: Bearer x]vf4yp0yf" GET http://localhost:3001/EMRs/1

curl -H "Content-Type: application/json" -H "Authorization: Bearer x]vf4yp0yf" -X POST  http://localhost:3001/newToken -d "{\"data\": \"xxx\"}"


Docker

docker-compose up --build

Open docker logs

D:
cd EMR
docker-compose logs -t -f

STATE

STATE_ID = {
  ADMIT: 1, # หน้าแรกรับ
  CURE: 2, # การรักษา
  DISPENSE: 3, # เภสัชจ่ายยา
  DIAGNOSE: 4, # หมอ/พยาบาล วินิฉัย
}

Routes


  POST /api/:hn/admit/:emrId # แรกรับ
  POST /api/:hn/cure/:emrId # รักษา
  POST /api/:hn/dispense/:emrId # เภสัชจ่ายยา
  POST /api/:hn/diagnose/:emrId # หมอ/พยาบาล วินิฉัย

  GET /api/cures # รายการที่ต้อง รักษา => หมอ ดึง | finished == false
  GET /api/dispenses # รายการที่ต้อง จ่ายยา => เภสัช ดึง | finished == false
  GET /api/diagnoses # รายการที่ต้อง วินิฉัย => หมอ/พยาบาล ดึง | finished == false

  GET /api/admiteds # รายการที่อยู่ admit state | ไม่สนใจ finished
  GET /api/cureds # รายการที่อยู่ cure state | ไม่สนใจ finished
  GET /api/dispenseds # รายการที่อยู่ dispense state | ไม่สนใจ finished
  GET /api/diagnoseds # รายการที่อยู่ diagnose state | ไม่สนใจ finished

  GET /api/:hn/emr/:emrId # ข้อมูล เข้ารักษา
  GET /api/:hn/history # ข้อมูลประวัติ

  GET /api/count จำนวน case
 # :hn id ผู้ป่วย
 # :emrId id เข้ารักษา


Diagram

alt tag


Test

Server down

docker-compose -f docker-compose.test.yml up --build

#call api
curl -H "Authorization: Bearer x]vf4yp0yf" GET http://localhost:8888/EMRs

docker-compose -f docker-compose.test.yml stop first_node

#call api again

docker-compose -f docker-compose.test.yml stop second_node
docker-compose -f docker-compose.test.yml start first_node

SSH

docker ps // ดู container ที่มีอยู่
docker exec –it [CONTAINER ID ที่จะเข้า] /bin/bash // เข้าไปใน container นั้นๆ
ls  // หาว่ามี blockchain.json มั้ย?
cat blockchain.json // ดูข้อมูลใน blockchain.json

Edit data

docker-compose -f docker-compose.3port.yml up --build

#call all data api
curl -H "Authorization: Bearer x]vf4yp0yf" GET http://localhost:3001/datas
curl -H "Authorization: Bearer x]vf4yp0yf" GET http://localhost:3002/datas
curl -H "Authorization: Bearer x]vf4yp0yf" GET http://localhost:3003/datas

#call mien-data api
curl -H "Content-Type: application/json" -H "Authorization: Bearer x]vf4yp0yf" -X POST  http://localhost:3001/mine-data -d "{\"data\":{\"info\": \"Add first data\"}}"

#edit data
node tests/mock.test.js

docker ps // third_node
docker exec –it [CONTAINER ID ที่จะเข้าแก้ใขข้อมูล] /bin/bash
apt-get update
apt-get install vim nano
cat blockchain.json // ดูข้อมูลใน blockchain.json

docker-compose -f docker-compose.3port.yml stop first_node
docker-compose -f docker-compose.3port.yml start first_node
#call all data api

curl -H "Content-Type: application/json" -H "Authorization: Bearer x]vf4yp0yf" -X POST  http://localhost:3003/mine-data -d "{\"data\":{\"info\": \"Add data intermittent\"}}"


#call all data api

curl -H "Content-Type: application/json" -H "Authorization: Bearer x]vf4yp0yf" -X POST  http://localhost:3001/mine-data -d "{\"data\":{\"info\": \"Add data continuously\"}}"


#call all data api

curl -H "Content-Type: application/json" -H "Authorization: Bearer x]vf4yp0yf" -X POST  http://localhost:3002/mine-data -d "{\"data\":{\"info\": \"Add data continuously\"}}"


#call all data api

Submodule

https://github.com/pokpack/frontend

About

License:GNU General Public License v3.0


Languages

Language:JavaScript 99.1%Language:Dockerfile 0.9%