GSoD 2020 - OpenMRS REST API Documentation

Hi @saurabh

Small info for you. If you don’t get any response for a resource like conceptattribute or any other resource. Please first go to the reference application because all resources related to openMRS and values are presented in the reference app. And if there are no values there add one and try again :slightly_smiling_face:.

1 Like

yes @ayesh I will do this from now onwards .

@ayesh @burke could you provider some usecases or examples for datatype config and handler config attributes.

POST /conceptattributetype
{
  "name": "Time Span",
  "description": "This attribute type will record the time span for the concept",
  "datatypeClassname": "org.openmrs.customdatatype.datatype.LongFreeTextDatatype",
  "minOccurs": 0,
  "maxOccurs": 1,
  "datatypeConfig": "default",
  "preferredHandlerClassname": "org.openmrs.web.attribute.handler.LongFreeTextTextareaHandler",
  "handlerConfig": "dafault"
}

If I remove the handlerConfig attribute (which is optional) then this payload is correct otherwise throws this error.

@ayesh @burke I looked up some examples of concept mapping same-as, narrower-than and broader-than concept map type what do they mean contextually which concepts would Ideally use them?

Concept mappings are generally used to map between a local concept and an external concept, most often a reference (standard) terminology but sometimes concepts from other systems with which you need to Inter operate (i.e., transform data moving between systems).

The simplest use case is when the external concept is an easy match: SAME-AS; however, life is frequently not so easy and the concepts created locally and elsewhere are similar, but not identical.

If you picture a Venn diagram of concepts, something is NARROWER-THAN when it is wholly contained in the other and BROADER-THAN if it wholly contains the other concept. If two concepts overlap, but not completely, they would most like mapped through other parent concepts or not mapped at all.

Here are some examples:

The topic The concept you created The concept they created Mapping
Lung anatomy Left lung Left lower lobe of lung “Left lung” is BROADER-THAN “Left lower lobe of lung” because the left lower lobe is part of the left lung
Pneumonia (lung infection) Streptococcal pneumonia Bacterial pneumonia “Streptococcal pneumonia” is NARROWER-THAN “Bacterial pneumonia” because streptococcus is a type of bacteria
Headache Tension headache Migraine headache Not mapped together, since they are two different types of headache. They might both be mapped as NARROWER-THAN the same “Headache” concept.
1 Like

Thanks @burke

OpenMRS uses a pattern of “attributes” to allow customization of certain resources (e.g. Person Attributes, Location Attributes, Provider Attributes, Visit Attributes, and Concept Attributes). The attribute type defines the datatype and the handler provides the code capable of processing new data for that attribute. A configuration setting allows these datatypes & handlers to be re-used (configured) for different purposes.

Unfortunately, there’s little to no documentation for these interfaces in our javadocs. There’s a small clue in BaseAttributeType.getHandlerConfig():

the configuration to be passed to the handler for a datatype. For example if the datatype is “regex-validated-string”, the handlerConfig would be the regular expression.

The LongFreeTextDatatype does not support any configuration, so the

"datatypeConfig": "default"

has no effect and could be omitted for this datatype. If you want an example of configuring a custom datatype, you’d need to use a different custom datatype like RegexValidatedTextDatatype.

The problem you are running into is because

"handlerConfig": "dafault"

does not match the configuration expected by LongFreeTextTextareaHandler, which appears to expect a map of rows and cols serialized using the system’s default serializer.

1 Like

@ayesh @burke I read more from the code snippets,

  1. if we dont pass any handler it runs into null checks and dosent gets inside but what is default for LongFreeTextDatatype mapped to here (I dont know much about handlers but default sounds legit to me it should be mapped to something default which doesnt result in an error, maybe )? but I have removed that attribute from the example and it works fine.

  2. what would be the dataTypeConfig for RegexValidatedTextDataType, can we pass in a default value there also , does it have any defaultHandler ?

A magic value of the literal string “default” is not needed. A handler would expect to exhibit default behavior if not given any configuration (i.e., configuration is null). In the code you linked, rows & cols default to 5 & 72, respectively.

The regex datatype is designed to implement a string that follows a pattern defined by a regular expression. There is no default pattern, so a configuration is required for it to function. For an example, you could use a simple pattern, like \d{3,12} to require 3 to 12 digits.

