-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c0e11e0
Showing
23 changed files
with
458 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const views = require('koa-views'); | ||
const logger = require('koa-logger'); | ||
const koaBody = require('koa-body'); | ||
const server = require('koa-static'); | ||
const path = require('path'); | ||
|
||
const Koa = require('koa'); | ||
const app = module.exports = new Koa(); | ||
|
||
const router = require('./routes/router') | ||
|
||
// middleware | ||
|
||
app.use(logger()); | ||
|
||
app.use( | ||
views( | ||
path.join(__dirname, '/views'), { | ||
extension: 'html', | ||
map: { html: 'swig' } | ||
} | ||
) | ||
); | ||
|
||
app.use(koaBody()); | ||
|
||
app.use(server(path.join(__dirname, '/static'))); | ||
|
||
app.use(router.routes()); | ||
|
||
app.listen(3001); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const db = mongoose.createConnection('mongodb://localhost:27017/Outpatient'); | ||
|
||
module.exports = db; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const mongoose = require('mongoose'); | ||
const Schema = mongoose.Schema; | ||
|
||
const db = require('./db'); | ||
|
||
const patientSchema = new Schema({ | ||
name: String, | ||
gender: String, | ||
birthDate: String, | ||
diagnosis: [String], | ||
treatment: [String] | ||
}, { | ||
versionKey: false | ||
}); | ||
|
||
const Patient = db.model('Patient', patientSchema); | ||
|
||
module.exports = Patient; |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const fs = require('fs'); | ||
|
||
let diagnosis = JSON.parse(fs.readFileSync('./config/diagnosis.json')); | ||
let treatment = JSON.parse(fs.readFileSync('./config/treatment.json')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "outpatient-service", | ||
"version": "1.0.0", | ||
"description": "Managing the patients.", | ||
"main": "app.js", | ||
"scripts": { | ||
"start": "node app.js" | ||
}, | ||
"author": "Shiyan Deng", | ||
"license": "ISC", | ||
"dependencies": { | ||
"koa": "^2.2.0", | ||
"koa-basic-auth": "^2.0.0", | ||
"koa-body": "^2.0.1", | ||
"koa-compose": "^4.0.0", | ||
"koa-csrf": "^3.0.6", | ||
"koa-logger": "^3.0.0", | ||
"koa-router": "^7.2.0", | ||
"koa-session": "^5.0.0", | ||
"koa-static": "^3.0.0", | ||
"koa-views": "^6.0.2", | ||
"mongoose": "^5.1.3", | ||
"swig": "^1.4.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const router = require('koa-router')(); | ||
const Patient = require('../db/patient'); | ||
|
||
router.get('/', showMainPage) | ||
.get('/searchByName', searchByName) | ||
.get('/addNewPatient', addNewPatient) | ||
.get('/patientDetail', showPatientDetail); | ||
|
||
async function showMainPage(ctx) { | ||
await ctx.render('main'); | ||
} | ||
|
||
async function searchByName(ctx) { | ||
let patients = await Patient.find({ name: ctx.query.name }); | ||
|
||
if (patients.length) { | ||
await ctx.render('patientList', {patients: patients}); | ||
} | ||
else { | ||
let newPatient = new Patient({name : ctx.query.name}); | ||
newPatient.save(); | ||
|
||
await ctx.render('newPatient', { name: ctx.query.name }); | ||
} | ||
} | ||
|
||
async function showPatientDetail(ctx) { | ||
|
||
} | ||
|
||
module.exports = router; |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$(document).ready( function () { | ||
$('#dataTable').DataTable({ | ||
"language": { | ||
"paginate": { | ||
"sNext": "下一页", | ||
"sPrevious": "上一页", | ||
}, | ||
"loadingRecords": "正在加载中.....", | ||
"zeroRecords": "对不起,查询不到相关数据!", | ||
"infoFiltered": "【从 _MAX_ 条数据中搜索的结果】", | ||
"sSearch": "搜索", | ||
"sLengthMenu": "每页显示 _MENU_ 条记录", | ||
"sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_ 条记录", | ||
} | ||
}); | ||
}); |
Oops, something went wrong.