diff --git a/backend/app/api/internal/endpoints/remote.py b/backend/app/api/internal/endpoints/remote.py index 45f9d8d8..590eb6d9 100644 --- a/backend/app/api/internal/endpoints/remote.py +++ b/backend/app/api/internal/endpoints/remote.py @@ -178,9 +178,6 @@ async def cnv_acmg(request: Request): data={"chromosome": chromosome, "start": start, "end": end, "func": func, "error": 0}, ) backend_resp = await client.send(backend_req) - if backend_resp.status_code != 200: - return Response(status_code=backend_resp.status_code, content=backend_resp.content) - if backend_resp.status_code != 200: return Response(status_code=backend_resp.status_code, content=backend_resp.content) return JSONResponse(backend_resp.json()) diff --git a/frontend/src/components/SeqvarDetails/ClinsigCard.vue b/frontend/src/components/SeqvarDetails/ClinsigCard.vue index 35ace805..ca73882e 100644 --- a/frontend/src/components/SeqvarDetails/ClinsigCard.vue +++ b/frontend/src/components/SeqvarDetails/ClinsigCard.vue @@ -23,6 +23,7 @@ import { import { type Seqvar } from '@/lib/genomicVars' import { StoreState } from '@/stores/misc' import { useSeqvarAcmgRatingStore } from '@/stores/seqvarAcmgRating' +import { useUserStore } from '@/stores/user' /** Data type used for component's props. */ interface Props { @@ -41,6 +42,9 @@ const emit = defineEmits<{ /** Store to use for ACMG ratings of sequence variants. */ const acmgRatingStore = useSeqvarAcmgRatingStore() +/** Store for user data. */ +const userStore = useUserStore() + /** Component state: error message to display, if any. */ const errorMessage = ref('') /** Component state: whether to enable summary view. */ @@ -172,6 +176,7 @@ watch( /** Fetch ACMG rating when mounted. */ onMounted(async () => { + userStore.initialize() if (props.seqvar?.genomeBuild === 'grch37') { const seqvar = props.seqvar // so that it is not undefined in the async function await tryCatchEmitErrorDisplay(async () => await acmgRatingStore.fetchAcmgRating(seqvar)) @@ -257,6 +262,7 @@ onMounted(async () => { @@ -268,6 +274,7 @@ onMounted(async () => { variant="text" rounded="sm" prepend-icon="mdi-cloud-upload-outline" + :disabled="!userStore.isAuthenticated" @click="() => saveAcmgRating()" > Save to Server @@ -277,6 +284,7 @@ onMounted(async () => { variant="text" rounded="sm" prepend-icon="mdi-cloud-download-outline" + :disabled="!userStore.isAuthenticated" @click="() => refetchAcmgRatingServer()" > Load from Server @@ -286,6 +294,7 @@ onMounted(async () => { variant="text" rounded="sm" prepend-icon="mdi-cloud-remove-outline" + :disabled="!userStore.isAuthenticated" @click="() => deleteAcmgRating()" > Delete from Server diff --git a/frontend/src/components/SeqvarDetails/ClinsigCard/SummarySheet.vue b/frontend/src/components/SeqvarDetails/ClinsigCard/SummarySheet.vue index 388afe03..e945d765 100644 --- a/frontend/src/components/SeqvarDetails/ClinsigCard/SummarySheet.vue +++ b/frontend/src/components/SeqvarDetails/ClinsigCard/SummarySheet.vue @@ -3,11 +3,13 @@ import { classColor } from '@/lib/utils' interface Props { calculatedAcmgClass?: string + interVarAvailable?: boolean } // eslint-disable-next-line @typescript-eslint/no-unused-vars const props = withDefaults(defineProps(), { - calculatedAcmgClass: 'N/A' + calculatedAcmgClass: 'N/A', + interVaravailable: false }) const emit = defineEmits(['clearAll', 'resetToAuto']) @@ -38,6 +40,7 @@ const emit = defineEmits(['clearAll', 'resetToAuto']) variant="text" rounded="sm" prepend-icon="mdi-file-restore-outline" + :disabled="!interVarAvailable" @click="emit('resetToAuto')" > Reset to InterVar diff --git a/frontend/src/stores/seqvarAcmgRating.ts b/frontend/src/stores/seqvarAcmgRating.ts index 38eba2e4..9852731b 100644 --- a/frontend/src/stores/seqvarAcmgRating.ts +++ b/frontend/src/stores/seqvarAcmgRating.ts @@ -10,6 +10,7 @@ import { InterVarClient } from '@/api/intervar' import { ALL_ACMG_CRITERIA, AcmgCriteria, + AcmgEvidenceLevel, MultiSourceAcmgCriteriaState, Presence, StateSource @@ -98,6 +99,9 @@ export const useSeqvarAcmgRatingStore = defineStore('seqvarAcmgRating', () => { // Load data from InterVar via API storeState.value = StoreState.Loading + // Set the variant + seqvar.value = seqvar$ + // Fetch the ACMG rating from InterVar try { const client = new InterVarClient() @@ -232,7 +236,7 @@ export const useSeqvarAcmgRatingStore = defineStore('seqvarAcmgRating', () => { throw new Error('Cannot save ACMG rating without a variant.') } const seqvarImpl = seqvarImplFromSeqvar(seqvar.value) - const acmgRating = transformAcmgRating() + const acmgRatingServer = transformAcmgRating() try { const acmgSeqvarClient = new AcmgSeqVarClient() @@ -242,9 +246,23 @@ export const useSeqvarAcmgRatingStore = defineStore('seqvarAcmgRating', () => { acmgSeqvar.detail !== 'ACMG Sequence Variant not found' && acmgSeqvar.detail !== 'Not Found' ) { - await acmgSeqvarClient.updateAcmgRating(seqvarImpl, acmgRating) + await acmgSeqvarClient.updateAcmgRating(seqvarImpl, acmgRatingServer) } else { - await acmgSeqvarClient.saveAcmgRating(seqvarImpl, acmgRating) + await acmgSeqvarClient.saveAcmgRating(seqvarImpl, acmgRatingServer) + } + // Go through the data and setPresense for each criteria + for (const criteria of acmgRatingServer.criterias) { + const criteriaKey = criteria.criteria as keyof typeof AcmgCriteria + acmgRating.value.setPresence( + StateSource.Server, + AcmgCriteria[criteriaKey], + criteria.presence as Presence + ) + acmgRating.value.setEvidenceLevel( + StateSource.Server, + AcmgCriteria[criteriaKey], + criteria.evidence as AcmgEvidenceLevel + ) } acmgRatingStatus.value = true } catch (e) { @@ -266,6 +284,10 @@ export const useSeqvarAcmgRatingStore = defineStore('seqvarAcmgRating', () => { try { const acmgSeqvarClient = new AcmgSeqVarClient() await acmgSeqvarClient.deleteAcmgRating(seqvarImpl) + // Go through the data and setPresense for each criteria + for (const criteria of ALL_ACMG_CRITERIA) { + acmgRating.value.setPresence(StateSource.Server, criteria, Presence.Unknown) + } acmgRatingStatus.value = false } catch (e) { throw new Error(`There was an error deleting the ACMG data: ${e}`)