Commit 13288a9f authored by Muhammad Kamran's avatar Muhammad Kamran

created reference component

parent f996eaa8
<!doctype html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
<script type="module" src="../node_modules/@lh-toolkit/fhir-reference/fhir-reference.js"></script>
<h1>Default element without passing url</h1>
<h1>Default element without passing url but with JSON</h1>
<fhir-reference value="high"></fhir-reference>
<h1>Default element when url is passed</h1>
<fhir-reference url=""></fhir-reference>
......@@ -60,6 +60,7 @@
<li><a href="demos/fhir-appointment-status.html">fhir-appointment-status</a> </li>
<li><a href="demos/fhir-instant.html">fhir-instant</a> </li>
<li><a href="demos/fhir-positiveInt.html">fhir-positiveInt</a> </li>
<li><a href="demos/fhir-reference.html">fhir-reference</a> </li>
<h6>*If you don't see the elements after clicking on the link, you probably forgot
to do: <code>lerna bootstrap --use-workspaces</code></h6>
# fhir-reference
The fhir-reference adds reference object. It is commonly used
as a form field. It uses input type text for reference and display name. and iron-ajax.
### Functionality
Default : shows an input field for the display name and the reference of the actor.
######a. GET:
- It selects an value from the text entered into the input fields. `value` can be passed as a string.
- It can also receive value from a 'url' which can be passed as property "url". The `reference` key value is checked for in key-value pair of data.
- If it does not receive any matching value, it shows blank.
- Setting `reference` property as true or false can help show and hide this component.
######b. SET:
### Properties of fhir-reference
- `value`:`Object` - used to take the input value of each field.
- `url`:`String` - used to make AJAX call to FHIR resource. Default: null.
- `typeField`:`String` - selectable option critical nature of allergy. Use this property to show/hide. Default: true.
### License
Mozilla Public License, v. 2.0.
### Typical Use:
- With url:
`<fhir-reference url=""></fhir-reference>`
- Without url:
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at
* `<fhir-reference>` adds critically of allergy to page to select from code if the critical nature of occurrence was low/moderate/high.
* Uses select to choose options.
* In typical use, just use `<fhir-reference url=""></fhir-reference>`
* @customElement
* @polymer
* @demo
import { LitElement, html } from '@polymer/lit-element/lit-element.js';
import '@material/mwc-textfield/mwc-textfield.js';
import '@polymer/iron-ajax/iron-ajax.js';
class FhirReference extends LitElement {
static get properties() {
return {
/**reference is a string. Use this property to show/hide. Default: true */
reference: String,
/**display is a string. Use this property to show/hide. Default: true */
display: String,
/**url is used to make AJAX call to FHIR resource. Default: null */
url: String,
/**value is used to take the input value of each field*/
value: Object
/**default value of properties set in constructor*/
constructor() {
this.reference = 'true';
this.display = 'true';
this.value = {};
/**_didRender() delivers only after _render*/
_didRender() {
.addEventListener('iron-ajax-response', function(e) {
var ref =;
if (e.detail.response.criticality !== undefined) {
ref.value = e.detail.response.reference;
} else {
_render({ reference, display, url, value }) {
return html`
<div id="referenceDiv">
${reference !== 'false'
? html`
on-input="${e =>
(this.value.reference =}"
: ''}
${display !== 'false'
? html`
on-input="${e => (this.value.display =}"
><br />
: ''}
window.customElements.define('fhir-reference', FhirReference);
"name": "@lh-toolkit/fhir-reference",
"version": "0.0.1",
"description": "The custom element for FHIR allergy criticallity",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"repository": {
"type": "git",
"url": ""
"license": "MPL-2.0",
"dependencies": {
"@polymer/lit-element": "^0.5.1",
"@polymer/iron-ajax": "^3.0.0-pre.19"
"publishConfig": {
"access": "public"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment