Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Completion reports - DO NOT MERGE #1283

Open
wants to merge 217 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
217 commits
Select commit Hold shift + click to select a range
0223035
Drush scrip WIP [ci skip]
anvmn Aug 14, 2024
65dd74e
Add 'reports_data' field to Nutrition encounter CT [ci skip]
anvmn Aug 14, 2024
7610897
Initial working script [ci skip]
anvmn Aug 14, 2024
11a35af
Improve code [ci skip]
anvmn Aug 15, 2024
12f2cbf
Completion menu infra on back-end [ci skip]
anvmn Aug 15, 2024
348b2a5
Initial Elm APP [ci skip]
anvmn Aug 15, 2024
9ef8634
Results page WIP [ci skip]
anvmn Aug 15, 2024
0642ff2
Display results [ci skip]
anvmn Aug 15, 2024
54c24c6
A fix [ci skip]
anvmn Aug 15, 2024
65554f5
Another fix [ci skip]
anvmn Aug 15, 2024
797fbad
Data filtering [ci skip]
anvmn Aug 17, 2024
c36647c
Add missing file [ci skip]
anvmn Aug 17, 2024
a403b6c
Add 'taken by' filter [ci skip]
anvmn Aug 17, 2024
2baaa56
Logic for generatig data [ci skip]
anvmn Aug 18, 2024
b2bea58
Add field to store completion data on attendance CT [ci skip]
anvmn Aug 18, 2024
6f84426
A fix [ci skip]
anvmn Aug 18, 2024
001b0d7
Rename script [ci skip]
anvmn Aug 18, 2024
cef1bd7
Save generated data on Attendance node [ci skip]
anvmn Aug 18, 2024
771ac0d
A fix [ci skip]
anvmn Aug 18, 2024
3c1376d
Add FBF and mother activities [ci skip]
anvmn Aug 18, 2024
628681c
A fix [ci skip]
anvmn Aug 18, 2024
896090a
Another fix [ci skip]
anvmn Aug 18, 2024
4803a80
Load, decode and store Group Nutrition completion data [ci skip]
anvmn Aug 18, 2024
1156e51
New report type - logic + view [ci skip]
anvmn Aug 18, 2024
e2660a0
A fix [ci skip]
anvmn Aug 18, 2024
da6f2c6
Store large sets data as content [ci skip]
anvmn Aug 19, 2024
227dc30
Merge branch 'issue-1285' of github.com:TIP-Global-Health/eheza-app i…
anvmn Aug 19, 2024
718e471
Try to reduce memory usage [ci skip]
anvmn Aug 19, 2024
0303ede
Addapt client side [ci skip]
anvmn Aug 19, 2024
809fa35
Improve code [ci skip]
anvmn Aug 19, 2024
fbd1a1f
Define mapping [ci skip]
anvmn Aug 19, 2024
c24d68b
Load participant encounters and sort then ASC [ci skip]
anvmn Aug 19, 2024
75ded4d
Add script [ci skip]
anvmn Aug 19, 2024
a3baa7b
Fixes [ci skip]
anvmn Aug 19, 2024
216c587
Acute Illness logic WIP [ci skip]
anvmn Aug 20, 2024
04e4bd9
Client side adjustments [ci skip]
anvmn Aug 20, 2024
1c5f7f8
Add physical exam activities [ci skip]
anvmn Aug 21, 2024
1eed780
Improve client-side code [ci skip]
anvmn Aug 21, 2024
bd9521f
Merge branch 'issue-1287' of github.com:TIP-Global-Health/eheza-app i…
anvmn Aug 21, 2024
6645dd1
More WIP [ci skip]
anvmn Aug 21, 2024
fc71208
More improvements [ci skip]
anvmn Aug 21, 2024
04961f3
Merge branch 'issue-1287' of github.com:TIP-Global-Health/eheza-app i…
anvmn Aug 21, 2024
14f4d63
Compelete Next Steps activities [ci skip]
anvmn Aug 21, 2024
3f5e7ae
More adjustments [ci skip]
anvmn Aug 21, 2024
b97c453
Generate and store completion data [ci skip]
anvmn Aug 21, 2024
32a2b19
A fix [ci skip]
anvmn Aug 21, 2024
38f67b9
Another fox [ci skip]
anvmn Aug 21, 2024
113596c
Add data field to Acute Illness Encounter CT [ci skip]
anvmn Aug 21, 2024
6dbaade
Add acute illness into 'large data sets' script [ci skip]
anvmn Aug 21, 2024
1778a8d
View report on client [ci skip]
anvmn Aug 21, 2024
8989c38
Improve code [ci skip]
anvmn Aug 21, 2024
d1787e1
Style [ci skip]
anvmn Aug 21, 2024
e6c1255
Fix for follow up [ci skip]
anvmn Aug 21, 2024
5744c3a
Fixes [ci skip]
anvmn Aug 22, 2024
ba07f10
More fixes [ci skip]
anvmn Aug 22, 2024
01f9be5
More fixes [ci skip]
anvmn Aug 22, 2024
1d13dc1
Fix launch dates [ci skip]
anvmn Aug 23, 2024
5d6808f
Fixes and some comments [ci skip]
anvmn Aug 23, 2024
862f132
Eliminate code duplications [ci skip]
anvmn Aug 23, 2024
28b972d
More fixes and comments [ci skip]
anvmn Aug 23, 2024
31bf559
Fixes for medication distribution [ci skip]
anvmn Aug 23, 2024
5c1eec6
More fixes and comments [ci skip]
anvmn Aug 23, 2024
68a6126
A fix [ci skip]
anvmn Aug 23, 2024
be37ef0
Fixes + docs
anvmn Aug 25, 2024
cfccc0a
Fix typo [ci skip]
anvmn Aug 26, 2024
448b646
Add script [ci skip]
anvmn Aug 26, 2024
972c7d4
Add field for completion data to Well Child encounter CT [ci skip]
anvmn Aug 26, 2024
a26f4c6
Update mapping [ci skip]
anvmn Aug 26, 2024
087e210
Generate initial activities [ci skip]
anvmn Aug 27, 2024
3957c7a
A fix [ci skip]
anvmn Aug 27, 2024
9710cac
Add Medications activities [ci skip]
anvmn Aug 27, 2024
f00369d
Merge branch 'issue-1289' of github.com:TIP-Global-Health/eheza-app i…
anvmn Aug 27, 2024
ee63b62
Next steps activities - WIP [ci skip]
anvmn Aug 28, 2024
16a7795
WIP [ci skip]
anvmn Aug 28, 2024
0b44b6c
Load immunisations data [ci skip]
anvmn Aug 29, 2024
a7a2cfd
Complete vaccination progress and history generation [ci skip]
anvmn Aug 29, 2024
593b0d0
Merge pull request #1286 from TIP-Global-Health/issue-1285
anvmn Aug 29, 2024
d7bf23e
Merge pull request #1288 from TIP-Global-Health/issue-1287
anvmn Aug 29, 2024
90afb19
Complete immunisations logic [ci skip]
anvmn Aug 29, 2024
8094827
Complete Next Steps activities logic [ci skip]
anvmn Sep 1, 2024
dbfb135
Generate data of front-end [ci skip]
anvmn Sep 1, 2024
0e2afae
Client side logic + view [ci skip]
anvmn Sep 1, 2024
32b5713
A fix [ci skip]
anvmn Sep 1, 2024
0850e9e
A fix [ci skip]
anvmn Sep 1, 2024
b7765f7
Styling [ci skip]
anvmn Sep 1, 2024
b070a4e
Merge branch 'issue-1289' of github.com:TIP-Global-Health/eheza-app i…
anvmn Sep 1, 2024
5286bfb
Another fix [ci skip]
anvmn Sep 2, 2024
c4071ae
Fix well_child_head_circumference [ci skip]
anvmn Sep 2, 2024
c587dfd
Send encounter type instead of taken by [ci skip]
anvmn Sep 2, 2024
a19cf0a
Add Newborn Exam report [ci skip]
anvmn Sep 2, 2024
b2fc5b7
Newborn exam report front-end logic [ci skip]
anvmn Sep 3, 2024
c93f4dd
Fixes [ci skip]
anvmn Sep 3, 2024
ef352f3
Docs
anvmn Sep 4, 2024
86259f5
Add reports data field to Home Visit encounter CT [ci skip]
anvmn Sep 4, 2024
6f93f66
Add script [ci skip]
anvmn Sep 4, 2024
03ab7a3
Backend logic [ci skip]
anvmn Sep 4, 2024
bd7f41e
A fix [ci skip]
anvmn Sep 4, 2024
af13fd1
Extend loaded data [ci skip]
anvmn Sep 4, 2024
7e42ddb
Rename script [ci skip]
anvmn Sep 4, 2024
d338d55
Decode and store data on client [ci skip]
anvmn Sep 4, 2024
e5e8210
View report
anvmn Sep 4, 2024
ac62f7a
Rename scripts [ci skip]
anvmn Sep 4, 2024
a4a33a8
A fix [ci skip]
anvmn Sep 4, 2024
1293e57
Another fix [ci skip]
anvmn Sep 4, 2024
c2a71ec
Elminate empty encounters
anvmn Sep 4, 2024
176a84b
Update server/hedley/modules/custom/hedley_reports/hedley_reports.module
anvmn Sep 5, 2024
d5e1883
Update server/hedley/modules/custom/hedley_reports/scripts/generate-w…
anvmn Sep 5, 2024
021dc78
Update server/elm/src/Pages/Completion/Utils.elm
anvmn Sep 5, 2024
9ba86e3
Code review fixes
anvmn Sep 5, 2024
9f59517
Merge branch 'issue-1289' of github.com:TIP-Global-Health/eheza-app i…
anvmn Sep 5, 2024
0d2fae1
Fix spelling [ci skip]
anvmn Sep 5, 2024
362093f
Merge branch 'develop' into issue-1289
anvmn Sep 5, 2024
afc0ef3
Merge branch 'issue-1289' into issue-1295
anvmn Sep 5, 2024
d870e1a
Merge pull request #1290 from TIP-Global-Health/issue-1289
anvmn Sep 5, 2024
3562f0a
Merge pull request #1297 from TIP-Global-Health/issue-1285
anvmn Sep 5, 2024
a605b51
Merge branch 'feature-completion-reports' into issue-1295
anvmn Sep 5, 2024
5e03cc7
Fixes
anvmn Sep 5, 2024
4483286
Add reports data field to encounter [ci skip]
anvmn Sep 5, 2024
f19a54f
Add script [ci skip]
anvmn Sep 5, 2024
5dde29a
Backend logic [ci skip]
anvmn Sep 6, 2024
32a271d
Fixes [ci skip]
anvmn Sep 6, 2024
102651f
Another fix [ci skip]
anvmn Sep 6, 2024
4ee1586
One more fix [ci skip]
anvmn Sep 6, 2024
42e9d5f
Load data on backend [ci skip]
anvmn Sep 6, 2024
26ed54b
Define, decode and store data on client [ci skip]
anvmn Sep 6, 2024
34a0fdf
Client logic
anvmn Sep 6, 2024
cf25542
Satisfy coder
anvmn Sep 6, 2024
0e6e307
Add reports data field to NCD encounter CT [ci skip]
anvmn Sep 8, 2024
1c27c92
Add script and implement partial logic [ci skip]
anvmn Sep 8, 2024
4be3c1c
Add labs activities [ci skip]
anvmn Sep 9, 2024
e5daf23
Add next steps activities [ci skip]
anvmn Sep 10, 2024
bf773e3
Add labs results activities [ci skip]
anvmn Sep 10, 2024
2da8641
Pull NCD data when loading large data sets [ci skip]
anvmn Sep 10, 2024
aa28561
Expand client data, decode and store on front-end [ci skip]
anvmn Sep 10, 2024
7e1e764
View logic on front-end [ci skip]
anvmn Sep 10, 2024
62abe64
A fix [ci skip]
anvmn Sep 10, 2024
36bb2a4
Another fix [ci skip]
anvmn Sep 10, 2024
e619f39
Fixes [ci skip]
anvmn Sep 10, 2024
d9f3abd
Fixes [ci skip]
anvmn Sep 10, 2024
9c550e2
Style [ci skip]
anvmn Sep 10, 2024
c4d2576
Fixes and docs
anvmn Sep 11, 2024
a5f6f70
Merge pull request #1296 from TIP-Global-Health/issue-1295
anvmn Sep 11, 2024
80b6b20
Data fields to encounters CT + scripts infra [ci skip]
anvmn Sep 11, 2024
179fe2f
Add back-end logic [ci skip]
anvmn Sep 11, 2024
cf78c3d
Pull data for large data sets [ci skip]
anvmn Sep 11, 2024
3101820
Merge pull request #1300 from TIP-Global-Health/issue-1299
anvmn Sep 11, 2024
1da1c80
Expand Model, decode and store data on client [ci skip]
anvmn Sep 11, 2024
fb47062
View logic [ci skip]
anvmn Sep 11, 2024
7966f26
Style [ci skip]
anvmn Sep 11, 2024
e104589
Satisfy coder
anvmn Sep 11, 2024
f0d714c
Merge pull request #1304 from TIP-Global-Health/issues-1301/2
anvmn Sep 13, 2024
1f9b9aa
Merge branch 'develop' into feature-completion-reports
anvmn Sep 15, 2024
661b9d1
Add completion data field to prenatal encounter CT [ci skip]
anvmn Sep 15, 2024
9c0a22a
Add script + infra [ci skip]
anvmn Sep 15, 2024
637624c
Pull data when recalculating large data sets [ci skip]
anvmn Sep 15, 2024
2a4f3fb
More infra [ci skip]
anvmn Sep 15, 2024
cfb4e2f
More infra [ci skip]
anvmn Sep 15, 2024
9157a8f
Complete assembling data [ci skip]
anvmn Sep 16, 2024
b290756
Activities logic WIP [ci skip]
anvmn Sep 16, 2024
7354e52
WIP [ci skip]
anvmn Sep 16, 2024
7fadb5f
Prenatal Photo activity logic [ci skip]
anvmn Sep 17, 2024
2cffbdf
Merge branch 'develop' into feature-completion-reports
anvmn Sep 18, 2024
c00e591
Merge branch 'feature-completion-reports' into issue-1312
anvmn Sep 18, 2024
ad86e63
Postpartum activiites logic [ci skip]
anvmn Sep 18, 2024
2a64029
Merge branch 'develop' into feature-completion-reports
anvmn Sep 23, 2024
9b77140
Merge branch 'develop' into issue-1312
anvmn Sep 23, 2024
f682edb
Merge branch 'develop' into feature-completion-reports
anvmn Oct 6, 2024
d12e767
Merge branch 'feature-completion-reports' into issue-1312
anvmn Oct 6, 2024
167a84d
Add Labs tests logic [ci skip]
anvmn Oct 7, 2024
f0d95e2
Add Birth plan logic [ci skip]
anvmn Oct 8, 2024
e41f947
Add logic for CHW Health Education [ci skip]
anvmn Oct 8, 2024
16e9540
Next steps logic WIP [ci skip]
anvmn Oct 8, 2024
368ad6b
Drop unneeded code [ci skip]
anvmn Oct 9, 2024
313413a
Merge branch 'develop' into feature-completion-reports
anvmn Oct 20, 2024
cc1dacf
Merge branch 'feature-completion-reports' into issue-1312
anvmn Oct 21, 2024
5f70174
Calcualte data fro Global scope last, to avoid script failure [ci skip]
anvmn Oct 29, 2024
b3f83cc
Merge branch 'feature-completion-reports' into issue-1312
anvmn Oct 29, 2024
8c9e990
Nurse Next Steps WIP [ci skip]
anvmn Oct 29, 2024
912a14a
Referral activity logic WIP [ci skip]
anvmn Oct 30, 2024
0a27628
Complete Referral activity logic [ci skip]
anvmn Oct 30, 2024
4e01819
WIP: Health education activity [ci skip]
anvmn Oct 30, 2024
f99a08e
Complete Health education activity logic [ci skip]
anvmn Oct 31, 2024
84ced24
WIP: Medication distribution activity logic [ci skip]
anvmn Oct 31, 2024
72eaf74
WIP [ci skip]
anvmn Nov 3, 2024
2b356e4
Complete Medication distribution activity logic [ci skip]
anvmn Nov 3, 2024
2b21422
Update for 'Send to HC' activity on recurrent phase [ci skip]
anvmn Nov 3, 2024
e186680
Vitals recheck activity logic [ci skip]
anvmn Nov 4, 2024
d5c136f
Labs test results activities [ci skip]
anvmn Nov 4, 2024
e9dffe1
Logic to determine if virtual activities are completed [ci skip]
anvmn Nov 5, 2024
d84dd00
View logic [ci skip]
anvmn Nov 5, 2024
82b0462
Fixes [ci skip]
anvmn Nov 5, 2024
a5d714a
Merge branch 'issue-1312' of github.com:TIP-Global-Health/eheza-app i…
anvmn Nov 5, 2024
eb1683c
Another fix [ci skip]
anvmn Nov 5, 2024
55449ab
Style [ci skip]
anvmn Nov 6, 2024
a191619
Drop unneeded code [ci skip]
anvmn Nov 6, 2024
6f8ec7b
Fix Obstetric History [ci skip]
anvmn Nov 6, 2024
b0453c1
Fix Syphilis Test Result [ci skip]
anvmn Nov 6, 2024
90aabf2
More fixes [ci skip]
anvmn Nov 7, 2024
2559937
Yet more fixes [ci skip]
anvmn Nov 7, 2024
858c310
Fixes for Next steps activities [ci skip]
anvmn Nov 7, 2024
8ff3bda
Docs WIP [ci skip]
anvmn Nov 7, 2024
cc30df1
More docs [ci skip]
anvmn Nov 7, 2024
ac1c11c
Complete comments
anvmn Nov 7, 2024
4e902f4
Referral fixes [ci skip]
anvmn Nov 8, 2024
d12f352
More medication distribution fixes
anvmn Nov 12, 2024
425dcf3
Code review fix [ci skip]
anvmn Nov 13, 2024
f0110ee
Drop @todo
anvmn Nov 13, 2024
32f3d49
ECD activity logic [ci skip]
anvmn Nov 14, 2024
990e55f
Allow ECD activity on front-end [ci skip]
anvmn Nov 14, 2024
c8ba2db
A fix [ci skip]
anvmn Nov 14, 2024
c89c907
Docs
anvmn Nov 15, 2024
3d7d36a
Merge branch 'develop' into feature-completion-reports
anvmn Nov 19, 2024
9c10e84
Merge branch 'feature-completion-reports' into issue-1312
anvmn Nov 19, 2024
b0ac514
Address code review
anvmn Nov 19, 2024
0c7812e
Merge pull request #1313 from TIP-Global-Health/issue-1312
anvmn Nov 19, 2024
6f3a470
Merge pull request #1372 from TIP-Global-Health/issue-1371
anvmn Nov 19, 2024
3e6c0d7
Merge branch 'develop' into feature-completion-reports
anvmn Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions server/elm/src/App/Fetch.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module App.Fetch exposing (fetch)

