Skip to content

Commit d4244fe

Browse files
liujoshuanrlakin
authored andcommitted
Get Subpopulation Guid from build config (#12)
* Each study has a default subpopulation which has the studyId as its guid * Additional subpopulations can be created
1 parent b426474 commit d4244fe

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

app/build.gradle

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ android {
1313
versionCode 1
1414
versionName '1.0'
1515
multiDexEnabled true
16+
17+
// To configure communications with Bridge Study Manager (https://research.sagebridge.org/),
18+
// create a 'gradle.properties' file in the same directory as this build.gradle and add
19+
// the needed values, for example studyId="bridge_study_id" to make them available as
20+
// BuildConfig.STUDY_ID, BuildConfig.STUDY_NAME, etc
21+
buildConfigField 'String', 'STUDY_ID', studyId
22+
buildConfigField 'String', 'STUDY_NAME', studyName
23+
buildConfigField 'String', 'STUDY_SUBPOPULATION_GUID', studyId // default subpopulation
24+
buildConfigField 'String', 'STUDY_BASE_URL', "\"https://webservices.sagebridge.org/\""
1625
}
1726
buildTypes {
1827
release {
1928
minifyEnabled false
2029
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21-
// create a 'gradle.properties' file in the same directory as this build.gradle and add
22-
// the needed values, for example studyId="bridge_study_id" to make them available as
23-
// BuildConfig.STUDY_ID, BuildConfig.STUDY_NAME, etc
24-
buildConfigField 'String', 'STUDY_ID', studyId
25-
buildConfigField 'String', 'STUDY_NAME', studyName
26-
buildConfigField 'String', 'STUDY_BASE_URL', "\"https://webservices.sagebridge.org/\""
2730
}
2831

2932
debug {
3033
debuggable true
3134
minifyEnabled false
3235
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33-
buildConfigField 'String', 'STUDY_ID', studyId
34-
buildConfigField 'String', 'STUDY_NAME', studyName
35-
buildConfigField 'String', 'STUDY_BASE_URL', "\"https://webservices-staging.sagebridge.org/\""
3636
}
3737
}
3838

app/src/main/java/org/researchstack/sampleapp/bridge/BridgeDataProvider.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private void checkForTempConsentAndUpload(Context context)
219219
try
220220
{
221221
ConsentSignatureBody consent = loadConsentSignatureBody(context);
222-
uploadConsent(context, consent);
222+
uploadConsent(context, BuildConfig.STUDY_SUBPOPULATION_GUID, consent);
223223
}
224224
catch(Exception e)
225225
{
@@ -444,12 +444,12 @@ private ConsentSignatureBody loadConsentSignatureBody(Context context)
444444
@Override
445445
public void uploadConsent(Context context, TaskResult consentResult)
446446
{
447-
uploadConsent(context, createConsentSignatureBody(consentResult));
447+
uploadConsent(context, BuildConfig.STUDY_SUBPOPULATION_GUID, createConsentSignatureBody(consentResult));
448448
}
449449

450-
private void uploadConsent(Context context, ConsentSignatureBody consent)
450+
private void uploadConsent(Context context, String subpopulationGuid, ConsentSignatureBody consent)
451451
{
452-
service.consentSignature(getStudyId(), consent)
452+
service.consentSignature(subpopulationGuid, consent)
453453
.compose(ObservableUtils.applyDefault())
454454
.subscribe(response -> {
455455
if(response.code() == 201 ||
@@ -966,8 +966,9 @@ public interface BridgeService
966966
Observable<Response<UserSessionInfo>> signIn(@Body SignInBody body);
967967

968968
@Headers("Content-Type: application/json")
969-
@POST("v3/subpopulations/{studyId}/consents/signature")
970-
Observable<Response<BridgeMessageResponse>> consentSignature(@Path("studyId") String studyId, @Body ConsentSignatureBody body);
969+
@POST("v3/subpopulations/{subpopulationGuid}/consents/signature")
970+
Observable<Response<BridgeMessageResponse>> consentSignature(@Path("subpopulationGuid") String subpopulationGuid,
971+
@Body ConsentSignatureBody body);
971972

972973
/**
973974
* @return Response code <b>200</b> w/ message explaining instructions on how the user should
@@ -978,8 +979,9 @@ public interface BridgeService
978979
Observable<Response<BridgeMessageResponse>> requestResetPassword(@Body EmailBody body);
979980

980981

981-
@POST("v3/subpopulations/{studyId}/consents/signature/withdraw")
982-
Observable<Response<BridgeMessageResponse>> withdrawConsent(@Path("studyId") String studyId, @Body WithdrawalBody withdrawal);
982+
@POST("v3/subpopulations/{subpopulationGuid}/consents/signature/withdraw")
983+
Observable<Response<BridgeMessageResponse>> withdrawConsent(@Path("subpopulationGuid") String subpopulationGuid,
984+
@Body WithdrawalBody withdrawal);
983985

984986
/**
985987
* @return Response code <b>200</b> w/ message explaining instructions on how the user should

0 commit comments

Comments
 (0)