Skip to content

Read only mode use case in catalog app. #2803

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
317 changes: 317 additions & 0 deletions catalog/src/main/assets/layout_default_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
{
"resourceType": "QuestionnaireResponse",
"extension": [
{
"url": "http://github.com/google-android/questionnaire-lastLaunched-timestamp",
"valueDateTime": "2025-03-12T11:09:41+05:30"
}
],
"authored": "2025-03-12T11:16:54+05:30",
"item": [
{
"linkId": "1",
"text": "Personal information"
},
{
"linkId": "2",
"answer": [
{
"valueString": "Jennifer",
"item": [
{
"linkId": "2.1",
"text": "First Name"
}
]
}
]
},
{
"linkId": "3",
"answer": [
{
"valueString": "Symond",
"item": [
{
"linkId": "3.1",
"text": "Family Name"
}
]
}
]
},
{
"linkId": "4",
"answer": [
{
"valueInteger": 1234567890,
"item": [
{
"linkId": "4.1",
"text": "ID number"
}
]
}
]
},
{
"linkId": "5",
"answer": [
{
"valueInteger": 1234567890,
"item": [
{
"linkId": "5.1",
"text": "Mobile number"
}
]
}
]
},
{
"linkId": "6",
"answer": [
{
"valueCoding": {
"code": "code",
"display": "Receive SMS reminders"
}
}
]
},
{
"linkId": "7",
"text": "Date of birth",
"answer": [
{
"valueDate": "2025-03-12",
"item": [
{
"linkId": "7.1",
"text": "If the real DOB is unknown, provide an estimated year."
}
]
}
]
},
{
"linkId": "8"
},
{
"linkId": "9",
"text": "Address"
},
{
"linkId": "10",
"answer": [
{
"valueString": "141, Jason street",
"item": [
{
"linkId": "10.1",
"text": "House number and street"
}
]
}
]
},
{
"linkId": "11",
"answer": [
{
"valueString": "A-141",
"item": [
{
"linkId": "11.1",
"text": "Apartment, unit"
}
]
}
]
},
{
"linkId": "12",
"answer": [
{
"valueString": "Sydney, vile Parle ",
"item": [
{
"linkId": "12.1",
"text": "City, town or village"
}
]
}
]
},
{
"linkId": "13",
"answer": [
{
"valueString": "Australia ",
"item": [
{
"linkId": "13.1",
"text": "County"
}
]
}
]
},
{
"linkId": "14",
"answer": [
{
"valueString": "412033",
"item": [
{
"linkId": "14.1",
"text": "Postal Code"
}
]
}
]
},
{
"linkId": "15",
"text": "Alternative contact person"
},
{
"linkId": "16",
"answer": [
{
"valueString": "Pamela",
"item": [
{
"linkId": "16.1",
"text": "Name"
}
]
}
]
},
{
"linkId": "17",
"answer": [
{
"valueCoding": {
"code": "mother",
"display": "Mother"
},
"item": [
{
"linkId": "17.1",
"text": "Relationship"
}
]
}
]
},
{
"linkId": "18",
"answer": [
{
"valueString": "1234567890",
"item": [
{
"linkId": "18.1",
"text": "Phone number"
}
]
}
]
},
{
"linkId": "19",
"text": "What is the highest level of education achieved?",
"answer": [
{
"valueCoding": {
"code": "higher-education",
"display": "Higher education"
},
"item": [
{
"linkId": "19.1",
"text": "Select one"
}
]
}
]
},
{
"linkId": "20",
"text": "Who does the client live with?",
"answer": [
{
"valueCoding": {
"code": "Parents",
"display": "Parents"
},
"item": [
{
"linkId": "20.1",
"text": "Check all that apply"
}
]
}
]
},
{
"linkId": "21",
"text": "Has the client received this year’s seasonal flu vaccine?",
"answer": [
{
"valueCoding": {
"code": "yes",
"display": "Yes"
},
"item": [
{
"linkId": "21.1",
"text": "Select one"
}
]
}
]
},
{
"linkId": "22",
"text": "When was their last menstrual period? (LMP)",
"answer": [
{
"valueDate": "2025-03-12",
"item": [
{
"linkId": "22.1",
"text": "First day of the most recent period"
}
]
}
]
},
{
"linkId": "23",
"text": "How many times have they been pregnant?",
"answer": [
{
"valueInteger": 1,
"item": [
{
"linkId": "23.1",
"text": "Including this pregnancy. Also referred to as gravida."
}
]
}
]
},
{
"linkId": "24",
"text": "What was the date and time of the ultrasound?",
"answer": [
{
"valueDateTime": "2025-03-12T11:14:00+05:30"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 Google LLC
* Copyright 2023-2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -146,6 +146,14 @@ class DemoQuestionnaireFragment : Fragment() {
.LOCATION_WIDGET_PROVIDER,
)
setQuestionnaire(args.questionnaireJsonStringKey!!)
when (args.layoutMode) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you please explore using a lambda to encapsulate these configurations? i think we might have more complex setups for different modes in the future and it's not ideal to have to change the demo questionnaire fragment class each time.

LayoutMode.DEFAULT -> {}
LayoutMode.REVIEW -> {}
LayoutMode.READ_ONLY -> {
setQuestionnaireResponse(args.questionnaireResponseJsonString!!)
setIsReadOnly(true)
}
}
}
.build()
add(R.id.container, questionnaireFragment, QUESTIONNAIRE_FRAGMENT_TAG)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 Google LLC
* Copyright 2022-2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -81,6 +81,13 @@ class LayoutListFragment : Fragment(R.layout.layout_list_fragment) {
backgroundContext = coroutineContext,
fileName = layout.questionnaireFileName,
),
questionnaireResponseJsonString =
getQuestionnaireJsonStringFromAssets(
context = requireContext(),
backgroundContext = coroutineContext,
fileName = layout.questionnaireResponseFileName,
),
layoutMode = layout.layoutMode,
),
)
}
Expand Down
Loading
Loading