import App.Model exposing (..)
import App.Types exposing (Page(..))
import Pages.Completion.Fetch
import Pages.Reports.Fetch
import Pages.Scoreboard.Fetch

Expand Down Expand Up @@ -39,5 +40,12 @@ fetch model =
Pages.Reports.Fetch.fetch model.backend model.reportsPage
|> List.map (\subMsg -> MsgBackend subMsg)

CompletionMenu ->
[]

Completion ->
Pages.Completion.Fetch.fetch model.backend model.completionPage
|> List.map (\subMsg -> MsgBackend subMsg)

NotFound ->
[]
8 changes: 8 additions & 0 deletions server/elm/src/App/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import App.Types exposing (Language(..), Page(..))
import Backend.Model
import Error.Model exposing (Error)
import Json.Decode exposing (Value)
import Pages.Completion.Model
import Pages.CompletionMenu.Model
import Pages.Reports.Model
import Pages.ReportsMenu.Model
import Pages.Scoreboard.Model
Expand All @@ -31,6 +33,8 @@ type Msg
| MsgScoreboardPage Pages.Scoreboard.Model.Msg
| MsgReportsMenuPage Pages.ReportsMenu.Model.Msg
| MsgReportsPage Pages.Reports.Model.Msg
| MsgCompletionMenuPage Pages.CompletionMenu.Model.Msg
| MsgCompletionPage Pages.Completion.Model.Msg
| SetCurrentTime Time.Posix


