gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] jl-gui et alii


From: Karsten Hilbert
Subject: Re: [Gnumed-devel] jl-gui et alii
Date: Mon, 19 Aug 2013 12:20:32 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Aug 19, 2013 at 10:10:07AM +0200, Karsten Hilbert wrote:

> I see that you've published quite some code on gitorious
> which is both impressive and really nice to see.

I've got a few questions on this view:

CREATE OR REPLACE VIEW clin.v_emr_tree AS
(
        SELECT DISTINCT
                enc.pk_patient,
                epi.pk_health_issue AS pk_issue,
                epi.health_issue AS issue_description,
                epi.pk_episode,
                epi.description AS episode_description,
                enc.pk_encounter,
                enc.assessment_of_encounter AS encounter_description,
                enc.started AS encounter_started,
                enc.l10n_type AS encounter_l10n_type
        FROM
                clin.v_pat_encounters enc
                        JOIN clin.clin_narrative cn ON enc.pk_encounter = 
cn.fk_encounter
                                JOIN clin.v_pat_episodes epi ON cn.fk_episode = 
epi.pk_episode
        ORDER BY
                enc.pk_patient,
                epi.pk_health_issue,
                epi.health_issue,
                epi.pk_episode,
                epi.description,
                enc.pk_encounter,
                enc.assessment_of_encounter,
                enc.started,
                enc.l10n_type
) UNION
        SELECT
                v_pat_episodes.pk_patient,
                v_pat_episodes.pk_health_issue AS pk_issue,
                v_pat_episodes.health_issue AS issue_description,
                v_pat_episodes.pk_episode,
                v_pat_episodes.description AS episode_description,
                NULL::unknown AS pk_encounter,
                NULL::unknown AS encounter_description,
                NULL::unknown AS encounter_started,
                NULL::unknown AS encounter_l10n_type
        FROM clin.v_pat_episodes
ORDER BY 1, 2, 4, 6
;


1) Do you intend to apply the "ORDER BY 1,2,4,6" to the
   entire view or to the second UNION sub query ? (if
   it is the second sub-query the 6 seems unhelpful
   as it is always NULL)

2) Do you see problems with rewriting the view to
   directly look at the base tables rather than
   views thereof ? (that way this view will be more
   robust when other views are modified)

3) Might the NULL::unknown casts be typed appropriately ?

4) What is the reason for choosing assessment to be the
   description of the encounter ?  (this will severely limit
   the generic applicability of this view)

5) I think I don't fully understand which expected duplicity
   you are protecting against with the sub-query global DISTINCT
   on the first UNION sub-query ?

Karsten
-- 
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346



reply via email to

[Prev in Thread] Current Thread [Next in Thread]