Skip to content

Commit

Permalink
Revert "230 - Remove simprints (#7461)" (#7591)
Browse files Browse the repository at this point in the history
This reverts commit dc0be4f.
  • Loading branch information
garethbowen authored Apr 20, 2022
1 parent 6f3551a commit c85d17a
Show file tree
Hide file tree
Showing 40 changed files with 536 additions and 12 deletions.
1 change: 1 addition & 0 deletions admin/src/js/services/get-summaries.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ angular.module('inboxServices').factory('GetSummaries',
contact_type: doc.contact_type,
contact: doc.contact && doc.contact._id,
lineage: getLineage(doc.parent),
simprints_id: doc.simprints_id,
date_of_death: doc.date_of_death,
muted: doc.muted
};
Expand Down
3 changes: 3 additions & 0 deletions admin/tests/unit/services/get-summaries.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ describe('GetSummaries service', () => {
_id: 'g'
}
},
simprints_id: '987',
muted: true
} },
] });
Expand All @@ -206,6 +207,7 @@ describe('GetSummaries service', () => {
contact: 'c',
lineage: [],
date_of_death: 999,
simprints_id: undefined,
muted: undefined
},
{
Expand All @@ -218,6 +220,7 @@ describe('GetSummaries service', () => {
contact: undefined,
lineage: [ 'f', 'g' ],
date_of_death: undefined,
simprints_id: '987',
muted: true
}
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ function(doc) {
if (doc.patient_id) {
emitReference('shortcode', doc.patient_id);
}
if (doc.simprints_id) {
emitReference('simprints', doc.simprints_id);
}
if (doc.rc_code) {
// need String because rewriter wraps everything in quotes
// keep refid case-insenstive since data is usually coming from SMS
Expand Down
3 changes: 3 additions & 0 deletions ddocs/medic/_attachments/translations/messages-en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,9 @@ setup.skip = Skip the setup wizard
setup.start = Finish
setup.statistics.description = Allow anonymous statistics to be submitted to Medic? Statistics will be sent monthly to help us improve the software and learn about the impact it's having. Strictly no confidential patient information will be shared with us. You can update these settings at any time from this wizard.
setup.statistics.title = Share impact statistics
simprints.disabled = Simprints isn't available on this device. Use a recent version of the Medic Android app to enable Simprints integration.
simprints.register = Register with Simprints
simprints.search = Search with Simprints
sms_message.message = Incoming message
sms_received = SMS message received; it will be reviewed shortly. If you were trying to submit a text form, please enter a correct form code and try again.
state.cleared = cleared
Expand Down
1 change: 1 addition & 0 deletions ddocs/medic/views/doc_summaries_by_id/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function(doc) {
contact_type: doc.contact_type,
contact: doc.contact && doc.contact._id,
lineage: getLineage(doc.parent),
simprints_id: doc.simprints_id,
date_of_death: doc.date_of_death,
muted: doc.muted
});
Expand Down
18 changes: 18 additions & 0 deletions shared-libs/search/src/generate-search-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,19 @@ const contactTypeRequest = function(filters, sortByLastVisitedDate) {
return request;
};

const simprintsRequest = function(filters) {
if (!filters.simprintsIdentities) {
return;
}
const keys = filters.simprintsIdentities.map(function(identity) {
return [ 'simprints', identity.id ];
});
return {
view: 'medic-client/contacts_by_reference',
params: { keys: keys }
};
};

const defaultReportRequest = function() {
return {
view: 'medic-client/reports_by_date',
Expand Down Expand Up @@ -193,6 +206,11 @@ const requestBuilders = {
return requests;
},
contacts: function(filters, extensions) {
const simprints = simprintsRequest(filters);
if (simprints) {
return [ simprints ];
}

const shouldSortByLastVisitedDate = module.exports.shouldSortByLastVisitedDate(extensions);

const typeRequest = contactTypeRequest(filters, shouldSortByLastVisitedDate);
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/forms/submit-photo-upload-form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Submit Photo Upload form', () => {
await genericForm.selectFormNative('photo-upload');
await helper.waitElementToPresentNative(photoUpload.imagePathInput());
await photoUpload.imagePathInput().sendKeys(
path.join(__dirname, '../../../webapp/src/img/setup-wizard-demo.png')
path.join(__dirname, '../../../webapp/src/img/simprints.png')
);
await helper.waitUntilReadyNative(photoUpload.imagePreview());

Expand Down
1 change: 1 addition & 0 deletions tests/e2e/service-worker.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ describe('Service worker cache', () => {
'/img/icon-pregnant.svg',
'/img/layers.png',
'/img/setup-wizard-demo.png',
'/img/simprints.png',
'/login/script.js',
'/login/style.css',
'/main.js',
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/css/enketo/medic.less
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@
}
}
}
.or .simprints-register img {
display: inherit;
}
.select2-container .select2-selection--single {
height: @input-height;
}
Expand Down
18 changes: 17 additions & 1 deletion webapp/src/css/inbox.less
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ body {
}

.reset-filter,
.sort-results {
.sort-results,
.simprints-filter {
line-height: 38px;
> a {
color: @text-normal-color;
Expand Down Expand Up @@ -1216,6 +1217,21 @@ a.fa:hover {
}
}

.simprints-stars {
&:after {
font-family: FontAwesome;
}
&.tier-1:after {
content: '\f005\f005\f005\f005\f005'; /* 5 stars full */
}
&.tier-2:after {
content: '\f005\f005\f005\f005\f006'; /* 4 stars full, 1 empty */
}
&.tier-3:after {
content: '\f005\f005\f005\f006\f006'; /* 3 star full, 2 empty */
}
}

.upgrade-config .status {
text-align: center;
}
Expand Down
Binary file added webapp/src/img/simprints.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions webapp/src/js/enketo/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require( './widgets/unselectable-radios' ),
require( './widgets/android-datepicker' ),
require( './widgets/bikram-sambat-datepicker' ),
require( './widgets/simprints' ),
require( './widgets/mrdt' ),
require( './widgets/android-app-launcher' ),
require( './widgets/display-base64-image' ),
Expand Down
78 changes: 78 additions & 0 deletions webapp/src/js/enketo/widgets/simprints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
'use strict';
const Widget = require('enketo-core/src/js/Widget');
const $ = require( 'jquery' );
require('enketo-core/src/js/plugins');

const pluginName = 'simprintswidget';

/**
* @constructor
* @param {Element} element [description]
* @param {(boolean|{touch: boolean, repeat: boolean})} options options
* @param {*=} e event
*/
function Simprintswidget( element, options ) {
this.namespace = pluginName;
Widget.call( this, element, options );
this._init();
}

//copy the prototype functions from the Widget super class
Simprintswidget.prototype = Object.create( Widget.prototype );

//ensure the constructor is the new one
Simprintswidget.prototype.constructor = Simprintswidget;

Simprintswidget.prototype._init = function() {
const $el = $( this.element );
const $input = $el.find( 'input' );
$input.attr( 'disabled', true );
const $translate = window.CHTCore.Translate;
// todo migrate when simprints are migrated
//const service = angularServices.get( 'Simprints' );
const service = {
enabled: () => {},
register: () => Promise.resolve(),
};

if ( !service.enabled() ) {
$translate.get( 'simprints.disabled' ).then(function( label ) {
$el.append( '<p>' + label + '</p>' );
});
return;
}

$el.on( 'click', '.btn.simprints-register', function() {
service.register().then( function(simprintsId) {
$input.val( simprintsId ).trigger( 'change' );
} );
} );

$translate.get( 'simprints.register' ).then( function( label ) {
$el.append( '<div><a class="btn btn-default simprints-register">' +
'<img src="/img/simprints.png" width="20" height="20"/> ' + label + '</a>' +
'</div>' );
} );
};

Simprintswidget.prototype.destroy = function( element ) {}; // eslint-disable-line no-unused-vars

$.fn[ pluginName ] = function( options, event ) {
return this.each( function() {
const $this = $( this );
let data = $this.data( pluginName );

options = options || {};

if ( !data && typeof options === 'object' ) {
$this.data( pluginName, ( data = new Simprintswidget( this, options, event ) ) );
} else if ( data && typeof options === 'string' ) {
data[ options ]( this );
}
} );
};

module.exports = {
'name': pluginName,
'selector': '.or-appearance-simprints-reg',
};
5 changes: 5 additions & 0 deletions webapp/src/ts/actions/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const Actions = {
setFilter: createSingleValueAction('SET_FILTER', 'filter'),
setFilters: createSingleValueAction('SET_FILTERS', 'filters'),
setSelectMode: createSingleValueAction('SET_SELECT_MODE', 'selectMode'),
setIsAdmin: createSingleValueAction('SET_IS_ADMIN', 'isAdmin'),
setTitle: createSingleValueAction('SET_TITLE', 'title'),
setPrivacyPolicyAccepted: createSingleValueAction('SET_PRIVACY_POLICY_ACCEPTED', 'accepted'),
setShowPrivacyPolicy: createSingleValueAction('SET_SHOW_PRIVACY_POLICY', 'show'),
Expand Down Expand Up @@ -104,6 +105,10 @@ export class GlobalActions {
return this.store.dispatch(Actions.setSelectMode(selectMode));
}

setIsAdmin(isAdmin) {
return this.store.dispatch(Actions.setIsAdmin(isAdmin));
}

setLoadingShowContent(id) {
this.setLoadingContent(id);
this.setShowContent(true);
Expand Down
1 change: 1 addition & 0 deletions webapp/src/ts/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export class AppComponent implements OnInit {
.then(() => this.checkDateService.check(true))
.then(() => this.startRecurringProcesses());

this.globalActions.setIsAdmin(this.sessionService.isAdmin());
this.watchBrandingChanges();
this.watchDDocChanges();
this.watchUserContextChanges();
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/ts/components/components.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { FormTypeFilterComponent } from '@mm-components/filters/form-type-filter
import { StatusFilterComponent } from '@mm-components/filters/status-filter/status-filter.component';
import { FreetextFilterComponent } from '@mm-components/filters/freetext-filter/freetext-filter.component';
import { ResetFiltersComponent } from '@mm-components/filters/reset-filters/reset-filters.component';
import { SimprintsFilterComponent} from '@mm-components/filters/simprints-filter/simprints-filter.component';
import { SortFilterComponent } from '@mm-components/filters/sort-filter/sort-filter.component';
import { SenderComponent } from '@mm-components/sender/sender.component';
import { ReportImageComponent } from '@mm-components/report-image/report-image.component';
Expand Down Expand Up @@ -52,6 +53,7 @@ import { MobileDetectionComponent } from '@mm-components/mobile-detection/mobile
StatusFilterComponent,
FreetextFilterComponent,
ResetFiltersComponent,
SimprintsFilterComponent,
SortFilterComponent,
SenderComponent,
ReportImageComponent,
Expand Down Expand Up @@ -84,6 +86,7 @@ import { MobileDetectionComponent } from '@mm-components/mobile-detection/mobile
StatusFilterComponent,
FreetextFilterComponent,
ResetFiltersComponent,
SimprintsFilterComponent,
SortFilterComponent,
SenderComponent,
ReportImageComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ <h4>
</div>
<p *ngIf="dob" [innerHTML]="dob | age:dod"></p>
<span *ngIf="muted && displayMuted">{{'contact.muted' | translate}}</span>
<div *ngIf="simprintsTier" class="simprints-stars tier-{{simprintsTier}}"></div>
<div *ngIf="lineage && lineage.length" class="detail" [innerHTML]="lineage | lineage"></div>
<div *ngIf="warning" class="warning">{{warning}}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class ContentRowListItemComponent {
@Input() verified;
// array: (optional) the hierarchy for the row
@Input() lineage;
// integer: (optional) the simprints tier of the contact match
@Input() simprintsTier;
// boolean: (optional) whether to mark this row as a primary contact
@Input() primaryContact;
// integer: (optional) how much tasks to show as pending for this contact
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<span class="simprints-filter" *ngIf="simprintsEnabled">
<a tabindex="-1" (click)="simprintsIdentify()" title="{{'simprints.search' | translate}}">
<img src="/img/simprints.png" width="20" height="20"/>
</a>
</span>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';

@Component({
selector: 'mm-simprints-filter',
templateUrl: './simprints-filter.component.html'
})
export class SimprintsFilterComponent {
@Input() simprintsEnabled;
@Output() identify: EventEmitter<any> = new EventEmitter();

simprintsIdentify() {
this.identify.emit();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<div class="basic-filters left-pane show-one-filter">
<mm-freetext-filter class="filter" (search)="applyFilters()" [disabled]="disabled"></mm-freetext-filter>
<mm-simprints-filter
[simprintsEnabled]="simprintsEnabled"
(identify)="simprintsIdentify()"
></mm-simprints-filter>
<reset-filters (resetFilters)="resetFilters()" [disabled]="disabled"></reset-filters>
<mm-sort-filter
[lastVisitedDateExtras]="lastVisitedDateExtras"
Expand Down
13 changes: 11 additions & 2 deletions webapp/src/ts/modules/contacts/contacts-filters.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, ViewChild, Output, Input, EventEmitter } from '@angular/core';
import { Store } from '@ngrx/store';

import { GlobalActions } from '@mm-actions/global';
import { Store } from '@ngrx/store';
import { FreetextFilterComponent } from '@mm-components/filters/freetext-filter/freetext-filter.component';
import { SimprintsFilterComponent } from '@mm-components/filters/simprints-filter/simprints-filter.component';

@Component({
selector: 'contacts-filters',
Expand All @@ -18,19 +18,28 @@ export class ContactsFiltersComponent {
}

@Output() search: EventEmitter<any> = new EventEmitter();
@Output() simIdentify: EventEmitter<any> = new EventEmitter();
@Output() sort: EventEmitter<any> = new EventEmitter();
@Input() reset;
@Input() disabled;
@Input() simprintsEnabled;
@Input() sortDirection;
@Input() lastVisitedDateExtras;

@ViewChild(FreetextFilterComponent)
freetextFilter:FreetextFilterComponent;

@ViewChild(SimprintsFilterComponent)
simprintsFilter:SimprintsFilterComponent;

applyFilters(force?) {
this.search.emit(force);
}

simprintsIdentify() {
this.simIdentify.emit();
}

resetFilters() {
this.globalActions.clearFilters();
this.freetextFilter?.clear();
Expand Down
4 changes: 4 additions & 0 deletions webapp/src/ts/modules/contacts/contacts.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<div class="inner">
<contacts-filters
(search)="search()"
(simIdentify)="simprintsIdentify()"
(sort)="sort($event)"
[simprintsEnabled]="simprintsEnabled"
[disabled]="false"
[sortDirection]="sortDirection"
[lastVisitedDateExtras]="lastVisitedDateExtras">
Expand Down Expand Up @@ -47,6 +49,8 @@ <h4>
<span>{{contact.visits.summary}}</span>
</div>
</div>

<div *ngIf="contact.simprintsTier" class="simprints-stars tier-{{contact.simprintsTier}}"></div>
</div>
</a>
</li>
Expand Down
Loading

0 comments on commit c85d17a

Please sign in to comment.