Expand All @@ -53,6 +57,8 @@ type alias Model =
, scoreboardPage : Pages.Scoreboard.Model.Model
, reportsMenuPage : Pages.ReportsMenu.Model.Model
, reportsPage : Pages.Reports.Model.Model
, completionMenuPage : Pages.CompletionMenu.Model.Model
, completionPage : Pages.Completion.Model.Model
}


Expand All @@ -68,4 +74,6 @@ emptyModel =
, scoreboardPage = Pages.Scoreboard.Model.emptyModel
, reportsMenuPage = Pages.ReportsMenu.Model.emptyModel
, reportsPage = Pages.Reports.Model.emptyModel
, completionMenuPage = Pages.CompletionMenu.Model.emptyModel
, completionPage = Pages.Completion.Model.emptyModel
}
6 changes: 4 additions & 2 deletions server/elm/src/App/Types.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ module App.Types exposing


type Page
= ScoreboardMenu
| Scoreboard
= CompletionMenu
| Completion
| ReportsMenu
| Reports
| ScoreboardMenu
| Scoreboard
| NotFound


Expand Down
52 changes: 52 additions & 0 deletions server/elm/src/App/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import App.Fetch exposing (fetch)
import App.Model exposing (..)
import App.Types exposing (Page(..))
import App.Utils exposing (updateSubModel)
import Backend.Completion.Model
import Backend.CompletionMenu.Model
import Backend.Model
import Backend.Reports.Model
import Backend.ReportsMenu.Model
import Backend.Scoreboard.Model
import Backend.ScoreboardMenu.Model
import Backend.Update
import Gizra.NominalDate exposing (fromLocalDateTime)
import Pages.Completion.Update
import Pages.CompletionMenu.Update
import Pages.Reports.Update
import Pages.ReportsMenu.Update
import Pages.Scoreboard.Update
Expand Down Expand Up @@ -70,6 +74,24 @@ init flags =
model
|> Tuple.first