1 Like

@ayesh my changes to concept-map type subresource arent visible on the hosted rest.openmrs.org even after you merged my changes. do I need to make a PR again ?

@ayesh @burke

{
            "uuid": "7a2cf354-d520-354d-b0f3-34613677a2ff",
            "display": "SNOMED CT: 186201000",
            "name": null,
            "conceptSource": {
                "uuid": "1ADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
                "display": "SNOMED CT",
                "name": "SNOMED CT",
                "description": "SNOMED Preferred mapping",
                "hl7Code": "SCT",
                "retired": false,
                "uniqueId": null,
                "links": [
                    {
                        "rel": "self",
                        "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/conceptsource/1ADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
                    },
                    {
                        "rel": "full",
                        "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/conceptsource/1ADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD?v=full"
                    }
                ],
                "resourceVersion": "2.1"
            },
            "description": null,
            "code": "186201000",
            "version": null,
            "retired": false,
            "auditInfo": {
                "creator": {
                    "uuid": "45ce6c2e-dd5a-11e6-9d9c-0242ac150002",
                    "display": "admin",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/user/45ce6c2e-dd5a-11e6-9d9c-0242ac150002"
                        }
                    ]
                },
                "dateCreated": "2010-04-25T00:00:00.000+0000",
                "changedBy": {
                    "uuid": "45ce6c2e-dd5a-11e6-9d9c-0242ac150002",
                    "display": "admin",
                    "links": [
                        {
                            "rel": "self",
                            "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/user/45ce6c2e-dd5a-11e6-9d9c-0242ac150002"
                        }
                    ]
                },
                "dateChanged": null
            },
            "links": [
                {
                    "rel": "self",
                    "uri": "http://demo.openmrs.org/openmrs/ws/rest/v1/conceptreferenceterm/7a2cf354-d520-354d-b0f3-34613677a2ff"
                }
            ],
            "resourceVersion": "1.9"
        }

  1. The name field in almost all the examples is null, ideally what should it be for ex, for code:274663001 as Acute Pain or will it be identical to the display field for the reference term type?
  2. There is no description for this concept-reference term type, will the concept-data type be equal to the desired value according to the code? in that case what would be the apt datatype for ex. acute pain?

When mapping to reference terminologies (e.g., SNOMED, LOINC, ICD10, etc) we often just have the code within that reference terminology. For example, the Acute pain concept is mapped to SNOMED-CT 274663001 (name & description from SNOMED-CT is not copied into the mapping).

I don’t know what you mean by a concept reference term type. Reference terms are links to codes within external (often standardized/reference) terminologies. We link to the reference term by its code, but do not try to represent full detail of the reference term within OpenMRS (just reference it).

1 Like

Ok thats why names are null , but @burke if we want to specify the name for the response I pasted above will it be Acute pain? or is it better to leave it null while creating a new reference term.

Actually I meant concept reference term and it has a attribute description which expects a string (I am not sure if it is generalised to string or it should be concept-datatype) while creating a concept reference term what should this attribute be assigned. with the description I think it should be a concept-datatype.

There’s no harm in including the name, especially in an example, to make it clearer what you’re doing. But it might be worth letting people know it’s optional & often omitted (e.g., in CIEL mappings).

The description is meant for a human readable description of the term, so it’s just a string. While this could be included from a reference terminology or another dictionary when mapping to another OpenMRS dictionary, the field is typically not used as far as I know.

1 Like

Thanks @burke

@burke this description of the parameter “description” isnt correct then? reading this I thought it must be a concept -datatype.

Correct, it’s incorrect.

2 Likes

@ayesh @burke Should I replace these attribute type to concept class and concept-source instead of general string or will it be technically incorrect to do so since its not expecting an object but rather its name ?

Hi @saurabh It’s just the type that the endpoint returns ut I think the description is enough for developers to get an idea,

1 Like

Hi, @saurabh I merged two of your latest PR’s it looks great.

Btw when can we expect to talk with developers to get the feedback?

Let me know I can ask from a few developers to help us

I see the resources we wanted to cover is almost done :slightly_smiling_face:

1 Like