Skip to content

Commit

Permalink
Merge pull request #279 from IHTSDO/ValueSetUrlSupport
Browse files Browse the repository at this point in the history
Add ValueSet based code selection to Module Builder UI
  • Loading branch information
jawalonoski authored Aug 18, 2020
2 parents bf51743 + a8fde3f commit db7d0ef
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 38 deletions.
20 changes: 19 additions & 1 deletion src/components/editor/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,28 @@ import { getTemplate } from '../../templates/Templates';
type Props = {
code: CodeType,
system: string,
onChange: any
onChange: any,
value_set: string
}

export class Code extends Component<Props> {

checkValueSetKey() {
if(this.props.code.value_set) {
return (
<div>
Value Set (Optional): <RIEInput className='editable-text' value={this.props.code.value_set} propName="value_set" change={this.props.onChange('value_set')} />
</div>
);
}else {
return (
<div>
Value Set (Optional): <RIEInput className='editable-text' value="" propName="value_set" change={this.props.onChange('value_set')} />
</div>
);
}
}

render() {
let code = this.props.code;
let system = this.props.system;
Expand All @@ -25,6 +42,7 @@ export class Code extends Component<Props> {
Code: <RIEInput className='editable-text' value={code.code} propName="code" change={this.props.onChange('code')} />
<br />
Display: <RIEInput className='editable-text' value={code.display} propName="display" change={this.props.onChange('display')} />
{this.checkValueSetKey()}
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/editor/Code.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { renderComponent , expect } from '../../helpers/test_helper';

import { Code, Codes } from './Code';

const codes = [{system:"RxNorm", code: '1234', display:'none'},
const codes = [{system:"RxNorm", code: '1234', display:'none', value_set: 'http://snomed.info/sct?fhir_vs=ecl/<<404684003:363698007=<<66019005&filter=ilium'},
{system:"SNOMED", code: '5678', display:'none'}]

const onChange = () => () => onChange;
Expand Down
68 changes: 34 additions & 34 deletions src/components/editor/State.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ class StateEditor extends Component<Props> {
<div className='Editor-panel-title'>
State Editor
</div>
<h3><RIEInput className='editable-text' className='editable-text' propName={'name'} value={this.props.state.name} change={this.props.renameNode} /></h3>
State Type: <RIESelect className='editable-text' className='editable-text' value={{id: this.props.state.type, text: this.props.state.type}} propName='type'change={this.props.changeType} options={typeOptions}/>
<h3><RIEInput className='editable-text' propName={'name'} value={this.props.state.name} change={this.props.renameNode} /></h3>
State Type: <RIESelect className='editable-text' value={{id: this.props.state.type, text: this.props.state.type}} propName='type'change={this.props.changeType} options={typeOptions}/>
<hr/>
<RIETextArea className='editable-text' value={remarks} propName="remarks" change={this.updateRemarks} />
<br/>
Expand All @@ -162,7 +162,7 @@ class StateEditor extends Component<Props> {
<hr />
<div>
<div className="Transition-Type">Transition Type:
<RIESelect className='editable-text' className='editable-text' value={{id: transitionType, text: transitionType}} propName='transition' change={(e) => this.props.addTransition(e.transition.id)} options={transitionOptions}/>
<RIESelect className='editable-text' value={{id: transitionType, text: transitionType}} propName='transition' change={(e) => this.props.addTransition(e.transition.id)} options={transitionOptions}/>
</div>
</div>
<div className="Transition">
Expand Down Expand Up @@ -308,12 +308,12 @@ class SetAttribute extends Component<Props> {
}
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
}
}
Expand Down Expand Up @@ -441,12 +441,12 @@ class Counter extends Component<Props> {
}
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
}
}
Expand Down Expand Up @@ -614,12 +614,12 @@ class Encounter extends Component<Props> {
}
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.reason}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.reason}</label>
<button classNameName="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.reason}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.reason}</label>
}
}
Expand Down Expand Up @@ -783,12 +783,12 @@ class ConditionOnset extends Component<Props> {
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
}
}
Expand Down Expand Up @@ -909,12 +909,12 @@ class ConditionEnd extends Component<Props> {
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
}
}
Expand Down Expand Up @@ -1041,12 +1041,12 @@ class AllergyOnset extends Component<Props> {
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
}
}
Expand Down Expand Up @@ -1166,12 +1166,12 @@ class AllergyEnd extends Component<Props> {
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
}
}
Expand Down Expand Up @@ -1322,12 +1322,12 @@ class MedicationOrder extends Component<Props> {
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
}
}
Expand Down Expand Up @@ -1639,12 +1639,12 @@ class MedicationEnd extends Component<Props> {
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
}
}
Expand Down Expand Up @@ -1776,12 +1776,12 @@ class CarePlanStart extends Component<Props> {
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
}
}
Expand Down Expand Up @@ -2016,12 +2016,12 @@ class CarePlanEnd extends Component<Props> {
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
}
}
Expand Down Expand Up @@ -2353,12 +2353,12 @@ class Observation extends Component<Props> {
if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.attribute}</label>
}
}
Expand Down Expand Up @@ -2788,12 +2788,12 @@ class Device extends Component<Props> {

if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.assign_to_attribute}</label>
}

}
Expand Down Expand Up @@ -2914,12 +2914,12 @@ class DeviceEnd extends Component<Props> {

if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
}

}
Expand Down Expand Up @@ -3124,12 +3124,12 @@ class Death extends Component<Props> {

if (others.length > 0)
{
displayAttribute = <span><label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <span><label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
<button className="attribute-button" onClick={this.props.displayAttributes}>See other uses</button>
</span>
}
else{
displayAttribute = <label class="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
displayAttribute = <label className="editable-text" onClick={this.toggleLabel}>{state.referenced_by_attribute}</label>
}

}
Expand Down
9 changes: 9 additions & 0 deletions src/components/menu/Download.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ class Download extends Component {
delete s.name;
}

