...
A "1.0" version of Metadata Mapping would include a MetadataService
MetadataService
within openmrs-core (could be introduced by a module initially or for the foreseeable future) and REST API endpoints to manage & search metadata mappings.
...
- Manage mappings (add or remove mappings, should support bulk operations)
- Search for mappings
- By source
- By code
- By metadata object (given an OpenmrsMetadata instance, return any associated mappings)
- Search for metadata (given a mapping UUID or source+code, return the OpenmrsMetadata instance)
API Call examples:
Fetch a location with the given source and code:
Location location = metadataService.getItem(Location.class, "SOME-SOURCE", "CODE"); //should be implemented as generic <T> getItem(T type, String source, String code);
Fetch all visit types from the given source:
List<VisitType> visitTypes = metadataService.getItems(VisitType.class, "SOME-SOURCE"); //should be implemented as generic <T> getItems(T type, String source);
Retire mapping:
List<MetadataTerm> terms = metadataService.getMetadataTerms(location);
metadataService.retireMapping(terms.get(0), "some reason");
Create term:
MetadataSource source = metadataService.getSourceByName("SOME-SOURCE");
MetadataTerm term = new MetadataTerm(source, "CODE", location);
metadataService.saveMetadataTerm(term);
Create terms in bulk:
List<MetadataTerm> terms = Arrays.asList(mapping1, mapping2, mapping3);
metadataService.saveMetadataTerms(terms);
Get mapping by source and code:
Mapping mapping = metadataService.getMapping(mappingSource, "CODE");
Get mappings by source:
List<Mapping> mappings = metadataService.getMappings(source);
Get mapping by uuid:
Mapping mapping = metadataService.getMappingByUuid(String uuid);
Get source by uuid:
MappingSource source = metadataService.getSourceByUuid(String uuid);
etc.