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

Practitioner Details implementation #890

Merged
merged 86 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
91e3b5c
-Add practitioner details url in OAuthService.kt
RaaziaTarique Dec 20, 2021
efffd14
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Dec 20, 2021
1cc39ad
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Dec 20, 2021
6695758
- Get practitioner-details call added.
RaaziaTarique Dec 23, 2021
c5d4bde
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Dec 23, 2021
55a2f9a
- Resolve failing tests
RaaziaTarique Dec 23, 2021
c0046f9
- Fix failing test cases
RaaziaTarique Dec 23, 2021
4762a23
- Remove practitioner details api call from OAuthService.kt
RaaziaTarique Dec 25, 2021
dc72fdd
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Jan 3, 2022
c06ed8b
- Custom files added for Practitioner Details API
RaaziaTarique Jan 4, 2022
4107d56
- Update practitioner detail payload
RaaziaTarique Jan 5, 2022
4c23587
- spotlessApply
RaaziaTarique Jan 5, 2022
a4e12de
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Jan 5, 2022
f8e0cea
- resolved merging error
RaaziaTarique Jan 5, 2022
a5b1876
- spotless check
RaaziaTarique Jan 5, 2022
7b3093c
- Write helper methods to fetch the keycloak.
RaaziaTarique Jan 6, 2022
21e19ec
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Jan 7, 2022
484a25d
- Update retrieveKeyClockInfo to decode json string using Gson
RaaziaTarique Jan 7, 2022
bc038a0
- Move sample_practitionar_payload.json from anc test directory to en…
RaaziaTarique Jan 7, 2022
457c610
- Remove unused runSync method.
RaaziaTarique Jan 7, 2022
737e817
- Refactoring
RaaziaTarique Jan 7, 2022
2ddd84a
- Rename KeyclockUtils.kt to UserDetailsUtils.kt
RaaziaTarique Jan 7, 2022
ee105a7
- Add remarks
RaaziaTarique Jan 11, 2022
4988bbb
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Jan 14, 2022
d7508cf
- Add domain mapper for multiple resource files.
RaaziaTarique Jan 14, 2022
50e1bf7
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Jan 24, 2022
d154c91
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Jan 27, 2022
ac14fc8
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Feb 2, 2022
b4ff9a9
- Remove PractitionerDetails API model classes from server and use or…
RaaziaTarique Feb 2, 2022
a131d30
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Feb 3, 2022
e0f6390
- Changes for storing resources in ResourceTable
RaaziaTarique Feb 3, 2022
85ffbe9
test for data
maimoonak Feb 4, 2022
21be7f7
- storing parameters into the resource entity table.
RaaziaTarique Feb 8, 2022
21e69df
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Feb 9, 2022
176f142
- Update PractitionerDetailsUtils to fetch resources using Parameters…
RaaziaTarique Feb 9, 2022
b6efd1d
- Updated payload.
RaaziaTarique Feb 9, 2022
d681da4
- Updated payload.
RaaziaTarique Feb 9, 2022
675b0a5
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Feb 9, 2022
3614568
- Update PractitionerDetails model library and modify code according …
RaaziaTarique Feb 10, 2022
d260cef
Merge remote-tracking branch 'origin/857_practitioner_details' into 8…
RaaziaTarique Feb 10, 2022
1b2992a
- Code refactoring
RaaziaTarique Feb 10, 2022
5ce8068
- Code refactoring
RaaziaTarique Feb 11, 2022
aeb8f99
- Modified parameters storing logic
RaaziaTarique Feb 11, 2022
6e64450
- code refactoring
RaaziaTarique Feb 11, 2022
f56bbef
- code refactoring
RaaziaTarique Feb 11, 2022
f7bda83
- code refactoring
RaaziaTarique Feb 14, 2022
78aece9
- Add test cases
RaaziaTarique Feb 14, 2022
6aae946
- Add test cases
RaaziaTarique Feb 14, 2022
d6e3175
- Add test cases
RaaziaTarique Feb 14, 2022
a173e85
- Add test cases
RaaziaTarique Feb 14, 2022
2462f45
- Add test cases
RaaziaTarique Feb 14, 2022
eb82c51
- Add test cases
RaaziaTarique Feb 14, 2022
77e18f4
- Fix failing tes
RaaziaTarique Feb 14, 2022
d5cacf6
- Add test case for FhirContextUtil
RaaziaTarique Feb 15, 2022
ecb6c79
- Add test case in AccountAuthenticatorTest.kt
RaaziaTarique Feb 15, 2022
f0c3903
- Add test case in PractitionerDetailsUtilsTest.kt
RaaziaTarique Feb 15, 2022
65e2e64
- spotless apply
RaaziaTarique Feb 15, 2022
d6bab5f
- code refactored
RaaziaTarique Feb 15, 2022
4f66dab
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Feb 21, 2022
7015322
- Fix tests
RaaziaTarique Feb 21, 2022
cdb795d
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Mar 11, 2022
0236de8
- resolved merge conflicts
RaaziaTarique Mar 11, 2022
b16eb3c
- Cater Elly's requested changes
RaaziaTarique Mar 11, 2022
f2bf536
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Mar 15, 2022
425c1cf
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Mar 15, 2022
401f600
Merge branch 'main' into 857_practitioner_details
RaaziaTarique Mar 18, 2022
3d688e5
Refactor Practitioner Details implementation (#1520)
FikriMilano Aug 16, 2022
272cdd9
Merge branch 'main' of github.com:opensrp/fhircore into 857_practitio…
FikriMilano Aug 16, 2022
2ce1c7b
Returns null when Organization is not found
FikriMilano Aug 16, 2022
eda4013
Update CHANGELOG.md
FikriMilano Aug 16, 2022
a2e4940
Merge branch 'main' into 857_practitioner_details
FikriMilano Aug 17, 2022
7de1d3a
Update sample payload
FikriMilano Aug 17, 2022
67a9e25
Rename sample payload
FikriMilano Aug 17, 2022
a653b0c
Create constant for practitioner details payload
FikriMilano Aug 17, 2022
a27e14c
Add TODO tracker for multi Organization
FikriMilano Aug 17, 2022
5443405
Remove obsolete code
FikriMilano Aug 17, 2022
ebc3903
Remove parameters template
FikriMilano Aug 17, 2022
7507d69
Fix failing test
FikriMilano Aug 17, 2022
02b28b1
Fix failing test
FikriMilano Aug 17, 2022
da08855
Fix failing test
FikriMilano Aug 18, 2022
59abebf
Fix failing test
FikriMilano Aug 18, 2022
a4248d7
Add test
FikriMilano Aug 19, 2022
9799a39
Add test
FikriMilano Aug 19, 2022
477087b
Merge branch 'main' of github.com:opensrp/fhircore into 857_practitio…
FikriMilano Aug 24, 2022
ebf2155
spotlessApply
FikriMilano Aug 23, 2022
97623e2
Migrate practitioner endpoint url as a String extension
FikriMilano Aug 24, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Adds internationalization(MLS) for App configs
- Adds register, navigation menus and profile configurations using JSON files
- Implements Practitioner Details

## [0.0.9 Quest, 0.0.10 EIR, 0.0.4 - ANC] - 2022-07-04, 2021-11-24, 2022-04-01
### Added
Expand Down
1 change: 1 addition & 0 deletions android/engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ dependencies {
implementation 'androidx.fragment:fragment-ktx:1.5.0'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'androidx.security:security-crypto:1.1.0-alpha03'
implementation 'org.smartregister:fhir-common-utils:0.0.2-SNAPSHOT'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation "androidx.cardview:cardview:1.0.0"
Expand Down
259 changes: 259 additions & 0 deletions android/engine/src/main/assets/sample_practitioner_payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
{
"resourceType": "Bundle",
"id": "51d382cf-63e5-4aa8-bcb3-369d2fd300cb",
"meta": {
"lastUpdated": "2022-08-17T07:24:25.608+00:00"
},
"type": "searchset",
"total": 1,
"link": [
{
"relation": "self",
"url": "https://fhir.labs.smartregister.org:443/fhir/practitioner-details?keycloak-uuid=34f0d616-afc8-4446-ae87-bb60be4bdbc9"
}
],
"entry": [
{
"fullUrl": "https://fhir.labs.smartregister.org:443/fhir/practitioner-details/34f0d616-afc8-4446-ae87-bb60be4bdbc9",
"resource": {
"resourceType": "practitioner-details",
"id": "34f0d616-afc8-4446-ae87-bb60be4bdbc9",
"meta": {
"profile": [
"http://hl7.org/fhir/profiles/custom-resource"
]
},
"KeycloakUserDetails": {
"id": "34f0d616-afc8-4446-ae87-bb60be4bdbc9",
"user-bio": [
{
"identifier": "b87ff3c2-cbc6-43e6-b753-a9620756f9e4",
"userName": "demo",
"preferredName": "demo",
"familyName": "41887",
"givenName": "Demo",
"emailVerified": "false"
}
],
"user-roles": [
"ROLE_realm-admin",
"ROLE_OPENMRS",
"ROLE_EDIT_KEYCLOAK_USERS",
"ROLE_offline_access",
"ROLE_VIEW_KEYCLOAK_USERS",
"ROLE_uma_authorization",
"ROLE_ALL_EVENTS",
"ROLE_PLANS_FOR_USER"
]
},
"fhir": {
"id": "136252",
"careteams": [
{
"resourceType": "CareTeam",
"id": "136253",
"meta": {
"versionId": "1",
"lastUpdated": "2022-07-25T16:41:45.221+00:00",
"source": "#98d1c5ca256d7e8b"
},
"identifier": [
{
"use": "official",
"value": "46384571-ad31-4c20-8aa0-266f80ef6582"
}
],
"status": "active",
"name": "Nala Team",
"participant": [
{
"member": {
"reference": "Practitioner/136252"
}
}
]
}
],
"teams": [
{
"resourceType": "Organization",
"id": "136254",
"meta": {
"versionId": "2",
"lastUpdated": "2022-07-25T16:42:51.523+00:00",
"source": "#dad854aca8ea9fcd"
},
"identifier": [
{
"use": "official",
"value": "e58c9509-8ff2-4664-b805-e9dd5bf0cf8a"
}
],
"active": true,
"type": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/organization-type",
"code": "prov"
}
]
}
],
"name": "Nala Team",
"alias": [
"nala"
]
}
],
"locations": [
{
"resourceType": "Location",
"id": "136256",
"meta": {
"versionId": "1",
"lastUpdated": "2022-07-25T16:44:38.620+00:00",
"source": "#b46640c1adfc6d38"
},
"identifier": [
{
"use": "official",
"value": "c3bd4bcc-889e-4e3d-a72b-a0b611b8fb64"
}
],
"status": "active",
"name": "Nala Location ",
"physicalType": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/location-physical-type",
"code": "jdn",
"display": "Jurisdiction"
}
]
},
"partOf": {
"reference": "Location/109211",
"display": "Charlie Clinic"
}
}
],
"locationHierarchyList": [
{
"resourceType": "LocationHierarchy",
"id": "Location Resource : 136256",
"meta": {
"profile": [
"http://hl7.org/fhir/profiles/custom-resource"
]
},
"LocationHierarchyTree": {
"locationsHierarchy": {
"listOfNodes": {
"treeNodeId": "Location/136256",
"treeNode": [
{
"nodeId": "Location/136256",
"label": "Nala Location ",
"node": {
"resourceType": "Location",
"id": "136256",
"meta": {
"versionId": "1",
"lastUpdated": "2022-07-25T16:44:38.620+00:00",
"source": "#b46640c1adfc6d38"
},
"identifier": [
{
"use": "official",
"value": "c3bd4bcc-889e-4e3d-a72b-a0b611b8fb64"
}
],
"status": "active",
"name": "Nala Location ",
"physicalType": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/location-physical-type",
"code": "jdn",
"display": "Jurisdiction"
}
]
},
"partOf": {
"reference": "Location/109211",
"display": "Charlie Clinic"
}
},
"parent": "Location/109211",
"children": [
{
"childId": "Location/137151",
"treeNode": {
"nodeId": "Location/137151",
"label": "Test Village",
"node": {
"resourceType": "Location",
"id": "137151",
"meta": {
"versionId": "1",
"lastUpdated": "2022-08-04T11:41:32.683+00:00",
"source": "#1bb63352eef7cefc"
},
"identifier": [
{
"use": "official",
"value": "f7f4c729-fd05-40aa-bdc3-fccd74589264"
}
],
"status": "active",
"name": "Test Village",
"description": "Test",
"physicalType": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/location-physical-type",
"code": "jdn",
"display": "Jurisdiction"
}
]
},
"partOf": {
"reference": "Location/136256",
"display": "Nala Location "
}
},
"parent": "Location/136256"
}
}
]
}
]
},
"parentChildren": [
{
"identifier": "Location/109211",
"childIdentifiers": [
"Location/136256"
]
},
{
"identifier": "Location/136256",
"childIdentifiers": [
"Location/137151"
]
}
]
}
},
"locationId": "136256"
}
],
"practitionerId": [
"136252"
]
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.core.os.bundleOf
import ca.uhn.fhir.parser.IParser
import dagger.hilt.android.qualifiers.ApplicationContext
import java.util.Locale
import javax.inject.Inject
Expand All @@ -37,9 +38,10 @@ import okhttp3.ResponseBody
import org.smartregister.fhircore.engine.R
import org.smartregister.fhircore.engine.configuration.app.ConfigService
import org.smartregister.fhircore.engine.data.remote.auth.OAuthService
import org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirResourceService
import org.smartregister.fhircore.engine.data.remote.model.response.OAuthResponse
import org.smartregister.fhircore.engine.ui.login.LoginActivity
import org.smartregister.fhircore.engine.util.DispatcherProvider
import org.smartregister.fhircore.engine.util.PractitionerDetailsUtil
import org.smartregister.fhircore.engine.util.SecureSharedPreference
import org.smartregister.fhircore.engine.util.SharedPreferencesHelper
import org.smartregister.fhircore.engine.util.extension.showToast
Expand All @@ -56,11 +58,12 @@ constructor(
@ApplicationContext val context: Context,
val accountManager: AccountManager,
val oAuthService: OAuthService,
val fhirResourceService: FhirResourceService,
val parser: IParser,
val configService: ConfigService,
val secureSharedPreference: SecureSharedPreference,
val tokenManagerService: TokenManagerService,
val sharedPreference: SharedPreferencesHelper,
val dispatcherProvider: DispatcherProvider
) : AbstractAccountAuthenticator(context) {

override fun addAccount(
Expand Down Expand Up @@ -183,6 +186,16 @@ constructor(
}
}

fun getPractitionerDetailsFromAssets(): org.hl7.fhir.r4.model.Bundle {
val jsonPayload =
context.assets.open(PATH_PRACTITIONER_DETAILS_PAYLOAD).bufferedReader().use { it.readText() }
return parser.parseResource(jsonPayload) as org.hl7.fhir.r4.model.Bundle
}

suspend fun getPractitionerDetails(keycloakUuid: String): org.hl7.fhir.r4.model.Bundle {
return fhirResourceService.getResource(url = PractitionerDetailsUtil.getUrl(keycloakUuid))
}

@Throws(NetworkErrorException::class)
fun fetchToken(username: String, password: CharArray): Call<OAuthResponse> {
val data = buildOAuthPayload(PASSWORD)
Expand Down Expand Up @@ -348,5 +361,6 @@ constructor(
const val USERNAME = "username"
const val PASSWORD = "password"
const val REFRESH_TOKEN = "refresh_token"
const val PATH_PRACTITIONER_DETAILS_PAYLOAD = "sample_practitioner_payload.json"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import org.hl7.fhir.r4.model.Composition
import org.hl7.fhir.r4.model.ResourceType
import org.smartregister.fhircore.engine.data.local.DefaultRepository
import org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirResourceDataSource
import org.smartregister.fhircore.engine.util.APP_ID_KEY
import org.smartregister.fhircore.engine.util.DispatcherProvider
import org.smartregister.fhircore.engine.util.SharedPreferenceKey
import org.smartregister.fhircore.engine.util.SharedPreferencesHelper
import org.smartregister.fhircore.engine.util.extension.camelCase
import org.smartregister.fhircore.engine.util.extension.decodeJson
Expand Down Expand Up @@ -276,7 +276,7 @@ constructor(
// TODO load these type of configs from assets too
CoroutineScope(dispatcherProvider.io()).launch {
try {
sharedPreferencesHelper.read(APP_ID_KEY, null)?.let { appId: String ->
sharedPreferencesHelper.read(SharedPreferenceKey.APP_ID.name, null)?.let { appId: String ->
repository.searchCompositionByIdentifier(appId)?.let { composition ->
composition
.retrieveCompositionSections()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import org.hl7.fhir.r4.model.ResourceType
import org.hl7.fhir.r4.model.SearchParameter
import org.smartregister.fhircore.engine.configuration.ConfigType
import org.smartregister.fhircore.engine.configuration.ConfigurationRegistry
import org.smartregister.fhircore.engine.data.remote.model.response.UserInfo
import org.smartregister.fhircore.engine.sync.SyncBroadcaster
import org.smartregister.fhircore.engine.task.FhirTaskPlanWorker
import org.smartregister.fhircore.engine.util.SharedPreferenceKey
import timber.log.Timber

/** An interface that provides the application configurations. */
Expand Down Expand Up @@ -82,7 +82,7 @@ interface ConfigService {
/** Retrieve registry sync params */
fun loadRegistrySyncParams(
configurationRegistry: ConfigurationRegistry,
authenticatedUserInfo: UserInfo?,
paramsMap: Map<String, List<String>>?,
): Map<ResourceType, Map<String, String>> {
val pairs = mutableListOf<Pair<ResourceType, Map<String, String>>>()

Expand All @@ -100,8 +100,13 @@ interface ConfigService {
val paramExpression = sp.expression
val expressionValue =
when (paramName) {
ConfigurationRegistry.ORGANIZATION -> authenticatedUserInfo?.organization
ConfigurationRegistry.PUBLISHER -> authenticatedUserInfo?.questionnairePublisher
// TODO: Does not support multi organization yet,
// https://github.com/opensrp/fhircore/issues/1550
ConfigurationRegistry.ORGANIZATION ->
paramsMap
?.get(SharedPreferenceKey.PRACTITIONER_DETAILS_ORGANIZATION_IDS.name)
?.firstOrNull()
?.substringAfter("/")
ConfigurationRegistry.ID -> paramExpression
ConfigurationRegistry.COUNT -> appConfig.remoteSyncPageSize.toString()
else -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ data class UserInfo(
@SerialName("questionnaire_publisher") var questionnairePublisher: String? = null,
@SerialName("organization") var organization: String? = null,
@SerialName("location") var location: String? = null,
@SerialName("family_name") var familyName: String? = null,
@SerialName("given_name") var givenName: String? = null,
@SerialName("name") var name: String? = null,
@SerialName("preferred_username") var preferredUsername: String? = null,
@SerialName("sub") var keycloakUuid: String? = null
)
Loading