// Remove empty code value sets
if(s['codes'] !== undefined){
s['codes'].forEach( c => {
if (c.value_set !== undefined && !c.value_set){
delete c.value_set;
}
})
}

// find table transitions and delete state data
if (s.lookup_table_transition !== undefined){
let name = s.lookup_table_transition.lookup_table_name_ModuleBuilder;
Expand Down
3 changes: 2 additions & 1 deletion src/types/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
export type Code = {
system: "SNOMED-CT" | "RxNorm" | "LOINC" | "NUBC" | "DICOM-DCM" | "DICOM-SOP",
code: string,
display: string
display: string,
value_set: string
}
19 changes: 18 additions & 1 deletion src/utils/graphviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,19 @@ const stateDescription = (state) =>{

if(state.codes !== undefined){
state['codes'].forEach( code => {
details = details + code['system'] + "[" + code['code'] + "]: " + code['display'] + "\\l"
if(code['value_set'] === undefined){
code['value_set'] = "";
}

let system_val = escapeVerticalBar(code['system']);
let code_val = escapeVerticalBar(code['code']);
let display_val = escapeVerticalBar(code['display']);
let valuSet_val = escapeVerticalBar(code['value_set']);

details = details + system_val + "[" + code_val + "]: " + display_val + "\\l";
if (valuSet_val) {
details += "Value Set:" + "[" + valuSet_val +"] " + "\\l";
}
})
}

Expand Down Expand Up @@ -676,6 +688,11 @@ const escapeLabel = (label) => {

}

const escapeVerticalBar = (inputStr) => {
inputStr = inputStr.toString();
return inputStr.replace(/\|/g, "\\|")
};

export const svgDefs = `<defs>
<filter id="outershadow" height="200%" width="200%" x="-75%" y="-75%" color-interpolation-filters="sRGB">
Expand Down

0 comments on commit db7d0ef

Please sign in to comment.