Giter Site home page Giter Site logo

The Server should separate the counselor entries into objects before saving to the database. about licensed-mental-health-counselors-browser HOT 13 CLOSED

redmega avatar redmega commented on June 28, 2024
The Server should separate the counselor entries into objects before saving to the database.

from licensed-mental-health-counselors-browser.

Comments (13)

Redmega avatar Redmega commented on June 28, 2024

@dsych Thanks for your contributions to the previous issue! Here's the continuation of it, if you want to work on it as well. I've already marked it as [In Progress] for you.

from licensed-mental-health-counselors-browser.

dsych avatar dsych commented on June 28, 2024

Here is what I am thinking: we certainly don't want to maintain two separate objects that are describing the Practitioner, so we can have a base class that describes properties needed for the json. The base will be an es6 class (stored in .js file inside /server/lib) and will receive an array which it will proceed to parse or nothing. The derived class will be a typescript class that is stored inside src/components/practitioner.ts. It will extend the base class and attache additional properties like address, phone etc.
This way, once we change anything inside the base class, the db, json signatures and the client side signatures are all in sync.
It will look something like this:

// /server/lib/practitioner.js
class Practitioner {
    constructor(raw) {
        if (raw && raw.length) {

            this.licId = raw[0];
            this.expDate = raw[1];
            this.orgDate = raw[2];
            this.licenseNum = raw[3];
            this.statusDate = raw[4];
            this.boardAction = raw[5];
            ...
            this.prescriptionIndicator = raw[30];
            this.dispensingIndicator = raw[31];
        } else {
            this.licId = "";
            this.expDate = "";
            this.orgDate = "";
            this.licenseNum = "";
            this.statusDate = "";
            this.boardAction = "";
            ...
            this.prescriptionIndicator = "";
            this.dispensingIndicator = "";
        }
    }
}
import { Practitioner as P } from "../../server/lib/practitioner"

// /src/components/practitioner.ts
export class Practitioner extends P {
    [x: string]: any;
 
    phone: Phone;

    mailingAddress: Address;
    practiceAddress: Address;

    constructor(src) {
        super();
        Object.keys(src).forEach(key => {
            this[key] = src[key];
        });
        this.mailingAddress = {
            line1: this.mailingAddressLine1
            ...
        };
        this.phone = {
            phoneNum: this.phoneNumber
            ...
        }
    }

}

from licensed-mental-health-counselors-browser.

Redmega avatar Redmega commented on June 28, 2024

That looks solid to me.

Another option might be to just use typescript on the server!

For development we can use ts-node as the executable for nodemon, and for prod we can just compile with babel / typescript into build/ and use "start": "node build/server.js"

from licensed-mental-health-counselors-browser.

dsych avatar dsych commented on June 28, 2024

If migrating to TS is an option, I think we should do that instead. Makes sense to have server and client code living side by side on the same stack.
Once that is done, I can do proper inheritance between objects as per TS standards. Even though what I proposed above works, I hate the use of call type signatures in this way.

from licensed-mental-health-counselors-browser.

Redmega avatar Redmega commented on June 28, 2024

Yeah, definitely an option. I can create a separate ticket for that and work on it tonight, or if you'd like you can take that on as well!

from licensed-mental-health-counselors-browser.

dsych avatar dsych commented on June 28, 2024

You can go ahead.

from licensed-mental-health-counselors-browser.

Redmega avatar Redmega commented on June 28, 2024

Ended up getting home late yesterday. Will work on it tonight!

from licensed-mental-health-counselors-browser.

Redmega avatar Redmega commented on June 28, 2024

OK, #10 is closed. Had some issues extending the Express Request -- if you're able to get the declaration merging working properly, I'd be super appreciative! In the meantime we just had to specifically type the req param in our middlewares that access .db.

from licensed-mental-health-counselors-browser.

Redmega avatar Redmega commented on June 28, 2024

From my perspective, looks like it's working properly (at least to vs-code), it just isn't being picked up by the typescript compiler:
screen shot 2018-10-24 at 10 10 52 pm

from licensed-mental-health-counselors-browser.

Redmega avatar Redmega commented on June 28, 2024

So, I did something...

4187da4

I don't think that's correct, but I'm fine with it for now since it's working.

from licensed-mental-health-counselors-browser.

dsych avatar dsych commented on June 28, 2024

Np, @Redmega, I will look into it tomorrow.

from licensed-mental-health-counselors-browser.

Redmega avatar Redmega commented on June 28, 2024

So saw this entry, definitely confirms that we need to show both line 1 and line 2.

screen shot 2018-10-25 at 1 14 43 am

from licensed-mental-health-counselors-browser.

Redmega avatar Redmega commented on June 28, 2024

👋 Made any progress on this yet?

I know hacktoberfest is over so if you're not so inclined I can take over this issue :)

from licensed-mental-health-counselors-browser.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.