Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8691

喉頭がんの治療プロトコルをNode.jsでVueに表示しHerokuにデプロイ

$
0
0

概要

プログラムの勉強を始めて4か月ほどの開業医です。

病気のおすすめの診断法や、治療法などを記載した診療ガイドランというものがあります。その中に治療の進め方(治療計画)を示す、治療プロトコルというものがあります。病気の程度や治療の効果によって、治療の進め方が枝分かれしていくものなので、ifとelseさえ知っていればプログラム初心者でも治療プロトコルが簡単に作成できます。

昔私が書いた喉頭がんの診療プロトコルの医学書の内容を基に勉強したばかりのVueを少し使ってNode.jsでプログラミングしHerokuにデプロイしました。

実装

質問に答えていくと喉頭がんの治療の進め方が分かるWEBアプリ。

動作


1.jpg

2.jpg
3.jpg
4.jpg

作成方法

1.ライブラリーのインストール

heroku-sampleというフォルダー作成します。

初期設定します。

npm init -y

必要なライブラリをインストールします。

npm i body-parser express

2.index.jsの作成

index.jsを作成し、こちらのコードをコピペします。

varexpress=require('express');varapp=express();// public というフォルダに入れられた静的ファイルはそのまま表示app.use(express.static(__dirname+'/public'));// bodyParservarbodyParser=require('body-parser');app.use(bodyParser.json());app.post('/post',function(req,res){for(keyinreq.body){console.log(key,'=',req.body[key]);}res.end();});app.listen(process.env.PORT||8080);console.log("server start! (heroku)");

3.index.htmlの作成
index.js と同じ階層に public フォルダを作りその中に index.html を新規作成します。
以下のようなコードを書きました。

<!DOCTYPEhtml><html><head><title>Step01</title>
<scriptsrc="https://unpkg.com/vue"></script>
</head>
<body><h1>今後の治療方針は?</h1>
<h2id="app">{{message}}</h2>
<script>letmes;varstage=window.prompt("喉頭がんのステージをローマ数字で入力");if(stage==""){varsize=window.prompt("bulky tumor?(yes,no)");if(size=="yes"){vareffect=window.prompt("多分割照射法 total 66~72.8Gy+化学療法(NDP or TS-1)施行 \n52Gy時点で治療効果判定\n反応良好?(yes,no)");if(effect=="yes"){varrecurrence=window.prompt("照射継続➡経過観察\n腫瘍残存or再発あり?(yes,no)");if(recurrence=="yes"){mes="喉頭全摘術(+頸部郭清術)施行";}else{mes="経過観察";}}else{mes="喉頭全摘術(+頸部郭清術)施行";}}else{vareffect=window.prompt("通常分割照射法 total 60~68Gy施行 \n52Gy時点で治療効果判定\n反応良好?(yes,no)");if(effect=="yes"){varrecurrence=window.prompt("照射継続➡経過観察\n腫瘍残存or再発あり?(yes,no)");if(recurrence=="yes"){mes="喉頭全摘術(+頸部郭清術)施行";}else{mes="経過観察";}}else{mes="喉頭全摘術(+頸部郭清術)施行";}}}elseif(stage==""){varsize=window.prompt("bulky tumor?(yes,no)");if(size=="yes"){vareffect=window.prompt("多分割照射法 total 66~72.8Gy+化学療法(NDP or TS-1)試行 \n52Gy時点で治療効果判定\n反応良好?(yes,no)");if(effect=="yes"){varrecurrence=window.prompt("照射継続➡経過観察\n腫瘍残存or再発あり?(yes,no)");if(recurrence=="yes"){mes="喉頭全摘術(+頸部郭清術)施行";}else{mes="経過観察";}}else{mes="喉頭全摘術(+頸部郭清術)施行";}}else{vareffect=window.prompt("通常分割照射法 total 60~68Gy施行 \n52Gy時点で治療効果判定\n反応良好?(yes,no)");if(effect=="yes"){varrecurrence=window.prompt("照射継続➡経過観察\n腫瘍残存or再発あり?(yes,no)");if(recurrence=="yes"){mes="喉頭全摘術(+頸部郭清術)施行";}else{mes="経過観察";}}else{mes="喉頭全摘術(+頸部郭清術)施行";}}}elseif(stage==""){vartumor=window.prompt("T3以上?(yes,no)");if(tumor=="yes"){varfix=window.prompt("T3NOで声帯固定?またはT3N1?(yes,no)");if(fix=="yes"){varconstriction=window.prompt("気道狭窄あり?(yes,no)");if(constriction=="yes"){varmalignancy=window.prompt("緊急気管切開\n施行\n(拡大)喉頭全摘術+患側甲状腺切除(+頸部郭清術)(+再建術)\n施行 \n病理検索結果:再発ハイリスク群?(yes,no)");if(malignancy=="yes"){mes="術後(化学)放射線療法施行";}else{mes="経過観察";}}else{varmalignancy=window.prompt("(拡大)喉頭全摘術+患側甲状腺切除(+頸部郭清術)(+再建術)\n施行 \n病理検索結果:再発ハイリスク群?(yes,no)");if(malignancy=="yes"){mes="術後(化学)放射線療法施行";}else{mes="経過観察";}}}else{vareffect=window.prompt("1コース目:通常分割照射法40Gy+化学療法(NDP40mg/m2+5FU700mg/m2)\n2コース目:加速分割照射法 24~27Gy+化学療法(NDP40mg/m2)\n試行 \n52Gy時点で治療効果判定\n反応良好?(yes,no)");if(effect=="yes"){varrecurrence=window.prompt("照射継続➡経過観察\n腫瘍残存or再発あり?(yes,no)");if(recurrence=="yes"){mes="喉頭全摘術(+頸部郭清術)";}else{mes="経過観察";}}else{mes="喉頭全摘術(+頸部郭清術)";}}}else{vareffect=window.prompt("多分割照射法 total 66~72.8Gy+化学療法(NDP or TS-1)\n試行 \n52Gy時点で治療効果判定\n反応良好?(yes,no)");if(effect=="yes"){varrecurrence=window.prompt("照射継続➡経過観察\n腫瘍残存or再発あり?(yes,no)");if(recurrence=="yes"){mes="喉頭全摘術(+頸部郭清術)";}else{mes="経過観察";}}else{mes="喉頭全摘術(+頸部郭清術)";}}}elseif(stage==""){varconstriction=window.prompt("気道狭窄あり?(yes,no)");if(constriction=="yes"){varope=window.prompt("緊急気管切開試行\n腫瘍切除可能?(yes,no)");if(ope=="yes"){varmalignancy=window.prompt("(拡大)喉頭全摘術+患側甲状腺切除(+頸部郭清術)(+再建術)\n施行 \n病理検索結果:再発ハイリスク群?(yes,no)");if(malignancy=="yes"){mes="術後(化学)放射線療法施行";}else{mes="経過観察";}}else{varcondition=window.prompt("全身状態良好?(yes,no)");if(condition=="yes"){mes="放射線療法or化学放射線療法(+胃瘻造設)";}else{mes="緩和療法(+胃瘻造設)";}}}else{varope=window.prompt("腫瘍切除可能?(yes,no)");if(ope=="yes"){varmalignancy=window.prompt("(拡大)喉頭全摘術+患側甲状腺切除(+頸部郭清術)(+再建術)\n施行 \n病理検索結果:再発ハイリスク群?(yes,no)");if(malignancy=="yes"){mes="術後(化学)放射線療法施行";}else{mes="経過観察";}}else{varcondition=window.prompt("全身状態良好?(yes,no)");if(condition=="yes"){mes="放射線療法or化学放射線療法(+胃瘻造設)";}else{mes="緩和療法(+胃瘻造設)";}}}}else{mes="Ⅰ、Ⅱ、Ⅲ、Ⅳのいずれかを入力してください。";}varapp=newVue({el:'#app',data:{message:mes}})</script>
</body>
</html>

