diff --git a/example/build.gradle b/example/build.gradle
index c96110fbfe..f2e9f4ad73 100644
--- a/example/build.gradle
+++ b/example/build.gradle
@@ -44,6 +44,8 @@ ext {
okhttpLoggingInterceptorVersion = '4.0.0'
lifecycleVersion = '2.2.0'
retrofitVersion = '2.7.2'
+ recyclerviewVersion = '1.1.0'
+ legacySupportVersion = '1.0.0'
}
dependencies {
@@ -67,6 +69,8 @@ dependencies {
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.retrofit2:retrofit-mock:$retrofitVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttpLoggingInterceptorVersion"
+ implementation "androidx.recyclerview:recyclerview:$recyclerviewVersion"
+ implementation "androidx.legacy:legacy-support-v4:$legacySupportVersion"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml
index b965c5f81a..e5cf219a4b 100644
--- a/example/src/main/AndroidManifest.xml
+++ b/example/src/main/AndroidManifest.xml
@@ -16,22 +16,37 @@
-->
-
+ package="com.google.fhirengine.example">
+
+
+
-
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:roundIcon="@mipmap/ic_launcher_round"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme">
+
+
+
+
+
\ No newline at end of file
diff --git a/example/src/main/assets/sample_patients_bundle.json b/example/src/main/assets/sample_patients_bundle.json
new file mode 100644
index 0000000000..9b8cac6f3b
--- /dev/null
+++ b/example/src/main/assets/sample_patients_bundle.json
@@ -0,0 +1,1023 @@
+{
+ "resourceType": "Bundle",
+ "id": "252c80d7-be4a-4231-9a04-883f7c82e380",
+ "meta": {
+ "lastUpdated": "2020-06-28T23:09:03.154+00:00"
+ },
+ "type": "searchset",
+ "link": [ {
+ "relation": "self",
+ "url": "http://hapi.fhir.org/baseR4/Patient?_pretty=true"
+ }, {
+ "relation": "next",
+ "url": "http://hapi.fhir.org/baseR4?_getpages=252c80d7-be4a-4231-9a04-883f7c82e380&_getpagesoffset=20&_count=20&_pretty=true&_bundletype=searchset"
+ } ],
+ "entry": [ {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/8eb8f884-cf96-47e9-b398-3cae896263c4",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "8eb8f884-cf96-47e9-b398-3cae896263c4",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-03-24T23:24:21.152+00:00",
+ "source": "#uyMut4VgPPx76nLf",
+ "profile": [ "http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient" ],
+ "tag": [ {
+ "system": "https://smarthealthit.org/tags",
+ "code": "Covid19 synthetic population from Synthea"
+ } ]
+ },
+ "text": {
+ "status": "generated",
+ "div": "
Generated by
Synthea.Version identifier: 7ff8db58\n . Person seed: -4830224382983951683 Population seed: 12345
"
+ },
+ "extension": [ {
+ "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
+ "extension": [ {
+ "url": "detailed",
+ "valueCoding": {
+ "system": "urn:oid:2.16.840.1.113883.6.238",
+ "code": "2131-1",
+ "display": "Other Races"
+ }
+ }, {
+ "url": "text",
+ "valueString": "Other"
+ } ]
+ }, {
+ "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
+ "extension": [ {
+ "url": "ombCategory",
+ "valueCoding": {
+ "system": "urn:oid:2.16.840.1.113883.6.238",
+ "code": "2135-2",
+ "display": "Hispanic or Latino"
+ }
+ }, {
+ "url": "text",
+ "valueString": "Hispanic or Latino"
+ } ]
+ }, {
+ "url": "http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName",
+ "valueString": "Shyla233 Weimann465"
+ }, {
+ "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex",
+ "valueCode": "F"
+ }, {
+ "url": "http://hl7.org/fhir/StructureDefinition/patient-birthPlace",
+ "valueAddress": {
+ "city": "Elk Grove",
+ "state": "California",
+ "country": "US"
+ }
+ }, {
+ "url": "http://synthetichealth.github.io/synthea/disability-adjusted-life-years",
+ "valueDecimal": 0.18086410619799592
+ }, {
+ "url": "http://synthetichealth.github.io/synthea/quality-adjusted-life-years",
+ "valueDecimal": 53.819135893802006
+ } ],
+ "identifier": [ {
+ "system": "https://github.com/synthetichealth/synthea",
+ "value": "6f4552d9-2290-447f-9761-b237b433110c"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "system": "http://hospital.smarthealthit.org",
+ "value": "6f4552d9-2290-447f-9761-b237b433110c"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "SS",
+ "display": "Social Security Number"
+ } ],
+ "text": "Social Security Number"
+ },
+ "system": "http://hl7.org/fhir/sid/us-ssn",
+ "value": "999-77-1206"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "DL",
+ "display": "Driver's License"
+ } ],
+ "text": "Driver's License"
+ },
+ "system": "urn:oid:2.16.840.1.113883.4.3.25",
+ "value": "S99958035"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "PPN",
+ "display": "Passport Number"
+ } ],
+ "text": "Passport Number"
+ },
+ "system": "http://standardhealthrecord.org/fhir/StructureDefinition/passportNumber",
+ "value": "X29682130X"
+ } ],
+ "name": [ {
+ "use": "official",
+ "family": "Krajcik437",
+ "given": [ "Mercedes82" ],
+ "prefix": [ "Mrs." ]
+ }, {
+ "use": "maiden",
+ "family": "Casper496",
+ "given": [ "Mercedes82" ],
+ "prefix": [ "Mrs." ]
+ } ],
+ "telecom": [ {
+ "system": "phone",
+ "value": "555-885-7330",
+ "use": "home"
+ } ],
+ "gender": "female",
+ "birthDate": "1956-09-25",
+ "deceasedDateTime": "2011-04-15T03:26:39-05:00",
+ "address": [ {
+ "extension": [ {
+ "url": "http://hl7.org/fhir/StructureDefinition/geolocation",
+ "extension": [ {
+ "url": "latitude",
+ "valueDecimal": 34.33328905678735
+ }, {
+ "url": "longitude",
+ "valueDecimal": -118.40139036957345
+ } ]
+ } ],
+ "line": [ "1058 Marvin Parade Suite 57" ],
+ "city": "Los Angeles",
+ "state": "CA",
+ "country": "US"
+ } ],
+ "maritalStatus": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus",
+ "code": "M",
+ "display": "M"
+ } ],
+ "text": "M"
+ },
+ "multipleBirthInteger": 3,
+ "communication": [ {
+ "language": {
+ "coding": [ {
+ "system": "urn:ietf:bcp:47",
+ "code": "en-US",
+ "display": "English"
+ } ],
+ "text": "English"
+ }
+ } ]
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246049",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246049",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:24.814+00:00",
+ "source": "#XXtCmyccInAX5Wja"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16029"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011346"
+ } ],
+ "name": [ {
+ "family": "Hill",
+ "given": [ "Kimberly" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246050",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246050",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:25.574+00:00",
+ "source": "#qoHSKGXqPeWN07Vy"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16030"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011347"
+ } ],
+ "name": [ {
+ "family": "Morrison",
+ "given": [ "Zoe" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246051",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246051",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:25.994+00:00",
+ "source": "#4YO59sOWtlmCwAfS"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16031"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011348"
+ } ],
+ "name": [ {
+ "family": "Manning",
+ "given": [ "Kylie" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246052",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246052",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:26.394+00:00",
+ "source": "#PCPOj9VkQEqT21iE"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16032"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011349"
+ } ],
+ "name": [ {
+ "family": "Johnston",
+ "given": [ "Vanessa" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246053",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246053",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:26.834+00:00",
+ "source": "#oYdVNgSf5RReYG07"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16033"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011350"
+ } ],
+ "name": [ {
+ "family": "Fraser",
+ "given": [ "Audrey" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246054",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246054",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:27.254+00:00",
+ "source": "#x0gIxZxZcgHHoWs7"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16034"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011351"
+ } ],
+ "name": [ {
+ "family": "Morrison",
+ "given": [ "Sophie" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246055",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246055",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:27.674+00:00",
+ "source": "#96OAtWqi1cQls6s0"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16035"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011352"
+ } ],
+ "name": [ {
+ "family": "Dowd",
+ "given": [ "Felicity" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246056",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246056",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:28.094+00:00",
+ "source": "#MgHxKQbxGeBjsC42"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16036"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011353"
+ } ],
+ "name": [ {
+ "family": "Alsop",
+ "given": [ "Nicola" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246057",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246057",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:28.514+00:00",
+ "source": "#B3d47HmlhMXDzGGg"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16037"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011354"
+ } ],
+ "name": [ {
+ "family": "Davies",
+ "given": [ "Ava" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246058",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246058",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:28.934+00:00",
+ "source": "#hspP8SVLUdCqcObc"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16038"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011355"
+ } ],
+ "name": [ {
+ "family": "Ross",
+ "given": [ "Sophie" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246059",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246059",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:29.334+00:00",
+ "source": "#1mks8kwRe2o7qD0Z"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16039"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011356"
+ } ],
+ "name": [ {
+ "family": "Gray",
+ "given": [ "Wanda" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246060",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246060",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:29.754+00:00",
+ "source": "#cu9FS9V6AxgEH4Lp"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16040"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011357"
+ } ],
+ "name": [ {
+ "family": "Chapman",
+ "given": [ "Lauren" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246061",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246061",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:30.154+00:00",
+ "source": "#JFfqhr0CxG6Zyn2Z"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16041"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011358"
+ } ],
+ "name": [ {
+ "family": "Avery",
+ "given": [ "Irene" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246062",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246062",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:30.894+00:00",
+ "source": "#v62NOzWS57JW4PVI"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16042"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011359"
+ } ],
+ "name": [ {
+ "family": "Bower",
+ "given": [ "Amelia" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246063",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246063",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:31.314+00:00",
+ "source": "#MyJwlQrdrenfYTht"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16043"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011360"
+ } ],
+ "name": [ {
+ "family": "Short",
+ "given": [ "Joanne" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246064",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246064",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:31.734+00:00",
+ "source": "#aNTUiaWrSrjYdcbx"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16044"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011361"
+ } ],
+ "name": [ {
+ "family": "Greene",
+ "given": [ "Maria" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246065",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246065",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:32.154+00:00",
+ "source": "#c2wBhwnMUjl1RzKT"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16045"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011362"
+ } ],
+ "name": [ {
+ "family": "Pullman",
+ "given": [ "Mary" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246066",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246066",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:32.594+00:00",
+ "source": "#ld54bTsIZO12jrjY"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16046"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011363"
+ } ],
+ "name": [ {
+ "family": "Anderson",
+ "given": [ "Kimberly" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ }, {
+ "fullUrl": "http://hapi.fhir.org/baseR4/Patient/1246067",
+ "resource": {
+ "resourceType": "Patient",
+ "id": "1246067",
+ "meta": {
+ "versionId": "1",
+ "lastUpdated": "2020-06-22T07:47:33.019+00:00",
+ "source": "#rRnnAyVQUncd3sZM"
+ },
+ "text": {
+ "status": "generated",
+ "div": ""
+ },
+ "identifier": [ {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "MR",
+ "display": "Medical Record Number"
+ } ],
+ "text": "Medical Record Number"
+ },
+ "value": "CT16047"
+ }, {
+ "type": {
+ "coding": [ {
+ "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
+ "code": "NIIP",
+ "display": "National Insurance Payor Identifier"
+ } ],
+ "text": "National Insurance Payor Identifier"
+ },
+ "value": "9800011364"
+ } ],
+ "name": [ {
+ "family": "Clarkson",
+ "given": [ "Bella" ]
+ } ],
+ "gender": "female"
+ },
+ "search": {
+ "mode": "match"
+ }
+ } ]
+}
\ No newline at end of file
diff --git a/example/src/main/java/com/google/fhirengine/example/PatientItemViewHolder.kt b/example/src/main/java/com/google/fhirengine/example/PatientItemViewHolder.kt
new file mode 100644
index 0000000000..7c1a8f1046
--- /dev/null
+++ b/example/src/main/java/com/google/fhirengine/example/PatientItemViewHolder.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.fhirengine.example
+
+import android.view.View
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.google.fhirengine.example.data.SamplePatients
+
+class PatientItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
+ private val idView: TextView = itemView.findViewById(
+ R.id.id_patient_number
+ )
+ private val nameView: TextView = itemView.findViewById(
+ R.id.name
+ )
+ private val genderView: TextView = itemView.findViewById(
+ R.id.gender
+ )
+ private val dobView: TextView = itemView.findViewById(
+ R.id.dob
+ )
+
+ fun bindTo(
+ patientItem: SamplePatients.PatientItem,
+ onItemClicked: (SamplePatients.PatientItem) -> Unit
+ ) {
+ this.idView.text = patientItem.id
+ this.nameView.text = patientItem.name
+ this.genderView.text = patientItem.gender
+ this.dobView.text = patientItem.dob
+
+ with(this.itemView) {
+ setOnClickListener { onItemClicked(patientItem) }
+ }
+ }
+}
diff --git a/example/src/main/java/com/google/fhirengine/example/PatientListViewModel.kt b/example/src/main/java/com/google/fhirengine/example/PatientListViewModel.kt
new file mode 100644
index 0000000000..ade59cf3a9
--- /dev/null
+++ b/example/src/main/java/com/google/fhirengine/example/PatientListViewModel.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.fhirengine.example
+
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.ViewModelProvider
+import com.google.fhirengine.example.data.SamplePatients
+
+/**
+ * The ViewModel helper class for SampleItemRecyclerViewAdapter, that is responsible for preparing
+ * data for UI.
+ */
+class PatientListViewModel(jsonString: String) : ViewModel() {
+ private val patients: MutableLiveData> =
+ MutableLiveData(SamplePatients().getPatientItems(jsonString))
+
+ fun getPatients(): LiveData> {
+ return patients
+ }
+}
+
+class PatientListViewModelFactory(
+ private val jsonString: String
+) : ViewModelProvider.Factory {
+ override fun create(modelClass: Class): T {
+ if (modelClass.isAssignableFrom(PatientListViewModel::class.java)) {
+ return PatientListViewModel(jsonString) as T
+ }
+ throw IllegalArgumentException("Unknown ViewModel class")
+ }
+}
diff --git a/example/src/main/java/com/google/fhirengine/example/SampleItemRecyclerViewAdapter.kt b/example/src/main/java/com/google/fhirengine/example/SampleItemRecyclerViewAdapter.kt
new file mode 100644
index 0000000000..43025ef2b6
--- /dev/null
+++ b/example/src/main/java/com/google/fhirengine/example/SampleItemRecyclerViewAdapter.kt
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.fhirengine.example
+
+import android.view.LayoutInflater
+import android.view.ViewGroup
+import androidx.recyclerview.widget.DiffUtil
+import androidx.recyclerview.widget.ListAdapter
+import com.google.fhirengine.example.data.SamplePatients
+
+/**
+ * UI Controller helper class to monitor Patient viewmodel and display list of patients, with
+ * possibly patient details, on a two pane device.
+ */
+class SampleItemRecyclerViewAdapter(
+ private val onItemClicked: (SamplePatients.PatientItem) -> Unit
+) : ListAdapter(PatientItemDiffCallback()) {
+
+ class PatientItemDiffCallback : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(
+ oldItem: SamplePatients.PatientItem,
+ newItem: SamplePatients.PatientItem
+ ): Boolean = oldItem.id == newItem.id
+
+ override fun areContentsTheSame(
+ oldItem: SamplePatients.PatientItem,
+ newItem: SamplePatients.PatientItem
+ ): Boolean = oldItem.id == newItem.id
+ }
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PatientItemViewHolder {
+ val view = LayoutInflater.from(parent.context)
+ .inflate(R.layout.patient_list_item, parent, false)
+ return PatientItemViewHolder(view)
+ }
+
+ override fun onBindViewHolder(holder: PatientItemViewHolder, position: Int) {
+ val item = currentList[position]
+ holder.bindTo(item, onItemClicked)
+ }
+}
diff --git a/example/src/main/java/com/google/fhirengine/example/SamplePatientDetailActivity.kt b/example/src/main/java/com/google/fhirengine/example/SamplePatientDetailActivity.kt
new file mode 100644
index 0000000000..80728e9f9b
--- /dev/null
+++ b/example/src/main/java/com/google/fhirengine/example/SamplePatientDetailActivity.kt
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.fhirengine.example
+
+import android.content.Intent
+import android.os.Bundle
+import android.view.MenuItem
+import androidx.appcompat.app.AppCompatActivity
+
+/**
+ * An activity representing a single SamplePatient detail screen. This activity is only used on
+ * narrow width devices. On tablet-size devices, item details are presented side-by-side with a list
+ * of items in a [SamplePatientListActivity].
+ */
+class SamplePatientDetailActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_samplepatient_detail)
+ setSupportActionBar(findViewById(R.id.detail_toolbar))
+
+ // Show the Up button in the action bar.
+ supportActionBar?.setDisplayHomeAsUpEnabled(true)
+
+ // savedInstanceState is non-null when there is fragment state saved from previous
+ // configurations of this activity (e.g. when rotating the screen from portrait to
+ // landscape). In this case, the fragment will automatically be re-added to its container so
+ // we don"t need to manually add it. For more information, see the Fragments API guide at:
+ //
+ // http://developer.android.com/guide/components/fragments.html
+ //
+ if (savedInstanceState == null) {
+ // Create the detail fragment and add it to the activity
+ // using a fragment transaction.
+ val fragment = SamplePatientDetailFragment().apply {
+ arguments = Bundle().apply {
+ putString(SamplePatientDetailFragment.ARG_ITEM_ID,
+ intent.getStringExtra(SamplePatientDetailFragment.ARG_ITEM_ID))
+ }
+ }
+
+ supportFragmentManager.beginTransaction()
+ .add(R.id.samplepatient_detail_container, fragment)
+ .commit()
+ }
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem) =
+ when (item.itemId) { android.R.id.home -> {
+
+ // This ID represents the Home or Up button. In the case of this activity, the
+ // Up button is shown. For more details, see the Navigation pattern on Android
+ // Design:
+ //
+ // http://developer.android.com/design/patterns/navigation.html#up-vs-back
+
+ navigateUpTo(Intent(this, SamplePatientListActivity::class.java))
+
+ true
+ }
+ else -> super.onOptionsItemSelected(item)
+ }
+}
diff --git a/example/src/main/java/com/google/fhirengine/example/SamplePatientDetailFragment.kt b/example/src/main/java/com/google/fhirengine/example/SamplePatientDetailFragment.kt
new file mode 100644
index 0000000000..ec39f630ee
--- /dev/null
+++ b/example/src/main/java/com/google/fhirengine/example/SamplePatientDetailFragment.kt
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.fhirengine.example
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.TextView
+import androidx.fragment.app.Fragment
+import com.google.android.material.appbar.CollapsingToolbarLayout
+import com.google.fhirengine.example.data.DummyDetailsContent
+
+/**
+ * A fragment representing a single SamplePatient detail screen.
+ * This fragment is either contained in a [SamplePatientDetailActivity].
+ */
+class SamplePatientDetailFragment : Fragment() {
+
+ /**
+ * The dummy content this fragment is presenting.
+ */
+ private var item: DummyDetailsContent.DummyItem? = null
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ arguments?.let {
+ if (it.containsKey(ARG_ITEM_ID)) {
+ // Load the dummy content specified by the fragment
+ // arguments. In a real-world scenario, use a Loader
+ // to load content from a content provider.
+ item = DummyDetailsContent.ITEM_MAP[it.getString(ARG_ITEM_ID)]
+ activity?.findViewById(R.id.toolbar_layout)?.title = item
+ ?.content
+ }
+ }
+ }
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ val rootView = inflater.inflate(R.layout.samplepatient_detail, container, false)
+
+ // Show the dummy content as text in a TextView.
+ item?.let {
+ rootView.findViewById(R.id.samplepatient_detail).text = it.details
+ }
+
+ return rootView
+ }
+
+ companion object {
+ /**
+ * The fragment argument representing the item ID that this fragment
+ * represents.
+ */
+ const val ARG_ITEM_ID = "item_id"
+ }
+}
diff --git a/example/src/main/java/com/google/fhirengine/example/SamplePatientListActivity.kt b/example/src/main/java/com/google/fhirengine/example/SamplePatientListActivity.kt
new file mode 100644
index 0000000000..cbee05b5db
--- /dev/null
+++ b/example/src/main/java/com/google/fhirengine/example/SamplePatientListActivity.kt
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.fhirengine.example
+
+import android.content.Intent
+import android.os.Bundle
+import androidx.appcompat.app.AppCompatActivity
+import androidx.appcompat.widget.Toolbar
+import androidx.lifecycle.Observer
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.RecyclerView
+import com.google.android.material.floatingactionbutton.FloatingActionButton
+import com.google.fhirengine.example.data.SamplePatients
+
+/**
+ * An activity representing a list of Patients.
+ */
+class SamplePatientListActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_patient_list)
+
+ val toolbar = findViewById(R.id.toolbar)
+ setSupportActionBar(toolbar)
+ toolbar.title = title
+
+ // Launch the old Fhir and CQL resources loading screen.
+ findViewById(R.id.fab).setOnClickListener {
+ val resLoadIntent = Intent(baseContext, MainActivity::class.java)
+ startActivity(resLoadIntent)
+ }
+
+ val jsonString = getJsonStrForPatientData()
+ val patientListViewModel = ViewModelProvider(this, PatientListViewModelFactory(jsonString))
+ .get(PatientListViewModel::class.java)
+ val recyclerView: RecyclerView = findViewById(R.id.samplepatient_list)
+
+ // Click handler to help display the details about the patients from the list.
+ val onPatientItemClicked: (SamplePatients.PatientItem) -> Unit = { patientItem ->
+ val intent = Intent(this.applicationContext,
+ SamplePatientDetailActivity::class.java).apply {
+ putExtra(SamplePatientDetailFragment.ARG_ITEM_ID, patientItem.id)
+ }
+ this.startActivity(intent)
+ }
+
+ val adapter = SampleItemRecyclerViewAdapter(onPatientItemClicked)
+ recyclerView.adapter = adapter
+
+ patientListViewModel.getPatients().observe(this,
+ Observer> {
+ adapter.submitList(it)
+ })
+ }
+
+ /**
+ * Helper function to read patient asset file data as string.
+ */
+ private fun getJsonStrForPatientData(): String {
+ val patientJsonFilename = "sample_patients_bundle.json"
+
+ return assets.open(patientJsonFilename).bufferedReader().use {
+ it.readText()
+ }
+ }
+}
diff --git a/example/src/main/java/com/google/fhirengine/example/data/DummyDetailsContent.kt b/example/src/main/java/com/google/fhirengine/example/data/DummyDetailsContent.kt
new file mode 100644
index 0000000000..71a30e8957
--- /dev/null
+++ b/example/src/main/java/com/google/fhirengine/example/data/DummyDetailsContent.kt
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.fhirengine.example.data
+
+import java.util.ArrayList
+import java.util.HashMap
+
+/**
+ * Helper class for providing sample content for user interfaces created by
+ * Android template wizards.
+ *
+ * TODO: Replace all uses of this class before publishing your app.
+ */
+object DummyDetailsContent {
+
+ /**
+ * An array of sample (dummy) items.
+ */
+ val ITEMS: MutableList = ArrayList()
+
+ /**
+ * A map of sample (dummy) items, by ID.
+ */
+ val ITEM_MAP: MutableMap = HashMap()
+
+ private val COUNT = 25
+
+ init {
+ // Add some sample items.
+ for (i in 1..COUNT) {
+ addItem(
+ createDummyItem(
+ i
+ )
+ )
+ }
+ }
+
+ private fun addItem(item: DummyItem) {
+ ITEMS.add(item)
+ ITEM_MAP.put(item.id, item)
+ }
+
+ private fun createDummyItem(position: Int): DummyItem {
+ return DummyItem(
+ position.toString(),
+ "Item " + position,
+ makeDetails(
+ position
+ )
+ )
+ }
+
+ private fun makeDetails(position: Int): String {
+ val builder = StringBuilder()
+ builder.append("Details about Item: ").append(position)
+ for (i in 0..position - 1) {
+ builder.append("\nMore details information here.")
+ }
+ return builder.toString()
+ }
+
+ /**
+ * A dummy item representing a piece of content.
+ */
+ data class DummyItem(val id: String, val content: String, val details: String) {
+ override fun toString(): String = content
+ }
+}
diff --git a/example/src/main/java/com/google/fhirengine/example/data/SamplePatients.kt b/example/src/main/java/com/google/fhirengine/example/data/SamplePatients.kt
new file mode 100644
index 0000000000..d30c6d2c11
--- /dev/null
+++ b/example/src/main/java/com/google/fhirengine/example/data/SamplePatients.kt
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.fhirengine.example.data
+
+import ca.uhn.fhir.context.FhirContext
+import org.hl7.fhir.r4.model.Bundle
+import org.hl7.fhir.r4.model.Patient
+
+private const val MAX_RESOURCE_COUNT = 20
+
+/**
+ * Helper class for loading a list of sample Fhir Patient Resource objects.
+ *
+ * Parses and loads Patient data from the passed JSON String into items that could be used by
+ * PatientListViewModel.
+ */
+class SamplePatients {
+ private val patients: MutableList = ArrayList()
+ // Maps a temporary patient display id to PatientItem, used to display patients both in list and
+ // details.
+ private val idsPatients: MutableMap = mutableMapOf()
+
+ // The resource bundle with Patient objects.
+ private var fhirBundle: Bundle? = null
+
+ companion object {
+ val fhirJsonParser = FhirContext.forR4().newJsonParser()
+ }
+ /**
+ * Returns list of PatientItem objects based on patients from the json string.
+ */
+ fun getPatientItems(jsonString: String): List {
+ fhirBundle = fhirJsonParser.parseResource(Bundle::class.java,
+ jsonString) as Bundle
+
+ // Create a list of PatientItems from fhirPatients. The display index is 1 based.
+ fhirBundle?.entry?.take(MAX_RESOURCE_COUNT)?.mapIndexed { index, entry ->
+ createPatientItem(index + 1, entry.resource as Patient)
+ }?.let { patients.addAll(it) }
+
+ // Create the PatientItems Map from PatientItem List.
+ idsPatients.putAll(patients.associateBy { it.id })
+
+ return patients
+ }
+
+ /**
+ * Creates PatientItem objects with displayable values from the Fhir Patient objects.
+ */
+ private fun createPatientItem(position: Int, patient: Patient): PatientItem {
+ val name = patient.name[0].nameAsSingleString
+
+ // Show nothing if no values available for gender and date of birth.
+ val gender = if (patient.hasGenderElement()) patient.genderElement.valueAsString else ""
+ val dob = if (patient.hasBirthDateElement()) patient.birthDateElement.valueAsString else ""
+
+ return PatientItem(position.toString(), name, gender, dob)
+ }
+
+ /**
+ * The Patient's details for display purposes.
+ */
+ data class PatientItem(val id: String, val name: String, val gender: String, val dob: String) {
+ override fun toString(): String = name
+ }
+}
diff --git a/example/src/main/res/layout/activity_patient_list.xml b/example/src/main/res/layout/activity_patient_list.xml
new file mode 100644
index 0000000000..8aec1c9242
--- /dev/null
+++ b/example/src/main/res/layout/activity_patient_list.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/src/main/res/layout/activity_samplepatient_detail.xml b/example/src/main/res/layout/activity_samplepatient_detail.xml
new file mode 100644
index 0000000000..87a469e1d6
--- /dev/null
+++ b/example/src/main/res/layout/activity_samplepatient_detail.xml
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/src/main/res/layout/patient_list.xml b/example/src/main/res/layout/patient_list.xml
new file mode 100644
index 0000000000..5b2414060b
--- /dev/null
+++ b/example/src/main/res/layout/patient_list.xml
@@ -0,0 +1,29 @@
+
+
+
+
\ No newline at end of file
diff --git a/example/src/main/res/layout/patient_list_item.xml b/example/src/main/res/layout/patient_list_item.xml
new file mode 100644
index 0000000000..d4a26d9757
--- /dev/null
+++ b/example/src/main/res/layout/patient_list_item.xml
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/src/main/res/layout/samplepatient_detail.xml b/example/src/main/res/layout/samplepatient_detail.xml
new file mode 100644
index 0000000000..447fca0160
--- /dev/null
+++ b/example/src/main/res/layout/samplepatient_detail.xml
@@ -0,0 +1,26 @@
+
+
+
+
\ No newline at end of file
diff --git a/example/src/main/res/values/dimens.xml b/example/src/main/res/values/dimens.xml
new file mode 100644
index 0000000000..f0fcf50701
--- /dev/null
+++ b/example/src/main/res/values/dimens.xml
@@ -0,0 +1,25 @@
+
+
+
+
+ 16dp
+ 200dp
+ 200dp
+ 24dp
+ 16dp
+ 2dp
+
\ No newline at end of file
diff --git a/example/src/main/res/values/strings.xml b/example/src/main/res/values/strings.xml
index a815094ec8..e59b584a78 100644
--- a/example/src/main/res/values/strings.xml
+++ b/example/src/main/res/values/strings.xml
@@ -16,4 +16,6 @@
FHIR Engine Example
+ Registered Patients
+ SamplePatient Detail
\ No newline at end of file
diff --git a/example/src/main/res/values/styles.xml b/example/src/main/res/values/styles.xml
index 07789109f7..4f807257fe 100644
--- a/example/src/main/res/values/styles.xml
+++ b/example/src/main/res/values/styles.xml
@@ -23,4 +23,13 @@
- @color/colorAccent
+
+
+
+
+
+
\ No newline at end of file