Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config CV list sort, Code system mapping, validate button reword #487

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/app/core/config/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export interface Config {
userProfile?: any;
stagingArea?: StagingAreaSettings;
privacyStatement: string;
CVDisplayOrder ?: {
[name: string]: Array<string>;
};
codeSystemMapping?: {
[code: string]: string;
};
structureEditor?: 'ketcher' | 'jsdraw';
}

Expand Down
14 changes: 13 additions & 1 deletion src/app/core/substance-form/codes/code-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ControlledVocabularyService } from '../../controlled-vocabulary/control
import { VocabularyTerm } from '../../controlled-vocabulary/vocabulary.model';
import { FormControl, Validators } from '@angular/forms';
import { UtilsService } from '../../utils/utils.service';
import { ConfigService } from '@gsrs-core/config';

@Component({
selector: 'app-code-form',
Expand All @@ -19,10 +20,13 @@ export class CodeFormComponent implements OnInit {
codeTypeList: Array<VocabularyTerm> = [];
deleteTimer: any;
viewFull = true;
codeSystemMapping: any;

constructor(
private cvService: ControlledVocabularyService,
private utilsService: UtilsService
private utilsService: UtilsService,
public configService: ConfigService

) { }

ngOnInit() {
Expand Down Expand Up @@ -56,6 +60,10 @@ export class CodeFormComponent implements OnInit {
this.setCodeSystemType();
this.codeTypeList = response['CODE_TYPE'].list;
});
if (this.configService.configData && this.configService.configData.codeSystemMapping) {
//This config object is meant to map certain code system values with an automatically filled out code value on selection.
this.codeSystemMapping = this.configService.configData.codeSystemMapping;
}
}

deleteCode(): void {
Expand Down Expand Up @@ -90,6 +98,10 @@ export class CodeFormComponent implements OnInit {
this.codeSystemType = this.codeSystemDictionary[this.privateCode.codeSystem]
&& this.codeSystemDictionary[this.privateCode.codeSystem].systemCategory || '';
}

if (this.codeSystemMapping && this.codeSystemMapping[this.code.codeSystem]) {
this.code.code = this.codeSystemMapping[this.code.codeSystem];
}
}

updateAccess(access: Array<string>): void {
Expand Down
35 changes: 34 additions & 1 deletion src/app/core/substance-form/cv-input/cv-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {CvDialogComponent} from '@gsrs-core/substance-form/cv-dialog/cv-dialog.c
import {DataDictionaryService} from '@gsrs-core/utils/data-dictionary.service';
import {AuthService} from '@gsrs-core/auth';
import { FragmentWizardComponent } from '@gsrs-core/admin/fragment-wizard/fragment-wizard.component';
import { ConfigService } from '@gsrs-core/config';

/*
used for any input that uses cv vocabulary to handle custom values after selecting 'other'
Expand Down Expand Up @@ -41,12 +42,15 @@ export class CvInputComponent implements OnInit, OnDestroy {
private utilsService: UtilsService,
private overlayContainerService: OverlayContainer,
private dictionaryService: DataDictionaryService,
private authService: AuthService
private authService: AuthService,
private configService: ConfigService
) { }

ngOnInit() {
if (this.vocabulary) {
this.vocabulary = this.addOtherOption(this.vocabulary, this.privateMod);
this.sortFromConfig();

} else if (this.key) {
this.dictionary = this.dictionaryService.getDictionaryRow(this.key);
if (!this.title) {
Expand All @@ -55,13 +59,16 @@ export class CvInputComponent implements OnInit, OnDestroy {
this.vocabName = this.dictionary.CVDomain;
const cvSubscription = this.cvService.getDomainVocabulary(this.vocabName).subscribe(response => {
this.vocabulary = response[this.vocabName].list;
this.sortFromConfig();

});
this.subscriptions.push(cvSubscription);
} else {
this.vocabulary = [];
this.vocabName = this.domain;
const cvSubscription = this.cvService.getDomainVocabulary(this.vocabName).subscribe(response => {
this.vocabulary = response[this.vocabName].list;
this.sortFromConfig();
});
this.subscriptions.push(cvSubscription);

Expand All @@ -76,6 +83,32 @@ export class CvInputComponent implements OnInit, OnDestroy {
});
}

//sort dropdown based on config settings
//for example "CVDisplayOrder": { "DOCUMENT_TYPE": ["IND", "NDA"],
sortFromConfig(vocab?: any) {
if (!vocab) {
vocab = this.vocabulary;
}
let vocabName = this.vocabName;
console.log(this.key);
if(this.key && this.key !== '') {
// wrong format, ignore for now
}
if (this.configService && this.configService.configData && this.configService.configData.CVDisplayOrder && this.configService.configData.CVDisplayOrder[vocabName] ) {
let configOrder = this.configService.configData.CVDisplayOrder[vocabName] ;
for(let i = configOrder.length-1; i >=0; i--) {
let check = configOrder[i];
vocab.forEach(function(item,j){
if(item.value == check){
vocab.splice(j, 1);
vocab.unshift(item);
}
});
}
this.vocabulary = vocab;
}
}

@Input()
set model(mod: any) {
this.privateMod = mod;
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/substance-form/substance-form.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
</div>
</div>
<span class="middle-fill"></span>
<button mat-flat-button color="primary" class="validate-button" (click)="validate()">Validate and Submit</button>
<button mat-flat-button color="primary" class="validate-button" (click)="validate()">Validate for Submission</button>
<button mat-flat-button color="primary" class="validate-button" [disabled]="!canApprove || approving"
*ngIf="definition && definition.substanceClass!=='concept' && !definition.approvalID && !imported && definitionType !== 'ALTERNATIVE'"
(click)="validate('approval')">Approve</button>
Expand Down
Loading