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

Mark many things as internal #2494

Merged
merged 10 commits into from
Jun 3, 2024
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 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 All @@ -26,7 +26,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.google.android.fhir.FhirEngine
import com.google.android.fhir.logicalId
import com.google.android.fhir.search.revInclude
import com.google.android.fhir.search.search
import java.text.SimpleDateFormat
Expand Down Expand Up @@ -379,3 +378,12 @@ data class RiskAssessmentItem(
var lastContacted: String,
var patientCardColor: Int,
)

/**
* The logical (unqualified) part of the ID. For example, if the ID is
* "http://example.com/fhir/Patient/123/_history/456", then this value would be "123".
*/
private val Resource.logicalId: String
get() {
return this.idElement?.idPart.orEmpty()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Google LLC
* Copyright 2021-2024 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 All @@ -18,11 +18,11 @@ package com.google.android.fhir

import okhttp3.MediaType.Companion.toMediaType

object ContentTypes {
internal object ContentTypes {
const val APPLICATION_JSON_PATCH = "application/json-patch+json"
const val APPLICATION_FHIR_JSON = "application/fhir+json"
}

object MediaTypes {
internal object MediaTypes {
val MEDIA_TYPE_FHIR_JSON = ContentTypes.APPLICATION_FHIR_JSON.toMediaType()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 Google LLC
* Copyright 2021-2024 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 All @@ -21,7 +21,7 @@ import java.time.Instant
import java.time.ZoneId

/** The DateProvider Instance [FhirEngine] uses for date/time related operations. */
object DateProvider {
internal object DateProvider {
lateinit var clock: Clock
private var fixed = false
// TODO possibly provide more customization options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ object FhirEngineProvider {
* `enableEncryptionIfSupported` is true, the FHIR SDK will only enable database encryption on
* supported devices.
*
* WARNING: If database encryption is enabled, devices that are on API 22 (Android 5.1) or lower
* **WARNING:** If database encryption is enabled, devices that are on API 22 (Android 5.1) or lower
* will have an unencrypted database. If those devices are later updated to API 23 or newer, they
* will encounter an `IllegalStateException`. This is because the database was created without
* encryption on the older API level, and enabling encryption in the new release will not
Expand All @@ -143,11 +143,10 @@ object FhirEngineProvider {
* engine with the Search API. These are in addition to the default
* [search parameters](https://www.hl7.org/fhir/searchparameter-registry.html) defined in the FHIR
* specification. Custom search parameters must be unique and not change existing or default
* search parameters.
*
* Note: The engine does not automatically reindex resources after new custom search parameters are
* added. You must manually reindex resources by updating them. Any new CRUD operations on a
* resource after adding new search parameters will automatically trigger reindexing.
* search parameters.<p> **Note:** The engine does not automatically reindex resources after new
* custom search parameters are added. You must manually reindex resources by updating them. Any
* new CRUD operations on a resource after adding new search parameters will automatically trigger
* reindexing.
*/
data class FhirEngineConfiguration(
val enableEncryptionIfSupported: Boolean = false,
Expand All @@ -157,6 +156,7 @@ data class FhirEngineConfiguration(
val customSearchParameters: List<SearchParameter>? = null,
)

/** How database errors should be handled. */
enum class DatabaseErrorStrategy {
/**
* If unspecified, all database errors will be propagated to the call site. The caller shall
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 Google LLC
* Copyright 2022-2024 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
10 changes: 5 additions & 5 deletions engine/src/main/java/com/google/android/fhir/Util.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Google LLC
* Copyright 2022-2024 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 @@ -50,7 +50,7 @@ internal fun isValidDateOnly(date: String) =
* The logical (unqualified) part of the ID. For example, if the ID is
* "http://example.com/fhir/Patient/123/_history/456", then this value would be "123".
*/
val Resource.logicalId: String
internal val Resource.logicalId: String
get() {
return this.idElement?.idPart.orEmpty()
}
Expand All @@ -62,14 +62,14 @@ val Resource.logicalId: String
* operation success/failure. TODO: pass along the HTTP result (or any other signal) to determine
* the outcome of an instance level RESTful operation.
*/
fun Resource.isUploadSuccess(): Boolean {
internal fun Resource.isUploadSuccess(): Boolean {
if (!this.resourceType.equals(ResourceType.OperationOutcome)) return false
val outcome: OperationOutcome = this as OperationOutcome
return outcome.issue.isNotEmpty() &&
outcome.issue.all { it.severity.equals(OperationOutcome.IssueSeverity.INFORMATION) }
}

class OffsetDateTimeTypeAdapter : TypeAdapter<OffsetDateTime>() {
internal class OffsetDateTimeTypeAdapter : TypeAdapter<OffsetDateTime>() {
override fun write(out: JsonWriter, value: OffsetDateTime) {
out.value(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(value))
}
Expand All @@ -78,7 +78,7 @@ class OffsetDateTimeTypeAdapter : TypeAdapter<OffsetDateTime>() {
}

/** Url for the UCUM system of measures. */
const val ucumUrl = "http://unitsofmeasure.org"
internal const val ucumUrl = "http://unitsofmeasure.org"

internal fun percentOf(value: Number, total: Number) =
if (total == 0) 0.0 else value.toDouble() / total.toDouble()
4 changes: 2 additions & 2 deletions engine/src/main/java/com/google/android/fhir/db/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ internal interface Database {
): List<LocalChangeResourceReference>
}

data class ResourceWithUUID<R>(
internal data class ResourceWithUUID<R>(
val uuid: UUID,
val resource: R,
)

data class LocalChangeResourceReference(
internal data class LocalChangeResourceReference(
val localChangeId: Long,
val resourceReferenceValue: String,
val resourceReferencePath: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ internal class DatabaseImpl(
}
}

data class DatabaseConfig(
internal data class DatabaseConfig(
val inMemory: Boolean,
val enableEncryption: Boolean,
val databaseErrorStrategy: DatabaseErrorStrategy,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 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 @@ -64,14 +64,14 @@ internal abstract class ResourceDatabase : RoomDatabase() {
abstract fun localChangeDao(): LocalChangeDao
}

val MIGRATION_1_2 =
internal val MIGRATION_1_2 =
object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("DROP table if exists SyncedResourceEntity")
}
}

val MIGRATION_2_3 =
internal val MIGRATION_2_3 =
object : Migration(2, 3) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
Expand All @@ -80,7 +80,7 @@ val MIGRATION_2_3 =
}
}

val MIGRATION_3_4 =
internal val MIGRATION_3_4 =
object : Migration(3, 4) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
Expand All @@ -105,7 +105,7 @@ val MIGRATION_3_4 =
}
}

val MIGRATION_4_5 =
internal val MIGRATION_4_5 =
object : Migration(4, 5) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
Expand All @@ -115,7 +115,7 @@ val MIGRATION_4_5 =
}

/** Changes column type of [LocalChangeEntity.timestamp] from [String] to [java.time.Instant]. */
val MIGRATION_5_6 =
internal val MIGRATION_5_6 =
object : Migration(5, 6) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
Expand All @@ -133,7 +133,7 @@ val MIGRATION_5_6 =
}

/** Add column resourceUuid in [LocalChangeEntity] */
val MIGRATION_6_7 =
internal val MIGRATION_6_7 =
object : Migration(6, 7) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
Expand All @@ -155,7 +155,7 @@ val MIGRATION_6_7 =
}

/** Create [LocalChangeResourceReferenceEntity] */
val MIGRATION_7_8 =
internal val MIGRATION_7_8 =
object : Migration(7, 8) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 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 @@ -33,7 +33,7 @@ import net.sqlcipher.database.SQLiteOpenHelper
import timber.log.Timber

/** A [SupportSQLiteOpenHelper] which initializes a [SQLiteDatabase] with a passphrase. */
class SQLCipherSupportHelper(
internal class SQLCipherSupportHelper(
private val configuration: SupportSQLiteOpenHelper.Configuration,
hook: SQLiteDatabaseHook? = null,
private val databaseErrorStrategy: DatabaseErrorStrategy,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 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 @@ -27,7 +27,7 @@ import org.hl7.fhir.r4.model.Resource
*
* TODO: Ideally we update the upstream's HapiWorkerContext to support ucumServices.
*/
class DualHapiWorkerContext : SimpleWorkerContext() {
internal class DualHapiWorkerContext : SimpleWorkerContext() {
val hapi =
HapiWorkerContext(
FhirContext.forR4Cached(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 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 @@ -389,4 +389,8 @@ internal class ResourceIndexer(
}
}

data class SearchParamDefinition(val name: String, val type: SearchParamType, val path: String)
internal data class SearchParamDefinition(
val name: String,
val type: SearchParamType,
val path: String,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Google LLC
* Copyright 2021-2024 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 All @@ -21,4 +21,4 @@ package com.google.android.fhir.index.entities
*
* See https://www.hl7.org/fhir/search.html#special.
*/
data class PositionIndex(val latitude: Double, val longitude: Double)
internal data class PositionIndex(val latitude: Double, val longitude: Double)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 Google LLC
* Copyright 2022-2024 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 @@ -44,7 +44,7 @@ import org.hl7.fhir.r4.model.ResourceType
* http://build.fhir.org/ig/HL7/sdc/expressions.html#x-fhir-query-enhancements and
* http://hl7.org/fhir/R4/search.html
*/
object XFhirQueryTranslator {
internal object XFhirQueryTranslator {
private const val XFHIR_QUERY_SORT_PARAM = "_sort"
private const val XFHIR_QUERY_COUNT_PARAM = "_count"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 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 All @@ -21,7 +21,7 @@ import java.time.Instant
import org.hl7.fhir.r4.model.Resource

/** Data class for squashed local changes for resource */
data class Patch(
internal data class Patch(
/** The [ResourceType] */
val resourceType: String,
/** The resource id [Resource.id] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 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 @@ -30,7 +30,7 @@ import org.hl7.fhir.r4.model.UriType
* [LocalChangeEntity]. See [https://www.hl7.org/fhir/http.html#transaction] for more info regarding
* the supported [Bundle.HTTPVerb].
*/
abstract class BundleEntryComponentGenerator(
internal abstract class BundleEntryComponentGenerator(
private val httpVerb: Bundle.HTTPVerb,
private val useETagForUpload: Boolean,
) {
Expand Down
Loading
Loading