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

Workflow api upgrade #2744

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

aditya-07
Copy link
Collaborator

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #2736

Description

  1. Added a new factory to get all activity flows for a Patient.
  2. Opened Request's Intent for app devs to access it.
  3. Added a new api to get previous phases of an ActivityFlow.
  4. Refactored demo app to use above api.

Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?

Type
Choose one: (Bug fix | Feature | Documentation | Testing | Code health | Builds | Releases | Other)

Screenshots (if applicable)

Checklist

  • I have read and acknowledged the Code of conduct.
  • I have read the Contributing page.
  • I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

@aditya-07 aditya-07 requested a review from a team as a code owner November 28, 2024 07:48
@aditya-07 aditya-07 requested a review from MJ1998 November 28, 2024 07:48
Copy link
Collaborator

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Aditya!

add some test.

}

/** Provides a read-only view of a request phase. */
class ReadOnlyRequestPhase<R : CPGRequestResource<*>>(private val cpgRequestResource: R) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should phase implement read only phrase?

Comment on lines +92 to +104
fun getPhase() =
when (cpgRequestResource.getIntent()) {
Intent.PROPOSAL -> Phase.PhaseName.PROPOSAL
Intent.PLAN -> Phase.PhaseName.PLAN
Intent.ORDER -> Phase.PhaseName.ORDER
else ->
throw IllegalArgumentException(
"Resource intent can't be ${cpgRequestResource.getIntent().code} ",
)
}

/** Returns the underlying [CPGRequestResource] of this phase. */
fun getRequestResource() = cpgRequestResource
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these just be in the base phase class?

* Returns an iterator to go over the previous states of the activity flow. The iterator provides
* a read-only view to the phase.
*/
fun getPreviousPhase(): PreviousPhaseIterator<R> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it's better or worse to just return a list?

i can see different arguments, it's only 3 phases at most, but maybe developers typically would want to display the previous phases together (maybe?) and if this is an interator, they actually have to repeated call till all phases are loaded anyway? so I'm not sure if this is better...

but on the other hand, if they only wan to check a immediately preceding phase, this would be good... i don't really know how often that would be

val eventTypes =
listOf(
MedicationDispense::class.java,
Communication::class.java,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment here to say we need to add new resource types to this list

CommunicationRequest::class.java,
)

val cache: MutableMap<String, CPGRequestResource<*>> =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename this variable.

* Represents the chain of event/requests of an activity flow. A [RequestChain] would either have a
* [request] or an [event].
*/
internal data class RequestChain(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

}
}

fun of(request: Resource): CPGEventResource<*> {
return when (request) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return when (request) {
return when (event) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Additional changes in Activity Flow api
2 participants