CompletionMenu ->
update
(Backend.CompletionMenu.Model.SetData flags.appData
|> Backend.Model.MsgCompletionMenu
|> MsgBackend
)
model
|> Tuple.first

Completion ->
update
(Backend.Completion.Model.SetData flags.appData
|> Backend.Model.MsgCompletion
|> MsgBackend
)
model
|> Tuple.first

NotFound ->
model

Expand Down Expand Up @@ -100,6 +122,12 @@ resolveActivePage page =
"reports-results" ->
Reports

"completion-menu" ->
CompletionMenu

"completion-results" ->
Completion

_ ->
NotFound

Expand Down Expand Up @@ -162,6 +190,30 @@ update msg model =
(\subCmds -> MsgReportsPage subCmds)
model

MsgCompletionMenuPage subMsg ->
updateSubModel
subMsg
model.completionMenuPage
(\subMsg_ subModel -> Pages.CompletionMenu.Update.update subMsg_ subModel)
(\subModel model_ -> { model_ | completionMenuPage = subModel })
(\subCmds -> MsgCompletionMenuPage subCmds)
model

MsgCompletionPage subMsg ->
updateSubModel
subMsg
model.completionPage
(\subMsg_ subModel ->
Pages.Completion.Update.update
(fromLocalDateTime model.currentTime)
model.backend
subMsg_
subModel
)
(\subModel model_ -> { model_ | completionPage = subModel })
(\subCmds -> MsgCompletionPage subCmds)
model

