Skip to content

Commit

Permalink
Release 1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Gematik-Entwicklung committed Apr 17, 2023
1 parent 281e0f0 commit 9b3f588
Show file tree
Hide file tree
Showing 111 changed files with 5,973 additions and 1,362 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Multibranch.Jenkinsfile
ci
ci-overrides.properties
nexus-init.gradle.kts
doc
documentation-internal
android/src/androidTest
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Release 1.10.0
- Began implementation for support of private insurances
- Bugfixes

# Release 1.9.0
- Small refactorings
- Bugfixes
Expand Down
41 changes: 27 additions & 14 deletions android/src/debug/java/de/gematik/ti/erp/app/debug/ui/DebugPKV.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,36 @@ package de.gematik.ti.erp.app.debug.ui

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.Button
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextAlign
import de.gematik.ti.erp.app.profiles.ui.LocalProfileHandler
import de.gematik.ti.erp.app.theme.PaddingDefaults
import de.gematik.ti.erp.app.utils.compose.AnimatedElevationScaffold
import de.gematik.ti.erp.app.utils.compose.NavigationBarMode
import kotlinx.coroutines.launch
import org.kodein.di.compose.rememberViewModel

@Composable
fun DebugScreenPKV(onBack: () -> Unit) {
val viewModel by rememberViewModel<DebugSettingsViewModel>()
val listState = rememberLazyListState()
val context = LocalContext.current

AnimatedElevationScaffold(
navigationMode = NavigationBarMode.Back,
Expand All @@ -54,7 +58,7 @@ fun DebugScreenPKV(onBack: () -> Unit) {
onBack = onBack
) { innerPadding ->
var invoiceBundle by remember { mutableStateOf("") }
var attachement by remember { mutableStateOf("") }
val scope = rememberCoroutineScope()

LazyColumn(
state = listState,
Expand All @@ -66,6 +70,24 @@ fun DebugScreenPKV(onBack: () -> Unit) {
verticalArrangement = Arrangement.spacedBy(PaddingDefaults.Medium),
contentPadding = PaddingValues(PaddingDefaults.Medium)
) {
item {
DebugCard(title = "Login state") {
val profileHandler = LocalProfileHandler.current
val activeProfile = profileHandler.activeProfile
Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
Button(
onClick = {
scope.launch {
profileHandler.switchProfileToPKV(activeProfile)
}
},
modifier = Modifier.fillMaxWidth()
) {
Text(text = "Set User with ${activeProfile.name} as PKV", textAlign = TextAlign.Center)
}
}
}
}
item {
DebugCard(
title = "Invoice Bundle"
Expand All @@ -79,18 +101,9 @@ fun DebugScreenPKV(onBack: () -> Unit) {
},
maxLines = 1
)
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
value = attachement,
label = { Text("Attachement") },
onValueChange = {
attachement = it
},
maxLines = 1
)
DebugLoadingButton(
onClick = { viewModel.shareInvoicePDF(context, invoiceBundle, attachement) },
text = "Share"
onClick = { viewModel.saveInvoice(invoiceBundle) },
text = "Save Invoice"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Card
import androidx.compose.material.Checkbox
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Icon
Expand Down Expand Up @@ -80,7 +79,6 @@ import androidx.navigation.compose.rememberNavController
import de.gematik.ti.erp.app.R
import de.gematik.ti.erp.app.TestTag
import de.gematik.ti.erp.app.debug.data.Environment
import de.gematik.ti.erp.app.profiles.ui.LocalProfileHandler
import de.gematik.ti.erp.app.theme.AppTheme
import de.gematik.ti.erp.app.theme.PaddingDefaults
import de.gematik.ti.erp.app.utils.compose.AlertDialog
Expand Down Expand Up @@ -172,54 +170,6 @@ fun EditablePathComponentSetButton(
)
}

@Composable
fun TextWithResetButtonComponent(
modifier: Modifier = Modifier,
label: String,
onClick: () -> Unit,
active: Boolean
) {
val color = if (active) Color.Green else Color.Red
Row(verticalAlignment = Alignment.CenterVertically, modifier = modifier.fillMaxWidth()) {
Text(
text = label,
modifier = Modifier
.weight(1f)
.padding(end = PaddingDefaults.Medium)
)
val text = if (active) "UNSET" else "RESET"
Button(
onClick = onClick,
colors = ButtonDefaults.buttonColors(backgroundColor = color),
enabled = !active
) {
Text(text = text)
}
}
}

@Composable
fun EditablePathComponentCheckable(
modifier: Modifier = Modifier,
label: String,
textFieldValue: String,
checked: Boolean,
onValueChange: (String, Boolean) -> Unit
) {
EditablePathComponentWithControl(
modifier = modifier,
label = label,
textFieldValue = textFieldValue,
onValueChange = onValueChange,
content = { onChange ->
Checkbox(
checked = checked,
onCheckedChange = onChange
)
}
)
}

@Composable
fun EditablePathComponentWithControl(
modifier: Modifier,
Expand Down Expand Up @@ -257,6 +207,7 @@ fun DebugScreen(
endpointHelper = instance(),
cardWallUseCase = instance(),
prescriptionUseCase = instance(),
invoiceRepository = instance(),
vauRepository = instance(),
idpRepository = instance(),
idpUseCase = instance(),
Expand Down Expand Up @@ -451,12 +402,6 @@ fun DebugScreenMain(
val modal = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)
val scope = rememberCoroutineScope()

val featuresState by produceState(initialValue = mutableMapOf<String, Boolean>()) {
viewModel.featuresState().collect {
value = it
}
}

ModalBottomSheetLayout(
sheetContent = {
EnvironmentSelector(
Expand Down Expand Up @@ -576,24 +521,6 @@ fun DebugScreenMain(
FeatureToggles(viewModel = viewModel)
}

item {
DebugCard(title = "Login state") {
val profileHandler = LocalProfileHandler.current
val active = profileHandler.activeProfile
Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
Button(
onClick = {
scope.launch {
profileHandler.switchProfileToPKV(active)
}
},
modifier = Modifier.fillMaxWidth()
) {
Text(text = "Set User with ${active.name} as PKV", textAlign = TextAlign.Center)
}
}
}
}
item {
RotatingLog(viewModel = viewModel)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package de.gematik.ti.erp.app.debug.ui

import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import androidx.compose.runtime.getValue
Expand All @@ -38,16 +37,10 @@ import de.gematik.ti.erp.app.debug.data.Environment
import de.gematik.ti.erp.app.di.EndpointHelper
import de.gematik.ti.erp.app.featuretoggle.FeatureToggleManager
import de.gematik.ti.erp.app.featuretoggle.Features
import de.gematik.ti.erp.app.fhir.model.extractPKVInvoiceBundle
import de.gematik.ti.erp.app.idp.model.IdpData
import de.gematik.ti.erp.app.idp.repository.IdpRepository
import de.gematik.ti.erp.app.idp.usecase.IdpUseCase
import de.gematik.ti.erp.app.invoice.usecase.PkvHtmlTemplate
import de.gematik.ti.erp.app.invoice.usecase.createPkvHtmlInvoiceTemplate
import de.gematik.ti.erp.app.invoice.usecase.createSharableFileInCache
import de.gematik.ti.erp.app.invoice.usecase.sharePDFFile
import de.gematik.ti.erp.app.invoice.usecase.writePDFAttachment
import de.gematik.ti.erp.app.invoice.usecase.writePdfFromHtml
import de.gematik.ti.erp.app.invoice.repository.InvoiceRepository
import de.gematik.ti.erp.app.pharmacy.usecase.PharmacyDirectRedeemUseCase
import de.gematik.ti.erp.app.prescription.usecase.PrescriptionUseCase
import de.gematik.ti.erp.app.profiles.repository.ProfileIdentifier
Expand Down Expand Up @@ -83,6 +76,7 @@ class DebugSettingsViewModel(
private val prescriptionUseCase: PrescriptionUseCase,
private val vauRepository: VauRepository,
private val idpRepository: IdpRepository,
private val invoiceRepository: InvoiceRepository,
private val idpUseCase: IdpUseCase,
private val profilesUseCase: ProfilesUseCase,
private val featureToggleManager: FeatureToggleManager,
Expand Down Expand Up @@ -162,6 +156,7 @@ class DebugSettingsViewModel(
pharmacyServiceUrl = BuildKonfig.PHARMACY_SERVICE_URI_RU,
pharmacyServiceActive = true
)

Environment.RUDEV -> debugSettingsData.copy(
eRezeptServiceURL = BuildKonfig.BASE_SERVICE_URI_RU_DEV,
eRezeptActive = true,
Expand All @@ -170,6 +165,7 @@ class DebugSettingsViewModel(
pharmacyServiceUrl = BuildKonfig.PHARMACY_SERVICE_URI_RU,
pharmacyServiceActive = true
)

Environment.TR -> debugSettingsData.copy(
eRezeptServiceURL = BuildKonfig.BASE_SERVICE_URI_TR,
eRezeptActive = true,
Expand Down Expand Up @@ -267,55 +263,6 @@ class DebugSettingsViewModel(
}
}

fun shareInvoicePDF(context: Context, bundle: String, attachement: String) {
viewModelScope.launch {
val html = extractPKVInvoiceBundle(
Json.parseToJsonElement(bundle),
processDispense = { whenHandedOver ->
whenHandedOver.formattedString()
},
processPharmacyAddress = { line, postalCode, city ->
requireNotNull(line)
requireNotNull(postalCode)
requireNotNull(city)
(line + "$postalCode $city").joinToString()
},
processPharmacy = { name, address, _, iknr, _, _ ->
PkvHtmlTemplate.createOrganization(
organizationName = requireNotNull(name),
organizationAddress = address,
organizationIKNR = iknr
)
},
processInvoice = { totalAdditionalFee, totalBruttoAmount, currency, items ->
PkvHtmlTemplate.createPriceData(
currency = currency,
totalBruttoAmount = totalBruttoAmount,
items = items
)
},
save = { pharmacy, invoice, dispense ->
createPkvHtmlInvoiceTemplate(
patient = "TODO",
patientBirthdate = "TODO",
prescriber = "TODO",
prescribedOn = "TODO",
organization = pharmacy,
dispensedOn = dispense,
priceData = invoice
)
}
)

requireNotNull(html) { "HTML string required" }

val file = createSharableFileInCache(context, "invoices", "invoice")
writePdfFromHtml(context, "Invoice", html, file)
writePDFAttachment(file, Triple("Test123", "text/plain", attachement.toByteArray()))
sharePDFFile(context, file)
}
}

fun features() = featureToggleManager.features

fun featuresState() =
Expand Down Expand Up @@ -406,4 +353,12 @@ class DebugSettingsViewModel(
recipientCertificates = certificates
).getOrThrow()
}

fun saveInvoice(invoiceBundle: String) {
viewModelScope.launch {
val profileId = profilesUseCase.activeProfileId().first()
val bundle = Json.parseToJsonElement(invoiceBundle)
invoiceRepository.saveInvoice(profileId, bundle)
}
}
}
Loading

0 comments on commit 9b3f588

Please sign in to comment.