This module will contain a Complex Observation Handler used to store unstructured data in the form of a complex observation to any storage systems suited for the purpose. It will also provide an API for other modules to store unstructured data using a DAO that can be implemented to store this data using various storage backends. It will also provide configuration options page allowing the user to select the preferred backend that is used for storage.
Design
Image Added
Implementing the ComplexObsHandler (and ComplexNoteHandler in the future)
Code Block |
---|
language | java |
---|
title | Complex Obs Handler |
---|
|
public class UnstructuredDataHandler extends AbstractHandler implements ComplexObsHandler {
@Override
public Obs saveObs(Obs obs) throws APIException {
DocumentHandler String handlercontentType = ContextgetContentType(obs.getServicegetComplexData(UnstructuredDataService.class).getHandlergetTitle());
UnstructuredDataHandler(){
handler.initialize();
}
@Override
public Obs saveObs(Obs obs) throws APIException {
if (UnstructuredDAOUnstructuredDataHandler.getUnstructuredDAO(contentType).saveObs(obs)){
obs.setComplexData(null);
obs.setValueComplex(obs.getTitle());
} else {
throw new UnstructuredDataStorageException();
}
return handler.saveObs(obs);
}
@Override
public boolean purgeComplexData(Obs obs) {
String contentType = getContentType(obs.getComplexData().getTitle());
return handler.purgeComplexDataUnstructuredDAOUnstructuredDataHandler.getUnstructuredDAO(contentType).purgeObs(obs);
}
@Override
public Obs getObs(Obs obs, String view) {
String contentType = getContentType(obs.getComplexData().getTitle());
return handlerUnstructuredDAOUnstructuredDataHandler.getUnstructuredDAO(contentType).getObs(obs, view););
}
String getContentType(String title){
//do parsing here
}
}
|
Interfaces
Code Block |
---|
language | java |
---|
title | Unstructured Data Service Interface |
---|
|
public interface UnstructuredDataServiceUnstructuredDataHandler extends OpenMRSService {
/** To be called by interfacethe modulesComplexObsHandler/ComplexNoteHandler */
ContentHandlerUnstructuredDAO getUnstructuredDAO(String contentType);
/** To For each DAO a call to this method will be calledadded byin Unstructuredthe DAOModuleActivator classes on startupwillStart() method */
void RegisterUnstructuredDAO (String contentType, UnstructuredDAO prototype) throws AlreadyRegisteredException;
/** To For each DAO a call to this method will be calledadded byin Unstructuredthe DAOModuleActivator classeswillStop() onmethod shutdown */
void DeregisterUnstructuredDAO(String contentType);
}
|
Code Block |
---|
title | Unstructured DAO Interface |
---|
|
public interface UnstructuredDAO {
Boolean saveObs(Obs obs);
Boolean saveNote(Note note);
Boolean purgeObs(Obs obs);
Boolean purgeNote(Note note);
Note getNote(Note note);
Obs getObs(Obs obs);
} |
Status |
---|
title | This page is a work in progress |
---|
|