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

Bhima data collector #3864

Merged
merged 31 commits into from
Nov 7, 2019
Merged

Conversation

lomamech
Copy link
Collaborator

  • Implente Client side for Data Collector
  • Implete API for Data Collector Management
  • Extend service color js adding new color
  • Implement integration test for dataCollectorManagement
  • Implement E2E test for dataCollectorManagement

This module makes it possible to configure the different types of the
choice lists, the lists of choices can be in the form of trees.

  • Implement client side of choice list management
  • Implement API for choice list Management
  • Add integration and E2E for choice List Management

This module allows to add the elements of the form of a data collector,
the elements of a form have a type, some elements can have filter
compared to other elements

  • Add new component for Data Collector

  • Add new component for select Survey Form Type Select

  • Add new component for Select Survey List Select

  • Implement client side for Survey Form management

  • Implement API for survey form manangement

  • Add Integration and End to End test for Survey Form management

  • Implementation of APIs related to the filling of forms as well as the
    display of survey data,

  • Implementation of links between patient-related forms on the patient
    management page,

  • Implementing the data collection report with a small search engine

  • Implementation of components for Choicelist Multipke Select, Patient
    Medical Sheet, Survey Form Select,

  • Adding Integration and End to End test for Displaying Metadata and
    Filling of survey Form

closes #3863

@kwilu kwilu added the size: XL label Aug 28, 2019
{ name : 'violet', value : '#EE82EE'},
{ name : 'wheat', value : '#F5DEB3'},
{ name : 'white', value : '#FFFFFF'},
{ name : 'whitesmoke', value : '#F5F5F5'}];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'turquoise', value : '#40E0D0'},
{ name : 'violet', value : '#EE82EE'},
{ name : 'wheat', value : '#F5DEB3'},
{ name : 'white', value : '#FFFFFF'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'tomato', value : '#FF6347'},
{ name : 'turquoise', value : '#40E0D0'},
{ name : 'violet', value : '#EE82EE'},
{ name : 'wheat', value : '#F5DEB3'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'thistle', value : '#D8BFD8'},
{ name : 'tomato', value : '#FF6347'},
{ name : 'turquoise', value : '#40E0D0'},
{ name : 'violet', value : '#EE82EE'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'teal', value : '#008080'},
{ name : 'thistle', value : '#D8BFD8'},
{ name : 'tomato', value : '#FF6347'},
{ name : 'turquoise', value : '#40E0D0'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'silver', value : '#C0C0C0'},
{ name : 'skyblue', value : '#87CEEB'},
{ name : 'slategray', value : '#708090'},
{ name : 'snow', value : '#FFFAFA'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'sienna', value : '#A0522D'},
{ name : 'silver', value : '#C0C0C0'},
{ name : 'skyblue', value : '#87CEEB'},
{ name : 'slategray', value : '#708090'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'seashell', value : '#FFF5EE'},
{ name : 'sienna', value : '#A0522D'},
{ name : 'silver', value : '#C0C0C0'},
{ name : 'skyblue', value : '#87CEEB'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'seagreen', value : '#2E8B57'},
{ name : 'seashell', value : '#FFF5EE'},
{ name : 'sienna', value : '#A0522D'},
{ name : 'silver', value : '#C0C0C0'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'sandybrown', value : '#F4A460'},
{ name : 'seagreen', value : '#2E8B57'},
{ name : 'seashell', value : '#FFF5EE'},
{ name : 'sienna', value : '#A0522D'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

'id', 'is_list', 'label', 'labelType', 'name', 'other_choice', 'required',
'type', 'typeForm', 'typeLabel', 'version_number', 'calculation', 'choiceListLabel',
'choice_list_id', 'color', 'constraint', 'data_collector_label', 'data_collector_management_id',
'default', 'description', 'filterLabel', 'filter_choice_list_id', 'hint', 'rank');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected newline before ')' function-paren-newline

*/

/* loading grid actions */
const GridRow = require('../shared/GridRow');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'GridRow' is assigned a value but never used no-unused-vars


