-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
124 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,73 @@ | ||
/** | ||
* Pinia store for handling per-variant ACMG rating. | ||
* | ||
* ## Store Dependencies | ||
* | ||
* - `caseDetailsStore` | ||
* Store for handling per-variant ACMG rating. | ||
*/ | ||
import { defineStore } from 'pinia' | ||
import { ref } from 'vue' | ||
|
||
import { StoreState } from '@/stores/misc' | ||
import { API_BASE_PREFIX } from '@/api/common' | ||
|
||
const API_BASE_URL = API_BASE_PREFIX | ||
|
||
/** Alias definition of SmallVariant type; to be defined later. */ | ||
type SmallVariant = any | ||
/** Alias definition of AcmgRating type; to be defined later. */ | ||
type AcmgRating = any | ||
|
||
export const useVariantAcmgRatingStore = defineStore('variantAcmgRating', () => { | ||
/** The current store state. */ | ||
const storeState = ref<StoreState>(StoreState.Initial) | ||
|
||
/** The small variant that acmgRating are handled for. */ | ||
const smallVariant = ref<SmallVariant | null>(null) | ||
|
||
/* The current store state. */ | ||
const storeState = ref<StoreState>(StoreState.Initial) | ||
|
||
/** The small variants ACMG rating as fetched from API. */ | ||
const acmgRating = ref<AcmgRating | null>(null) | ||
|
||
function clearData() { | ||
storeState.value = StoreState.Initial | ||
acmgRating.value = null | ||
smallVariant.value = null | ||
} | ||
|
||
const createAcmgRating = async (smallVariant: SmallVariant, acmgRating: Object) => { | ||
console.log('createAcmgRating', smallVariant, acmgRating) | ||
} | ||
const retrieveAcmgRating = async (smallVar: SmallVariant) => { | ||
// Do not re-load data if the small variant is the same | ||
if (smallVar === smallVariant.value) { | ||
return | ||
} | ||
|
||
const retrieveAcmgRating = async (smallVariant: SmallVariant) => { | ||
console.log('retrieveAcmgRating', smallVariant) | ||
} | ||
// Clear against artifact | ||
clearData() | ||
|
||
const updateAcmgRating = async (acmgRating: Object) => { | ||
console.log('updateAcmgRating', acmgRating) | ||
// Load data via API | ||
storeState.value = StoreState.Loading | ||
try { | ||
const response = await fetch(`${API_BASE_URL}acmg/?small-var=${smallVar}`, { | ||
method: 'GET' | ||
}) | ||
// const body = await response.json() | ||
acmgRating.value = response.json() | ||
smallVariant.value = smallVar | ||
storeState.value = StoreState.Active | ||
} catch (e) { | ||
console.error('There was an error loading the ACMG data.', e) | ||
clearData() | ||
storeState.value = StoreState.Error | ||
} | ||
} | ||
|
||
const deleteAcmgRating = async () => { | ||
console.log('deleteAcmgRating') | ||
const submitAcmgRating = async (smallVar: SmallVariant, payload: Object) => { | ||
// TODO: Implement the API call to submit the ACMG rating to ClinVar | ||
smallVariant.value = smallVar | ||
acmgRating.value = payload | ||
} | ||
|
||
return { | ||
smallVariant, | ||
storeState, | ||
acmgRating, | ||
clearData, | ||
createAcmgRating, | ||
retrieveAcmgRating, | ||
updateAcmgRating, | ||
deleteAcmgRating | ||
submitAcmgRating | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters