Skip to content

Commit 379dffd

Browse files
committed
added more changes
1 parent 5673c71 commit 379dffd

File tree

4 files changed

+98
-17
lines changed

4 files changed

+98
-17
lines changed

api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirBatchDaoImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams
3333
case FhirConstants.ENCOUNTER_TYPE_REFERENCE_SEARCH_HANDLER:
3434
entry.getValue()
3535
.forEach(param -> handleAndListParam((TokenAndListParam) param.getParam(),
36-
t -> Optional.of(eq("et.uuid", t.getValue())))
37-
.ifPresent(t -> criteria.createAlias("encounterType", "et").add(t)));
36+
t -> Optional.of(eq("bh.uuid", t.getValue()))));
37+
3838
break;
3939
}
4040
});

api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirBatchServiceImpl.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,43 @@
1515
import lombok.Getter;
1616
import lombok.Setter;
1717
import org.hl7.fhir.r4.model.Bundle;
18-
import org.openmrs.BaseOpenmrsData;
1918
import org.openmrs.module.fhir2.FhirConstants;
2019
import org.openmrs.module.fhir2.api.FhirBatchService;
21-
import org.openmrs.module.fhir2.api.dao.FhirDao;
20+
import org.openmrs.module.fhir2.api.dao.FhirBatchDao;
21+
import org.openmrs.module.fhir2.api.search.SearchQuery;
22+
import org.openmrs.module.fhir2.api.search.SearchQueryInclude;
2223
import org.openmrs.module.fhir2.api.search.param.SearchParameterMap;
23-
import org.openmrs.module.fhir2.api.translators.OpenmrsFhirTranslator;
24+
import org.openmrs.module.fhir2.api.translators.BatchTranslator;
25+
import org.openmrs.module.fhir2.model.FhirBatch;
26+
import org.springframework.beans.factory.annotation.Autowired;
2427
import org.springframework.stereotype.Component;
2528
import org.springframework.transaction.annotation.Transactional;
2629

2730
@Component
2831
@Transactional
2932
@Setter(AccessLevel.PACKAGE)
3033
@Getter(AccessLevel.PROTECTED)
31-
public class FhirBatchServiceImpl extends BaseFhirService<Bundle, org.openmrs.BaseOpenmrsData> implements FhirBatchService {
34+
public class FhirBatchServiceImpl extends BaseFhirService<Bundle, FhirBatch> implements FhirBatchService {
35+
36+
@Autowired
37+
private FhirBatchDao dao;
38+
39+
@Autowired
40+
private SearchQueryInclude<Bundle> searchQueryInclude;
41+
42+
@Autowired
43+
private BatchTranslator translator;
44+
45+
@Autowired
46+
private SearchQuery<FhirBatch, Bundle, FhirBatchDao, BatchTranslator, SearchQueryInclude<Bundle>> searchQuery;
47+
3248

3349
@Override
3450
public IBundleProvider searchBatches(TokenAndListParam identifier, TokenAndListParam batchType) {
3551
SearchParameterMap theParams = new SearchParameterMap()
3652
.addParameter(FhirConstants.OPENMRS_FHIR_EXT_BATCH_IDENTIFIER, identifier)
3753
.addParameter(FhirConstants.ENCOUNTER_TYPE_REFERENCE_SEARCH_HANDLER, batchType);
3854

39-
return null;
40-
}
41-
42-
@Override
43-
protected FhirDao<BaseOpenmrsData> getDao() {
44-
return null;
45-
}
46-
47-
@Override
48-
protected OpenmrsFhirTranslator<BaseOpenmrsData, Bundle> getTranslator() {
49-
return null;
55+
return searchQuery.getQueryResults(theParams, dao, translator, searchQueryInclude);
5056
}
5157
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.openmrs.module.fhir2.api.translators;
2+
3+
import org.hl7.fhir.r4.model.Bundle;
4+
import org.hl7.fhir.r4.model.DiagnosticReport;
5+
import org.openmrs.Order;
6+
import org.openmrs.module.fhir2.api.translators.ToFhirTranslator;
7+
import org.openmrs.module.fhir2.model.FhirBatch;
8+
import org.openmrs.module.fhir2.model.FhirDiagnosticReport;
9+
10+
import javax.annotation.Nonnull;
11+
12+
public interface BatchTranslator extends OpenmrsFhirUpdatableTranslator<FhirBatch, Bundle> {
13+
14+
/**
15+
* Maps a {@link Order} to a {@link Bundle}
16+
*
17+
* @param fhirBatch the FhirBatch object to translate
18+
* @return the corresponding FHIR Bundle
19+
*/
20+
@Override
21+
Bundle toFhirResource(@Nonnull FhirBatch fhirBatch);
22+
23+
/**
24+
* Maps {@link Bundle} to {@link FhirBatch}
25+
*
26+
* @param bundle the FHIR batch to translate
27+
* @return the corresponding OpenMRS FhirBatch
28+
*/
29+
@Override
30+
FhirBatch toOpenmrsType(@Nonnull Bundle bundle);
31+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.openmrs.module.fhir2.api.translators.impl;
2+
3+
import org.hl7.fhir.r4.model.Bundle;
4+
import org.hl7.fhir.r4.model.DiagnosticReport;
5+
import org.openmrs.Concept;
6+
import org.openmrs.Obs;
7+
import org.openmrs.module.fhir2.FhirConstants;
8+
import org.openmrs.module.fhir2.api.translators.BatchTranslator;
9+
import org.openmrs.module.fhir2.model.FhirBatch;
10+
import org.openmrs.module.fhir2.model.FhirDiagnosticReport;
11+
12+
import javax.annotation.Nonnull;
13+
14+
import static org.apache.commons.lang3.Validate.notNull;
15+
16+
public class BatchTranslatorImpl implements BatchTranslator {
17+
18+
@Override
19+
public Bundle toFhirResource(@Nonnull FhirBatch fhirBatch) {
20+
notNull(fhirBatch, "The batch operation should not be null");
21+
22+
Bundle bundle = new Bundle();
23+
24+
bundle.setId(fhirBatch.getUuid());
25+
26+
if (fhirBatch.getDateChanged() != null) {
27+
bundle.getMeta().setLastUpdated(fhirBatch.getDateChanged());
28+
} else {
29+
bundle.getMeta().setLastUpdated(fhirBatch.getDateCreated());
30+
}
31+
32+
return bundle;
33+
}
34+
35+
@Override
36+
public FhirBatch toOpenmrsType(@Nonnull Bundle bundle) {
37+
return toOpenmrsType(new FhirBatch(), bundle);
38+
}
39+
40+
@Override
41+
public FhirBatch toOpenmrsType(@Nonnull FhirBatch existingObject, @Nonnull Bundle resource) {
42+
return null;
43+
}
44+
}

0 commit comments

Comments
 (0)