...
Code Block |
---|
language | java |
---|
title | Complex Obs Handler |
---|
|
package org.openmrs.module.shr.unstructureddata.obs.handler;
import java.io.IOException;
import org.openmrs.Obs;
import org.openmrs.api.APIException;
import org.openmrs.api.context.Context;
import org.openmrs.module.shr.unstructureddata.dao.handler.UnstructuredDAOHandler;
import org.openmrs.module.shr.unstructureddata.dao.handler.UnstructuredDAOService;
import org.openmrs.obs.ComplexData;
import org.openmrs.obs.ComplexObsHandler;
import org.openmrs.obs.handler.AbstractHandler;
public class UnstructuredDataHandler extends AbstractHandler implements ComplexObsHandler {
@Override
public Obs saveObs(Obs obs) throws APIException {
String contentType = getContentType(obs.getComplexData().getTitle());
if (UnstructuredDAOHandler String key = obs.getUuid();
if (Context.getService(UnstructuredDAOService.class).getUnstructuredDAO(contentType).saveObssaveObject(key, obs.getComplexData().getData())){
obs.setComplexData(null);
obs.setValueComplex(obs.getComplexData().getTitle());
} else {
throw new IOException();
}
}
return obs;
}
@Override
@Override
public boolean purgeComplexData(Obs obs) {
String contentType = getContentType(obs.getComplexData().getTitle());
return UnstructuredDAOHandler
String key = obs.getUuid();
return Context.getService(UnstructuredDAOService.class).getUnstructuredDAO(contentType).purgeObspurgeObject(obskey);
}
@Override
public Obs getObs(Obs obs, String view) {
String contentType = getContentType(obs.getComplexData().getTitle());
return UnstructuredDAOHandler
String key = obs.getUuid();
ComplexData complexData = new ComplexData(obs.getComplexData().getTitle(), Context.getService(UnstructuredDAOService.class).getUnstructuredDAO(contentType).getObs(obsgetObject(key));
obs.setComplexData(complexData);
return obs;
}
String getContentType(String title){
return null;
//do parsing here
return null;
}
}
|
Service
Code Block |
---|
language | java |
---|
title | Unstructured Data Service Interface |
---|
|
package org.openmrs.module.shr.unstructureddata.api;
import org.openmrs.api.OpenmrsService;
import org.openmrs.module.shr.unstructureddata.dao.UnstructuredDAO;
import org.openmrs.module.shr.unstructureddata.exception.AlreadyRegisteredException;
public interface UnstructuredDAOService extends UnstructuredDataHandlerOpenmrsService {
/** To be called by the ComplexObsHandler/ComplexNoteHandler */
UnstructuredDAO getUnstructuredDAO(String contentType);
/** For each DAO a call to this method will be added in the ModuleActivator willStart() method */
void RegisterUnstructuredDAO (String contentType, UnstructuredDAO prototype) throws AlreadyRegisteredException;
/** For each DAO a call to this method will be added in the ModuleActivator willStop() method */
void DeregisterUnstructuredDAO(String contentType);
}
|
Interfaces
Code Block |
---|
title | Unstructured DAO Interface |
---|
|
package org.openmrs.module.shr.unstructureddata.dao;
public interface UnstructuredDAO {
Boolean saveObs(Obs obssaveObject(String key, Object value);
Boolean saveNote(Note note);
Boolean purgeObs(Obs obs);
Boolean purgeNote(Note note);
Note getNote(Note note);
Obs getObs(Obs obs);
}
Object getObject(String key);
Boolean purgeObject(String key);
}
|
Status |
---|
title | This page is a work in progress |
---|
|