|
1 | 1 | use chrono::Utc;
|
2 | 2 | use repository::{
|
3 |
| - Document, DocumentFilter, DocumentRegistry, DocumentRegistryCategory, DocumentRegistryFilter, |
4 |
| - DocumentRegistryRepository, DocumentRepository, DocumentStatus, EqualFilter, Pagination, |
5 |
| - ProgramFilter, ProgramRepository, ProgramRow, RepositoryError, StringFilter, TransactionError, |
| 3 | + Document, DocumentRegistry, DocumentRegistryCategory, DocumentRegistryFilter, |
| 4 | + DocumentRegistryRepository, DocumentStatus, EqualFilter, PatientFilter, PatientRepository, |
| 5 | + ProgramFilter, ProgramRepository, ProgramRow, RepositoryError, TransactionError, |
6 | 6 | };
|
7 | 7 |
|
8 | 8 | use crate::{
|
9 | 9 | document::{document_service::DocumentInsertError, is_latest_doc, raw_document::RawDocument},
|
10 |
| - programs::patient::{main_patient_doc_name, patient_doc_name}, |
| 10 | + programs::patient::patient_doc_name, |
11 | 11 | service_provider::{ServiceContext, ServiceProvider},
|
12 | 12 | };
|
13 | 13 |
|
@@ -133,15 +133,13 @@ fn validate_patient_exists(
|
133 | 133 | ctx: &ServiceContext,
|
134 | 134 | patient_id: &str,
|
135 | 135 | ) -> Result<bool, RepositoryError> {
|
136 |
| - let doc_name = main_patient_doc_name(patient_id); |
137 |
| - let document = DocumentRepository::new(&ctx.connection) |
138 |
| - .query( |
139 |
| - Pagination::one(), |
140 |
| - Some(DocumentFilter::new().name(StringFilter::equal_to(&doc_name))), |
| 136 | + let patient = PatientRepository::new(&ctx.connection) |
| 137 | + .query_by_filter( |
| 138 | + PatientFilter::new().id(EqualFilter::equal_to(patient_id)), |
141 | 139 | None,
|
142 | 140 | )?
|
143 | 141 | .pop();
|
144 |
| - Ok(document.is_some()) |
| 142 | + Ok(patient.is_some()) |
145 | 143 | }
|
146 | 144 |
|
147 | 145 | fn validate_program_not_exists(
|
|
0 commit comments