private Device initializeDevice(Patient p) {
    log("Initializing device");

    Device d = newDevice();
    d.setManufacturer(deviceInfo.getManufacturerName());
    d.setModel(deviceInfo.getModelNumber());
    d.setVersion(deviceInfo.getFirmwareRevision());
    NarrativeDt n = getNarrative(d);
    n.setDiv(
        n.getDiv()
            .getValueAsString()
            .substring(5, n.getDiv().getValueAsString().length() - 6)
            .concat("<strong>Serial Number: </strong>")
            .concat(deviceInfo.getSerialNumber())
            .concat("<br /><strong>Name: </strong>")
            .concat(deviceInfo.getName())
            .concat("<br /><strong>MAC Address: </strong>")
            .concat(deviceInfo.getAddress()));
    d.setText(n);
    CodeableConceptDt type = new CodeableConceptDt();
    // TODO find valid url
    type.addCoding()
        .setCode("15-102")
        .setDisplay("Glukose-Analysegerät")
        .setSystem("http://umdns.org");
    d.setType(type);

    d.setPatient(newResourceReference(p.getId()));
    d.setIdentifier(Arrays.asList(getIdentifier("/devices/", "" + deviceInfo.getSysID())));

    log("Initializing device done");

    return d;
  }