<commit_before>import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Store} from '@ngrx/store';
import {PatientsStore} from '../stores/PatientsStore';
import 'rxjs/add/operator/map';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/first';
import {IcpcCode} from '../model/IcpcCode';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';

@Injectable()
export class IcpcService {
  private LETTERS = ['A', 'B', 'D', 'F', 'H', 'K', 'L', 'N', 'P', 'R', 'S', 'T', 'U', 'W', 'X', 'Y', 'Z'];
  public codes: Observable<IcpcCode[]>;
  public staticCodes: IcpcCode[];

  public actions: Observable<IcpcCode[]>;
  public diagnoses: Observable<IcpcCode[]>;
  public reasons: Observable<IcpcCode[]>;

  constructor(private httpClient: HttpClient, private store: Store<PatientsStore>) {
    let codes = new BehaviorSubject<IcpcCode[]>([]);
    store.select('icpc').filter(codes => true).subscribe(codes);
    this.codes = codes;
    this.loadItems();
  }

  public loadItems() {
    return this.httpClient.get<IcpcCode[]>('assets/icpc.json')
      .do(codes => {
        let actions: IcpcCode[] = [];
        let reasons: IcpcCode[] = [];
        let diagnoses: IcpcCode[] = [];

        codes = codes.reduce((acc, code) => {
          let codeString = code.code;
          let cn = parseInt(codeString.replace(/[\D]/gi, ''), 10);
          let fitsDiapason = cn >= 37 && cn <= 47 || cn >= 49 && cn <= 62 || cn >= 63 && cn <= 69;
          fitsDiapason && console.log(cn);
          if (codeString.startsWith('-') && fitsDiapason) {
            this.LETTERS.forEach(l => {
              let newCode = Object.assign({}, code);
              newCode.code = l + cn;
              acc.push(newCode);
            });
          } else {
            acc.push(code);
          }
          return acc;
        }, []).sort((a, b) => {
          if (a.code === b.code) {
            return 0;
          } else if (a.code > b.code) {
            return 1;
          } else {
            return -1;
          }
        });

        codes.forEach(code => {
          let reasonFilter = true;

          let diagnosisExec = /[A-Z](\d{2})/gi.exec(code.code);
          let diagnosisCode = parseInt(diagnosisExec && diagnosisExec[1]);
          if (reasonFilter) {
            reasons.push(code);
          }
          if (diagnosisCode <= 29 || diagnosisCode >= 70 && diagnosisCode <= 99) {<commit_msg>FIX: removed logging<commit_after>import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Store} from '@ngrx/store';
import {PatientsStore} from '../stores/PatientsStore';
import 'rxjs/add/operator/map';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/first';
import {IcpcCode} from '../model/IcpcCode';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';

@Injectable()
export class IcpcService {
  private LETTERS = ['A', 'B', 'D', 'F', 'H', 'K', 'L', 'N', 'P', 'R', 'S', 'T', 'U', 'W', 'X', 'Y', 'Z'];
  public codes: Observable<IcpcCode[]>;
  public staticCodes: IcpcCode[];

  public actions: Observable<IcpcCode[]>;
  public diagnoses: Observable<IcpcCode[]>;
  public reasons: Observable<IcpcCode[]>;

  constructor(private httpClient: HttpClient, private store: Store<PatientsStore>) {
    let codes = new BehaviorSubject<IcpcCode[]>([]);
    store.select('icpc').filter(codes => true).subscribe(codes);
    this.codes = codes;
    this.loadItems();
  }

  public loadItems() {
    return this.httpClient.get<IcpcCode[]>('assets/icpc.json')
      .do(codes => {
        let actions: IcpcCode[] = [];
        let reasons: IcpcCode[] = [];
        let diagnoses: IcpcCode[] = [];

        codes = codes.reduce((acc, code) => {
          let codeString = code.code;
          let cn = parseInt(codeString.replace(/[\D]/gi, ''), 10);
          let fitsDiapason = cn >= 37 && cn <= 47 || cn >= 49 && cn <= 62 || cn >= 63 && cn <= 69;
          if (codeString.startsWith('-') && fitsDiapason) {
            this.LETTERS.forEach(l => {
              let newCode = Object.assign({}, code);
              newCode.code = l + cn;
              acc.push(newCode);
            });
          } else {
            acc.push(code);
          }
          return acc;
        }, []).sort((a, b) => {
          if (a.code === b.code) {
            return 0;
          } else if (a.code > b.code) {
            return 1;
          } else {
            return -1;
          }
        });

        codes.forEach(code => {
          let reasonFilter = true;

          let diagnosisExec = /[A-Z](\d{2})/gi.exec(code.code);
          let diagnosisCode = parseInt(diagnosisExec && diagnosisExec[1]);
          if (reasonFilter) {
            reasons.push(code);
          }
          if (diagnosisCode <= 29 || diagnosisCode >= 70 && diagnosisCode <= 99) {
{'fraction_non_alphanumeric': 0.1747833264548081, 'fraction_numerical': 0.010317787866281469, 'mean_word_length': 2.387141858839972, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1761383', 'n_tokens_mistral': 1599, 'n_tokens_neox': 1538, 'n_words': 356}