formula = formula.replace(/.{/g, 'data.');
formula = formula.replace(/}/g, '');
const calculation = util.roundDecimal(eval(formula), 2);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eval can be harmful no-eval

.done();
}

function getCalculation(survey, data) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'data' is defined but never used no-unused-vars


db.exec(sql, [data])
.then((row) => {
res.status(201).json({ id: row.insertId });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after key 'id' key-spacing

{ name : 'purple', value : '#800080'},
{ name : 'rosybrown', value : '#BC8F8F'},
{ name : 'royalblue', value : '#4169E1'},
{ name : 'saddlebrown', value : '#8B4513'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'powderblue', value : '#B0E0E6'},
{ name : 'purple', value : '#800080'},
{ name : 'rosybrown', value : '#BC8F8F'},
{ name : 'royalblue', value : '#4169E1'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'plum', value : '#DDA0DD'},
{ name : 'powderblue', value : '#B0E0E6'},
{ name : 'purple', value : '#800080'},
{ name : 'rosybrown', value : '#BC8F8F'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'pink', value : '#FFC0CB'},
{ name : 'plum', value : '#DDA0DD'},
{ name : 'powderblue', value : '#B0E0E6'},
{ name : 'purple', value : '#800080'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

{ name : 'peru', value : '#CD853F'},
{ name : 'pink', value : '#FFC0CB'},
{ name : 'plum', value : '#DDA0DD'},
{ name : 'powderblue', value : '#B0E0E6'},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required before '}' object-curly-spacing

@lomamech lomamech force-pushed the bhima_data_collector branch from f9f3e25 to 1acfd66 Compare August 28, 2019 12:04
{ name : 'violet', value : '#EE82EE' },
{ name : 'wheat', value : '#F5DEB3' },
{ name : 'white', value : '#FFFFFF' },
{ name : 'whitesmoke', value : '#F5F5F5' }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing trailing comma comma-dangle

$ctrl.hasError = false;
$ctrl.loading = true;

DataCollectorManagement.read(null, {is_related_patient : 1})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required after '{' object-curly-spacing
A space is required before '}' object-curly-spacing

@lomamech
Copy link
Collaborator Author

@jniles @mbayopanda @jeremielodi All the tests pass for this PR, do not hesitate to consult me for the review of this PR

@jeremielodi
Copy link
Collaborator

jeremielodi commented Sep 10, 2019

The data collector module works perfectly, there are just few things that we have to fix

  • We can put the module "Collecte des données" and "Kit de collecte de données" together for better
    understanding of users, we can just use "Collecte des données" as the unique module. So inside we
    will have the setup and filling of surveys.

  • /#!/survey_form
    the add field button should be disabled if the survey is not selected

  • #!/data_collector_management
    There should be a link between a survey on this grid with his configuration in /#!/survey_form page

  • #!/display_metadata
    Add the Export data into Ms Excel feature
    Add the number of submissions for each servey

Copy link
Collaborator

@jniles jniles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lomamech,

This PR is incredible - it represents a lot of work, and it performs very well. Well done!

As discussed, I've limited my review to the DisplayMetaData modules for the moment, and mostly the graphical user interface.

Let me know if you have any questions!

</div>
</div>

<div ng-if="SurveyFormModalCtrl.selectList" style="background-color:#ededed; padding-left: 10%; padding-right: 3%">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this padding - it looks a bit off. There is a bootstrap class that is pretty close to what you want though - it is called .well. See how it works below.

8fW4Iki2dZ

Would you be willing to change these styles to class="well"?

<span class="fa fa-file-pdf-o"></span> <span translate>DOWNLOADS.PDF</span>
</a>
</li>
<li role="separator" class="divider"></li>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's comment out the "separator" until the rest are done. It makes the dropdown menu look a bit funny:

DisplayMetadataExtraButton

<ul uib-dropdown-menu role="menu" class="dropdown-menu-right">
<li role="menuitem">
<a target='_blank'
ng-href="/data_kit/report/?{{ DisplayMetadataCtrl.download(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having this large DisplayMetadataCtrl.download() call, it would be better to move this into the controller in a function called downloadPDF(). This href will become ng-href="/data_key/report?{{DisplayMetadataCtrl.downloadPDF()".

And then in your controller you can make a function:

ctrl.downloadPDF = () => {
  return ctrl.download('pdf', ctrl.changes, ctrl.collectorId, /* etc ... */ );
};

</button>
</div>

<div ng-if="DisplayMetadataCtrl.patientData" class="toolbar-item">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have two ng-if="DisplayMetadataCtrl.patientData" next to each other. Can you merge them?

renderer : type,
changes,
lang : Languages.key,
patient_uuid : patientUuid || null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you specify patient and patientUuid as two different parameters?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter 'patient' contains patient information for the purpose of no longer querying the database for its information

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just use patient.uuid?

vm.remove = remove;

function edit(data) {
if (!$state.params.patient) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already checked for this in the startup code with hasPatientData. Could we use that variable instead of $state?

if (hasPatientData) {
  // do x
} else {
  // do y
}

if (cache.collector && !vm.collectorId && !$state.params.patient) {
vm.collectorId = cache.collector.id;
}
const changesLength = Object.keys(vm.changes).length;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this into a boolean:

const hasNoChanges = Object.keys(vm.changes).length === 0;

Then we can use it in a nice check:

if (cache.changes && hasNoChanges) {
  // do x
}

.then((survey) => {
vm.filterElements = DisplayMetadata.displayFilters(survey, vm.changes);

vm.params = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does vm.params depend on the result of SurveyForm.read()? If not, let's move it out:

vm.params = {
  data_collector_management_id : vm.collectorId,
  changes : vm.changes,
};

SurveyForm.read(/* etc ...*/)

vm.gridOptions.columnDefs = data.columns;
vm.gridOptions.data = data.surveyData;

return DataCollectorManagement.read(vm.collectorId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a nice promise chain here that sends a request for:

  1. SurveyForm.read()
  2. DisplayMetadata.read()
  3. DataCollectorManagement.read()

However, it doesn't look like any of these actually depend on one another. So, let's send them in parallel using Promise.all()!

vm.params = {/* etc  */};
return Promise.all([
  SurveyForm.read(null, { data_collector_management_id : vm.collectorId }),
  DisplayMetadata.read(null, vm.params),
  DataCollectorManagement.read(vm.collectorId),
])
.then(([survey, data, collector]) => {
  // process all queries...
});

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jniles, i try this options but the displaying became too slow

changes : vm.changes,
};

DisplayMetadata.read(null, vm.params)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if you can do a similar Promise.all() system here.

Copy link
Collaborator Author

@lomamech lomamech Sep 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
The displaying became very very too slow

@lomamech lomamech force-pushed the bhima_data_collector branch from 715786e to 049c27d Compare September 16, 2019 19:34
@kwilu
Copy link

kwilu commented Sep 16, 2019

Hello @lomamech, it seems like you have referenced #3863 in your pull request description, but you have not referenced them in your commit message description(s). When you reference an issue in a commit message, it automatically closes the corresponding issue when the commit is merged.

Please run git commit --amend in your command line client to amend your commit message description with Fixes #3863..

An example of a correctly-formatted commit:

commit fabd5e450374c8dde65ec35f02140383940fe146
Author: kwilu
Date:   Sat Mar 18 13:42:40 2017 -0700

    pull requests: Check PR commits reference when issue is referenced.

    Fixes #51.

Thank you for your contributions to BHIMA!

}

function displayFilters(survey, search) {
let filters = [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'filters' is never reassigned. Use 'const' instead prefer-const

@kwilu
Copy link

kwilu commented Sep 16, 2019

Hello @lomamech, it seems like you have referenced #3863 in your pull request description, but you have not referenced them in your commit message description(s). When you reference an issue in a commit message, it automatically closes the corresponding issue when the commit is merged.

Please run git commit --amend in your command line client to amend your commit message description with Fixes #3863..

An example of a correctly-formatted commit:

commit fabd5e450374c8dde65ec35f02140383940fe146
Author: kwilu
Date:   Sat Mar 18 13:42:40 2017 -0700

    pull requests: Check PR commits reference when issue is referenced.

    Fixes #51.

Thank you for your contributions to BHIMA!

@lomamech
Copy link
Collaborator Author

@jniles I have finish with the first review

@lomamech lomamech force-pushed the bhima_data_collector branch from 58e34f2 to 738a988 Compare September 17, 2019 09:43
Copy link
Collaborator

@jniles jniles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lomamech Great work on making these changes.

I'm still working through most of the code, but I've made a few more comments. Take a look :)

👍

listLabel : '@?',
isTitle : '<?',
isGroup : '<?',
parentId : '<',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the parentId is optional (line 36). This should be <?.

listLabel : '@?',
isTitle : '<?',
isGroup : '<?',
parentId : '<',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be optional <?.

}

function closeModal() {
$state.transitionTo('choices_list_management');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of our $state changes use $state.go(). Can you use that there?


<ul data-row-menu="{{row.entity.label}}" class="dropdown-menu-right" bh-dropdown-menu-auto-dropup uib-dropdown-menu>
<li class="dropdown-header text-ellipsis" style="max-width:250px;">
<a> {{row.entity.label}} </a>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be wrapped in a <a> tag? Can you just put it in plain <span> tag instead?

}

function closeModal() {
$state.transitionTo('data_collector_management');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$state.go() should be sued here as well.


function DataCollectorManagementModalController($state, DataCollectorManagement, Notify, AppCache, Color) {
const vm = this;
const cache = AppCache('AccountReferenceModal');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be AccountReferenceModal.


function SurveyFormModalController($state, SurveyForm, Notify, AppCache, DataCollectorManagement) {
const vm = this;
const cache = AppCache('AccountReferenceModal');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably shouldn't be AccountReferenceModal.

function submit(surveyForm) {
vm.hasNoChange = surveyForm.$submitted && surveyForm.$pristine && !vm.isCreating;
if (surveyForm.$invalid) { return null; }
if (!surveyForm.$dirty) { return null; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of !surveyForm.$dirty, go ahead and use surveyForm.$pristine. It is the same thing, but without a !.

function closeModal() {
const transitionTo = vm.updateMode ? 'display_metadata' : 'fill_form';
if (!vm.stateParams.patient) {
$state.transitionTo(transitionTo);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use $state.go() here?

<div class="row">
<!-- Medical Sheet -->
<div class="col-xs-12">
<bh-patient-medical-sheet patient-uuid="PatientRecordCtrl.patient.uuid">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose we name this something else - "medical sheet" makes it sound like it has something to do with the patient's medical information, but it is actually just data collections about the patient.

Let's call this <bh-patient-data-collection-forms> or something like that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the use of the term "medical sheet" simply wanted to mention that this area is dedicated to medical information of patients.

Logically, the forms that should appear on this zone should only be those collecting medical information

@jeremielodi
Copy link
Collaborator

I propose that we use "Survey Form management" instead of "Survey Form" and
"Survey Form setting" instead of "Data Collector Management", that way the module names will be more understandable

@lomamech lomamech force-pushed the bhima_data_collector branch from 738a988 to eb0bf63 Compare September 20, 2019 10:28
.controller('DisplayMetadataSearchModalController', DisplayMetadataSearchModalController);

DisplayMetadataSearchModalController.$inject = [
'$uibModalInstance', 'Store', 'SurveyFormService', 'NotifyService', 'AppCache', 'ChoicesListManagementService', 'filters',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 5 exceeds the maximum line length of 120 max-len

@jeremielodi
Copy link
Collaborator

Make sure the user can see a warning message if he submit an invalid form.
Currently you return null in your JavaScript code for this problem.

@lomamech
Copy link
Collaborator Author

@jniles @jeremielodi I wait another review

Copy link
Collaborator

@jniles jniles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lomamech, a few more comments. Your changes from last time look good.

function ChoicesListManagementService(Api) {
const service = new Api('/choices_list_management/');

service.formatStore = formatStore;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... looks like we have identical code in the AccountService. Is there any way we can move this into a shared service so that we don't have to duplicate code?

ng-true-value="1"
ng-false-value="0"
ng-model="DataCollectorManagementModalCtrl.dataCollector.is_related_patient">
<span translate>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This translate tag needs to be on the <strong> not the <span>.

}

function toggleLoadingIndicator() {
$ctrl.loading = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Toggle loading indicator always sets "loading" to be "false". Shouldn't it turn loading on and off?

$ctrl.gridApi = {};
$ctrl.filterEnabled = false;
$ctrl.toggleFilter = toggleFilter;
$ctrl.consult = consult;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI - for functions, you don't need to put them in the $onInit call. The $onInit() is most for variables that are passed in and/or need to be initialized with each component.

// S'il sont multiples afin de les affecter dans des tableaux
form.forEach(f => {
data.forEach(d => {
if ((f.id === d.survey_form_id) && (f.type === '4')) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is type === '4'? Why not type === '7'?

Copy link
Collaborator Author

@lomamech lomamech Oct 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
It's form multiple value, look in bhima.sql in table survey_form_type

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you instead use the label? It will make it much easier for a developer to read. Like this:

f.label === 'FORM.LABELS.SELECT_MULTIPLE' // now all future developers knows what this means!


<div ng-if="!formItem.constraint || $eval(formItem.constraintCheck)">
<!-- Type text -->
<div ng-if="formItem.typeForm === 'text'" class="form-group" ng-class="{ 'has-error' : FillFormForm.$submitted && FillFormForm.{{ formItem.name }}.$invalid }">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed together, I think that you can simply do FillFormForm[formItem.name].$invalid and save yourself a bit of parsing.

<div ng-if="formItem.typeForm === 'text'" class="form-group" ng-class="{ 'has-error' : FillFormForm.$submitted && FillFormForm.{{ formItem.name }}.$invalid }">
<label class="control-label"> {{ formItem.label }} </label>
<span style="color: #cecece"><em> {{ formItem.hint }} </em></span>
<div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this <div> here?

<span ng-if="formItem.required">
<input name="{{ formItem.name }}" ng-model="FillFormModalCtrl.form[formItem.name]" autocomplete="off" ng-maxlength="90" class="form-control" required>
</span>
<span ng-if="!formItem.required">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use ngRequired?

</div>

<!-- TextArea -->
<div ng-if="formItem.typeForm === 'text_area'">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are doing a lot of formItem.typeForm === "x", could you use an ngSwitch? It would probably make the code easier to read.

if (vm.reportDetails.multipleChoice[key].length) {
for (let i = 0; i < vm.reportDetails.multipleChoice[key].length; i++) {
vm.choicesLists.forEach(list => {
if (list.id === vm.reportDetails.multipleChoice[key][i]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So .. it looks like you are taking a list of ids and turning them into a list of labels. So, you are trying to do:

var ids = [3, 3, 5, 7, 1]
// do something
console.log(ids) // => ['formA', 'formA', 'formZ', 'formX', 'formT']

Let's try to clean this up a bit. Here is what I think the basic structure could look like:

angular.forEach(vm.reportDetails.mulitpleChoice, (values, key) => {
  // values is an array.
  values.forEach(value => {
    vm.choicesLists.forEach(list => {
      if (list.id === value) {
         // replace value with list.label
      }
    });
  });
});

Let's see if we can go one step further:

// create a way to map id -> label for the choice list
let choiceListMap = vm.choicesList.reduce((map, item) => {
  map[item.id] = item.label;
}, {});

angular.forEach(vm.reportDetails.mulitpleChoice, (values, key) => {
  // unfortunately, angular.map() doesn't exist for object.  We have to use an ugly forEach
  vm.multipleChoice[key] = values.map(value => choiceListMap[value]);
});

I think that should do it.

First, we create an object to make choiceList ids map to their labels. This takes up memory but removes the choiceLists.forEach() loop.

Then, we use angular.forEach() to loop through the object. This removes all the Object.keys() calls and checks for .length.

Try it out and see if I've missed anything.

@kwilu
Copy link

kwilu commented Oct 17, 2019

Heads up @lomamech, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/master branch and resolve your pull request's merge conflicts accordingly.

name1 : 'Name with space',
name2 : 'Namewith,and;',
name3 : 'Namewith@',
name4 : 'Namewith\'and\"',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary escape character: " no-useless-escape

*/

/* loading grid actions */
const { expect } = require('chai');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'expect' is assigned a value but never used no-unused-vars


it('Failed to create a form element whose name parameter with Quotation mark and apostrophe', () => {
// This is the value to get
const variableName = 'Namewith\'and\"';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary escape character: " no-useless-escape

const startString = /^[a-zA-Z]/;

// Regular expression to check if a variable does not have special characters
const haventSpecial = /^[\w \-]+$/;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary escape character: - no-useless-escape

];

function AnalysisAuxiliaryCashController($sce, Notify, SavedReports, AppCache, reportData, $state, Accounts) {
function AnalysisAuxiliaryCashController($sce, Notify, SavedReports, AppCache, reportData, $state, Accounts, FormatTreeData) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 9 exceeds the maximum line length of 120 max-len

@@ -18,7 +19,7 @@ AccountsController.$inject = [
*/
function AccountsController(
$rootScope, $timeout, AccountGrid, Notify, Constants, Language,
uiGridConstants, Modal, Accounts
uiGridConstants, Modal, Accounts, FormatTreeData
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'FormatTreeData' is defined but never used no-unused-vars

* @class FormatTreeDataService
*
*/
function FormatTreeDataService(Api) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Api' is defined but never used no-unused-vars

@lomamech
Copy link
Collaborator Author

@jniles @mbayopanda @jeremielodi can I have another Review

@jniles
Copy link
Collaborator

jniles commented Oct 29, 2019

bors r+

bors bot added a commit that referenced this pull request Oct 29, 2019
3864: Bhima data collector r=jniles a=lomamech

- Implente Client side for Data Collector
- Implete API for Data Collector Management
- Extend service color js adding new color
- Implement integration test for dataCollectorManagement
- Implement E2E test for dataCollectorManagement

This module makes it possible to configure the different types of the
choice lists, the lists of choices can be in the form of trees.
- Implement client side of choice list management
- Implement API for choice list Management
- Add integration and E2E for choice List Management

This module allows to add the elements of the form of a data collector,
the elements of a form have a type, some elements can have filter
compared to other elements
- Add new component for Data Collector
- Add new component for select Survey Form Type Select
- Add new component for Select Survey List Select
- Implement client side for Survey Form management
- Implement API for survey form manangement
- Add Integration and End to End test for Survey Form management

- Implementation of APIs related to the filling of forms as well as the
  display of survey data,

- Implementation of links between patient-related forms on the patient
  management page,

- Implementing the data collection report with a small search engine

- Implementation of components for Choicelist Multipke Select, Patient
  Medical Sheet, Survey Form Select,

- Adding Integration and End to End test for Displaying Metadata and
  Filling of survey Form

closes #3863


Co-authored-by: Chris Lomame <lomamech@gmail.com>
@bors
Copy link
Contributor

bors bot commented Oct 29, 2019

Build failed

- Improve display metadata, reduice the function downloadD
- avoid apostrophes in the search parameter
- Added the listHint property to display information about the component
  selection lists bhChoiceListMultipleSelect and bhChoiceListSelect

- Using function downloadPDF and Using an object instead of a function with
  multiple parameters

- Using Mao from the survey array for mere efficient
- Update component bhChoiceListSelect bhChoiceListMultipleSelect change
  params parentId in '<' to '<?'
- Using $state.go instead $state.transitionTo
- Using <span> instead not necessary tag <a> ... </a>
- Using $pristine instead !<--->.$dirty
- Sanitaze and Clear Code
- Improved form selection component, added disable option when viewing
  patient data
- Reformated the research params by the using of components bh-filters
- Improved data display module, removal of entangled requests in the
  controller
-
- Update placeHolder message in component bhSurveyTypeSelect
- Using function parseDataValue and use structure swith for manage type of
  data
- Using ng-required instead to duplicate block of code
- Update survey form modals, hide the selection filter for Select Multiple
- Use the basic structure for manage vm.reportDetails.multipleChoice value
  in form of search in Report Data kit
- Added the option to include the patient selection component in the data
  collection form

- Display of the name of the user as well as that of the patient if the
  form is associated with the patient
- Implementation of a service to validate the variable name parameter when
  configuring forms,
- Implementation of the unit test for the validation of the variable
  parameter name
- Implementation of the E2E test for the validation of the variable
  name parameter when configuring formulators
@lomamech lomamech force-pushed the bhima_data_collector branch from ab8e762 to 320b69f Compare November 6, 2019 12:00
@lomamech
Copy link
Collaborator Author

lomamech commented Nov 6, 2019

@jniles @mbayopanda After several attempts this old PR is ready to be merged

@jniles
Copy link
Collaborator

jniles commented Nov 7, 2019

I'm hoping we can just get this in. Let's do it bors.

bors r+

bors bot added a commit that referenced this pull request Nov 7, 2019
3864: Bhima data collector r=jniles a=lomamech

- Implente Client side for Data Collector
- Implete API for Data Collector Management
- Extend service color js adding new color
- Implement integration test for dataCollectorManagement
- Implement E2E test for dataCollectorManagement

This module makes it possible to configure the different types of the
choice lists, the lists of choices can be in the form of trees.
- Implement client side of choice list management
- Implement API for choice list Management
- Add integration and E2E for choice List Management

This module allows to add the elements of the form of a data collector,
the elements of a form have a type, some elements can have filter
compared to other elements
- Add new component for Data Collector
- Add new component for select Survey Form Type Select
- Add new component for Select Survey List Select
- Implement client side for Survey Form management
- Implement API for survey form manangement
- Add Integration and End to End test for Survey Form management

- Implementation of APIs related to the filling of forms as well as the
  display of survey data,

- Implementation of links between patient-related forms on the patient
  management page,

- Implementing the data collection report with a small search engine

- Implementation of components for Choicelist Multipke Select, Patient
  Medical Sheet, Survey Form Select,

- Adding Integration and End to End test for Displaying Metadata and
  Filling of survey Form

closes #3863


Co-authored-by: Chris Lomame <lomamech@gmail.com>
@bors
Copy link
Contributor

bors bot commented Nov 7, 2019

Build failed

@jniles
Copy link
Collaborator

jniles commented Nov 7, 2019

bors try

bors bot added a commit that referenced this pull request Nov 7, 2019
@bors
Copy link
Contributor

bors bot commented Nov 7, 2019

try

Build failed

@jeremielodi
Copy link
Collaborator

bors r+

bors bot added a commit that referenced this pull request Nov 7, 2019
3864: Bhima data collector r=jeremielodi a=lomamech

- Implente Client side for Data Collector
- Implete API for Data Collector Management
- Extend service color js adding new color
- Implement integration test for dataCollectorManagement
- Implement E2E test for dataCollectorManagement

This module makes it possible to configure the different types of the
choice lists, the lists of choices can be in the form of trees.
- Implement client side of choice list management
- Implement API for choice list Management
- Add integration and E2E for choice List Management

This module allows to add the elements of the form of a data collector,
the elements of a form have a type, some elements can have filter
compared to other elements
- Add new component for Data Collector
- Add new component for select Survey Form Type Select
- Add new component for Select Survey List Select
- Implement client side for Survey Form management
- Implement API for survey form manangement
- Add Integration and End to End test for Survey Form management

- Implementation of APIs related to the filling of forms as well as the
  display of survey data,

- Implementation of links between patient-related forms on the patient
  management page,

- Implementing the data collection report with a small search engine

- Implementation of components for Choicelist Multipke Select, Patient
  Medical Sheet, Survey Form Select,

- Adding Integration and End to End test for Displaying Metadata and
  Filling of survey Form

closes #3863


Co-authored-by: Chris Lomame <lomamech@gmail.com>
@bors
Copy link
Contributor

bors bot commented Nov 7, 2019

@bors bors bot merged commit 320b69f into Third-Culture-Software:master Nov 7, 2019
@lomamech lomamech deleted the bhima_data_collector branch April 7, 2020 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature creation of a Bhima data collection system
4 participants