以下の部分で少しVue.jsを使って書いています。

varapp=newVue({el:'#app',data:{message:mes}})

4..gitignore を作成
node_modules フォルダはアップロードから除外するため .gitignore というファイルを最上部のindex.jsなどと同じ場所に作成し以下のコードをコピペします。

#Logslogs*.lognpm-debug.log*yarn-debug.log*yarn-error.log*#Runtimedatapids*.pid*.seed*.pid.lock#Directoryforinstrumentedlibsgeneratedbyjscoverage/JSCoverlib-cov#Coveragedirectoryusedbytoolslikeistanbulcoverage#nyctestcoverage.nyc_output#Gruntintermediatestorage(http://gruntjs.com/creating-plugins#storing-task-files).grunt#Bowerdependencydirectory(https://bower.io/)bower_components#node-wafconfiguration.lock-wscript#Compiledbinaryaddons(https://nodejs.org/api/addons.html)build/Release#Dependencydirectoriesnode_modules/jspm_packages/#TypeScriptv1declarationfilestypings/#Optionalnpmcachedirectory.npm#Optionaleslintcache.eslintcache#OptionalREPLhistory.node_repl_history#Outputof'npm pack'*.tgz#YarnIntegrityfile.yarn-integrity#dotenvenvironmentvariablesfile.env#next.jsbuildoutput.next

5.Procfile
一番上の階層にProcfileというファイルを新規作成し以下のコードをコピペします。

web:nodeindex.js

6.herokuにデプロイ
gitリポジトリの対象にする初期設定をします。

git init

gitリポジトリにアプリを追加します。

git add --a

gitリポジトリにコミットします。

git commit -m "commit"

herokuアプリ追加します。自分で考えたアプリケーションネーム(英語)を入力します。

heroku create アプリケーションネーム

herokuにプッシュして完了です。

git push heroku master

6.URL
https://selfcheck.herokuapp.com/

考察

ifとelseだけで書いているので、きれいなコードではありませんが、喉頭がんの診療プロトコルが実装できました。プログラム初心者の方にif文だけでもなんとかなるという参考になれば幸いです。


Viewing all articles
Browse latest Browse all 8691

Trending Articles