I am trying to create a new encounter on same page ( which works publically/without authentication)
On opening the page , server log shows following error
ERROR - JDBCExceptionReporter.logExceptions(234) |2014-06-18 02:13:33,502| Column 'creator' cannot be null
ERROR - LoggingAdvice.invoke(135) |2014-06-18 02:13:33,505| An error occurred while executing this method.
Current user: Guest (Not logged in)
Error message: could not insert: [org.openmrs.EncounterProvider]
I have set creator for encounter but couldn't make out what how should set creator for EncounterProvider
this is the code I wrote,
Encounter enc = new Encounter();
enc.setEncounterDatetime(d);
enc.setPatient(patient);
enc.setEncounterType((EncounterType)Context.getEncounterService().getEncounterType(1));
List<User> a = Context.getUserService().getAllUsers();
User u = a.get(0);
enc.setCreator(u);
enc.setProvider((EncounterRole)Context.getEncounterService().getEncounterRole(1),(Provider) Context.getProviderService().getProvider(1));
Encounter enc_formed = (Encounter)Context.getEncounterService().saveEncounter(enc);
I verified user and it getting set as Super User , also I tried to do a toString of Encounter before saveEncounter which shows following
Encounter: [(no ID) Wed Jun 18 02:13:33 IST 2014 ADULTINITIAL (no Location) 2 (no Form) num Obs: [] num Orders: 0 ]
I have following privileges on top of my controller
Context.addProxyPrivilege(PrivilegeConstants.VIEW_ENCOUNTERS);
Context.addProxyPrivilege(PrivilegeConstants.VIEW_ENCOUNTER_TYPES);
Context.addProxyPrivilege(PrivilegeConstants.VIEW_ENCOUNTER_ROLES);
Context.addProxyPrivilege(PrivilegeConstants.VIEW_PROVIDERS);
Context.addProxyPrivilege(PrivilegeConstants.VIEW_USERS);
Context.addProxyPrivilege(PrivilegeConstants.ADD_OBS);
Context.addProxyPrivilege(PrivilegeConstants.ADD_ENCOUNTERS);
can you please suggest something I could do to fix this
thanks