Commit b6343953 authored by Muhammad Kamran's avatar Muhammad Kamran

created appointment participant component

parent 0506ca9a
<!doctype html>
<html>
<head>
<title>
<fhir-appointment-participant>demo
</title>
<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-appointment-participant/fhir-appointment-participant.js"></script>
</head>
<body>
<p>
<h1>Default element without passing url</h1>
<fhir-appointment-participant></fhir-appointment-participant>
</p>
<p>
<h1>Default element without passing url but with JSON</h1>
<fhir-appointment-participant value='true'></fhir-appointment-participant>
</p>
<p>
<p>
<h1>Default element when url is passed - patient data has active:false</h1>
<fhir-appointment-participant url="http://hapi.fhir.org/baseDstu3/Appointment/2"></fhir-appointment-participant>
</p>
<p>
<h1>Default element when another url is passed - patient data has active:true</h1>
<fhir-appointment-participant url="http://hapi.fhir.org/baseDstu3/Appointment/3685978"></fhir-appointment-participant>
</p>
</body>
</html>
......@@ -61,6 +61,7 @@
<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>
<li><a href="demos/fhir-appointment-participant.html">fhir-appointment-participant</a> </li>
</ul>
<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-appointment-reference
The fhir-appointment-reference adds reference of appointment to page. It is commonly used
as a form field. It uses input type "select" and iron-ajax.It is a coded concept in FHIR and hence hard-coded into the pattern.
### Functionality
Default : shows a selectable input field for `participant status`. Options include : Accepted, Declined, Tentative, Needs Action as options. And also an actor reference
######a. GET:
- It selects and option from available select options when it receives a value. `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 `typeField` property as true or false can help show and hide this component.
######b. SET:
- A selection of option sets the value of the component used for posting purposes.
### Properties of fhir-appointment-reference
- `value`:`Array` - 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 category of allergy. Use this property to show/hide. Default: true.
### License
Mozilla Public License, v. 2.0.
### Typical Use:
- With url:
`<fhir-appointment-reference url=""></fhir-appointment-reference>`
- Without url:
`<fhir-appointment-reference></fhir-appointment-reference>`
/**
@license
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 http://mozilla.org/MPL/2.0/.
*/
/**
* `<fhir-appointment-status>` adds status of appointment to page. Uses select to choose options.
* It is a code concept in FHIR and hence hard-coded into the pattern.
* In typical use, just use `<fhir-appointment-status url=""></fhir-appointment-status>`
* @customElement
* @polymer
* @demo https://librehealth.gitlab.io/toolkit/lh-toolkit-webcomponents/demos/fhir-appointment-status.html
*
*/
import { LitElement, html } from '@polymer/lit-element/lit-element.js';
import '@material/mwc-textfield/mwc-textfield.js';
import '@lh-toolkit/fhir-reference/fhir-reference.js';
import '@polymer/iron-ajax/iron-ajax.js';
class FhirAppointmentParticipant extends LitElement {
static get properties() {
return {
/**status is a selectable option type of status. Use this property to show/hide. Default: true */
status: String,
/**reference is a selectable option type of status. Use this property to show/hide. Default: true */
reference: 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() {
super();
this.status = 'true';
this.reference = 'true';
this.value = {};
}
/**_didRender() delivers only after _render*/
_didRender() {
this.shadowRoot
.getElementById('ajax')
.addEventListener('iron-ajax-response', function(e) {
var appointmentStatus = this.parentNode.host;
if (e.detail.response.status !== undefined) {
appointmentStatus.value = e.detail.response.category;
} else {
this.parentNode.removeChild(
this.parentNode.querySelector('#appointmentStatus')
);
}
});
}
_render({ status, reference, url, value }) {
return html`
<div id="appointmentStatus">
${status !== 'false'
? html`
<label>Status:</label>
<select
class="status"
value="${this.value.status}"
on-change="${e => (this.value.status = e.target.value)}"
>
<option value="accepted">Accepted</option>
<option value="declined">Declined</option>
<option value="tentative">Tentative</option>
<option value="needs-action">Needs Action</option>
</select>
`
: ''}
${reference !== 'false'
? html`
<fhir-reference
class="reference"
value="${this.value.actor}"
on-input="${e => (this.value.actor = e.target.value)}"
></fhir-reference>
`
: ''}
</div>
<iron-ajax
id="ajax"
bubbles
auto
handle-as="json"
url="${url}"
></iron-ajax>
`;
}
}
window.customElements.define(
'fhir-appointment-participant',
FhirAppointmentParticipant
);
{
"name": "@lh-toolkit/fhir-appointment-participant",
"version": "0.0.1",
"description": "The custom element for FHIR Appointment Participant",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gitlab.com/librehealth/toolkit/lh-toolkit-webcomponents.git"
},
"license": "MPL-2.0",
"dependencies": {
"@polymer/lit-element": "^0.5.1",
"@polymer/iron-ajax": "^3.0.0-pre.19"
},
"publishConfig": {
"access": "public"
}
}
{
"name": "@lh-toolkit/fhir-reference",
"version": "0.0.1",
"description": "The custom element for FHIR allergy criticallity",
"description": "The custom element for FHIR reference",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
......
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