class IncidentService extends RecordService {

    public Incident save(ItemValuesMap itemValues) throws IOException {
        if (!itemValues.has(DATE_OF_INTERVIEW)) {
            itemValues.addStringItem(DATE_OF_INTERVIEW, getCurrentRegistrationDateAsString());
        }
        String uniqueId = generateUniqueId();
        itemValues.addStringItem(INCIDENT_DISPLAY_ID, getShortUUID(uniqueId));
        itemValues.addStringItem(INCIDENT_ID, uniqueId);
        String username = PrimeroAppConfiguration.getCurrentUser().getUsername();
        itemValues.addStringItem(MODULE, MODULE_GBV_CASE);
        itemValues.addStringItem(RECORD_OWNED_BY, username);
        itemValues.addStringItem(RECORD_CREATED_BY, username);
        itemValues.addStringItem(PREVIOUS_OWNER, username);

        Gson gson = new Gson();
        Date date = new Date(Calendar.getInstance().getTimeInMillis());
        Blob tracingBlob = new Blob(gson.toJson(itemValues.getValues()).getBytes());

        Incident incident = new Incident();
        incident.setUniqueId(uniqueId);
        incident.setShortId(getShortUUID(uniqueId));
        incident.setCreateDate(date);
        incident.setLastUpdatedDate(date);
        incident.setContent(tracingBlob);
        incident.setName(getName(itemValues));
        incident.setSurvivorCode(getSurvivorCode(itemValues));
        incident.setTypeOfViolence(getTypeOfViolence(itemValues));
        incident.setLocation(getLocation(itemValues));
        incident.setServerUrl(TextUtils.lintUrl(PrimeroAppConfiguration.getApiBaseUrl()));
        int age = itemValues.getAsInt(AGE) != null ? itemValues.getAsInt(AGE) : EMPTY_AGE;
        incident.setAge(age);
        incident.setCaregiver(getCaregiverName(itemValues));
        incident.setRegistrationDate(Utils.getRegisterDateByYyyyMmDd(itemValues.getAsString(DATE_OF_INTERVIEW)));
        incident.setCreatedBy(username);
        incident.setOwnedBy(username);
        String caseId = itemValues.has(CASE_ID) ? itemValues.getAsString(CASE_ID) : EMPTY_ID;
        incident.setCaseUniqueId(caseId);
        incidentDao.save(incident);
        return incident;
    }

    public  IncidentService();
    public  IncidentService(IncidentDao incidentDao);

}