feat: implement queue store with clinic API integration, WebSocket sync, and patient data management
This commit is contained in:
No files matched your search
+54
@@ -0,0 +1,54 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
path = r'e:\antrean operasi\web-antrean\stores\queueStore.ts'
|
||||
try:
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 1. Add import for useQueueSync at the top
|
||||
if 'useQueueSync' not in content:
|
||||
content = content.replace("import { useQueueAPI } from '@/composables/useQueueAPI';", "import { useQueueAPI } from '@/composables/useQueueAPI';\nimport { useQueueSync } from '@/composables/useQueueSync';")
|
||||
|
||||
# 2. Remove the WEBSOCKET INTEGRATION block
|
||||
ws_pattern = re.compile(r' // WEBSOCKET INTEGRATION \(CENTRALIZED\).*? const disconnectWebSocket = \(\) => \{\n disconnect\(\);\n \};', re.DOTALL)
|
||||
|
||||
content = ws_pattern.sub(' // WS and AutoSync logic extracted to composables/useQueueSync.ts', content)
|
||||
|
||||
# 3. Add the initialization right before return
|
||||
init_code = """
|
||||
// Initialize Queue Sync
|
||||
const queueSync = useQueueSync({
|
||||
allPatients,
|
||||
currentProcessingPatient,
|
||||
activeLoketInterest,
|
||||
activeClinicInterest,
|
||||
globalInterestCount,
|
||||
fetchPatientsForLoket,
|
||||
fetchPatientsForClinic,
|
||||
fetchAllPatients
|
||||
});
|
||||
|
||||
const {
|
||||
isWsConnected,
|
||||
wsClientId,
|
||||
lastGlobalCall,
|
||||
lastKlinikCall,
|
||||
initWebSocket,
|
||||
disconnectWebSocket,
|
||||
sendViaPost,
|
||||
startAutoSync,
|
||||
stopAutoSync
|
||||
} = queueSync;
|
||||
|
||||
return {
|
||||
"""
|
||||
|
||||
content = content.replace(" return {\n // State\n allPatients,", init_code + " // State\n allPatients,")
|
||||
|
||||
with open(path, 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
print("Success")
|
||||
except Exception as e:
|
||||
print("Error:", e)
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user