SetCurrentTime date ->
( { model | currentTime = date }
, Cmd.none
Expand Down
25 changes: 25 additions & 0 deletions server/elm/src/App/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import App.Types exposing (Page(..))
import Error.View
import Gizra.NominalDate exposing (fromLocalDateTime)
import Html exposing (..)
import Pages.Completion.View
import Pages.CompletionMenu.View
import Pages.Reports.View
import Pages.ReportsMenu.View
import Pages.Scoreboard.View
Expand Down Expand Up @@ -58,6 +60,29 @@ view model =
model.reportsPage
]

CompletionMenu ->
div []
[ Error.View.view model.language model.errors
, Html.map MsgCompletionMenuPage <|
Pages.CompletionMenu.View.view
model.language
model.themePath
model.backend
model.completionMenuPage
]

Completion ->
div []
[ Error.View.view model.language model.errors
, Html.map MsgCompletionPage <|
Pages.Completion.View.view
model.language
(fromLocalDateTime model.currentTime)
model.themePath
model.backend
model.completionPage
]

NotFound ->
div []
[ text "Wrong page?" ]
70 changes: 70 additions & 0 deletions server/elm/src/Backend/Completion/Decoder.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module Backend.Completion.Decoder exposing (decodeCompletionData)

import AssocList as Dict
import Backend.Completion.Model exposing (..)
import Backend.Completion.Utils exposing (..)
import Backend.Decoder exposing (decodeSite, decodeWithFallback)
import Date
import EverySet exposing (EverySet)
import Gizra.Json exposing (decodeFloat, decodeInt)
import Gizra.NominalDate exposing (NominalDate, decodeYYYYMMDD, diffMonths)
import Json.Decode exposing (Decoder, andThen, bool, fail, list, map, maybe, nullable, oneOf, string, succeed)
import Json.Decode.Pipeline exposing (optional, optionalAt, required)
import Maybe.Extra exposing (isNothing)


