-
Notifications
You must be signed in to change notification settings - Fork 16
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
6266 todays encounter report #6375
Open
lache-melvin
wants to merge
12
commits into
develop
Choose a base branch
from
6266-encounter-report
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d69cb28
add initial encounter report
lache-melvin 596ddb0
display in UI
lache-melvin c268bd2
add translation keys
lache-melvin 4683254
add next of kin loader to patient node
lache-melvin a22cbe6
add next of kin to report
lache-melvin fd63ee7
render program options in input modal
lache-melvin 7832e0a
accept start-end dates
lache-melvin 6f24629
fix datetime renderer
lache-melvin 20430b4
fix translations
lache-melvin 694836e
change to report-manifest
lache-melvin e7d7482
Merge branch 'develop' into 6266-encounter-report
lache-melvin f6cf644
keep old program search, add patient one
lache-melvin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
38 changes: 38 additions & 0 deletions
38
client/packages/programs/src/Components/PatientProgramSearchInput.tsx
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,38 @@ | ||
import React, { useEffect } from 'react'; | ||
import { Autocomplete } from '@openmsupply-client/common'; | ||
import { DocumentRegistryFragment } from '../api/operations.generated'; | ||
import { useDocumentRegistry } from '../api'; | ||
|
||
type PatientProgramSearchInputProps = { | ||
value: DocumentRegistryFragment | null; | ||
onChange: (newProgram: DocumentRegistryFragment) => void; | ||
}; | ||
|
||
export const PatientProgramSearchInput = ({ | ||
value, | ||
onChange, | ||
}: PatientProgramSearchInputProps) => { | ||
const { data, isLoading } = useDocumentRegistry.get.programRegistries(); | ||
|
||
// If there is only one value, set it automatically | ||
useEffect(() => { | ||
if (data?.nodes.length == 1 && !value) { | ||
onChange(data.nodes[0]!); // if length is 1, the first element must exist | ||
} | ||
}, [data?.nodes.length]); | ||
|
||
return ( | ||
<Autocomplete | ||
fullWidth | ||
loading={isLoading} | ||
options={data?.nodes ?? []} | ||
optionKey="name" | ||
onChange={(_, newVal) => | ||
newVal && newVal.id !== value?.id && onChange(newVal) | ||
} | ||
value={value ? { label: value.name ?? '', ...value } : null} | ||
isOptionEqualToValue={(option, value) => option.id === value.id} | ||
clearable={false} | ||
/> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './DocumentHistory'; | ||
export * from './ProgramSearchModal'; | ||
export * from './ProgramSearchInput'; | ||
export * from './PatientProgramSearchInput'; |
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
48 changes: 48 additions & 0 deletions
48
client/packages/programs/src/JsonForms/components/ProgramSearch.tsx
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,48 @@ | ||
import React from 'react'; | ||
import { rankWith, ControlProps, uiTypeIs } from '@jsonforms/core'; | ||
import { withJsonFormsControlProps } from '@jsonforms/react'; | ||
import { Box, DetailInputWithLabelRow } from '@openmsupply-client/common'; | ||
import { DefaultFormRowSx, FORM_GAP, FORM_LABEL_WIDTH } from '../common'; | ||
import { PatientProgramSearchInput } from '../../Components'; | ||
import { DocumentRegistryFragment } from '../../api'; | ||
|
||
export const programSearchTester = rankWith(10, uiTypeIs('ProgramSearch')); | ||
|
||
const UIComponent = (props: ControlProps) => { | ||
const { handleChange, label, path } = props; | ||
|
||
const [program, setProgram] = React.useState<DocumentRegistryFragment | null>( | ||
null | ||
); | ||
|
||
const onChangeProgram = async (program: DocumentRegistryFragment) => { | ||
setProgram(program); | ||
handleChange(path, program.contextId); | ||
}; | ||
|
||
return ( | ||
<DetailInputWithLabelRow | ||
sx={DefaultFormRowSx} | ||
label={label} | ||
labelWidthPercentage={FORM_LABEL_WIDTH} | ||
inputAlignment={'start'} | ||
Input={ | ||
<Box display="flex" alignItems="center" gap={FORM_GAP} width="100%"> | ||
<PatientProgramSearchInput | ||
onChange={onChangeProgram} | ||
value={program} | ||
/> | ||
</Box> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
const UIComponentWrapper = (props: ControlProps) => { | ||
if (!props.visible) { | ||
return null; | ||
} | ||
return <UIComponent {...props} />; | ||
}; | ||
|
||
export const ProgramSearch = withJsonFormsControlProps(UIComponentWrapper); |
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
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
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
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 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,7 +2,7 @@ use async_graphql::dataloader::DataLoader; | |||||||||||||||||||
use async_graphql::*; | ||||||||||||||||||||
use chrono::{DateTime, Local, NaiveDate, Utc}; | ||||||||||||||||||||
use graphql_core::generic_filters::{DateFilterInput, EqualFilterStringInput, StringFilterInput}; | ||||||||||||||||||||
use graphql_core::loader::DocumentLoader; | ||||||||||||||||||||
use graphql_core::loader::{DocumentLoader, PatientLoader}; | ||||||||||||||||||||
use graphql_core::{map_filter, ContextExt}; | ||||||||||||||||||||
|
||||||||||||||||||||
use graphql_core::pagination::PaginationInput; | ||||||||||||||||||||
|
@@ -217,6 +217,25 @@ impl PatientNode { | |||||||||||||||||||
}) | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
pub async fn next_of_kin(&self, ctx: &Context<'_>) -> Result<Option<PatientNode>> { | ||||||||||||||||||||
let loader = ctx.get_loader::<DataLoader<PatientLoader>>(); | ||||||||||||||||||||
|
||||||||||||||||||||
if let Some(next_of_kin_id) = &self.patient.next_of_kin_id { | ||||||||||||||||||||
let result = loader | ||||||||||||||||||||
Comment on lines
+220
to
+224
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably copy pasta things but nit:
Suggested change
Don't need to initialise the loader for the other branch? |
||||||||||||||||||||
.load_one(next_of_kin_id.to_owned()) | ||||||||||||||||||||
.await? | ||||||||||||||||||||
.map(|patient| PatientNode { | ||||||||||||||||||||
patient, | ||||||||||||||||||||
allowed_ctx: self.allowed_ctx.clone(), | ||||||||||||||||||||
store_id: self.store_id.clone(), | ||||||||||||||||||||
}); | ||||||||||||||||||||
|
||||||||||||||||||||
return Ok(result); | ||||||||||||||||||||
} else { | ||||||||||||||||||||
return Ok(None); | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
pub async fn document(&self, ctx: &Context<'_>) -> Result<Option<DocumentNode>> { | ||||||||||||||||||||
let loader = ctx.get_loader::<DataLoader<DocumentLoader>>(); | ||||||||||||||||||||
|
||||||||||||||||||||
|
30 changes: 30 additions & 0 deletions
30
server/reports/encounters/2_6_0/argument_schemas/arguments.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,30 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"definitions": { | ||
"Filters": { | ||
"properties": { | ||
"programId": { | ||
"description": "Program ID", | ||
"type": "string" | ||
}, | ||
"after": { | ||
"description": "From date", | ||
"format": "date-time", | ||
"type": "string" | ||
}, | ||
"before": { | ||
"description": "To date", | ||
"format": "date-time", | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["programId"] | ||
} | ||
}, | ||
"type": "object", | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/Filters" | ||
} | ||
] | ||
} |
26 changes: 26 additions & 0 deletions
26
server/reports/encounters/2_6_0/argument_schemas/arguments_ui.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,26 @@ | ||
{ | ||
"type": "VerticalLayout", | ||
"elements": [ | ||
{ | ||
"type": "ProgramSearch", | ||
"scope": "#/properties/programId", | ||
"label": "T#label.program" | ||
}, | ||
{ | ||
"type": "Control", | ||
"scope": "#/properties/after", | ||
"label": "T#label.from-date", | ||
"options": { | ||
"dateOnly": true | ||
} | ||
}, | ||
{ | ||
"type": "Control", | ||
"scope": "#/properties/before", | ||
"label": "T#label.to-date", | ||
"options": { | ||
"dateOnly": true | ||
} | ||
} | ||
] | ||
} |
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,15 @@ | ||
{ | ||
"is_custom": false, | ||
"version": "2.6.0", | ||
"code": "encounters", | ||
"context": "DISPENSARY", | ||
"sub_context": "Encounters", | ||
"name": "Pending Encounters", | ||
"queries": { | ||
"gql": "encountersQuery.graphql" | ||
}, | ||
"arguments": { | ||
"schema": "argument_schemas/arguments.json", | ||
"ui": "argument_schemas/arguments_ui.json" | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo another day ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to not show if vaccines aren't on at all... I kinda don't have my head around this part of OMS product though, OG had encounters before vaccines were ever in which, though rarely used, would mean showing encounter context reports regardless of vaccines being used.