Class ObservationMapping

java.lang.Object
com.framed.interop.mapping.ObservationMapping

public final class ObservationMapping extends Object
Bidirectional mapping between FRAMED channels and CodedConcepts, loaded from a JSON file.

Keys are channel identifiers in one of two forms, resolved most-specific first:

  • "<className>.<deviceID>.<channelID>" — device-specific
  • "<className>.<channelID>" — applies to any device

The reverse index (code -> channel) is used for inbound HL7: a received observation's code is mapped back to the FRAMED channel coordinates it should be published under.

  • Method Details

    • load

      public static ObservationMapping load(Path path) throws IOException
      Loads a mapping from the given JSON file.
      Parameters:
      path - path to the mapping JSON (object of channelKey -> concept)
      Returns:
      the loaded mapping
      Throws:
      IOException - if the file cannot be read
    • fromJson

      public static ObservationMapping fromJson(org.json.JSONObject json)
      Builds a mapping from an already-parsed JSON object (testing-friendly).
      Parameters:
      json - object of channelKey -> { code, system, display, unit, valueType, mdc, kind } (mdc and kind are optional, see CodedConcept)
      Returns:
      the constructed mapping
    • lookup

      public Optional<CodedConcept> lookup(String className, String deviceID, String channelID)
      Looks up the concept for a FRAMED channel, most-specific key first.
      Parameters:
      className - the channel's class name
      deviceID - the producing device id
      channelID - the channel id
      Returns:
      the concept, or empty if the channel is not mapped
    • channelForCode

      public Optional<ObservationMapping.Channel> channelForCode(String code)
      Reverse-maps an incoming code to the FRAMED channel it should be published under.
      Parameters:
      code - the observation code (e.g. LOINC)
      Returns:
      the channel coordinates, or empty if the code is unknown
    • size

      public int size()
      Returns:
      the number of mapped channels.