decodeCompletionData : Decoder CompletionData
decodeCompletionData =
succeed CompletionData
|> required "site" decodeSite
|> required "entity_name" string
|> required "entity_type" decodeSelectedEntity
|> required "results" (list (decodeEncounterData decodeNutritionActivities))


decodeSelectedEntity : Decoder SelectedEntity
decodeSelectedEntity =
string
|> andThen
(\entityType ->
case entityType of
"global" ->
succeed EntityGlobal

"health-center" ->
succeed EntityHealthCenter

_ ->
fail <| entityType ++ " is unknown SelectedEntity type"
)


decodeEncounterData : Decoder (List activity) -> Decoder (EncounterData activity)
decodeEncounterData activitiesDecoder =
succeed EncounterData
|> required "start_date" decodeYYYYMMDD
|> required "expected" activitiesDecoder
|> required "completed" activitiesDecoder
|> required "taken_by" (nullable (decodeWithFallback TakenByUnknown decodeTakenBy))


decodeNutritionActivities : Decoder (List NutritionActivity)
decodeNutritionActivities =
string
|> andThen
(String.split ","
>> List.map nutritionActivityFromMapping
>> Maybe.Extra.values
>> succeed
)


decodeTakenBy : Decoder TakenBy
decodeTakenBy =
string
|> andThen
(\takenBy ->
takenByFromString takenBy
|> Maybe.map succeed
|> Maybe.withDefault (fail <| takenBy ++ " is unknown TakenBy type")
)
51 changes: 51 additions & 0 deletions server/elm/src/Backend/Completion/Model.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module Backend.Completion.Model exposing (..)

