private DeviceMetric initializeDeviceMetric(Device d) {
    log("Initializing device metric");

    DeviceMetric metric = new DeviceMetric();
    CodeableConceptDt metricType = new CodeableConceptDt();
    // TODO is this the right code and display?
    metricType
        .addCoding()
        .setCode("160020")
        .setSystem("https://rtmms.nist.gov")
        .setDisplay("MDC_CONC_GLU_GEN");
    metric.setType(metricType);
    metric.setSource(newResourceReference(d.getId()));
    metric.setText(getNarrative(metric));
    metric.setCategory(DeviceMetricCategoryEnum.MEASUREMENT);
    CodeableConceptDt unitConcept = new CodeableConceptDt();
    unitConcept
        .addCoding()
        .setDisplay("MDC_DIM_MILLI_MOLE_PER_L")
        .setSystem("https://rtmms.nist.gov")
        .setCode("266866");
    metric.setUnit(unitConcept);
    // TODO what is the identifier here??? especially the value
    metric.setIdentifier(
        new IdentifierDt().setSystem(SYSTEM_URL + "/metric/").setValue("glucosemillimolperliter"));

    log("Initializing device metric done.");
    return metric;
  }
 public void addFHIRCoding(
     CodeableConceptDt codeableConcept, String code, String system, String display) {
   CodingDt coding = codeableConcept.addCoding();
   coding.setCode(code);
   coding.setSystem(system);
   coding.setDisplay(display);
 }
  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;
  }
 public CodeableConceptDt addTRCodingOrDisplay(Concept concept) {
   CodeableConceptDt codeableConceptDt = addTRCoding(concept);
   if (CollectionUtils.isEmpty(codeableConceptDt.getCoding())) {
     CodingDt coding = codeableConceptDt.addCoding();
     coding.setDisplay(concept.getName().getName());
   }
   return codeableConceptDt;
 }
 public CodeableConceptDt getTRValueSetCodeableConcept(
     Concept concept, String valueSetURL, CodeableConceptDt codeableConcept) {
   CodingDt coding = codeableConcept.addCoding();
   if (null != idMappingsRepository.findByInternalId(concept.getUuid())) {
     coding.setCode(getTRValueSetCode(concept));
     coding.setSystem(valueSetURL);
   }
   coding.setDisplay(concept.getName().getName());
   return codeableConcept;
 }
  private CodeableConceptDt createCode(int unit) {
    log("get code done");
    CodeableConceptDt codeableConceptDt = new CodeableConceptDt();
    CodingDt coding = new CodingDt();

    String code = "", display = "";
    switch (unit) {
      case GlucoseRecord.UNIT_kgpl:
        code = "2339-0";
        display = "Glucose [Mass/volume] in Blood";
        break;
      case GlucoseRecord.UNIT_molpl:
        code = "15074-8";
        display = "Glucose [Moles/volume] in Blood";
        break;
    }

    codeableConceptDt.addCoding().setSystem("http://loinc.org").setCode(code).setDisplay(display);
    log("get code done");
    return codeableConceptDt;
  }