import App.Types exposing (Site)
import AssocList as Dict exposing (Dict)
import EverySet exposing (EverySet)
import Gizra.NominalDate exposing (NominalDate)
import Json.Encode exposing (Value)


type alias CompletionData =
{ site : Site
, entityName : String
, entityType : SelectedEntity
, nutritionIndividualData : List (EncounterData NutritionActivity)
}


type SelectedEntity
= EntityGlobal
| EntityHealthCenter


type alias EncounterData activity =
{ startDate : NominalDate
, expectedActivities : List activity
, completedActivities : List activity
, takenBy : Maybe TakenBy
}


type NutritionActivity
= NutritionHeight
| NutritionNutrition
| NutritionPhoto
| NutritionWeight
| NutritionMUAC
| NutritionContributingFactors
| NutritionFollowUp
| NutritionHealthEducation
| NutritionSendToHC
| NutritionNCDA


type TakenBy
= TakenByNurse
| TakenByCHW
| TakenByUnknown


type Msg
= SetData Value
24 changes: 24 additions & 0 deletions server/elm/src/Backend/Completion/Update.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Backend.Completion.Update exposing (update)

import Backend.Completion.Decoder exposing (decodeCompletionData)
import Backend.Completion.Model exposing (Msg(..))
import Backend.Model exposing (ModelBackend)
import Backend.Types exposing (BackendReturn)
import Error.Utils exposing (noError)
import Gizra.NominalDate exposing (NominalDate)
import Json.Decode exposing (decodeValue)


update : NominalDate -> Msg -> ModelBackend -> BackendReturn Msg
update currentDate msg model =
case msg of
SetData value ->
let
modelUpdated =
{ model | completionData = Just <| decodeValue decodeCompletionData value }
in
BackendReturn
modelUpdated
Cmd.none
noError
[]
Loading